From b69c515a7c199bb014f916e2125997fa05ef59eb Mon Sep 17 00:00:00 2001 From: sladecraven Date: Thu, 14 Jan 2021 10:32:15 +0100 Subject: [PATCH] Increase version --- module/actor-sheet.js | 2 + module/actor.js | 20 ++---- module/rdd-utility.js | 1 + styles/simple.css | 8 +++ system.json | 2 +- templates/actor-sheet-competence-partial.html | 0 templates/actor-sheet.html | 64 +++++++++++++++---- templates/chat-actor-carac-xp.html | 7 +- templates/chat-actor-competence-xp.html | 10 +-- 9 files changed, 79 insertions(+), 35 deletions(-) create mode 100644 templates/actor-sheet-competence-partial.html diff --git a/module/actor-sheet.js b/module/actor-sheet.js index c72a189b..0b85db12 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -46,6 +46,7 @@ export class RdDActorSheet extends ActorSheet { data.itemsByType.competence, item => item.data.categorie, item => { + item.data.isLevelUp = item.data.xp >= RdDItemCompetence.getCompetenceNextXp(item.data.niveau); // Flag de niveau à MAJ this.actor.checkCompetenceXP(item.name); // Petite vérification experience item.data.showCompetence = !data.data.showCompNiveauBase || (Number(item.data.niveau) != Number(RdDUtility.getLevelCategory(item.data.categorie))); // Ignorer les compétences 'troncs' à ce stade @@ -62,6 +63,7 @@ export class RdDActorSheet extends ActorSheet { if (!currentCarac.derivee) { sum += parseInt(currentCarac.value); } + currentCarac.isLevelUp = (currentCarac.xp >= RdDUtility.getCaracNextXp(currentCarac.value)); } data.data.caracSum = sum; diff --git a/module/actor.js b/module/actor.js index b45b03e9..7dba22ec 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1441,15 +1441,11 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async checkCaracXP(caracName) { let carac = this.data.data.carac[caracName]; - console.log("XP check", carac, caracName); if (carac && carac.xp > 0) { let xpNeeded = RdDUtility.getCaracNextXp(carac.value); if (carac.xp >= xpNeeded) { carac = duplicate(carac); carac.value = Number(carac.value) + 1; - await this.updateCarac(caracName, carac.value); - carac.xp -= xpNeeded; - await this.updateCaracXP(caracName, carac.xp); let xpData = { alias: this.name, @@ -1470,18 +1466,16 @@ export class RdDActor extends Actor { if (competence && competence.data.xp > 0) { let xpNeeded = RdDItemCompetence.getCompetenceNextXp(competence.data.niveau); if (competence.data.xp >= xpNeeded) { - competence.data.xp -= xpNeeded; - competence.data.niveau += 1; - let update = { _id: competence._id, "data.xp": competence.data.xp, "data.niveau": competence.data.niveau }; - await this.updateEmbeddedEntity("OwnedItem", update); + let newCompetence = duplicate(competence); + newCompetence.data.niveau += 1; let xpData = { alias: this.name, - competence: competence.name, - niveau: competence.data.niveau, - xp: competence.data.xp, - archetype: competence.data.niveau_archetype, - archetypeWarning: competence.data.niveau > competence.data.niveau_archetype + competence: newCompetence.name, + niveau: newCompetence.data.niveau, + xp: newCompetence.data.xp, + archetype: newCompetence.data.niveau_archetype, + archetypeWarning: newCompetence.data.niveau > competence.data.niveau_archetype } ChatUtility.createChatMessage(this.name, "default", { content: await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-competence-xp.html`, xpData) diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 03847804..707a8dd0 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -164,6 +164,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-entite-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/actor-vehicule-sheet.html', + 'systems/foundryvtt-reve-de-dragon/templates/actor-sheet-competence-partial.html', //Items 'systems/foundryvtt-reve-de-dragon/templates/item-competence-sheet.html', 'systems/foundryvtt-reve-de-dragon/templates/item-competencecreature-sheet.html', diff --git a/styles/simple.css b/styles/simple.css index 6eb17d5c..e0a767a4 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -575,6 +575,14 @@ ul, li { .alterne-list > .list-item:nth-child(odd) { background: rgb(160, 130, 100, 0.05); } +.xp-level-up { + margin: 0.125rem; + box-shadow: inset 0px 0px 1px #00000096; + border-radius: 0.25rem; + padding: 0.125rem; + flex: 1 1 5rem; + background: rgba(195, 152, 22, 0.5); +} .blessures-list ul { display: flex; diff --git a/system.json b/system.json index 66170ad0..e6c52ba4 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.2.18", + "version": "1.2.19", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.8", diff --git a/templates/actor-sheet-competence-partial.html b/templates/actor-sheet-competence-partial.html new file mode 100644 index 00000000..e69de29b diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index c47dad70..74ecd058 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -117,7 +117,11 @@ >{{#if data.editCaracComp}}Vérouiller{{else}}Dévérouiller{{/if}}