Revert "Remove enemy attack pre-calc"

This reverts commit 310a497627.
This commit is contained in:
RedstonewolfX 2024-08-14 10:03:29 -04:00
parent 310a497627
commit ba491391b4
5 changed files with 16 additions and 54 deletions

View File

@ -131,7 +131,6 @@ export default class BattleScene extends SceneBase {
public disableDailyShinies: boolean = true; // Disables shiny luck in Daily Runs to prevent affecting RNG public disableDailyShinies: boolean = true; // Disables shiny luck in Daily Runs to prevent affecting RNG
public quickloadDisplayMode: string = "Dailies"; public quickloadDisplayMode: string = "Dailies";
public waveShinyFlag: boolean = false; public waveShinyFlag: boolean = false;
public waveShinyMinToBreak: integer = 0;
public waveShinyChecked: boolean = false; public waveShinyChecked: boolean = false;
public tempWaveSeed: string; public tempWaveSeed: string;
public tempRngCounter: integer = 0; public tempRngCounter: integer = 0;
@ -1289,9 +1288,7 @@ export default class BattleScene extends SceneBase {
doShinyCheck() { doShinyCheck() {
this.waveShinyChecked = true; this.waveShinyChecked = true;
var r = runShinyCheck(this, 1, this.currentBattle.waveIndex) this.waveShinyFlag = runShinyCheck(this, 1, this.currentBattle.waveIndex);
this.waveShinyFlag = r[0] as boolean;
this.waveShinyMinToBreak = r[1] as integer;
if (this.waveShinyFlag) { if (this.waveShinyFlag) {
this.arenaFlyout.display2() this.arenaFlyout.display2()
} }

View File

@ -1958,7 +1958,7 @@ export class StealHeldItemChanceAttr extends MoveEffectAttr {
console.error("Reload discrepancy: Succeeds now, but fails after reload") console.error("Reload discrepancy: Succeeds now, but fails after reload")
LoggerTools.flagReset(user.scene, user.scene.currentBattle.waveIndex) LoggerTools.flagReset(user.scene, user.scene.currentBattle.waveIndex)
} }
//*/ */
if (rand >= this.chance) { if (rand >= this.chance) {
return resolve(false); return resolve(false);

View File

@ -186,9 +186,9 @@ function findBest(scene: BattleScene, pokemon: EnemyPokemon, override?: boolean)
} }
}) })
if (func_output != "") { if (func_output != "") {
//return func_output return func_output
} }
//return "Can't catch" return "Can't catch"
var n = "" var n = ""
switch (rates2[0]) { switch (rates2[0]) {
case rates[0]: case rates[0]:
@ -215,7 +215,7 @@ function findBest(scene: BattleScene, pokemon: EnemyPokemon, override?: boolean)
return "No balls" return "No balls"
} }
} }
//return n + " (FAIL)" return n + " (FAIL)"
return n + Math.round(rates2[0] * 100) + "%"; return n + Math.round(rates2[0] * 100) + "%";
} }
export function parseSlotData(slotId: integer): SessionSaveData { export function parseSlotData(slotId: integer): SessionSaveData {
@ -2901,7 +2901,7 @@ export class TurnInitPhase extends FieldPhase {
LoggerTools.enemyPlan[2] = "" LoggerTools.enemyPlan[2] = ""
LoggerTools.enemyPlan[3] = "" LoggerTools.enemyPlan[3] = ""
if (true) { if (false) {
this.scene.getField().forEach((pokemon, i) => { this.scene.getField().forEach((pokemon, i) => {
if (pokemon?.isActive()) { if (pokemon?.isActive()) {
if (pokemon.isPlayer()) { if (pokemon.isPlayer()) {
@ -3302,8 +3302,8 @@ export class EnemyCommandPhase extends FieldPhase {
console.log(enemyPokemon.name + " selects:", "Switch to " + this.scene.getEnemyParty()[index].name) console.log(enemyPokemon.name + " selects:", "Switch to " + this.scene.getEnemyParty()[index].name)
battle.enemySwitchCounter++; battle.enemySwitchCounter++;
//LoggerTools.enemyPlan[this.fieldIndex*2] = "Switching out" LoggerTools.enemyPlan[this.fieldIndex*2] = "Switching out"
//LoggerTools.enemyPlan[this.fieldIndex*2 + 1] = "→ " + this.scene.getEnemyParty()[index].name LoggerTools.enemyPlan[this.fieldIndex*2 + 1] = "→ " + this.scene.getEnemyParty()[index].name
enemyPokemon.flyout.setText() enemyPokemon.flyout.setText()
@ -3357,8 +3357,8 @@ export class EnemyCommandPhase extends FieldPhase {
console.log(enemyPokemon.name + " selects:", mv.getName() + " → " + nextMove.targets.map((m) => targetLabels[m + 1])) console.log(enemyPokemon.name + " selects:", mv.getName() + " → " + nextMove.targets.map((m) => targetLabels[m + 1]))
this.scene.currentBattle.enemySwitchCounter = Math.max(this.scene.currentBattle.enemySwitchCounter - 1, 0); this.scene.currentBattle.enemySwitchCounter = Math.max(this.scene.currentBattle.enemySwitchCounter - 1, 0);
//LoggerTools.enemyPlan[this.fieldIndex*2] = mv.getName() LoggerTools.enemyPlan[this.fieldIndex*2] = mv.getName()
//LoggerTools.enemyPlan[this.fieldIndex*2 + 1] = "→ " + nextMove.targets.map((m) => targetLabels[m + 1]) LoggerTools.enemyPlan[this.fieldIndex*2 + 1] = "→ " + nextMove.targets.map((m) => targetLabels[m + 1])
this.scene.arenaFlyout.updateFieldText() this.scene.arenaFlyout.updateFieldText()
var txt = ["Turn: " + this.scene.currentBattle.turn] var txt = ["Turn: " + this.scene.currentBattle.turn]
@ -3368,9 +3368,6 @@ export class EnemyCommandPhase extends FieldPhase {
txt = txt.concat(findBest(this.scene, pk)) txt = txt.concat(findBest(this.scene, pk))
}) })
} }
if (txt.length > 2) {
txt = ["Turn: " + this.scene.currentBattle.turn]
}
this.scene.arenaFlyout.updateFieldText() this.scene.arenaFlyout.updateFieldText()
@ -6773,7 +6770,6 @@ const tierNames = [
* @returns * @returns
*/ */
export function shinyCheckStep(scene: BattleScene, predictionCost: Utils.IntegerHolder, rerollOverride: integer, modifierOverride?: integer) { export function shinyCheckStep(scene: BattleScene, predictionCost: Utils.IntegerHolder, rerollOverride: integer, modifierOverride?: integer) {
var minLuck = -1
var modifierPredictions = [] var modifierPredictions = []
const party = scene.getParty(); const party = scene.getParty();
regenerateModifierPoolThresholds(party, ModifierPoolType.PLAYER, rerollOverride); regenerateModifierPoolThresholds(party, ModifierPoolType.PLAYER, rerollOverride);
@ -6792,15 +6788,13 @@ export function shinyCheckStep(scene: BattleScene, predictionCost: Utils.Integer
//lastTier = option.alternates[i] //lastTier = option.alternates[i]
//console.log("Conflict found! (" + i + " luck, " + rerollOverride + " rolls, item " + (idx + 1) + ")") //console.log("Conflict found! (" + i + " luck, " + rerollOverride + " rolls, item " + (idx + 1) + ")")
isOk = false // Shiny Luck affects this wave in some way isOk = false // Shiny Luck affects this wave in some way
if (minLuck == -1 && i != 0)
minLuck = i
} }
} }
} }
}) })
modifierPredictions.push(typeOptions) modifierPredictions.push(typeOptions)
predictionCost.value += (Math.min(Math.ceil(scene.currentBattle.waveIndex / 10) * 250 * Math.pow(2, rerollOverride), Number.MAX_SAFE_INTEGER)) predictionCost.value += (Math.min(Math.ceil(scene.currentBattle.waveIndex / 10) * 250 * Math.pow(2, rerollOverride), Number.MAX_SAFE_INTEGER))
return [isOk, minLuck]; return isOk;
} }
/** /**
* Simulates modifier rolls for as many rerolls as you can afford, checking to see if shiny luck will alter your results. * Simulates modifier rolls for as many rerolls as you can afford, checking to see if shiny luck will alter your results.
@ -6808,7 +6802,6 @@ export function shinyCheckStep(scene: BattleScene, predictionCost: Utils.Integer
* @returns `true` if no changes were detected, `false` otherwise * @returns `true` if no changes were detected, `false` otherwise
*/ */
export function runShinyCheck(scene: BattleScene, mode: integer, wv?: integer) { export function runShinyCheck(scene: BattleScene, mode: integer, wv?: integer) {
var minLuck: integer = -1
if (mode == 1) { if (mode == 1) {
scene.emulateReset(wv) scene.emulateReset(wv)
} else { } else {
@ -6816,18 +6809,8 @@ export function runShinyCheck(scene: BattleScene, mode: integer, wv?: integer) {
} }
const predictionCost = new Utils.IntegerHolder(0) const predictionCost = new Utils.IntegerHolder(0)
var isOk = true; var isOk = true;
for (var i = 0; predictionCost.value < scene.money && i < 8; i++) { for (var i = 0; isOk && predictionCost.value < scene.money && i < 20; i++) {
var r = shinyCheckStep(scene, predictionCost, i) isOk = isOk && shinyCheckStep(scene, predictionCost, i)
isOk = isOk && (r[0] as boolean)
if (isOk || (r[1] as integer) === -1) {
// Do nothing
} else if (minLuck == -1) {
minLuck = (r[1] as integer)
console.log("Luck " + r[1] + " breaks")
} else {
console.log("Updated from " + minLuck + " to " + Math.min(minLuck, (r[1] as integer)))
minLuck = Math.min(minLuck, (r[1] as integer))
}
} }
if (mode == 1) { if (mode == 1) {
scene.restoreSeed(wv) scene.restoreSeed(wv)
@ -6837,10 +6820,7 @@ export function runShinyCheck(scene: BattleScene, mode: integer, wv?: integer) {
if (!isOk) { if (!isOk) {
console.log("Conflict found!") console.log("Conflict found!")
} }
if (minLuck == 15) { return isOk
//minLuck = 0
}
return [isOk, minLuck]
} }
export class SelectModifierPhase extends BattlePhase { export class SelectModifierPhase extends BattlePhase {
private rerollCount: integer; private rerollCount: integer;

View File

@ -15,7 +15,6 @@ import * as LoggerTools from "../logger"
import { BattleEndPhase } from "#app/phases.js"; import { BattleEndPhase } from "#app/phases.js";
import { Gender } from "#app/data/gender.js"; import { Gender } from "#app/data/gender.js";
import { getBiomeName } from "#app/data/biomes.js"; import { getBiomeName } from "#app/data/biomes.js";
import { getLuckString } from "#app/modifier/modifier-type.js";
/** Enum used to differentiate {@linkcode Arena} effects */ /** Enum used to differentiate {@linkcode Arena} effects */
enum ArenaEffectType { enum ArenaEffectType {
@ -96,7 +95,6 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
private flyoutTextField: Phaser.GameObjects.Text; private flyoutTextField: Phaser.GameObjects.Text;
private shinyCharmIcon: Phaser.GameObjects.Sprite; private shinyCharmIcon: Phaser.GameObjects.Sprite;
private shinyCharmLuckCount: Phaser.GameObjects.Text;
public shinyState: integer = 0; public shinyState: integer = 0;
/** Container for all field effects observed by this object */ /** Container for all field effects observed by this object */
@ -200,38 +198,26 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
this.shinyCharmIcon.setScale(0.4) this.shinyCharmIcon.setScale(0.4)
this.shinyCharmIcon.setInteractive(new Phaser.Geom.Rectangle(2, 2, 26, 27), Phaser.Geom.Rectangle.Contains); this.shinyCharmIcon.setInteractive(new Phaser.Geom.Rectangle(2, 2, 26, 27), Phaser.Geom.Rectangle.Contains);
this.flyoutContainer.add(this.shinyCharmIcon) this.flyoutContainer.add(this.shinyCharmIcon)
this.shinyCharmLuckCount = addTextObject(this.scene, this.flyoutWidth - 9, 5, "?", TextStyle.BATTLE_INFO);
this.shinyCharmLuckCount.setLineSpacing(-1);
this.shinyCharmLuckCount.setFontSize(40);
this.shinyCharmLuckCount.setAlign("center");
this.shinyCharmLuckCount.setOrigin(0, 0);
this.flyoutContainer.add(this.shinyCharmLuckCount)
} }
doShinyCharmTooltip() { doShinyCharmTooltip() {
if ((this.scene as BattleScene).currentBattle.waveIndex % 10 == 0) { if ((this.scene as BattleScene).currentBattle.waveIndex % 10 == 0) {
this.shinyCharmIcon.setVisible(false) this.shinyCharmIcon.setVisible(false)
this.shinyCharmLuckCount.setVisible(false)
return; return;
} }
this.shinyCharmIcon.setVisible(true) this.shinyCharmIcon.setVisible(true)
this.shinyCharmLuckCount.setVisible(true)
if (true) { // this.shinyCharmIcon.visible if (true) { // this.shinyCharmIcon.visible
this.shinyCharmIcon.removeAllListeners() this.shinyCharmIcon.removeAllListeners()
if (!(this.scene as BattleScene).waveShinyChecked) { if (!(this.scene as BattleScene).waveShinyChecked) {
this.shinyCharmIcon.setVisible(false) this.shinyCharmIcon.setVisible(false)
this.shinyCharmLuckCount.setVisible(false)
return; return;
//this.shinyCharmIcon.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `???`)); //this.shinyCharmIcon.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `???`));
} else if ((this.scene as BattleScene).waveShinyFlag) { } else if ((this.scene as BattleScene).waveShinyFlag) {
this.shinyCharmIcon.clearTint() this.shinyCharmIcon.clearTint()
this.shinyCharmIcon.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `Shinies are OK`)); this.shinyCharmIcon.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `Shinies are OK`));
this.shinyCharmLuckCount.setVisible(false)
} else { } else {
this.shinyCharmIcon.setTintFill(0x000000) this.shinyCharmIcon.setTintFill(0x000000)
this.shinyCharmIcon.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `Shinies change shop with luck ${(this.scene as BattleScene).waveShinyMinToBreak} or higher`)); this.shinyCharmIcon.on("pointerover", () => (this.scene as BattleScene).ui.showTooltip(null, `Shinies change shop`));
this.shinyCharmLuckCount.text = getLuckString((this.scene as BattleScene).waveShinyMinToBreak)
} }
this.shinyCharmIcon.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip()); this.shinyCharmIcon.on("pointerout", () => (this.scene as BattleScene).ui.hideTooltip());
} }

View File

@ -126,7 +126,6 @@ export default class BattleFlyout extends Phaser.GameObjects.Container {
/** Sets and formats the text property for all {@linkcode Phaser.GameObjects.Text} in the flyoutText array */ /** Sets and formats the text property for all {@linkcode Phaser.GameObjects.Text} in the flyoutText array */
setText(highlight?: integer) { setText(highlight?: integer) {
highlight = undefined // Disable move highlighting - for now, it shows what the pokemon used last turn, which is confusing
var e = this.battleScene.getEnemyField() var e = this.battleScene.getEnemyField()
console.log(this.moveInfo.map(v => v.move.name)) console.log(this.moveInfo.map(v => v.move.name))
for (let i = 0; i < this.flyoutText.length; i++) { for (let i = 0; i < this.flyoutText.length; i++) {