Implement Double Battles (#1)
* Add WiP logic for double battles * Minor changes for double battles * More fixes for double battles * Show battle info for both in double battles * Improvements to double battles * Add double battle version of party UI * Fix some issues with double battles * Updates to double battles * More work on double battles for stability * Fix issues with ability bar and evolution screen * Add chance for double battles
This commit is contained in:
1 parent
e2d6890072
commit
b9f7ba173d
31 files changed
+1583
-702
No files matched your search
@@ -24,7 +24,7 @@ export function initAutoPlay() {
|
||||
const commandUiHandler = this.ui.handlers[Mode.COMMAND] as CommandUiHandler;
|
||||
const fightUiHandler = this.ui.handlers[Mode.FIGHT] as FightUiHandler;
|
||||
const partyUiHandler = this.ui.handlers[Mode.PARTY] as PartyUiHandler;
|
||||
const switchCheckUiHandler = this.ui.handlers[Mode.CONFIRM] as ConfirmUiHandler;
|
||||
const confirmUiHandler = this.ui.handlers[Mode.CONFIRM] as ConfirmUiHandler;
|
||||
const modifierSelectUiHandler = this.ui.handlers[Mode.MODIFIER_SELECT] as ModifierSelectUiHandler;
|
||||
|
||||
const getBestPartyMemberIndex = () => {
|
||||
@@ -153,15 +153,15 @@ export function initAutoPlay() {
|
||||
}
|
||||
};
|
||||
|
||||
const originalSwitchCheckUiHandlerShow = switchCheckUiHandler.show;
|
||||
switchCheckUiHandler.show = function (args: any[]) {
|
||||
const originalSwitchCheckUiHandlerShow = confirmUiHandler.show;
|
||||
confirmUiHandler.show = function (args: any[]) {
|
||||
originalSwitchCheckUiHandlerShow.apply(this, [ args ]);
|
||||
if (thisArg.auto) {
|
||||
const bestPartyMemberIndex = getBestPartyMemberIndex();
|
||||
thisArg.time.delayedCall(20, () => {
|
||||
if (bestPartyMemberIndex)
|
||||
nextPartyMemberIndex = bestPartyMemberIndex;
|
||||
switchCheckUiHandler.setCursor(bestPartyMemberIndex ? 1 : 0);
|
||||
confirmUiHandler.setCursor(bestPartyMemberIndex ? 1 : 0);
|
||||
thisArg.time.delayedCall(20, () => this.processInput(Button.ACTION));
|
||||
});
|
||||
}
|
||||
@@ -193,7 +193,7 @@ export function initAutoPlay() {
|
||||
|
||||
const party = thisArg.getParty();
|
||||
const modifierTypeOptions = modifierSelectUiHandler.options.map(o => o.modifierTypeOption);
|
||||
const faintedPartyMemberIndex = party.findIndex(p => !p.hp);
|
||||
const faintedPartyMemberIndex = party.findIndex(p => p.isFainted());
|
||||
const lowHpPartyMemberIndex = party.findIndex(p => p.getHpRatio() <= 0.5);
|
||||
const criticalHpPartyMemberIndex = party.findIndex(p => p.getHpRatio() <= 0.25);
|
||||
|
||||
|
||||
+13
-10
@@ -21,7 +21,7 @@ interface SystemSaveData {
|
||||
|
||||
interface SessionSaveData {
|
||||
party: PokemonData[];
|
||||
enemyParty: PokemonData[];
|
||||
enemyField: PokemonData[];
|
||||
modifiers: PersistentModifierData[];
|
||||
enemyModifiers: PersistentModifierData[];
|
||||
arena: ArenaData;
|
||||
@@ -126,9 +126,9 @@ export class GameData {
|
||||
saveSession(scene: BattleScene): boolean {
|
||||
const sessionData = {
|
||||
party: scene.getParty().map(p => new PokemonData(p)),
|
||||
enemyParty: scene.getEnemyParty().map(p => new PokemonData(p)),
|
||||
modifiers: scene.findModifiers(m => true).map(m => new PersistentModifierData(m, true)),
|
||||
enemyModifiers: scene.findModifiers(m => true, false).map(m => new PersistentModifierData(m, false)),
|
||||
enemyField: scene.getEnemyField().map(p => new PokemonData(p)),
|
||||
modifiers: scene.findModifiers(() => true).map(m => new PersistentModifierData(m, true)),
|
||||
enemyModifiers: scene.findModifiers(() => true, false).map(m => new PersistentModifierData(m, false)),
|
||||
arena: new ArenaData(scene.arena),
|
||||
pokeballCounts: scene.pokeballCounts,
|
||||
waveIndex: scene.currentBattle.waveIndex,
|
||||
@@ -153,7 +153,7 @@ export class GameData {
|
||||
|
||||
try {
|
||||
const sessionData = JSON.parse(atob(localStorage.getItem('sessionData')), (k: string, v: any) => {
|
||||
if (k === 'party' || k === 'enemyParty') {
|
||||
if (k === 'party' || k === 'enemyField') {
|
||||
const ret: PokemonData[] = [];
|
||||
for (let pd of v)
|
||||
ret.push(new PokemonData(pd));
|
||||
@@ -187,17 +187,20 @@ export class GameData {
|
||||
loadPokemonAssets.push(pokemon.loadAssets());
|
||||
party.push(pokemon);
|
||||
}
|
||||
|
||||
const enemyPokemon = sessionData.enemyParty[0].toPokemon(scene) as EnemyPokemon;
|
||||
|
||||
Object.keys(scene.pokeballCounts).forEach((key: string) => {
|
||||
scene.pokeballCounts[key] = sessionData.pokeballCounts[key] || 0;
|
||||
});
|
||||
|
||||
scene.newArena(sessionData.arena.biome, true);
|
||||
scene.newBattle(sessionData.waveIndex).enemyPokemon = enemyPokemon;
|
||||
scene.newArena(sessionData.arena.biome, sessionData.enemyField.length > 1);
|
||||
const battle = scene.newBattle(sessionData.waveIndex, sessionData.enemyField.length > 1);
|
||||
|
||||
loadPokemonAssets.push(enemyPokemon.loadAssets());
|
||||
sessionData.enemyField.forEach((enemyData, e) => {
|
||||
const enemyPokemon = enemyData.toPokemon(scene) as EnemyPokemon;
|
||||
battle.enemyField[e] = enemyPokemon;
|
||||
|
||||
loadPokemonAssets.push(enemyPokemon.loadAssets());
|
||||
});
|
||||
|
||||
scene.arena.weather = sessionData.arena.weather;
|
||||
// TODO
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class ModifierData {
|
||||
type.generatorId = this.typeGeneratorId;
|
||||
|
||||
if (type instanceof ModifierTypeGenerator)
|
||||
type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyParty(), this.typePregenArgs);
|
||||
type = (type as ModifierTypeGenerator).generateType(this.player ? scene.getParty() : scene.getEnemyField(), this.typePregenArgs);
|
||||
|
||||
const ret = Reflect.construct(constructor, ([ type ] as any[]).concat(this.args).concat(this.stackCount)) as PersistentModifier
|
||||
|
||||
|
||||
Reference in new issue
Block a user