diff --git a/system/lang/en-en.json b/system/lang/en-en.json index 46cbdbb..59ac91e 100644 --- a/system/lang/en-en.json +++ b/system/lang/en-en.json @@ -250,6 +250,7 @@ "title": "Advancements", "title_new": "New advancement", "total": "Total", + "cost": "Cost", "spent": "Used", "saved": "Saved", "rank": "Rank Total Xp", diff --git a/system/lang/es-es.json b/system/lang/es-es.json index b6687ce..577f3d1 100644 --- a/system/lang/es-es.json +++ b/system/lang/es-es.json @@ -250,6 +250,7 @@ "title": "Advancements", "title_new": "New advancement", "total": "Total", + "cost": "Cost", "spent": "Usada", "saved": "Restante", "rank": "Rank Total Xp", diff --git a/system/lang/fr-fr.json b/system/lang/fr-fr.json index 0813dcd..694df07 100644 --- a/system/lang/fr-fr.json +++ b/system/lang/fr-fr.json @@ -250,6 +250,7 @@ "title": "Progressions", "title_new": "Nouvelle progression", "total": "Totale", + "cost": "Coût", "spent": "Dépensée", "saved": "Restante", "total_xp_rank": "Xp Total du rang", diff --git a/system/lang/pt-BR.json b/system/lang/pt-BR.json deleted file mode 100644 index 0050159..0000000 --- a/system/lang/pt-BR.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "I18N.MAINTAINERS": [ "Innocenti" ], - - "HEXA.COLOR": "Digite uma cor hexadecimal (ex. #FFFFFF).", - "IC.BG.COLOR": "IC Cor de Fundo", - "IC.TEXT.COLOR": "IC Cor do Texto", - "EMOTE.BG.COLOR": "Cor de fundo do Emote", - "EMOTE.TEXT.COLOR": "Cor de texto do Emote", - "ROLL.BG.COLOR": "Cor de fundo das Rolagens", - "ROLL.TEXT.COLOR": "Cor de texto das Rolagens", - "OTHER.BG.COLOR": "Outra Cor de Fundo", - "OTHER.TEXT.COLOR": "Outra Cor de Texto", - "DEF.CHAT.PREF": "Prefixo padrão do bate-papo", - "SPE.CHAT.PREF": "Se especificada, essa sequência será prefixada para todas as mensagens de bate-papo que ainda não são comandos (como / emote.)" -} diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index ab94663..1853a36 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -199,8 +199,9 @@ export class BaseSheetL5r5e extends ActorSheet { }); const item = this.actor.getOwnedItem(created._id); - // assign current school rank to the new tech - if (item.data.type === "advancement") { + // assign current school rank to the new adv/tech + if (["advancement", "technique"].includes(item.data.type)) { + item.data.data.rank = this.actor.data.data.identity.school_rank; item.data.data.bought_at_rank = this.actor.data.data.identity.school_rank; } @@ -230,6 +231,25 @@ export class BaseSheetL5r5e extends ActorSheet { return; } + // Specific advancements, remove 1 to selected ring/skill + if (tmpItem.type === "advancement") { + const actor = duplicate(this.actor.data.data); + const itmData = tmpItem.data.data; + if (itmData.advancement_type === "ring") { + // Ring + actor.rings[itmData.ring] = Math.max(1, actor.rings[itmData.ring] - 1); + } else { + // Skill + const skillCatId = CONFIG.l5r5e.skills.get(itmData.skill); + actor.skills[skillCatId][itmData.skill] = Math.max(0, actor.skills[skillCatId][itmData.skill] - 1); + } + + // Update Actor + this.actor.update({ + data: diffObject(this.actor.data.data, actor), + }); + } + return this.actor.deleteOwnedItem(itemId); } diff --git a/system/scripts/actors/character-sheet.js b/system/scripts/actors/character-sheet.js index de95b3d..e27a730 100644 --- a/system/scripts/actors/character-sheet.js +++ b/system/scripts/actors/character-sheet.js @@ -52,7 +52,7 @@ export class CharacterSheetL5r5e extends BaseSheetL5r5e { sheetData.data.xp_spent_rank = totalXp.rank; sheetData.data.xp_spent = totalXp.total; sheetData.data.xp_saved = sheetData.data.xp_total - sheetData.data.xp_spent; - sheetData.data.xp_goal = CONFIG.l5r5e.xpPerRank[this.actor.data.data.identity.school_rank - 1] || null; + sheetData.data.xp_goal = CONFIG.l5r5e.xp.costPerRank[this.actor.data.data.identity.school_rank - 1] || null; return sheetData; } diff --git a/system/scripts/actors/twenty-questions-dialog.js b/system/scripts/actors/twenty-questions-dialog.js index 5e150f6..b54f622 100644 --- a/system/scripts/actors/twenty-questions-dialog.js +++ b/system/scripts/actors/twenty-questions-dialog.js @@ -138,7 +138,7 @@ export class TwentyQuestionsDialog extends FormApplication { } const stepKey = $(event.target).data("step"); if (!stepKey) { - console.log("event stepKey is undefined"); + console.warn("event stepKey is undefined"); return; } @@ -151,7 +151,7 @@ export class TwentyQuestionsDialog extends FormApplication { (type !== "item" && item.data.type !== type) || (type === "item" && !["item", "weapon", "armor"].includes(item.data.type)) ) { - console.log("forbidden item for this drop zone", type, item.data.type); + console.warn("forbidden item for this drop zone", type, item.data.type); return; } // Add the item (step and cache) diff --git a/system/scripts/actors/twenty-questions.js b/system/scripts/actors/twenty-questions.js index bfee3d3..f516b24 100644 --- a/system/scripts/actors/twenty-questions.js +++ b/system/scripts/actors/twenty-questions.js @@ -208,7 +208,7 @@ export class TwentyQuestions { * Fill a actor data from this object */ async toActor(actor, itemsCache) { - const actorDatas = actor.data.data; + const actorDatas = duplicate(actor.data.data); const formData = this.data; // Update the actor real datas @@ -280,7 +280,7 @@ export class TwentyQuestions { // Update actor actor.update({ name: (formData.step2.family + " " + formData.step19.firstname).trim(), - data: actorDatas, + data: diffObject(actor.data.data, actorDatas), }); // TODO Tmp diff --git a/system/scripts/config.js b/system/scripts/config.js index 51f1dec..ef1d313 100644 --- a/system/scripts/config.js +++ b/system/scripts/config.js @@ -7,7 +7,12 @@ L5R5E.paths = { L5R5E.stances = ["earth", "air", "water", "fire", "void"]; L5R5E.techniques = ["kata", "kiho", "invocation", "ritual", "shuji", "maho", "ninjutsu"]; -L5R5E.xpPerRank = [20, 24, 32, 44, 60]; +L5R5E.xp = { + costPerRank: [20, 24, 32, 44, 60], + ringCostMultiplier: 3, + skillCostMultiplier: 2, + techniqueCost: 3, +}; // Map SkillId - CategoryId L5R5E.skills = new Map(); diff --git a/system/scripts/items/advancement-sheet.js b/system/scripts/items/advancement-sheet.js index 8bd7b5e..8b502b2 100644 --- a/system/scripts/items/advancement-sheet.js +++ b/system/scripts/items/advancement-sheet.js @@ -7,7 +7,7 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e { /** * Sub Types of advancements */ - static types = ["ring", "skill"]; // "advantage" and "technique" have theirs own xp count + static types = ["ring", "skill"]; // "peculiarity" and "technique" have theirs own xp count /** @override */ static get defaultOptions() { @@ -28,4 +28,110 @@ export class AdvancementSheetL5r5e extends ItemSheetL5r5e { return sheetData; } + + /** + * Subscribe to events from the sheet. + * @param html HTML content of the sheet. + */ + activateListeners(html) { + super.activateListeners(html); + + // Everything below here is only needed if the sheet is editable + if (!this.options.editable) { + return; + } + + // const currentType = this.object.data.data.advancement_type; + const currentRing = this.object.data.data.ring; + const currentSkill = this.object.data.data.skill; + + html.find("#advancement_type").on("change", (event) => { + if ($(event.target).val() === "skill") { + this._updateChoice( + { + ring: currentRing, + }, + { + skill: currentSkill, + } + ); + } else { + this._updateChoice( + { + skill: currentSkill, + }, + { + ring: currentRing, + } + ); + } + }); + + html.find("#advancement_ring").on("change", (event) => { + this._updateChoice( + { + ring: currentRing, + }, + { + ring: $(event.target).val(), + } + ); + }); + + html.find("#advancement_skill").on("change", (event) => { + this._updateChoice( + { + skill: currentSkill, + }, + { + skill: $(event.target).val(), + } + ); + }); + } + + /** + * Update Actor and Object to the current choice + * @private + */ + _updateChoice(oldChoice, newChoice) { + let skillCatId = null; + const actor = duplicate(this.actor.data.data); + let xp_used = this.object.data.data.xp_used; + + // Old choices + if (oldChoice.ring) { + actor.rings[oldChoice.ring] = Math.max(1, actor.rings[oldChoice.ring] - 1); + } + if (oldChoice.skill) { + skillCatId = CONFIG.l5r5e.skills.get(oldChoice.skill); + actor.skills[skillCatId][oldChoice.skill] = Math.max(0, actor.skills[skillCatId][oldChoice.skill] - 1); + } + + // new choices + if (newChoice.ring) { + actor.rings[newChoice.ring] = actor.rings[newChoice.ring] + 1; + xp_used = actor.rings[newChoice.ring] * CONFIG.l5r5e.xp.ringCostMultiplier; + } + if (newChoice.skill) { + skillCatId = CONFIG.l5r5e.skills.get(newChoice.skill); + actor.skills[skillCatId][newChoice.skill] = actor.skills[skillCatId][newChoice.skill] + 1; + xp_used = actor.skills[skillCatId][newChoice.skill] * CONFIG.l5r5e.xp.skillCostMultiplier; + } + + // Update Actor + this.actor.update({ + data: diffObject(this.actor.data.data, actor), + }); + + // Update object + this.object.update({ + data: { + xp_used: xp_used, + }, + }); + + // Re render + this.render(false); + } } diff --git a/system/system.json b/system/system.json index a3716fe..bd5d562 100644 --- a/system/system.json +++ b/system/system.json @@ -18,9 +18,45 @@ "entity": "Item" }, { - "name": "core-techniques", - "label": "Techniques", - "path": "packs/core-techniques.db", + "name": "core-techniques-kata", + "label": "Techniques Kata", + "path": "packs/core-techniques-kata.db", + "entity": "Item" + }, + { + "name": "core-techniques-kiho", + "label": "Techniques Kihõ", + "path": "packs/core-techniques-kiho.db", + "entity": "Item" + }, + { + "name": "core-techniques-invocation", + "label": "Techniques Invocations", + "path": "packs/core-techniques-invocations.db", + "entity": "Item" + }, + { + "name": "core-techniques-ritual", + "label": "Techniques Rituals", + "path": "packs/core-techniques-rituals.db", + "entity": "Item" + }, + { + "name": "core-techniques-shuji", + "label": "Techniques Shuji", + "path": "packs/core-techniques-shuji.db", + "entity": "Item" + }, + { + "name": "core-techniques-maho", + "label": "Techniques Mahõ", + "path": "packs/core-techniques-maho.db", + "entity": "Item" + }, + { + "name": "core-techniques-ninjutsu", + "label": "Techniques Ninjutsu", + "path": "packs/core-techniques-ninjutsu.db", "entity": "Item" }, { @@ -42,27 +78,27 @@ "entity": "Item" }, { - "name": "core-distinctions", + "name": "core-peculiarities-distinctions", "label": "Distinctions", - "path": "packs/core-distinctions.db", + "path": "packs/core-peculiarities-distinctions.db", "entity": "Item" }, { - "name": "core-passions", + "name": "core-peculiarities-passions", "label": "Passions", - "path": "packs/core-passions.db", + "path": "packs/core-peculiarities-passions.db", "entity": "Item" }, { - "name": "core-adversities", + "name": "core-peculiarities-adversities", "label": "Adversities", - "path": "packs/core-adversities.db", + "path": "packs/core-peculiarities-adversities.db", "entity": "Item" }, { - "name": "core-anxieties", + "name": "core-peculiarities-anxieties", "label": "Anxieties", - "path": "packs/core-anxieties.db", + "path": "packs/core-peculiarities-anxieties.db", "entity": "Item" }, { diff --git a/system/template.json b/system/template.json index 77c463e..0cb4804 100644 --- a/system/template.json +++ b/system/template.json @@ -186,7 +186,8 @@ "technique": { "templates": ["basics", "advancement"], "technique_type": "kata", - "effects": "" + "effects": "", + "xp_cost": 3 }, "property": { "templates": ["basics"] @@ -198,7 +199,7 @@ }, "advancement": { "templates": ["basics", "advancement"], - "advancement_type": "", + "advancement_type": "skill", "skill": "" } } diff --git a/system/templates/items/advancement/advancement-sheet.html b/system/templates/items/advancement/advancement-sheet.html index 24b5b56..f1a5a1e 100644 --- a/system/templates/items/advancement/advancement-sheet.html +++ b/system/templates/items/advancement/advancement-sheet.html @@ -8,7 +8,7 @@ {{!-- Attributes Tab --}}
- {{#select item.data.advancement_type}} {{#each item.data.subTypesList as |type|}} @@ -16,12 +16,8 @@ {{/select}} - {{#ifCond item.data.advancement_type '==' 'advantage' }} - - {{/ifCond}} - {{#ifCond item.data.advancement_type '==' 'ring' }} - {{#select item.data.ring}} {{#each item.data.ringsList as |obj|}} @@ -31,7 +27,7 @@ {{/ifCond}} {{#ifCond item.data.advancement_type '==' 'skill' }} - {{#select item.data.skill}} {{#each item.data.skillsList as |skills catId|}} diff --git a/system/templates/items/technique/technique-sheet.html b/system/templates/items/technique/technique-sheet.html index 61bda5f..9f4731e 100644 --- a/system/templates/items/technique/technique-sheet.html +++ b/system/templates/items/technique/technique-sheet.html @@ -26,6 +26,10 @@ {{ localize 'l5r5e.advancements.curriculum' }} +