Advertisement
Guest User

Vitamin Applier

a guest
Feb 28th, 2023
1,702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const NoteTypes = {
  2.  info: 0,
  3.  success: 1,
  4.  warning: 2,
  5.  danger: 3,
  6.  primary: 4,
  7.  secondary: 5,
  8.  dark: 6,
  9.  light: 7,
  10. }
  11.  
  12. // helpers for logging to check toggle and do coloring
  13. const offLog =   (m) => {if(cheatLogs.toggles) Notifier.notify({timeout: 60*1000,type: NoteTypes.danger,  message: `${m} OFF`})};
  14. const onLog =    (m) => {if(cheatLogs.toggles) Notifier.notify({timeout: 60*1000,type: NoteTypes.success, message: `${m} ON`})};
  15. const checkLog = (m) => {if(cheatLogs.checks)  Notifier.notify({timeout:  1*1000,type: NoteTypes.warning, message: `${m} check...`})};
  16. const fireLog =  (m) => {if(cheatLogs.fires)   Notifier.notify({timeout:  5*1000,type: NoteTypes.info,    message: m})};
  17.  
  18. const cheatHelpers = {
  19.     guessSteps: (pkmn, carbos, calcium, protein) => {
  20.         const div = 300;
  21.         const extraCycles = (calcium + protein) / 2;
  22.         const steps = App.game.breeding.getSteps(pkmn.eggCycles + extraCycles);
  23.         return steps <= div ? steps : Math.round((Math.pow((steps / div), (1 - carbos / 70))) * div);
  24.     },
  25.  
  26.     guessBonus: (pkmn, carbos, calcium, protein) => {
  27.         const attackBonusPercent = (GameConstants.BREEDING_ATTACK_BONUS + calcium) / 100;
  28.         const proteinBoost = protein;
  29.         return Math.floor((pkmn.baseAttack * attackBonusPercent) + proteinBoost);
  30.     },
  31.  
  32.     getSizes: (pkmn) => {
  33.         let max = {
  34.             r: 0,
  35.             carbos:0,
  36.             calcium:0,
  37.             protein:0,
  38.             steps: 0,
  39.             bonus: 0,
  40.             cost: 0,
  41.         };
  42.  
  43.         const regionBonus = BreedingController.calculateRegionalMultiplier(pkmn);
  44.         const evbonus = pkmn.calculateEVAttackBonus();
  45.         const carbosPrice = ItemList.Carbos.totalPrice(1);
  46.         const calciumPrice = ItemList.Calcium.totalPrice(1);
  47.         const proteinPrice = ItemList.Protein.totalPrice(1);
  48.  
  49.         for(let carbos = 0; carbos <= 40; carbos++){
  50.             for(let calcium = 0; calcium <= 40 - carbos; calcium++){
  51.                 for(let protein = 0; protein <= 40 - carbos - calcium; protein++){
  52.                     const steps = cheatHelpers.guessSteps(pkmn, carbos, calcium, protein);
  53.                     const bonus = cheatHelpers.guessBonus(pkmn, carbos, calcium, protein)
  54.                     const cost = ItemList.Carbos.totalPrice(carbos) + ItemList.Calcium.totalPrice(calcium) + ItemList.Protein.totalPrice(protein);
  55.  
  56.                     const r = (bonus * regionBonus * evbonus) / steps ;
  57.                     if(r > max.r || (r === max.r && cost < max.cost)){
  58.                         max = {r, carbos, calcium, protein, steps, bonus, cost};
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.  
  64.         return max;
  65.     },
  66.  
  67.     // uses the pokemon augmented by getSizes
  68.     applyVitamins: (obj) => {
  69.         const {pkmn, carbos, calcium, protein} = obj;
  70.         if(player.itemList.Carbos() > 0 && carbos > 0) pkmn.useVitamin(GameConstants.VitaminType.Carbos, Math.min(player.itemList.Carbos(),carbos));
  71.         if(player.itemList.Calcium() > 0 && calcium > 0) pkmn.useVitamin(GameConstants.VitaminType.Calcium, Math.min(player.itemList.Calcium(),calcium));
  72.         if(player.itemList.Protein() > 0 && protein > 0) pkmn.useVitamin(GameConstants.VitaminType.Protein, Math.min(player.itemList.Protein(),protein));
  73.     },
  74.  
  75.     applySpareVitamins: (obj) => {
  76.         const {pkmn} = obj;
  77.         if(pkmn.vitaminUsesRemaining() && player.itemList.Carbos() > 0) pkmn.useVitamin(GameConstants.VitaminType.Carbos, Infinity);
  78.         if(pkmn.vitaminUsesRemaining() && player.itemList.Calcium() > 0) pkmn.useVitamin(GameConstants.VitaminType.Calcium, Infinity);
  79.         if(pkmn.vitaminUsesRemaining() && player.itemList.Protein() > 0) pkmn.useVitamin(GameConstants.VitaminType.Protein, Infinity);
  80.     }
  81. }
  82.  
  83. const cheat = {
  84.     setVitamins: () => {let pkmnList = PartyController.getvitaminSortedList().filter(p => !p.hideFromProteinList());
  85.         pkmnList = pkmnList.map(pkmn => ({pkmn, ...(cheatHelpers.getSizes(pkmn))}))
  86.         pkmnList.forEach(cheatHelpers.applyVitamins);
  87.         Notifier.notify({timeout: 5*1000,type: NoteTypes.info, message: 'Vitamins applied as optimally as possible'});
  88.  
  89.         pkmnList.forEach(cheatHelpers.applySpareVitamins);
  90.         Notifier.notify({timeout: 5*1000,type: NoteTypes.info, message: 'Used remaining vitamins'});
  91.     },
  92.     setOptimalVitamins: () => {let pkmnList = App.game.party.caughtPokemon;
  93.         if(Settings.getSetting('vitaminHideShinyPokemon').observableValue()) {
  94.             pkmnList = pkmnList.filter(pkmn => !pkmn.shiny)
  95.         }
  96.         pkmnList = pkmnList.map(pkmn => ({pkmn, ...(cheatHelpers.getSizes(pkmn))}))
  97.         pkmnList = pkmnList.sort((a,b) => b.r - a.r);
  98.         pkmnList.forEach(cheatHelpers.applyVitamins);
  99.         Notifier.notify({timeout: 5*1000,type: NoteTypes.info, message: 'Vitamins applied as optimally as possible'});
  100.  
  101.         pkmnList.forEach(cheatHelpers.applySpareVitamins);
  102.         Notifier.notify({timeout: 5*1000,type: NoteTypes.info, message: 'Used remaining vitamins'});
  103.     },
  104. }
  105.  
  106. document.getElementById('right-column-2').insertAdjacentHTML('beforeEnd', '<div id="cheatsContainer" class="card sortable border-secondary mb-3" draggable="false" style=""><div class="card-header p-0" data-toggle="collapse" href="#cheatsBody"><span style="text-align: center">Vitamins</span></div><div id="cheatsBody" class="card-body show p-0"><table class="table table-sm m-0"><tbody id="cheatsTable"></tbody></table></div></div>')
  107. document.getElementById('cheatsTable').insertAdjacentHTML('beforeEnd','<tr><td><button id="cheatSetVitamins" class="btn btn-danger btn-sm btn-block p-0" onClick="cheat.setVitamins()">Set Vitamins (Ordered)</button></td></tr>');
  108. document.getElementById('cheatsTable').insertAdjacentHTML('beforeEnd','<tr><td><button id="cheatSetOptimalVitamins" class="btn btn-danger btn-sm btn-block p-0" onClick="cheat.setOptimalVitamins()">Set Vitamins (Optimal)</button></td></tr>');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement