summaryrefslogtreecommitdiff
path: root/resources/js/ui.js
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-08-19 15:32:48 +0200
committerDaniel Weipert <code@drogueronin.de>2023-08-19 15:32:48 +0200
commitc1fe94a630a88c4f7203d54f34985c109030791c (patch)
treee6e75fe468dddddcbe440cbd356ddaaaf605144f /resources/js/ui.js
parent218da95a4b387ee5ac25f168d1529419039f2e54 (diff)
translations
Diffstat (limited to 'resources/js/ui.js')
-rw-r--r--resources/js/ui.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/resources/js/ui.js b/resources/js/ui.js
index 6c077b7..f6c490f 100644
--- a/resources/js/ui.js
+++ b/resources/js/ui.js
@@ -9,7 +9,7 @@ const Template = {
battleMonster: document.querySelector('#tpl___battle__monster'),
battleHpBar: document.querySelector('#tpl___battle__hp-bar'),
battleExpBar: document.querySelector('#tpl___battle__exp-bar'),
- battleDamage: document.querySelector('#tpl___battle__damage'),
+ battleActionFeedback: document.querySelector('#tpl___battle__action-feedback'),
techniques: document.querySelector('#tpl___techniques'),
technique: document.querySelector('#tpl___technique'),
@@ -244,7 +244,7 @@ const UI = {
createElementTypeIcon (type) {
const img = document.createElement('img');
img.src = `/modules/tuxemon/mods/tuxemon/gfx/ui/icons/element/${type}_type.png`;
- img.title = slugToName(type);
+ img.title = translate(type) || slugToName(type);
return img;
},
@@ -425,7 +425,7 @@ const UI = {
},
- /* Battle - Damage */
+ /* Battle - Action Feedback */
/**
* @type {MouseEvent}
@@ -442,7 +442,7 @@ const UI = {
* @returns {HTMLElement}
*/
createActionFeedback (feedback) {
- const feedbackNode = UI.createTemplate(Template.battleDamage);
+ const feedbackNode = UI.createTemplate(Template.battleActionFeedback);
feedbackNode.innerHTML = feedback;
feedbackNode.style.top = UI.battleClickEvent.pageY - UI.elements.battleOpponent.offsetTop + (Math.random() * 40 - 20) + 'px';
@@ -644,12 +644,25 @@ const UI = {
for (const item of Memory.state.player.inventory) {
const inventoryItemNode = UI.createTemplate(Template.inventoryItem);
+ inventoryItemNode.title = item.description;
+
inventoryItemNode.querySelector('[data-template-slot="sprite"]').src = `/modules/tuxemon/mods/tuxemon/${item.sprite}`;
inventoryItemNode.querySelector('[data-template-slot="name"]').textContent = item.name;
inventoryItemNode.querySelector('[data-template-slot="quantity"]').textContent = item.quantity;
- inventoryItemNode.addEventListener('click', () => {
- alert(item.conditions + item.effects);
+ 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();
+ }
+ }
+ }
});
if (['potion', 'revive'].includes(item.category)) {
@@ -784,6 +797,8 @@ const UI = {
const technique = await fetchTechnique(move.technique);
const movesetItemNode = UI.createTemplate(Template.movesetItem);
+ movesetItemNode.title = technique.description;
+
movesetItemNode.querySelector('[data-template-slot="name"]').textContent = technique.name;
movesetItemNode.querySelector('[data-template-slot="types"]').innerHTML = technique.types.map((type) => UI.createElementTypeIcon(type).outerHTML).join('');
movesetItemNode.querySelector('[data-template-slot="power"]').textContent = technique.power;