summaryrefslogtreecommitdiff
path: root/resources/js/ui.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-20 14:32:40 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-20 14:32:40 +0200
commitb227fc9c2ef361f8aa5ee2f24aa1ade6bc972a73 (patch)
tree8fdd7e980107bfd8fcd58ffe21f2299b37d310c8 /resources/js/ui.js
parent2c7890e90e1aad371854cfe60ad63eaa88e64fec (diff)
area progress
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r--resources/js/ui.js50
1 files changed, 37 insertions, 13 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js
index a623f9d..0d6a8f9 100644
--- a/resources/js/ui.js
+++ b/resources/js/ui.js
@@ -34,6 +34,7 @@ const Template = {
const UI = {
elements: {
+ battle: document.querySelector('#battle'),
battleOpponent: document.querySelector('#battle__opponent'),
battleOpponentSprite: null,
battleOpponentAnimation: document.querySelector('.battle__monster-sprite__animation'),
@@ -41,7 +42,7 @@ const UI = {
techniques: document.querySelector('#techniques'),
- money: document.querySelector('#money'),
+ status: document.querySelector('#status'),
menuParty: document.querySelector('#menu__party'),
menuInventory: document.querySelector('#menu__inventory'),
@@ -354,6 +355,13 @@ const UI = {
UI.elements.battleOpponentSprite = battleMonsterNode.querySelector('[data-template-slot="sprite"]');
UI.elements.battleOpponentSprite.style.transitionDuration = `${UI.damageHighlightClickDuration}s`;
+ // en/disable catch
+ if (Memory.state.opponent.type === 'trainer') {
+ UI.elements.menuCatch.setAttribute('disabled', true);
+ } else {
+ UI.elements.menuCatch.removeAttribute('disabled');
+ }
+
const previousBattleMonsterNode = UI.elements.battleOpponent.querySelector('.battle__monster');
if (previousBattleMonsterNode) {
UI.elements.battleOpponentSprite.classList = previousBattleMonsterNode.querySelector('[data-template-slot="sprite"]').classList;
@@ -427,6 +435,20 @@ const UI = {
requestAnimationFrame(techniqueAnimationLoop);
},
+ /**
+ * @param {Area} area
+ */
+ drawArea (area) {
+ UI.elements.battle.style.backgroundImage = `url(/modules/tuxemon/mods/tuxemon/gfx/ui/combat/${area.environment.battle_graphics.background})`;
+ },
+
+ progressTurn () {
+ UI.drawOpponentMonster();
+ UI.drawActiveMonster();
+ UI.drawActiveTechniques();
+ UI.drawStatus();
+ },
+
/* Battle - Action Feedback */
@@ -544,6 +566,19 @@ const UI = {
partySelectionMode: 'select',
+ drawStatus () {
+ UI.elements.status.querySelector('[data-template-slot="money"]').textContent = `${Memory.state.money} €`;
+ UI.elements.status.querySelector('[data-template-slot="monster-progress"]').textContent = `${Memory.state.currentArea.monsterProgress} / ${'10'}`;
+ UI.elements.status.querySelector('[data-template-slot="trainer-progress"]').textContent = `${Memory.state.currentArea.trainerProgress} / ${Memory.state.currentArea.trainers.length}`;
+
+ const nextTrainerButton = UI.elements.status.querySelector('[data-template-slot="next-trainer"]');
+ if (Memory.state.currentArea.monsterProgress >= Memory.state.currentArea.requiredEncounters) {
+ nextTrainerButton.disabled = false;
+ } else {
+ nextTrainerButton.disabled = true;
+ }
+ },
+
openPartyMenu () {
const popup = UI.createPopup();
@@ -654,18 +689,7 @@ const UI = {
inventoryItemNode.querySelector('[data-template-slot="quantity"]').textContent = item.quantity;
inventoryItemNode.addEventListener('click', async () => {
- for (const itemEffectCode of item.effects) {
- const itemEffect = new ItemEffect(itemEffectCode);
-
- if (itemEffect.type === 'evolve') {
- const evolution = Memory.state.player.activeMonster.getPossibleEvolutions('item')[0];
- if (evolution) {
- await fetchMonster(evolution.monster_slug);
- Memory.state.player.activeMonster.evolve(evolution);
- UI.drawActiveMonster();
- }
- }
- }
+ Game.useItem(item);
});
if (['potion', 'revive'].includes(item.category)) {