Refresh detection

This commit is contained in:
RedstonewolfX 2024-08-11 23:49:15 -04:00
parent 5371ab611d
commit 63604b5a79
3 changed files with 63 additions and 0 deletions

View File

@ -241,6 +241,9 @@ export default class BattleScene extends SceneBase {
private enemyModifierBar: ModifierBar;
public arenaFlyout: ArenaFlyout;
public battleRNGState: string;
public battleBaseRNGState: string;
private fieldOverlay: Phaser.GameObjects.Rectangle;
private shopOverlay: Phaser.GameObjects.Rectangle;
private shopOverlayShown: boolean = false;
@ -1444,6 +1447,10 @@ export default class BattleScene extends SceneBase {
}
}
this.battleRNGState = Phaser.Math.RND.state()
console.log(this.battleBaseRNGState, this.battleRNGState)
return this.currentBattle;
}
@ -1659,6 +1666,8 @@ export default class BattleScene extends SceneBase {
Phaser.Math.RND.sow([ this.waveSeed ]);
console.log("Wave Seed:", this.waveSeed, wave);
this.rngCounter = 0;
this.battleRNGState = Phaser.Math.RND.state()
this.battleBaseRNGState = Phaser.Math.RND.state()
//this.setScoreText("RNG: 0")
}

View File

@ -28,6 +28,7 @@ import { BattlerTagType } from "#enums/battler-tag-type";
import { Biome } from "#enums/biome";
import { Moves } from "#enums/moves";
import { Species } from "#enums/species";
import * as LoggerTools from "../logger"
export enum MoveCategory {
PHYSICAL,
@ -1941,7 +1942,21 @@ export class StealHeldItemChanceAttr extends MoveEffectAttr {
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): Promise<boolean> {
return new Promise<boolean>(resolve => {
const rand = Phaser.Math.RND.realInRange(0, 1);
// Swap to RNG state for a reload
const tempState = Phaser.Math.RND.state()
Phaser.Math.RND.state(user.scene.battleRNGState)
const rand_reload = Phaser.Math.RND.realInRange(0, 1);
user.scene.battleRNGState = Phaser.Math.RND.state()
Phaser.Math.RND.state(tempState)
console.log("Phaser.Math.RND.realInRange(0, 1)", rand)
if (rand >= this.chance && rand_reload < this.chance) {
console.error("Reload discrepancy: Fails now, but succeeds after reload")
LoggerTools.flagReset(user.scene, user.scene.currentBattle.waveIndex)
}
if (rand_reload >= this.chance && rand < this.chance) {
console.error("Reload discrepancy: Succeeds now, but fails after reload")
LoggerTools.flagReset(user.scene, user.scene.currentBattle.waveIndex)
}
if (rand >= this.chance) {
return resolve(false);
}

View File

@ -184,6 +184,45 @@ export function getLogs() {
}
}
}
/*
logs.forEach((log, idx) => {
var dat = JSON.parse(localStorage.getItem(logs[idx][1])) as DRPD;
logs[idx][4] = dat.version + "-" + dat.date
})
logs.sort((a, b) => {
var data1 = a[4].split("-")
var data2 = b[4].split("-")
var S = 0
// Sort by game version
if (S == 0) {
S = acceptedVersions.indexOf(data1[0]) - acceptedVersions.indexOf(b[0])
if (acceptedVersions.indexOf(data1[0]) == -1) {
S = -1
if (acceptedVersions.indexOf(data2[0]) == -1) {
S = 0
}
} else if (acceptedVersions.indexOf(data2[0]) == -1) {
S = 1
}
}
// Sort by year
if (S == 0) {
S = (Number(data1[1]) - Number(data2[1]))
}
// Sort by month
if (S == 0) {
S = (Number(data1[2]) - Number(data2[2]))
}
// Sort by day
if (S == 0) {
S = (Number(data1[3]) - Number(data2[3]))
}
return S;
})
logs.forEach((log, idx) => {
logs[idx][4] = ""
})
*/
}
/**
* Returns a string for the name of the current game mode.