mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-26 09:19:31 +02:00
Reroll prediction
Gets a list of every result from all the rerolls you can afford Shows extra items if you have Golden Poke Balls Doesn't use lock capsule Ingame display is todo
This commit is contained in:
parent
73f5d51dd2
commit
c138d1b4e1
117
src/phases.ts
117
src/phases.ts
@ -6726,12 +6726,42 @@ export class AttemptRunPhase extends PokemonPhase {
|
|||||||
export class SelectModifierPhase extends BattlePhase {
|
export class SelectModifierPhase extends BattlePhase {
|
||||||
private rerollCount: integer;
|
private rerollCount: integer;
|
||||||
private modifierTiers: ModifierTier[];
|
private modifierTiers: ModifierTier[];
|
||||||
|
private modifierPredictions: ModifierTypeOption[][] = []
|
||||||
|
private predictionCost: integer;
|
||||||
|
|
||||||
constructor(scene: BattleScene, rerollCount: integer = 0, modifierTiers?: ModifierTier[]) {
|
constructor(scene: BattleScene, rerollCount: integer = 0, modifierTiers?: ModifierTier[], predictionCost?: integer, modifierPredictions?: ModifierTypeOption[][]) {
|
||||||
super(scene);
|
super(scene);
|
||||||
|
|
||||||
this.rerollCount = rerollCount;
|
this.rerollCount = rerollCount;
|
||||||
this.modifierTiers = modifierTiers;
|
this.modifierTiers = modifierTiers;
|
||||||
|
this.modifierPredictions = []
|
||||||
|
if (modifierPredictions != undefined) {
|
||||||
|
this.modifierPredictions = modifierPredictions;
|
||||||
|
}
|
||||||
|
this.predictionCost = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
generateSelection(rerollOverride: integer, modifierOverride?: integer) {
|
||||||
|
//const STATE = Phaser.Math.RND.state() // Store RNG state
|
||||||
|
//console.log("====================")
|
||||||
|
//console.log(" Reroll Prediction: " + rerollOverride)
|
||||||
|
const party = this.scene.getParty();
|
||||||
|
regenerateModifierPoolThresholds(party, this.getPoolType(), rerollOverride);
|
||||||
|
const modifierCount = new Utils.IntegerHolder(3);
|
||||||
|
if (this.isPlayer()) {
|
||||||
|
this.scene.applyModifiers(ExtraModifierModifier, true, modifierCount);
|
||||||
|
}
|
||||||
|
if (modifierOverride) {
|
||||||
|
//modifierCount.value = modifierOverride
|
||||||
|
}
|
||||||
|
const typeOptions: ModifierTypeOption[] = this.getModifierTypeOptions(modifierCount.value);
|
||||||
|
typeOptions.forEach((option, idx) => {
|
||||||
|
//console.log(option.type.name)
|
||||||
|
})
|
||||||
|
//console.log("====================")
|
||||||
|
this.modifierPredictions.push(typeOptions)
|
||||||
|
this.predictionCost += this.getRerollCost(typeOptions, false, rerollOverride)
|
||||||
|
//Phaser.Math.RND.state(STATE) // Restore RNG state like nothing happened
|
||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
@ -6739,6 +6769,12 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
|
|
||||||
if (!this.rerollCount) {
|
if (!this.rerollCount) {
|
||||||
this.updateSeed();
|
this.updateSeed();
|
||||||
|
console.log("\n\nPerforming reroll prediction\n\n")
|
||||||
|
this.predictionCost = 0
|
||||||
|
for (var idx = 0; idx < 10 && this.predictionCost < this.scene.money; idx++) {
|
||||||
|
this.generateSelection(idx)
|
||||||
|
}
|
||||||
|
this.updateSeed();
|
||||||
} else {
|
} else {
|
||||||
this.scene.reroll = false;
|
this.scene.reroll = false;
|
||||||
}
|
}
|
||||||
@ -6759,7 +6795,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
this.scene.ui.revertMode();
|
this.scene.ui.revertMode();
|
||||||
this.scene.ui.setMode(Mode.MESSAGE);
|
this.scene.ui.setMode(Mode.MESSAGE);
|
||||||
super.end();
|
super.end();
|
||||||
}, () => this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), typeOptions, modifierSelectCallback, this.getRerollCost(typeOptions, this.scene.lockModifierTiers)));
|
}, () => this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), typeOptions, modifierSelectCallback, this.getRerollCost(typeOptions, this.scene.lockModifierTiers), this.modifierPredictions));
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -6768,23 +6804,54 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
switch (rowCursor) {
|
switch (rowCursor) {
|
||||||
case 0:
|
case 0:
|
||||||
switch (cursor) {
|
switch (cursor) {
|
||||||
case 0:
|
case 0:
|
||||||
const rerollCost = this.getRerollCost(typeOptions, this.scene.lockModifierTiers);
|
const rerollCost1 = this.getRerollCost(typeOptions, this.scene.lockModifierTiers);
|
||||||
if (this.scene.money < rerollCost) {
|
if (this.scene.money < rerollCost1) {
|
||||||
this.scene.ui.playError();
|
this.scene.ui.playError();
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.scene.reroll = true;
|
this.scene.reroll = true;
|
||||||
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Reroll" + (this.scene.lockModifierTiers ? " (Locked)" : ""))
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "Reroll" + (this.scene.lockModifierTiers ? " (Locked)" : ""))
|
||||||
this.scene.unshiftPhase(new SelectModifierPhase(this.scene, this.rerollCount + 1, typeOptions.map(o => o.type.tier)));
|
this.scene.unshiftPhase(new SelectModifierPhase(this.scene, this.rerollCount + 1, typeOptions.map(o => o.type.tier), this.predictionCost, this.modifierPredictions));
|
||||||
this.scene.ui.clearText();
|
this.scene.ui.clearText();
|
||||||
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
||||||
this.scene.money -= rerollCost;
|
this.scene.money -= rerollCost1;
|
||||||
this.scene.updateMoneyText();
|
this.scene.updateMoneyText();
|
||||||
this.scene.animateMoneyChanged(false);
|
this.scene.animateMoneyChanged(false);
|
||||||
this.scene.playSound("buy");
|
this.scene.playSound("buy");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 0.1:
|
||||||
|
const rerollCost2 = this.getRerollCost(this.modifierPredictions[this.rerollCount], false);
|
||||||
|
if (this.scene.money < rerollCost2) {
|
||||||
|
this.scene.ui.playError();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.scene.reroll = true;
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "+1 Reroll")
|
||||||
|
this.scene.unshiftPhase(new SelectModifierPhase(this.scene, this.rerollCount + 1, typeOptions.map(o => o.type.tier), this.predictionCost, this.modifierPredictions));
|
||||||
|
this.scene.ui.clearText();
|
||||||
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
||||||
|
this.scene.money -= rerollCost2;
|
||||||
|
this.scene.updateMoneyText();
|
||||||
|
this.scene.animateMoneyChanged(false);
|
||||||
|
this.scene.playSound("buy");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 0.2:
|
||||||
|
const rerollCost3 = this.getRerollCost(this.modifierPredictions[this.rerollCount + 1], false);
|
||||||
|
{
|
||||||
|
this.scene.reroll = true;
|
||||||
|
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, "-1 Reroll")
|
||||||
|
this.scene.unshiftPhase(new SelectModifierPhase(this.scene, this.rerollCount - 1, typeOptions.map(o => o.type.tier), this.predictionCost, this.modifierPredictions));
|
||||||
|
this.scene.ui.clearText();
|
||||||
|
this.scene.ui.setMode(Mode.MESSAGE).then(() => super.end());
|
||||||
|
this.scene.money += rerollCost3;
|
||||||
|
this.scene.updateMoneyText();
|
||||||
|
this.scene.animateMoneyChanged(false);
|
||||||
|
this.scene.playSound("buy");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: integer, itemIndex: integer, itemQuantity: integer, toSlotIndex: integer, isAll: boolean, isFirst: boolean) => {
|
this.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER, -1, (fromSlotIndex: integer, itemIndex: integer, itemQuantity: integer, toSlotIndex: integer, isAll: boolean, isFirst: boolean) => {
|
||||||
if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) {
|
if (toSlotIndex !== undefined && fromSlotIndex < 6 && toSlotIndex < 6 && fromSlotIndex !== toSlotIndex && itemIndex > -1) {
|
||||||
@ -6918,6 +6985,14 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
|
|
||||||
return !cost;
|
return !cost;
|
||||||
};
|
};
|
||||||
|
if (this.rerollCount == 0) {
|
||||||
|
this.modifierPredictions.forEach((mp, r) => {
|
||||||
|
console.log("Rerolls: " + r)
|
||||||
|
mp.forEach((m, i) => {
|
||||||
|
console.log(" " + m.type.name)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), typeOptions, modifierSelectCallback, this.getRerollCost(typeOptions, this.scene.lockModifierTiers));
|
this.scene.ui.setMode(Mode.MODIFIER_SELECT, this.isPlayer(), typeOptions, modifierSelectCallback, this.getRerollCost(typeOptions, this.scene.lockModifierTiers));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6929,7 +7004,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRerollCost(typeOptions: ModifierTypeOption[], lockRarities: boolean): integer {
|
getRerollCost(typeOptions: ModifierTypeOption[], lockRarities: boolean, rerollOverride?: integer): integer {
|
||||||
let baseValue = 0;
|
let baseValue = 0;
|
||||||
if (lockRarities) {
|
if (lockRarities) {
|
||||||
const tierValues = [50, 125, 300, 750, 2000];
|
const tierValues = [50, 125, 300, 750, 2000];
|
||||||
@ -6939,7 +7014,7 @@ export class SelectModifierPhase extends BattlePhase {
|
|||||||
} else {
|
} else {
|
||||||
baseValue = 250;
|
baseValue = 250;
|
||||||
}
|
}
|
||||||
return Math.min(Math.ceil(this.scene.currentBattle.waveIndex / 10) * baseValue * Math.pow(2, this.rerollCount), Number.MAX_SAFE_INTEGER);
|
return Math.min(Math.ceil(this.scene.currentBattle.waveIndex / 10) * baseValue * Math.pow(2, (rerollOverride != undefined ? rerollOverride : this.rerollCount)), Number.MAX_SAFE_INTEGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPoolType(): ModifierPoolType {
|
getPoolType(): ModifierPoolType {
|
||||||
|
@ -11,6 +11,7 @@ import MoveInfoOverlay from "./move-info-overlay";
|
|||||||
import { allMoves } from "../data/move";
|
import { allMoves } from "../data/move";
|
||||||
import * as Utils from "./../utils";
|
import * as Utils from "./../utils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
import { GameModes } from "#app/game-mode.js";
|
||||||
|
|
||||||
export const SHOP_OPTIONS_ROW_LIMIT = 6;
|
export const SHOP_OPTIONS_ROW_LIMIT = 6;
|
||||||
|
|
||||||
@ -31,9 +32,18 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
private transferButtonWidth: integer;
|
private transferButtonWidth: integer;
|
||||||
private checkButtonWidth: integer;
|
private checkButtonWidth: integer;
|
||||||
|
|
||||||
|
public args: any[] = [];
|
||||||
|
public refreshIndex: integer = 0;
|
||||||
|
public optionP: ModifierTypeOption[][];
|
||||||
|
|
||||||
public options: ModifierOption[];
|
public options: ModifierOption[];
|
||||||
public shopOptionsRows: ModifierOption[][];
|
public shopOptionsRows: ModifierOption[][];
|
||||||
|
|
||||||
|
private rerollUpContainer: Phaser.GameObjects.Container;
|
||||||
|
private rerollDownContainer: Phaser.GameObjects.Container;
|
||||||
|
private rerollUpLabel: Phaser.GameObjects.Text;
|
||||||
|
private rerollDownLabel: Phaser.GameObjects.Text;
|
||||||
|
|
||||||
private cursorObj: Phaser.GameObjects.Image;
|
private cursorObj: Phaser.GameObjects.Image;
|
||||||
|
|
||||||
constructor(scene: BattleScene) {
|
constructor(scene: BattleScene) {
|
||||||
@ -92,6 +102,32 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.rerollCostText.setPositionRelative(rerollButtonText, rerollButtonText.displayWidth + 5, 1);
|
this.rerollCostText.setPositionRelative(rerollButtonText, rerollButtonText.displayWidth + 5, 1);
|
||||||
this.rerollButtonContainer.add(this.rerollCostText);
|
this.rerollButtonContainer.add(this.rerollCostText);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.rerollUpContainer = this.scene.add.container(100, -78);
|
||||||
|
this.rerollUpContainer.setName("reroll-brn");
|
||||||
|
this.rerollUpContainer.setVisible(false);
|
||||||
|
ui.add(this.rerollUpContainer);
|
||||||
|
|
||||||
|
this.rerollUpLabel = addTextObject(this.scene, -4, -2, "+1 Reroll", TextStyle.PARTY);
|
||||||
|
this.rerollUpLabel.setName("text-reroll-btn");
|
||||||
|
this.rerollUpLabel.setOrigin(0, 0);
|
||||||
|
this.rerollUpContainer.add(this.rerollUpLabel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.rerollDownContainer = this.scene.add.container(100, -64);
|
||||||
|
this.rerollDownContainer.setName("reroll-brn");
|
||||||
|
this.rerollDownContainer.setVisible(false);
|
||||||
|
ui.add(this.rerollDownContainer);
|
||||||
|
|
||||||
|
this.rerollDownLabel = addTextObject(this.scene, -4, -2, "-1 Reroll", TextStyle.PARTY);
|
||||||
|
this.rerollDownLabel.setName("text-reroll-btn");
|
||||||
|
this.rerollDownLabel.setOrigin(0, 0);
|
||||||
|
this.rerollDownContainer.add(this.rerollDownLabel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.lockRarityButtonContainer = this.scene.add.container(16, -64);
|
this.lockRarityButtonContainer = this.scene.add.container(16, -64);
|
||||||
this.lockRarityButtonContainer.setVisible(false);
|
this.lockRarityButtonContainer.setVisible(false);
|
||||||
ui.add(this.lockRarityButtonContainer);
|
ui.add(this.lockRarityButtonContainer);
|
||||||
@ -117,6 +153,7 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
show(args: any[]): boolean {
|
show(args: any[]): boolean {
|
||||||
|
this.args = args
|
||||||
if (this.active) {
|
if (this.active) {
|
||||||
if (args.length >= 3) {
|
if (args.length >= 3) {
|
||||||
this.awaitingActionInput = true;
|
this.awaitingActionInput = true;
|
||||||
@ -151,6 +188,11 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.lockRarityButtonContainer.setVisible(false);
|
this.lockRarityButtonContainer.setVisible(false);
|
||||||
this.lockRarityButtonContainer.setAlpha(0);
|
this.lockRarityButtonContainer.setAlpha(0);
|
||||||
|
|
||||||
|
this.rerollUpContainer.setVisible(false)
|
||||||
|
this.rerollUpContainer.setAlpha(0)
|
||||||
|
this.rerollDownContainer.setVisible(false)
|
||||||
|
this.rerollDownContainer.setAlpha(0)
|
||||||
|
|
||||||
this.rerollButtonContainer.setPositionRelative(this.lockRarityButtonContainer, 0, canLockRarities ? -12 : 0);
|
this.rerollButtonContainer.setPositionRelative(this.lockRarityButtonContainer, 0, canLockRarities ? -12 : 0);
|
||||||
|
|
||||||
this.rerollCost = args[3] as integer;
|
this.rerollCost = args[3] as integer;
|
||||||
@ -158,6 +200,8 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.updateRerollCostText();
|
this.updateRerollCostText();
|
||||||
|
|
||||||
const typeOptions = args[1] as ModifierTypeOption[];
|
const typeOptions = args[1] as ModifierTypeOption[];
|
||||||
|
//const typeOptionP = args[4] as ModifierTypeOption[][];
|
||||||
|
//this.optionP = typeOptionP;
|
||||||
const shopTypeOptions = !this.scene.gameMode.hasNoShop
|
const shopTypeOptions = !this.scene.gameMode.hasNoShop
|
||||||
? getPlayerShopModifierTypeOptionsForWave(this.scene.currentBattle.waveIndex, this.scene.getWaveMoneyAmount(1))
|
? getPlayerShopModifierTypeOptionsForWave(this.scene.currentBattle.waveIndex, this.scene.getWaveMoneyAmount(1))
|
||||||
: [];
|
: [];
|
||||||
@ -235,9 +279,15 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
this.rerollButtonContainer.setAlpha(0);
|
this.rerollButtonContainer.setAlpha(0);
|
||||||
this.checkButtonContainer.setAlpha(0);
|
this.checkButtonContainer.setAlpha(0);
|
||||||
this.lockRarityButtonContainer.setAlpha(0);
|
this.lockRarityButtonContainer.setAlpha(0);
|
||||||
|
this.rerollUpContainer.setAlpha(0)
|
||||||
|
this.rerollDownContainer.setAlpha(0)
|
||||||
this.rerollButtonContainer.setVisible(true);
|
this.rerollButtonContainer.setVisible(true);
|
||||||
this.checkButtonContainer.setVisible(true);
|
this.checkButtonContainer.setVisible(true);
|
||||||
this.lockRarityButtonContainer.setVisible(canLockRarities);
|
this.lockRarityButtonContainer.setVisible(canLockRarities);
|
||||||
|
this.rerollUpContainer.setVisible(false)
|
||||||
|
this.rerollDownContainer.setVisible(false)
|
||||||
|
|
||||||
|
// , this.rerollUpContainer, this.rerollDownContainer
|
||||||
|
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
targets: [ this.rerollButtonContainer, this.lockRarityButtonContainer, this.checkButtonContainer ],
|
targets: [ this.rerollButtonContainer, this.lockRarityButtonContainer, this.checkButtonContainer ],
|
||||||
@ -258,6 +308,12 @@ export default class ModifierSelectUiHandler extends AwaitableUiHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
this.clear()
|
||||||
|
this.args[1] = this.optionP[this.refreshIndex]
|
||||||
|
this.show(this.args)
|
||||||
|
}
|
||||||
|
|
||||||
processInput(button: Button): boolean {
|
processInput(button: Button): boolean {
|
||||||
const ui = this.getUi();
|
const ui = this.getUi();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user