#171 - Gestion potion de soins (WIP)

This commit is contained in:
sladecraven 2021-04-04 18:37:16 +02:00
parent e4f432c781
commit a5561b7b88
9 changed files with 99 additions and 18 deletions

View File

@ -3049,6 +3049,13 @@ export class RdDActor extends Actor {
await this.update({ 'data.subacteurs.suivants': newSuivants }); await this.update({ 'data.subacteurs.suivants': newSuivants });
await this.update({ 'data.subacteurs.montures': newMontures }); 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) { async onUpdateActor(update, options, actorId) {
const updatedEndurance = update?.data?.sante?.endurance; const updatedEndurance = update?.data?.sante?.endurance;

View File

@ -67,7 +67,7 @@ export class RdDItemCompetence extends Item {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getNiveauBase(category) { static getNiveauBase(category) {
return categorieCompetences[category].niveau; return categorieCompetences[category].base;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getLabelCategorie(category) { static getLabelCategorie(category) {

View File

@ -3,6 +3,7 @@ import { RdDUtility } from "./rdd-utility.js";
import { RdDItem } from "./item-rdd.js"; import { RdDItem } from "./item-rdd.js";
import { RdDAlchimie } from "./rdd-alchimie.js"; import { RdDAlchimie } from "./rdd-alchimie.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { RdDHerbes } from "./rdd-herbes.js";
import { Misc } from "./misc.js"; import { Misc } from "./misc.js";
/** /**
@ -49,7 +50,6 @@ export class RdDItemSheet extends ItemSheet {
/* -------------------------------------------- */ /* -------------------------------------------- */
async getData() { async getData() {
const objectData = Misc.data(this.object); const objectData = Misc.data(this.object);
console.log("3", objectData);
let formData ={ let formData ={
title: objectData.name, title: objectData.name,
@ -62,6 +62,8 @@ export class RdDItemSheet extends ItemSheet {
owner: this.document.isOwner, owner: this.document.isOwner,
editable: this.isEditable, editable: this.isEditable,
cssClass: this.isEditable ? "editable" : "locked", cssClass: this.isEditable ? "editable" : "locked",
isSoins: false,
isEnchante: false
} }
formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences(); formData.categorieCompetences = RdDItemCompetence.getCategorieCompetences();
if ( formData.type == 'tache' || formData.type == 'livre' || formData.type == 'meditation' || formData.type == 'oeuvre') { 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' ) { if ( formData.type == 'recettealchimique' ) {
RdDAlchimie.processManipulation(objectData, this.actor && this.actor.id ); 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 ) { if ( this.actor ) {
formData.isOwned = true; formData.isOwned = true;
formData.actorId = this.actor.id; formData.actorId = this.actor.id;
@ -94,6 +104,7 @@ export class RdDItemSheet extends ItemSheet {
// Select competence categorie // Select competence categorie
html.find(".categorie").on("click", this._onClickSelectCategorie.bind(this) ); html.find(".categorie").on("click", this._onClickSelectCategorie.bind(this) );
html.find(".categoriepotion").on("click", this.render(true) );
html.find('.sheet-competence-xp').change((event) => { html.find('.sheet-competence-xp').change((event) => {
if ( this.object.data.type == 'competence') { 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) => { html.find('.creer-tache-livre').click((event) => {
let actorId = event.currentTarget.attributes['data-actor-id'].value; let actorId = event.currentTarget.attributes['data-actor-id'].value;
let actor = game.actors.get( actorId ); let actor = game.actors.get( actorId );
actor.creerTacheDepuisLivre( this.item ); 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) => { html.find('.alchimie-tache a').click((event) => {
let actorId = event.currentTarget.attributes['data-actor-id'].value; let actorId = event.currentTarget.attributes['data-actor-id'].value;

View File

@ -39,7 +39,7 @@ export class RdDCalendrier extends Application {
async initCalendrier() { async initCalendrier() {
// Calendrier // Calendrier
this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "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) { if (this.calendrier == undefined || this.calendrier.moisRdD == undefined) {
this.calendrier.heureRdD = 0; // Index dans heuresList this.calendrier.heureRdD = 0; // Index dans heuresList
this.calendrier.minutesRelative = 0; this.calendrier.minutesRelative = 0;
@ -88,6 +88,14 @@ export class RdDCalendrier extends Application {
return day + " " + heuresList[month]; 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() { getCurrentHeure() {
return heuresList[this.calendrier.heureRdD]; return heuresList[this.calendrier.heureRdD];
@ -98,6 +106,10 @@ export class RdDCalendrier extends Application {
return (this.calendrier.moisRdD * 28) + this.calendrier.jour; return (this.calendrier.moisRdD * 28) + this.calendrier.jour;
} }
/* -------------------------------------------- */
getIndexFromDate(jour, mois) {
return (heuresDef[mois].heure * 28) + (jour-1);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
getJoursSuivants(num) { getJoursSuivants(num) {
let jours = []; let jours = [];

View File

@ -22,13 +22,13 @@ import { RdDTokenHud } from "./rdd-token-hud.js";
import { RdDCommands } from "./rdd-commands.js"; import { RdDCommands } from "./rdd-commands.js";
import { RdDCombatManager, RdDCombat } from "./rdd-combat.js"; import { RdDCombatManager, RdDCombat } from "./rdd-combat.js";
import { ChatUtility } from "./chat-utility.js"; import { ChatUtility } from "./chat-utility.js";
import { RdDItemCompetence } from "./item-competence.js";
import { StatusEffects } from "./status-effects.js"; import { StatusEffects } from "./status-effects.js";
import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js"; import { RddCompendiumOrganiser } from "./rdd-compendium-organiser.js";
import { ReglesOptionelles } from "./regles-optionelles.js"; import { ReglesOptionelles } from "./regles-optionelles.js";
import { TMRRencontres } from "./tmr-rencontres.js"; import { TMRRencontres } from "./tmr-rencontres.js";
import { RdDHotbar } from "./rdd-hotbar-drop.js" import { RdDHotbar } from "./rdd-hotbar-drop.js"
import { EffetsDraconiques } from "./tmr/effets-draconiques.js"; import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
import { RdDHerbes } from "./rdd-herbes.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Foundry VTT Initialization */ /* Foundry VTT Initialization */
@ -186,6 +186,7 @@ function messageDeBienvenue() {
Hooks.once("ready", function () { Hooks.once("ready", function () {
StatusEffects.onReady(); StatusEffects.onReady();
RdDHerbes.initializeHerbes();
/* -------------------------------------------- */ /* -------------------------------------------- */
/* Affiche/Init le calendrier */ /* Affiche/Init le calendrier */

View File

@ -2,11 +2,11 @@
"name": "foundryvtt-reve-de-dragon", "name": "foundryvtt-reve-de-dragon",
"title": "Rêve de Dragon", "title": "Rêve de Dragon",
"description": "Rêve de Dragon RPG for FoundryVTT", "description": "Rêve de Dragon RPG for FoundryVTT",
"version": "1.4.0", "version": "1.4.1",
"manifestPlusVersion": "1.0.0", "manifestPlusVersion": "1.0.0",
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.9", "compatibleCoreVersion": "0.7.9",
"templateVersion": 110, "templateVersion": 111,
"author": "LeRatierBretonnien", "author": "LeRatierBretonnien",
"authors": [ "authors": [
{ {

View File

@ -723,9 +723,11 @@
"encombrement": 0, "encombrement": 0,
"rarete": "", "rarete": "",
"categorie": "", "categorie": "",
"soinherbe": "", "herbe": "",
"soinherbebonus": 0, "herbebrins": 0,
"herbebonus": 0,
"pr": 0, "pr": 0,
"prpermanent": false,
"prdate": 0, "prdate": 0,
"cout": 0 "cout": 0
}, },

View File

@ -1,7 +1,10 @@
<option value=""></option> <option value=""></option>
<option value="Alchimie">Potion d'Alchimie</option> <option value="Alchimie">Potion d'Alchimie</option>
<option value="AlchimieEnchante">Potion d'Alchimie Enchantée</option>
<option value="Cuisine">Potion de Cuisine</option> <option value="Cuisine">Potion de Cuisine</option>
<option value="Repos">Potion de Repos</option> <option value="Repos">Potion de Repos</option>
<option value="ReposEnchante">Potion de Repos Enchantée</option> <option value="ReposEnchante">Potion de Repos Enchantée</option>
<option value="Soin">Potion de Soin</option> <option value="Soin">Potion de Soin</option>
<option value="SoinEnchante">Potion de Soin Enchantée</option> <option value="SoinEnchante">Potion de Soin Enchantée</option>
<option value="Autre">Potion Autre</option>
<option value="AutreEnchante">Potion Autre Enchantée</option>

View File

@ -30,32 +30,66 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Catégorie</label> <label>Catégorie</label>
<select name="data.categorie" class="categorie" data-dtype="String"> <select name="data.categorie" class="categoriepotion" data-dtype="String">
{{#select data.categorie}} {{#select data.categorie}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/enum-categorie-ingredient.html"}}
{{/select}} {{/select}}
</select> </select>
</div> </div>
{{#if isHerbe}}
<div class="form-group"> <div class="form-group">
<label>Herbe</label> <label>Herbe</label>
<select name="data.soinherbe" class="soinherbe" data-dtype="String"> <select name="data.herbe" class="herbe" data-dtype="String">
{{#select data.soinherbe}} {{selectOptions herbesSoins selected=data.herbe localize=false}}
{{>"systems/foundryvtt-reve-de-dragon/templates/enum-herbesoin-ingredient.html"}}
{{/select}}
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Bonus de l'herbe</label> <label>Nombre de brins</label>
<input class="attribute-value" type="text" name="data.soinherbebonus" value="{{data.soinherbebonus}}" data-dtype="Number" /> <input class="attribute-value" type="text" name="data.herbebrins" value="{{data.herbebrins}}" data-dtype="Number" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Points de rêve investis</label> <label>Bonus</label>
<input class="attribute-value" type="text" name="data.herbebonus" value="{{data.herbebonus}}" data-dtype="Number" />
</div>
{{/if}}
{{#if isEnchante}}
<div class="form-group">
<label>Points de rêve</label>
<input class="attribute-value" type="text" name="data.pr" value="{{data.pr}}" data-dtype="Number" /> <input class="attribute-value" type="text" name="data.pr" value="{{data.pr}}" data-dtype="Number" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label>Date de l'Enchantement</label> <label for="xp">Permanente ? </label>
<input class="attribute-value" type="text" name="data.prdate" value="{{data.prdate}}" data-dtype="Number" /> <input class="attribute-value" type="checkbox" name="data.prpermanent" {{#if data.prpermanent}}checked{{/if}}/>
</div> </div>
{{#if isHerbe}}
<div class="form-group">
<label for="xp">Points de guérison </label>
<label for="xp">{{pointsGuerison}}</label>
</div>
{{/if}}
<div class="form-group">
<label>Date de l'Enchantement : Jour/Mois (date actuelle : {{dateActuelle}})</label>
</div>
<div class="form-group">
<select name="splitDate.day" class="enchanteDate" id="jourMois" data-dtype="String">
{{#select splitDate.day}}
{{#each jourMoisOptions as |key|}}
<option value="{{key}}">{{numberFormat key decimals=0}}</option>
{{/each}}
{{/select}}
</select>
<select name="splitDate.month" class="enchanteDate" id="nomMois" data-dtype="String">
{{#select splitDate.month}}
{{>"systems/foundryvtt-reve-de-dragon/templates/heures-select-option.html"}}
{{/select}}
</select>
</div>
{{/if}}
{{#if isOwned}}
<div class="form-group">
<span for="xp"><a class="consommer-potion" data-actor-id="{{actorId}}">Consommer cette potion</a></span>
</div>
{{/if}}
<div class="flexcol"> <div class="flexcol">
<span><label>Description :</label></span> <span><label>Description :</label></span>
<div class="form-group editor"> <div class="form-group editor">