Update console-logging for debug purposes

Simulated rolls are now announced in the console and can have labels

Code to display catch rates, which had been repeated 3 times, has been moved to a function
This commit is contained in:
RedstonewolfX 2024-08-14 14:47:31 -04:00
parent 35a2b45fd1
commit b1a2943ff6
2 changed files with 21 additions and 44 deletions

View File

@ -356,7 +356,7 @@ export default class Battle {
return null;
}
multiInt(scene: BattleScene, out: integer[], count: integer, range: integer, min: integer = 0, offset?: integer): integer {
multiInt(scene: BattleScene, out: integer[], count: integer, range: integer, min: integer = 0, reason: string = "Unlabeled randSeedInt", offset?: integer): integer {
if (range <= 1) {
return min;
}
@ -376,6 +376,7 @@ export default class Battle {
for (var i = 0; i < count; i++) {
out.push(Utils.randSeedInt(range, min))
}
console.log("[SIMULATED] " + reason + " (x" + count + (offset ? " + offset " + offset : "") + ")", out)
Phaser.Math.RND.state(state);
//scene.setScoreText("RNG: " + tempRngCounter + " (Last sim: " + this.rngCounter + ")")
scene.rngCounter = tempRngCounter;

View File

@ -143,7 +143,7 @@ function findBest(scene: BattleScene, pokemon: EnemyPokemon, override?: boolean)
}
})
})
scene.currentBattle.multiInt(scene, rolls, offset + 3, 65536)
scene.currentBattle.multiInt(scene, rolls, offset + 3, 65536, undefined, "Catch prediction")
//console.log(rolls)
//console.log(rolls.slice(offset, offset + 3))
if (scene.pokeballCounts[0] == 0 && !override) rates[0] = 0
@ -2974,24 +2974,26 @@ export class TurnInitPhase extends FieldPhase {
this.scene.pushPhase(new TurnStartPhase(this.scene));
var txt = ["Turn: " + this.scene.currentBattle.turn]
if (!this.scene.getEnemyField()[0].hasTrainer()) {
this.scene.getEnemyField().forEach((pk, i) => {
if (pk.isActive() && pk.hp > 0)
txt = txt.concat(findBest(this.scene, pk))
})
}
if (txt.length > 2) {
txt = ["Turn: " + this.scene.currentBattle.turn]
}
this.scene.arenaFlyout.updateFieldText()
this.scene.setScoreText(txt.join(" / "))
updateCatchRate()
this.end();
}
}
function updateCatchRate() {
var txt = ["Turn: " + this.scene.currentBattle.turn]
if (!this.scene.getEnemyField()[0].hasTrainer()) {
this.scene.getEnemyField().forEach((pk, i) => {
if (pk.isActive() && pk.hp > 0)
txt = txt.concat(findBest(this.scene, pk))
})
}
if (txt.length > 2) {
txt = ["Turn: " + this.scene.currentBattle.turn]
}
this.scene.arenaFlyout.updateFieldText()
this.scene.setScoreText(txt.join(" / "))
}
//#endregion
@ -3310,20 +3312,7 @@ export class EnemyCommandPhase extends FieldPhase {
enemyPokemon.flyout.setText()
var txt = ["Turn: " + this.scene.currentBattle.turn]
if (!this.scene.getEnemyField()[0].hasTrainer()) {
this.scene.getEnemyField().forEach((pk, i) => {
if (pk.isActive() && pk.hp > 0)
txt = txt.concat(findBest(this.scene, pk))
})
}
if (txt.length > 2) {
txt = ["Turn: " + this.scene.currentBattle.turn]
}
this.scene.arenaFlyout.updateFieldText()
this.scene.setScoreText(txt.join(" / "))
updateCatchRate()
return this.end();
}
@ -3364,20 +3353,7 @@ export class EnemyCommandPhase extends FieldPhase {
//LoggerTools.enemyPlan[this.fieldIndex*2 + 1] = "→ " + nextMove.targets.map((m) => targetLabels[m + 1])
this.scene.arenaFlyout.updateFieldText()
var txt = ["Turn: " + this.scene.currentBattle.turn]
if (!this.scene.getEnemyField()[0].hasTrainer()) {
this.scene.getEnemyField().forEach((pk, i) => {
if (pk.isActive() && pk.hp > 0)
txt = txt.concat(findBest(this.scene, pk))
})
}
if (txt.length > 2) {
txt = ["Turn: " + this.scene.currentBattle.turn]
}
this.scene.arenaFlyout.updateFieldText()
this.scene.setScoreText(txt.join(" / "))
updateCatchRate()
this.end();
}