Reapply "Fix team display"

This reverts commit 708ae2699d.
This commit is contained in:
RedstonewolfX 2024-07-20 16:15:50 -04:00
parent 8efdda8528
commit d94d5d6efb
2 changed files with 75 additions and 31 deletions

View File

@ -721,6 +721,21 @@ export function getWave(drpd: DRPD, floor: integer, scene: BattleScene): Wave {
} }
} }
if (wv == undefined) { if (wv == undefined) {
if (scene.gameMode.modeId != GameModes.DAILY) {
drpd.waves.push({
id: floor,
reload: false,
//type: floor % 10 == 0 ? "boss" : (floor % 10 == 5 ? "trainer" : "wild"),
type: floor % 10 == 0 ? "boss" : "wild",
double: scene.currentBattle.double,
actions: [],
shop: "",
biome: getBiomeName(scene.arena.biomeType),
clearActionsFlag: false,
//pokemon: []
})
return drpd.waves[drpd.waves.length - 1]
}
console.error("Out of wave slots??") console.error("Out of wave slots??")
scene.ui.showText("Out of wave slots!\nClearing duplicates...", null, () => { scene.ui.showText("Out of wave slots!\nClearing duplicates...", null, () => {
for (var i = 0; i < drpd.waves.length - 1; i++) { for (var i = 0; i < drpd.waves.length - 1; i++) {
@ -1389,7 +1404,7 @@ export function generateEditHandler(scene: BattleScene, logId: string, callback:
export function logActions(scene: BattleScene, floor: integer, action: string) { export function logActions(scene: BattleScene, floor: integer, action: string) {
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene) var drpd = getDRPD(scene)
console.log("Log Action", drpd) console.log(`Logging an action: "${action}"`)
var wv: Wave = getWave(drpd, floor, scene) var wv: Wave = getWave(drpd, floor, scene)
if (wv.double == undefined) if (wv.double == undefined)
wv.double = false wv.double = false
@ -1399,7 +1414,7 @@ export function logActions(scene: BattleScene, floor: integer, action: string) {
wv.actions = [] wv.actions = []
} }
wv.actions.push(action) wv.actions.push(action)
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
@ -1413,7 +1428,34 @@ export function logActions(scene: BattleScene, floor: integer, action: string) {
export function appendAction(scene: BattleScene, floor: integer, action: string) { export function appendAction(scene: BattleScene, floor: integer, action: string) {
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene) var drpd = getDRPD(scene)
console.log("Append to Action", drpd) var wv: Wave = getWave(drpd, floor, scene)
if (wv.clearActionsFlag) {
console.log("Triggered clearActionsFlag")
wv.clearActionsFlag = false
wv.actions = []
}
console.log(`Appending to an action: "${wv.actions[wv.actions.length - 1]}" + "${action}"`)
if (wv.double == undefined)
wv.double = false
wv.actions[wv.actions.length - 1] = wv.actions[wv.actions.length - 1] + action
console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
}
/**
* Logs the actions that the player took.
*
* This includes attacks you perform, items you transfer during the shop, Poke Balls you throw, running from battl, (or attempting to), and switching (including pre-switches).
* @param scene The BattleScene. Used to get the log ID.
* @param floor The wave index to write to.
* @param action The text you want to add to the actions list.
*
* @see resetWaveActions
*/
export function getActionCount(scene: BattleScene, floor: integer) {
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene)
console.log(`Checking action count`)
console.log(drpd)
var wv: Wave = getWave(drpd, floor, scene) var wv: Wave = getWave(drpd, floor, scene)
if (wv.double == undefined) if (wv.double == undefined)
wv.double = false wv.double = false
@ -1422,9 +1464,7 @@ export function appendAction(scene: BattleScene, floor: integer, action: string)
wv.clearActionsFlag = false wv.clearActionsFlag = false
wv.actions = [] wv.actions = []
} }
wv.actions[wv.actions.length - 1] = wv.actions[wv.actions.length - 1] + action return (wv.actions.length)
console.log(drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
* Logs that a Pokémon was captured. * Logs that a Pokémon was captured.
@ -1435,11 +1475,11 @@ export function appendAction(scene: BattleScene, floor: integer, action: string)
export function logCapture(scene: BattleScene, floor: integer, target: EnemyPokemon) { export function logCapture(scene: BattleScene, floor: integer, target: EnemyPokemon) {
//if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) //if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene) var drpd = getDRPD(scene)
console.log("Log Capture", drpd) console.log(`Logging successful capture: ${target.name}`)
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;
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
@ -1451,12 +1491,12 @@ export function logCapture(scene: BattleScene, floor: integer, target: EnemyPoke
export function logPlayerTeam(scene: BattleScene) { export function logPlayerTeam(scene: BattleScene) {
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene) var drpd = getDRPD(scene)
console.log("Log Player Starters", drpd) console.log(`Logging player starters: ${scene.getParty().map(p => p.name).join(", ")}`)
var P = scene.getParty() var P = scene.getParty()
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])
} }
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
@ -1471,7 +1511,7 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
if (floor == undefined) floor = scene.currentBattle.waveIndex if (floor == undefined) floor = scene.currentBattle.waveIndex
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene) var drpd = getDRPD(scene)
console.log("Log Enemy Pokemon", drpd) console.log(`Logging opposing team member: ${pokemon.name}`)
var wv: Wave = getWave(drpd, floor, scene) var wv: Wave = getWave(drpd, floor, scene)
var pk: PokeData = exportPokemon(pokemon, encounterRarity) var pk: PokeData = exportPokemon(pokemon, encounterRarity)
pk.source = pokemon pk.source = pokemon
@ -1538,7 +1578,7 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
//wv.actions = [] //wv.actions = []
wv.clearActionsFlag = false; wv.clearActionsFlag = false;
wv.shop = "" wv.shop = ""
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
@ -1550,10 +1590,10 @@ export function logPokemon(scene: BattleScene, floor: integer = undefined, slot:
export function logShop(scene: BattleScene, floor: integer, action: string) { export function logShop(scene: BattleScene, floor: integer, action: string) {
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd = getDRPD(scene) var drpd = getDRPD(scene)
console.log("Log Shop Item", drpd) 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
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
@ -1566,12 +1606,12 @@ export function logTrainer(scene: BattleScene, floor: integer = undefined) {
if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run"))) if (localStorage.getItem(getLogID(scene)) == null) localStorage.setItem(getLogID(scene), JSON.stringify(newDocument(getMode(scene) + " Run")))
var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD; var drpd: DRPD = JSON.parse(localStorage.getItem(getLogID(scene))) as DRPD;
drpd = updateLog(drpd); drpd = updateLog(drpd);
console.log("Log Trainer", drpd) console.log(`Logging trainer: ${scene.currentBattle.trainer.getTitleOnly()} ${scene.currentBattle.trainer.getNameOnly()}`)
var wv: Wave = getWave(drpd, floor, scene) var wv: Wave = getWave(drpd, floor, scene)
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"
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
@ -1593,7 +1633,7 @@ 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;
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
/** /**
@ -1622,7 +1662,7 @@ 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;
console.log(drpd) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
@ -1647,7 +1687,7 @@ export function resetWaveActions(scene: BattleScene, floor: integer = undefined,
} else { } else {
wv.actions = [] wv.actions = []
} }
console.log(drpd, wv) console.log("--> ", drpd)
localStorage.setItem(getLogID(scene), JSON.stringify(drpd)) localStorage.setItem(getLogID(scene), JSON.stringify(drpd))
} }
//#endregion //#endregion

View File

@ -551,18 +551,20 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
} }
var total_visible = 0 var total_visible = 0
for (var i = 0; i < P.length; i++) { for (var i = 0; i < P.length; i++) {
states[i] = "ball" if (P[i] != undefined) {
if (!party[i].hp) { states[i] = "ball"
states[i] = "faint" if (!party[i].hp) {
} else if (party[i].status) { states[i] = "faint"
states[i] = (this.scene as BattleScene).showTeamSprites ? "ball" : "status" } else if (party[i].status) {
states[i] = (this.scene as BattleScene).showTeamSprites ? "ball" : "status"
}
if (P[i].isOnField()) {
//console.log(P[i].name + " is in battle; set it as seen")
P[i].usedInBattle = true
}
if (P[i].usedInBattle) total_visible++;
//console.log(P[i].name, P[i].getIconAtlasKey(true))
} }
if (P[i].isOnField()) {
//console.log(P[i].name + " is in battle; set it as seen")
P[i].usedInBattle = true
}
if (P[i].usedInBattle) total_visible++;
//console.log(P[i].name, P[i].getIconAtlasKey(true))
} }
console.log("Updating ball icons for party (" + P.length + ")") console.log("Updating ball icons for party (" + P.length + ")")
if (staticparty.length > 0) { if (staticparty.length > 0) {
@ -713,6 +715,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
if (this.lastStatus !== StatusEffect.NONE) { if (this.lastStatus !== StatusEffect.NONE) {
this.statusIndicator.setFrame(StatusEffect[this.lastStatus].toLowerCase()); this.statusIndicator.setFrame(StatusEffect[this.lastStatus].toLowerCase());
this.statusIndicator.setVisible(!!this.lastStatus);
} else if (this.player) { } else if (this.player) {
this.statusIndicator.setVisible(!!this.lastStatus); this.statusIndicator.setVisible(!!this.lastStatus);
} else { } else {
@ -987,8 +990,9 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
targets: this.statusIndicator, targets: this.statusIndicator,
duration: Utils.fixedInt(125), duration: Utils.fixedInt(125),
ease: "Sine.easeInOut", ease: "Sine.easeInOut",
alpha: visible && this.iconsActive ? 0 : (!!this.lastStatus ? 1 : 0) alpha: visible && this.iconsActive ? 0 : (this.lastStatus == 0 ? 0 : 1)
}); });
console.log(this.iconsActive, this.lastStatus, this.statusIndicator.visible, this.statusIndicator.alpha)
} }
/** /**