diff --git a/module/actor.js b/module/actor.js index 5d272dac..e5c399ab 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3049,6 +3049,13 @@ export class RdDActor extends Actor { await this.update({ 'data.subacteurs.suivants': newSuivants }); await this.update({ 'data.subacteurs.montures': newMontures }); } + + /* -------------------------------------------- */ + consommerPotion( potion ) { + const potionData = Misc.data(potion); + console.log("Potion consommée", potionData); + } + /* -------------------------------------------- */ async onUpdateActor(update, options, actorId) { const updatedEndurance = update?.data?.sante?.endurance; diff --git a/module/item-competence.js b/module/item-competence.js index 4476775b..85d38ef6 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -67,7 +67,7 @@ export class RdDItemCompetence extends Item { } /* -------------------------------------------- */ static getNiveauBase(category) { - return categorieCompetences[category].niveau; + return categorieCompetences[category].base; } /* -------------------------------------------- */ static getLabelCategorie(category) { diff --git a/module/item-sheet.js b/module/item-sheet.js index 98fcafc2..4e49b82c 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -3,6 +3,7 @@ import { RdDUtility } from "./rdd-utility.js"; import { RdDItem } from "./item-rdd.js"; import { RdDAlchimie } from "./rdd-alchimie.js"; import { RdDItemCompetence } from "./item-competence.js"; +import { RdDHerbes } from "./rdd-herbes.js"; import { Misc } from "./misc.js"; /** @@ -49,7 +50,6 @@ export class RdDItemSheet extends ItemSheet { /* -------------------------------------------- */ async getData() { const objectData = Misc.data(this.object); - console.log("3", objectData); let formData ={ title: objectData.name, @@ -62,6 +62,8 @@ export class RdDItemSheet extends ItemSheet { owner: this.document.isOwner, editable: this.isEditable, cssClass: this.isEditable ? "editable" : "locked", + isSoins: false, + isEnchante: false } formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences(); if ( formData.type == 'tache' || formData.type == 'livre' || formData.type == 'meditation' || formData.type == 'oeuvre') { @@ -75,6 +77,14 @@ export class RdDItemSheet extends ItemSheet { if ( formData.type == 'recettealchimique' ) { RdDAlchimie.processManipulation(objectData, this.actor && this.actor.id ); } + if ( formData.type == 'potion') { + if (this.dateUpdated) { + formData.data.prdate = this.dateUpdated; + this.dateUpdated = undefined; + } + RdDHerbes.updatePotionData(formData); + } + if ( this.actor ) { formData.isOwned = true; formData.actorId = this.actor.id; @@ -94,6 +104,7 @@ export class RdDItemSheet extends ItemSheet { // Select competence categorie html.find(".categorie").on("click", this._onClickSelectCategorie.bind(this) ); + html.find(".categoriepotion").on("click", this.render(true) ); html.find('.sheet-competence-xp').change((event) => { if ( this.object.data.type == 'competence') { @@ -101,11 +112,22 @@ export class RdDItemSheet extends ItemSheet { } } ); + html.find('.enchanteDate').change((event) => { + let jour = Number($('#jourMois').val()); + let mois = $('#nomMois').val(); + this.dateUpdated = game.system.rdd.calendrier.getIndexFromDate(jour, mois); + }); + html.find('.creer-tache-livre').click((event) => { let actorId = event.currentTarget.attributes['data-actor-id'].value; let actor = game.actors.get( actorId ); actor.creerTacheDepuisLivre( this.item ); }); + html.find('.consommer-potion').click((event) => { + let actorId = event.currentTarget.attributes['data-actor-id'].value; + let actor = game.actors.get( actorId ); + actor.consommerPotion( this.item ); + }); html.find('.alchimie-tache a').click((event) => { let actorId = event.currentTarget.attributes['data-actor-id'].value; diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 0827d520..91380b69 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -39,7 +39,7 @@ export class RdDCalendrier extends Application { async initCalendrier() { // Calendrier this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier")); - console.log("CALENDRIER", this.calendrier); + //console.log("CALENDRIER", this.calendrier); if (this.calendrier == undefined || this.calendrier.moisRdD == undefined) { this.calendrier.heureRdD = 0; // Index dans heuresList this.calendrier.minutesRelative = 0; @@ -88,6 +88,14 @@ export class RdDCalendrier extends Application { return day + " " + heuresList[month]; } + /* -------------------------------------------- */ + getNumericDateFromIndex(index = undefined) { + if (!index) index = this.getCurrentDayIndex(); + let month = Math.floor(index / 28) + return { month: heuresList[month], + day: (index - (month * 28)) + 1 } + } + /* -------------------------------------------- */ getCurrentHeure() { return heuresList[this.calendrier.heureRdD]; @@ -98,6 +106,10 @@ export class RdDCalendrier extends Application { return (this.calendrier.moisRdD * 28) + this.calendrier.jour; } + /* -------------------------------------------- */ + getIndexFromDate(jour, mois) { + return (heuresDef[mois].heure * 28) + (jour-1); + } /* -------------------------------------------- */ getJoursSuivants(num) { let jours = []; diff --git a/module/rdd-main.js b/module/rdd-main.js index 8802a03e..2a2b3f05 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -22,13 +22,13 @@ import { RdDTokenHud } from "./rdd-token-hud.js"; import { RdDCommands } from "./rdd-commands.js"; import { RdDCombatManager, RdDCombat } from "./rdd-combat.js"; import { ChatUtility } from "./chat-utility.js"; -import { RdDItemCompetence } from "./item-competence.js"; import { StatusEffects } from "./status-effects.js"; import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js"; import { ReglesOptionelles } from "./regles-optionelles.js"; import { TMRRencontres } from "./tmr-rencontres.js"; import { RdDHotbar } from "./rdd-hotbar-drop.js" import { EffetsDraconiques } from "./tmr/effets-draconiques.js"; +import { RdDHerbes } from "./rdd-herbes.js"; /* -------------------------------------------- */ /* Foundry VTT Initialization */ @@ -186,6 +186,7 @@ function messageDeBienvenue() { Hooks.once("ready", function () { StatusEffects.onReady(); + RdDHerbes.initializeHerbes(); /* -------------------------------------------- */ /* Affiche/Init le calendrier */ diff --git a/system.json b/system.json index 0412d539..c2818c66 100644 --- a/system.json +++ b/system.json @@ -2,11 +2,11 @@ "name": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", "description": "Rêve de Dragon RPG for FoundryVTT", - "version": "1.4.0", + "version": "1.4.1", "manifestPlusVersion": "1.0.0", "minimumCoreVersion": "0.7.5", "compatibleCoreVersion": "0.7.9", - "templateVersion": 110, + "templateVersion": 111, "author": "LeRatierBretonnien", "authors": [ { diff --git a/template.json b/template.json index 1934018a..b8f084e6 100644 --- a/template.json +++ b/template.json @@ -723,9 +723,11 @@ "encombrement": 0, "rarete": "", "categorie": "", - "soinherbe": "", - "soinherbebonus": 0, + "herbe": "", + "herbebrins": 0, + "herbebonus": 0, "pr": 0, + "prpermanent": false, "prdate": 0, "cout": 0 }, diff --git a/templates/enum-categorie-ingredient.html b/templates/enum-categorie-ingredient.html index a6a2b039..a70476e9 100644 --- a/templates/enum-categorie-ingredient.html +++ b/templates/enum-categorie-ingredient.html @@ -1,7 +1,10 @@ + + + diff --git a/templates/item-potion-sheet.html b/templates/item-potion-sheet.html index 86abf880..174a677d 100644 --- a/templates/item-potion-sheet.html +++ b/templates/item-potion-sheet.html @@ -30,32 +30,66 @@
- {{#select data.categorie}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}} {{/select}}
+ {{#if isHerbe}}
- + {{selectOptions herbesSoins selected=data.herbe localize=false}}
- - + +
- + + +
+ {{/if}} + {{#if isEnchante}} +
+
- - + +
+ {{#if isHerbe}} +
+ + +
+ {{/if}} +
+ +
+
+ + +
+ {{/if}} + {{#if isOwned}} +
+ Consommer cette potion +
+ {{/if}}