diff options
author | Daniel Weipert <code@drogueronin.de> | 2023-08-27 15:21:47 +0200 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2023-08-27 15:21:47 +0200 |
commit | 8e829d4497efd6a23514901a1a6724fe7579c6b5 (patch) | |
tree | a829ba890ad0dfafdf7689fc8e6e0c5f22a0670e /resources/js/ui.js | |
parent | 5582c3c07069f7766aabd81f3a4a3f97def134e9 (diff) |
box in healing centers!
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r-- | resources/js/ui.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js index e69fd83..3275835 100644 --- a/resources/js/ui.js +++ b/resources/js/ui.js @@ -788,6 +788,65 @@ const UI = { UI.drawPopup(monsterSelectionPopup); })); + template.querySelector('[data-template-slot="box.withdraw"]').addEventListener('click', UI.wrapCallback(() => { + if (Memory.state.monsters.length === 0) { + alert('No Tuxemon to withdraw in Box!'); + return; + } + if (Memory.state.player.monsters.length === 6) { + alert('Not enough space in party!'); + return; + } + + const boxPopup = UI.createPopup(); + const monsterSelection = UI.createMonsterSelection(Memory.state.monsters); + monsterSelection.addEventListener('monster:selected', UI.wrapCallback((event) => { + Memory.state.player.monsters.push(event.detail.monster); + Memory.state.monsters.splice(Memory.state.monsters.findIndex((monster) => monster === event.detail.monster), 1); + event.detail.node.remove(); + + if (Memory.state.player.monsters.length === 6) { + boxPopup.remove(); + } + })) + + boxPopup.querySelector('.popup').appendChild(monsterSelection); + UI.drawPopup(boxPopup); + })); + + template.querySelector('[data-template-slot="box.deposit"]').addEventListener('click', UI.wrapCallback(() => { + if (Memory.state.player.monsters.length === 1) { + alert('Can\'t deposit last Tuxemon!'); + return; + } + + const boxPopup = UI.createPopup(); + const monsterSelection = UI.createMonsterSelection(Memory.state.player.monsters); + monsterSelection.addEventListener('monster:selected', UI.wrapCallback((event) => { + Memory.state.monsters.push(event.detail.monster); + Memory.state.player.monsters.splice(Memory.state.player.monsters.findIndex((monster) => monster === event.detail.monster), 1); + event.detail.node.remove(); + + if (Memory.state.player.monsters.length === 1) { + boxPopup.remove(); + } + })) + + boxPopup.querySelector('.popup').appendChild(monsterSelection); + UI.drawPopup(boxPopup); + })); + + template.querySelector('[data-template-slot="box.view"]').addEventListener('click', UI.wrapCallback(() => { + const boxPopup = UI.createPopup(); + const monsterSelection = UI.createMonsterSelection(Memory.state.monsters); + monsterSelection.addEventListener('monster:selected', UI.wrapCallback((event) => { + UI.openStatsMenu(event.detail.monster); + })) + + boxPopup.querySelector('.popup').appendChild(monsterSelection); + UI.drawPopup(boxPopup); + })); + popup.querySelector('.popup').appendChild(template); UI.drawPopup(popup); }, |