This commit is contained in:
Bertie690 2025-09-22 21:44:46 -04:00 committed by GitHub
commit 7ec044e12f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 0 additions and 28 deletions

View File

@ -151,8 +151,6 @@ import Phaser from "phaser";
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import type UIPlugin from "phaser3-rex-plugins/templates/ui/ui-plugin";
const DEBUG_RNG = false;
export interface PokeballCounts {
[pb: string]: number;
}
@ -312,7 +310,6 @@ export class BattleScene extends SceneBase {
private bgmCache: Set<string> = new Set();
private playTimeTimer: Phaser.Time.TimerEvent;
public rngCounter = 0;
public rngSeedOverride = "";
public rngOffset = 0;
@ -359,20 +356,6 @@ export class BattleScene extends SceneBase {
}
async preload() {
if (DEBUG_RNG) {
const originalRealInRange = Phaser.Math.RND.realInRange;
Phaser.Math.RND.realInRange = function (min: number, max: number): number {
const ret = originalRealInRange.apply(this, [min, max]);
const args = ["RNG", ++this.rngCounter, ret / (max - min), `min: ${min} / max: ${max}`];
args.push(`seed: ${this.rngSeedOverride || this.waveSeed || this.seed}`);
if (this.rngOffset) {
args.push(`offset: ${this.rngOffset}`);
}
console.log(...args);
return ret;
};
}
/**
* These moves serve as fallback animations for other moves without loaded animations, and
* must be loaded prior to game start.
@ -1103,7 +1086,6 @@ export class BattleScene extends SceneBase {
setSeed(seed: string): void {
this.seed = seed;
this.rngCounter = 0;
this.waveCycleOffset = this.getGeneratedWaveCycleOffset();
this.offsetGym = this.gameMode.isClassic && this.getGeneratedOffsetGym();
}
@ -1823,24 +1805,20 @@ export class BattleScene extends SceneBase {
this.waveSeed = shiftCharCodes(this.seed, wave);
Phaser.Math.RND.sow([this.waveSeed]);
console.log("Wave Seed:", this.waveSeed, wave);
this.rngCounter = 0;
}
executeWithSeedOffset(func: () => void, offset: number, seedOverride?: string): void {
if (!func) {
return;
}
const tempRngCounter = this.rngCounter;
const tempRngOffset = this.rngOffset;
const tempRngSeedOverride = this.rngSeedOverride;
const state = Phaser.Math.RND.state();
Phaser.Math.RND.sow([shiftCharCodes(seedOverride || this.seed, offset)]);
this.rngCounter = 0;
this.rngOffset = offset;
this.rngSeedOverride = seedOverride || "";
func();
Phaser.Math.RND.state(state);
this.rngCounter = tempRngCounter;
this.rngOffset = tempRngOffset;
this.rngSeedOverride = tempRngSeedOverride;
}

View File

@ -97,8 +97,6 @@ export class Battle {
*/
public failedRunAway = false;
private rngCounter = 0;
constructor(gameMode: GameMode, waveIndex: number, battleType: BattleType, trainer?: Trainer, double = false) {
this.gameMode = gameMode;
this.waveIndex = waveIndex;
@ -440,7 +438,6 @@ export class Battle {
if (range <= 1) {
return min;
}
const tempRngCounter = globalScene.rngCounter;
const tempSeedOverride = globalScene.rngSeedOverride;
const state = Phaser.Math.RND.state();
if (this.battleSeedState) {
@ -449,12 +446,10 @@ export class Battle {
Phaser.Math.RND.sow([shiftCharCodes(this.battleSeed, this.turn << 6)]);
console.log("Battle Seed:", this.battleSeed);
}
globalScene.rngCounter = this.rngCounter++;
globalScene.rngSeedOverride = this.battleSeed;
const ret = randSeedInt(range, min);
this.battleSeedState = Phaser.Math.RND.state();
Phaser.Math.RND.state(state);
globalScene.rngCounter = tempRngCounter;
globalScene.rngSeedOverride = tempSeedOverride;
return ret;
}

View File

@ -118,7 +118,6 @@ describe("SelectModifierPhase", () => {
scene.waveSeed = shiftCharCodes(scene.seed, 5);
Phaser.Math.RND.sow([scene.waveSeed]);
console.log("Wave Seed:", scene.waveSeed, 5);
scene.rngCounter = 0;
});
game.move.select(MoveId.FISSURE);