From c657c77d0cf49afba627b93848e1915e2ce7d3ff Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 31 Aug 2023 20:23:06 +0200 Subject: story and npcs --- resources/js/game.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'resources/js/game.js') diff --git a/resources/js/game.js b/resources/js/game.js index fb25ea4..2c6ecc0 100644 --- a/resources/js/game.js +++ b/resources/js/game.js @@ -26,6 +26,7 @@ const Game = { isProgressingTurn: false, playerIsChoosingNextMonster: false, isStoryBattle: false, + didWinStoryBattle: true, doBattleAnimation: true, opponentActionTimeout: null, didTechniqueHit: false, @@ -127,6 +128,7 @@ const Game = { UI.showMap(); } + Game.didWinStoryBattle = true; Game.isStoryBattle = false; } else { await Game.encounterNextTrainerMonster(); @@ -151,6 +153,7 @@ const Game = { // whole party defeated if (!Memory.state.player.monsters.some((monster) => monster.hp > 0)) { Memory.state.Game.isInBattle = false; + Game.didWinStoryBattle = false; Game.isStoryBattle = false; if (Memory.state.currentArea.monsterProgress < Memory.state.currentArea.requiredEncounters) { @@ -161,16 +164,10 @@ const Game = { await Game.goToArea(Memory.state.lastVisitedTown); // heal all monsters full - let totalHealingCenterPrice = 0; - for (const monster of Memory.state.player.monsters) { - monster.hp = monster.stats.hp; - monster.statusEffect = null; - - // pay healing center - const healingCenterPrice = Object.values(Memory.state.currentArea.locations).find((location) => location.type === 'healingCenter').price; - totalHealingCenterPrice += healingCenterPrice; - } + Game.healParty(); + const healingCenterPrice = Object.values(Memory.state.currentArea.locations).find((location) => location.type === 'healingCenter').price; + const totalHealingCenterPrice = healingCenterPrice * Memory.state.player.monsters.length; Memory.state.money -= totalHealingCenterPrice; Game.addPhaseEvent('postTurnEnd', () => { @@ -1006,6 +1003,13 @@ const Game = { monster.evolve(monster.evolutions[0]); }, + healParty () { + for (const monster of Memory.state.player.monsters) { + monster.hp = monster.stats.hp; + monster.statusEffect = null; + } + }, + /** * @param {string} type * -- cgit v1.2.3