Revert "Reload Detection is here"

This reverts commit 15d2278cc7.
This commit is contained in:
RedstonewolfX 2024-07-20 16:00:57 -04:00
parent 6d9606329c
commit ecdc035ab5
2 changed files with 32 additions and 135 deletions

View File

@ -47,13 +47,8 @@ export const rarities = []
export const rarityslot = [0, ""] export const rarityslot = [0, ""]
/** Stores a list of the user's battle actions in a turn. /** Stores a list of the user's battle actions in a turn.
* *
* Its contents are printed to the current wave's `actions` list, separated by pipes `|`, when the turn begins playing out. */ * Its contents are printed to the current wave's actions list, separated by pipes `|`, when the turn begins playing out. */
export const Actions = [] export const Actions = []
/** Stores a list of the opponent's battle actions in a turn.
*
* Its contents are printed to the current wave's `initialActions` list, separated by pipes `|`, when the turn begins playing out.
*/
export const EnemyActions = []
// Booleans // Booleans
export const isPreSwitch: Utils.BooleanHolder = new Utils.BooleanHolder(false); export const isPreSwitch: Utils.BooleanHolder = new Utils.BooleanHolder(false);
@ -217,7 +212,7 @@ export function getDRPD(scene: BattleScene): DRPD {
} }
export function save(scene: BattleScene, drpd: DRPD) { export function save(scene: BattleScene, drpd: DRPD) {
console.log("--> ", drpd) console.log(drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
@ -566,7 +561,6 @@ export interface Wave {
*/ */
trainer?: TrainerData, trainer?: TrainerData,
/** The Pokémon that you have to battle against. /** The Pokémon that you have to battle against.
*
* Not included if this is a trainer battle. * Not included if this is a trainer battle.
* @see PokeData * @see PokeData
* @see Wave.type * @see Wave.type
@ -574,20 +568,11 @@ export interface Wave {
pokemon?: PokeData[], pokemon?: PokeData[],
/** /**
* Contains the first 3 turns or so of the enemy's actions. * Contains the first 3 turns or so of the enemy's actions.
*
* Used to check for refreshes. * Used to check for refreshes.
*/ */
initialActions: string[], initialActions: string[],
/**
* The current writing index in the `initialActions` array.
*
* Used to track changes between this wave's actions and the previous one
* @see Wave.initialActions
*/
turnIndex: integer,
/** /**
* Contains the names of the first set of modifier rewards. * Contains the names of the first set of modifier rewards.
*
* Used to check for refreshes. * Used to check for refreshes.
*/ */
modifiers: string[] modifiers: string[]
@ -608,7 +593,6 @@ export function exportWave(scene: BattleScene): Wave {
clearActionsFlag: false, clearActionsFlag: false,
biome: getBiomeName(scene.arena.biomeType), biome: getBiomeName(scene.arena.biomeType),
initialActions: [], initialActions: [],
turnIndex: 0,
modifiers: [] modifiers: []
} }
if (ret.double == undefined) ret.double = false; if (ret.double == undefined) ret.double = false;
@ -726,7 +710,7 @@ function printWave(inData: string, indent: string, wave: Wave): string {
export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave { export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
var wv: Wave; var wv: Wave;
var insertPos: integer; var insertPos: integer;
//console.log(drpd.waves) console.log(drpd.waves)
for (var i = 0; i < drpd.waves.length; i++) { for (var i = 0; i < drpd.waves.length; i++) {
if (drpd.waves[i] != undefined && drpd.waves[i] != null) { if (drpd.waves[i] != undefined && drpd.waves[i] != null) {
if (drpd.waves[i].id == floor) { if (drpd.waves[i].id == floor) {
@ -752,7 +736,6 @@ export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
clearActionsFlag: false, clearActionsFlag: false,
biome: getBiomeName(scene.arena.biomeType), biome: getBiomeName(scene.arena.biomeType),
initialActions: [], initialActions: [],
turnIndex: 0,
modifiers: [], modifiers: [],
//pokemon: [] //pokemon: []
} }
@ -788,7 +771,6 @@ export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
biome: getBiomeName(scene.arena.biomeType), biome: getBiomeName(scene.arena.biomeType),
clearActionsFlag: false, clearActionsFlag: false,
initialActions: [], initialActions: [],
turnIndex: 0,
modifiers: [], modifiers: [],
//pokemon: [] //pokemon: []
}) })
@ -827,7 +809,6 @@ export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
biome: getBiomeName(scene.arena.biomeType), biome: getBiomeName(scene.arena.biomeType),
clearActionsFlag: false, clearActionsFlag: false,
initialActions: [], initialActions: [],
turnIndex: 0,
modifiers: [], modifiers: [],
//pokemon: [] //pokemon: []
} }
@ -858,7 +839,6 @@ export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
clearActionsFlag: false, clearActionsFlag: false,
biome: getBiomeName(scene.arena.biomeType), biome: getBiomeName(scene.arena.biomeType),
initialActions: [], initialActions: [],
turnIndex: 0,
modifiers: [], modifiers: [],
//pokemon: [] //pokemon: []
} }
@ -1523,34 +1503,10 @@ export function logActions(scene: BattleScene, floor: integer, action: string) {
console.log("Triggered clearActionsFlag") console.log("Triggered clearActionsFlag")
wv.clearActionsFlag = false wv.clearActionsFlag = false
wv.actions = [] wv.actions = []
wv.turnIndex = 0
} }
wv.actions.push(action) wv.actions.push(action)
save(scene, drpd) console.log("--> ", drpd)
} localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
/**
* Logs an opposing Pokemon's attack. If there is existing data, and it is different from the new data, a reload is flagged.
* @param scene The BattleScene. Used to get the log ID.
* @param floor The wave index to write to. Defaults to the current wave.
* @param action The action to write.
*/
export function logEnemyAction(scene: BattleScene, floor: integer = undefined, action: string) {
if (floor == undefined)
floor = scene.currentBattle.waveIndex;
var drpd = getDRPD(scene)
var wv = getWave(drpd, floor, scene)
if (wv.turnIndex >= EnemyEventLogCount) {
// Don't log any actions if we already logged the maximum amount
return;
}
console.log(`Log enemy action: "${action}" (Turn ${wv.turnIndex})`, drpd)
if (wv.initialActions[wv.turnIndex] != undefined && wv.initialActions[wv.turnIndex] != action) {
console.log(`New action (${action}) is different from old action (${wv.initialActions[wv.turnIndex]})! Flagging a reload`)
wv.reload = true
}
wv.initialActions[wv.turnIndex] = action
wv.turnIndex++
save(scene, drpd)
} }
/** /**
* Logs the actions that the player took, adding text to the most recent action. * Logs the actions that the player took, adding text to the most recent action.
@ -1568,13 +1524,13 @@ export function appendAction(scene: BattleScene, floor: integer, action: string)
console.log("Triggered clearActionsFlag") console.log("Triggered clearActionsFlag")
wv.clearActionsFlag = false wv.clearActionsFlag = false
wv.actions = [] wv.actions = []
wv.turnIndex = 0
} }
console.log(`Appending to an action: "${wv.actions[wv.actions.length - 1]}" + "${action}"`) console.log(`Appending to an action: "${wv.actions[wv.actions.length - 1]}" + "${action}"`)
if (wv.double == undefined) if (wv.double == undefined)
wv.double = false wv.double = false
wv.actions[wv.actions.length - 1] = wv.actions[wv.actions.length - 1] + action wv.actions[wv.actions.length - 1] = wv.actions[wv.actions.length - 1] + action
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
* Logs the actions that the player took. * Logs the actions that the player took.
@ -1597,7 +1553,6 @@ export function getActionCount(scene: BattleScene, floor: integer) {
console.log("Triggered clearActionsFlag") console.log("Triggered clearActionsFlag")
wv.clearActionsFlag = false wv.clearActionsFlag = false
wv.actions = [] wv.actions = []
wv.turnIndex = 0
} }
return (wv.actions.length) return (wv.actions.length)
} }
@ -1614,30 +1569,8 @@ export function logCapture(scene: BattleScene, floor: integer, target: EnemyPoke
var wv: Wave = getWave(drpd, floor, scene) var wv: Wave = getWave(drpd, floor, scene)
var pkslot = target.partyslot var pkslot = target.partyslot
wv.pokemon[pkslot].captured = true; wv.pokemon[pkslot].captured = true;
save(scene, drpd) console.log("--> ", drpd)
} localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
/**
* Logs the player's modifiers/loot. If there is existing data, and it is different from the new data, a reload is flagged.
* @param scene The BattleScene. Used to get the log ID.
* @param floor The wave index to write to. Defaults to the current wave.
* @param logModifiers The action to write.
*/
export function logModifiers(scene: BattleScene, floor: integer = undefined, modifiers: string[]) {
if (floor == undefined)
floor = scene.currentBattle.waveIndex;
var drpd = getDRPD(scene)
var wv = getWave(drpd, floor, scene)
console.log("Log modifiers list", drpd)
if (wv.modifiers.length > 0 && wv.modifiers.join(", ") != modifiers.join(", ")) {
console.log("The modifiers list changed!")
for (var i = 0; i < wv.modifiers.length; i++) {
console.log(wv.modifiers[i], modifiers[i])
console.log("Flagging a reload")
}
wv.reload = true
}
wv.modifiers = modifiers
save(scene, drpd)
} }
/** /**
* Logs the player's current party. * Logs the player's current party.
@ -1652,7 +1585,8 @@ export function logPlayerTeam(scene: BattleScene) {
for (var i = 0; i < P.length; i++) { for (var i = 0; i < P.length; i++) {
drpd.starters[i] = exportPokemon(P[i]) drpd.starters[i] = exportPokemon(P[i])
} }
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
* Logs a wild Pokémon to a wave's data. * Logs a wild Pokémon to a wave's data.
@ -1732,7 +1666,8 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
//wv.actions = [] //wv.actions = []
wv.clearActionsFlag = false; wv.clearActionsFlag = false;
wv.shop = "" wv.shop = ""
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
* Logs what the player took from the rewards pool and, if applicable, who they used it on. * Logs what the player took from the rewards pool and, if applicable, who they used it on.
@ -1746,7 +1681,8 @@ export function logShop(scene: BattleScene, floor: integer, action: string) {
console.log(`Logging shop result: "${action}"`) console.log(`Logging shop result: "${action}"`)
var wv: Wave = getWave(drpd, floor, scene) var wv: Wave = getWave(drpd, floor, scene)
wv.shop = action wv.shop = action
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
* Logs the current floor's Trainer. * Logs the current floor's Trainer.
@ -1763,33 +1699,18 @@ export function logTrainer(scene: BattleScene, floor: integer = undefined) {
var t: TrainerData = exportTrainer(scene.currentBattle.trainer) var t: TrainerData = exportTrainer(scene.currentBattle.trainer)
wv.trainer = t wv.trainer = t
wv.type = "trainer" wv.type = "trainer"
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/**
* Logs the player's modifiers/loot. If there is existing data, and it is different from the new data, a reload is flagged.
* @param scene The BattleScene. Used to get the log ID.
* @param floor The wave index to write to. Defaults to the current wave.
*/
export function deleteReloadDetectionData(scene: BattleScene, floor: integer = undefined) {
if (floor == undefined)
floor = scene.currentBattle.waveIndex;
var drpd = getDRPD(scene)
var wv = getWave(drpd, floor, scene)
console.log("Clear action & modifier storage", drpd)
wv.modifiers = []
wv.initialActions = []
wv.turnIndex = 0
save(scene, drpd)
}
/** /**
* Flags a wave as a reset. * Flags a wave as a reset.
* @param scene The BattleScene. Used to get the log ID. * @param scene The BattleScene. Used to get the log ID.
* @param floor The wave index to write to. Defaults to the current wave. * @param floor The wave index to write to.
*/ */
export function flagReset(scene: BattleScene, floor: integer = undefined) { export function flagReset(scene: BattleScene, floor: integer = undefined) {
if (floor == undefined) if (floor == undefined)
@ -1800,7 +1721,8 @@ export function flagReset(scene: BattleScene, floor: integer = undefined) {
console.log("Flag Reset", drpd) console.log("Flag Reset", drpd)
var wv = getWave(drpd, floor, scene) var wv = getWave(drpd, floor, scene)
wv.reload = true; wv.reload = true;
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
* Flags a wave as a reset, unless this is your first time playing the wave. * Flags a wave as a reset, unless this is your first time playing the wave.
@ -1828,7 +1750,8 @@ export function flagResetIfExists(scene: BattleScene, floor: integer = undefined
console.log("Flag reset as wave was already played before", drpd) console.log("Flag reset as wave was already played before", drpd)
var wv = getWave(drpd, floor, scene) var wv = getWave(drpd, floor, scene)
wv.reload = true; wv.reload = true;
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
@ -1850,9 +1773,9 @@ export function resetWaveActions(scene: BattleScene, floor: integer = undefined,
if (softflag) { if (softflag) {
wv.clearActionsFlag = true; wv.clearActionsFlag = true;
} else { } else {
wv.actions = []; wv.actions = []
wv.turnIndex = 0;
} }
save(scene, drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
//#endregion //#endregion

View File

@ -1700,30 +1700,6 @@ export class EncounterPhase extends BattlePhase {
} }
} }
} }
// Get this run's log (or generate it, if there isn't one)
var d = LoggerTools.getDRPD(this.scene)
if (d != undefined) {
// Get the current wave (or generate one, if there isn't any data)
var w = LoggerTools.getWave(d, this.scene.currentBattle.waveIndex, this.scene)
if (w != undefined) {
if (w.initialActions == undefined) w.initialActions = []
if (w.modifiers == undefined) w.modifiers = []
if (w.turnIndex == undefined) w.turnIndex = 0
// If any data has been written for this wave
if (w.initialActions.length > 0 || w.modifiers.length > 0 || w.turnIndex > 0) {
this.scene.ui.showText("This wave has existing data.\nClear it?", undefined, () => {
this.scene.ui.setMode(Mode.CONFIRM, () => {
//this.scene.ui.revertMode()
this.scene.ui.clearText()
LoggerTools.deleteReloadDetectionData(this.scene)
}, () => {
//this.scene.ui.revertMode()
this.scene.ui.clearText()
})
}, 500)
}
}
}
handleTutorial(this.scene, Tutorial.Access_Menu).then(() => super.end()); handleTutorial(this.scene, Tutorial.Access_Menu).then(() => super.end());
} }
@ -3336,7 +3312,6 @@ export class TurnStartPhase extends FieldPhase {
this.scene.pushPhase(new MovePhase(this.scene, pokemon, turnCommand.targets || turnCommand.move.targets, move, false, queuedMove.ignorePP)); this.scene.pushPhase(new MovePhase(this.scene, pokemon, turnCommand.targets || turnCommand.move.targets, move, false, queuedMove.ignorePP));
var targets = turnCommand.targets || turnCommand.move.targets var targets = turnCommand.targets || turnCommand.move.targets
var mv = new PokemonMove(queuedMove.move) var mv = new PokemonMove(queuedMove.move)
LoggerTools.EnemyActions[pokemon.getBattlerIndex() - 2] = move.getName()
} }
break; break;
case Command.BALL: case Command.BALL:
@ -3385,8 +3360,8 @@ export class TurnStartPhase extends FieldPhase {
if (LoggerTools.Actions.length > 1 && (LoggerTools.Actions[0] == "" || LoggerTools.Actions[0] == undefined || LoggerTools.Actions[0] == null)) if (LoggerTools.Actions.length > 1 && (LoggerTools.Actions[0] == "" || LoggerTools.Actions[0] == undefined || LoggerTools.Actions[0] == null))
LoggerTools.Actions.shift() // If the left slot isn't doing anything, delete its entry LoggerTools.Actions.shift() // If the left slot isn't doing anything, delete its entry
LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, LoggerTools.Actions.join(" | ")) LoggerTools.logActions(this.scene, this.scene.currentBattle.waveIndex, LoggerTools.Actions.join(" | "))
LoggerTools.logEnemyAction(this.scene, this.scene.currentBattle.waveIndex, LoggerTools.EnemyActions.join(" | "))
this.end(); this.end();
} }
@ -6428,6 +6403,12 @@ export class SelectModifierPhase extends BattlePhase {
start() { start() {
super.start(); super.start();
if (!this.rerollCount) {
this.updateSeed();
} else {
this.scene.reroll = false;
}
const party = this.scene.getParty(); const party = this.scene.getParty();
regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount); regenerateModifierPoolThresholds(party, this.getPoolType(), this.rerollCount);
const modifierCount = new Utils.IntegerHolder(3); const modifierCount = new Utils.IntegerHolder(3);
@ -6601,13 +6582,6 @@ export class SelectModifierPhase extends BattlePhase {
applyModifier(modifierType.newModifier()); applyModifier(modifierType.newModifier());
} }
if (!this.rerollCount) {
this.updateSeed();
LoggerTools.logModifiers(this.scene, undefined, typeOptions.map(v => v.type.name))
} else {
this.scene.reroll = false;
}
return !cost; return !cost;
}; };
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));