diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 6c43d5c1..221b4ae7 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -151,6 +151,15 @@ export class RdDActorSheet extends RdDBaseActorSheet { this.html.find('.creer-tache').click(async event => { this.createEmptyTache(); }); + this.html.find('.creer-tache-blessure-legere').click(async event => { + this.actor.createTacheBlessure('legere'); + }); + this.html.find('.creer-tache-blessure-grave').click(async event => { + this.actor.createTacheBlessure('grave'); + }); + this.html.find('.creer-tache-blessure-critique').click(async event => { + this.actor.createTacheBlessure('critique'); + }); this.html.find('.creer-une-oeuvre').click(async event => { this.selectTypeOeuvreToCreate(); }); @@ -249,7 +258,7 @@ export class RdDActorSheet extends RdDBaseActorSheet { // Points de reve actuel this.html.find('.ptreve-actuel a').click(async event => { - this.actor.rollCarac('reve-actuel'); + this.actor.rollCarac('reve-actuel', true); }); // Roll Weapon1 @@ -477,7 +486,6 @@ export class RdDActorSheet extends RdDBaseActorSheet { async createEmptyTache() { await this.actor.createItem('tache', 'Nouvelle tache'); } - _optionRecherche(target) { if (!target.value?.length) { return undefined; diff --git a/module/actor.js b/module/actor.js index 59a3402f..22467755 100644 --- a/module/actor.js +++ b/module/actor.js @@ -35,6 +35,7 @@ import { Targets } from "./targets.js"; import { DialogRepos } from "./dialog-repos.js"; import { RdDBaseActor } from "./actor/base-actor.js"; import { RdDTimestamp } from "./rdd-timestamp.js"; +import { RdDItemTache } from "./item-tache.js"; const POSSESSION_SANS_DRACONIC = { img: 'systems/foundryvtt-reve-de-dragon/icons/entites/possession.webp', @@ -46,7 +47,6 @@ const POSSESSION_SANS_DRACONIC = { }; const PAS_DE_BLESSURE = { "active": false, "psdone": false, "scdone": false, "premiers_soins": 0, "soins_complets": 0, "jours": 0, "loc": "" }; - export const MAINS_DIRECTRICES = ['Droitier', 'Gaucher', 'Ambidextre'] /* -------------------------------------------- */ @@ -859,7 +859,7 @@ export class RdDActor extends RdDBaseActor { return undefined } const path = getPath(fieldName); - if (path){ + if (path) { await this.updateEmbeddedDocuments('Item', [{ _id: competence.id, [path]: value }]); // updates one EmbeddedEntity } } @@ -1284,12 +1284,7 @@ export class RdDActor extends RdDBaseActor { async finDeRound(options = { terminer: false }) { for (let effect of this.getEffects()) { if (effect.duration.type !== 'none' && (effect.duration.remaining <= 0 || options.terminer)) { - if (effect.system.origin) { - await effect.update({ 'disabled': true }); - } - else { - await effect.delete(); - } + await effect.delete(); ChatMessage.create({ content: `${this.name} n'est plus ${Misc.lowerFirst(game.i18n.localize(effect.system.label))} !` }); } } @@ -1764,6 +1759,7 @@ export class RdDActor extends RdDBaseActor { forceAlcool: forceAlcool, nbDoses: nbDoses, selectedCarac: this.system.sante.vie, + jetResistance: 'ethylisme', carac: this.system.carac, caracValue: this.system.sante.vie.max, finalLevel: etat + forceAlcool - nbDoses @@ -1972,7 +1968,7 @@ export class RdDActor extends RdDBaseActor { async appliquerAjoutExperience(rollData, hideChatMessage = 'show') { if (!this.isPersonnage()) return; hideChatMessage = hideChatMessage == 'hide' || (Misc.isRollModeHiddenToPlayer() && !game.user.isGM) - let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence); + let xpData = await this._appliquerExperience(rollData.rolled, rollData.selectedCarac.label, rollData.competence, rollData.jetResistance); if (xpData) { const content = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/chat-actor-gain-xp.html`, xpData); if (hideChatMessage) { @@ -2197,10 +2193,11 @@ export class RdDActor extends RdDBaseActor { } /* -------------------------------------------- */ - async rollCarac(caracName) { + async rollCarac(caracName, jetResistance = undefined) { let rollData = { selectedCarac: this.getCaracByName(caracName), - competences: this.itemTypes['competence'] + competences: this.itemTypes['competence'], + jetResistance: jetResistance ? caracName : undefined }; const dialog = await RdDRoll.create(this, rollData, @@ -2328,6 +2325,13 @@ export class RdDActor extends RdDBaseActor { return tachesExistantes.length > 0 ? tachesExistantes[0] : undefined; } + async createTacheBlessure(gravite) { + const tache = RdDItemTache.prepareTacheSoin(gravite) + if (tache) { + await this.createEmbeddedDocuments('Item', [tache], { renderSheet: false }); + } + } + /* -------------------------------------------- */ async rollTache(id) { const tacheData = this.getTache(id) @@ -2754,7 +2758,7 @@ export class RdDActor extends RdDBaseActor { } /* -------------------------------------------- */ - async _appliquerExperience(rolled, caracName, competence) { + async _appliquerExperience(rolled, caracName, competence, jetResistance) { if (!this.isPersonnage()) return; // Pas d'XP if (!rolled.isPart || rolled.finalLevel >= 0) { @@ -2771,16 +2775,19 @@ export class RdDActor extends RdDBaseActor { if (caracName == 'Vie') caracName = 'constitution'; if (caracName == 'derobee') caracName = 'agilite'; if (caracName == 'reve-actuel') caracName = 'reve'; - let xp = Math.abs(rolled.finalLevel); // impair: arrondi inférieur en carac let xpCarac = competence ? Math.floor(xp / 2) : Math.max(Math.floor(xp / 2), 1); - let xpData = { - alias: this.name, - caracName: caracName, xpCarac: xpCarac, - competence: competence, xpCompetence: competence ? xp - xpCarac : 0 - }; + const xpCompetence = competence ? xp - xpCarac : 0; + if (jetResistance) { + const message = `Jet de résistance ${jetResistance}, l'expérience est limitée à 1`; + ui.notifications.info(message); + console.log(message) + // max 1 xp sur jets de résistance + xpCarac = Math.min(1, xpCarac); + } + let xpData = { alias: this.name, caracName, xpCarac, competence, xpCompetence }; await this._xpCompetence(xpData); await this._xpCarac(xpData); diff --git a/module/item-tache.js b/module/item-tache.js index 43b441d5..f17bb9af 100644 --- a/module/item-tache.js +++ b/module/item-tache.js @@ -1,4 +1,18 @@ -export class RdDItemTache extends Item { - +const BASE_TACHE_SOIN_BLESSURE = { type: "tache", img: 'systems/foundryvtt-reve-de-dragon/icons/competence_chirurgie.webp', system: { carac: "dexterite", competence: "Chirurgie", periodicite: "1 round", fatigue: 0, } } +const TACHES_SOIN_BLESSURE = { + 'critique': { name: 'Blessure critique', system: { difficulte: -6, points_de_tache: 6 } }, + 'grave': { name: 'Blessure grave', system: { difficulte: -4, points_de_tache: 4 } }, + 'legere': { name: 'Blessure légère', system: { difficulte: -2, points_de_tache: 2 } }, +} +export class RdDItemTache extends Item { + + static prepareTacheSoin(gravite) { + const blessure = TACHES_SOIN_BLESSURE[gravite] + if (blessure) { + return mergeObject(duplicate(BASE_TACHE_SOIN_BLESSURE), blessure) + } + ui.notifications.warn(`Pas de tâche de soins pour une blessure ${gravite}`) + return undefined; + } } \ No newline at end of file diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 45202088..9aedd422 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -1,6 +1,5 @@ import { ChatUtility } from "./chat-utility.js"; -import { ENTITE_BLURETTE, ENTITE_INCARNE, ENTITE_NONINCARNE, HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; -import { DialogSelectTarget } from "./dialog-select-target.js"; +import { ENTITE_BLURETTE, HIDE_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { Grammar } from "./grammar.js"; import { RdDItemArme } from "./item-arme.js"; import { RdDItemCompetence } from "./item-competence.js"; @@ -111,10 +110,10 @@ export class RdDCombatManager extends Combat { if (!roll.total) { roll.evaluate({ async: false }); } - if (roll.total <= 0) roll.total = 0.00; - console.log("Compute init for", rollFormula, roll.total, combatant); + const total = Math.max(roll.total, 0.00); + console.log("Compute init for", rollFormula, roll, total, combatant); let id = combatant._id || combatant.id; - await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: roll.total }]); + await this.updateEmbeddedDocuments("Combatant", [{ _id: id, initiative: total }]); // Send a chat message let rollMode = messageOptions.rollMode || game.settings.get("core", "rollMode"); diff --git a/module/rdd-timestamp.js b/module/rdd-timestamp.js index 831e48e1..5dbce01d 100644 --- a/module/rdd-timestamp.js +++ b/module/rdd-timestamp.js @@ -73,6 +73,9 @@ export class RdDTimestamp { * @returns L'entrée de DEFINITION_HEURES correspondant au signe */ static definition(signe) { + if (signe == undefined) { + signe = 0; + } if (Number.isInteger(signe)) { return DEFINITION_HEURES[signe % RDD_HEURES_PAR_JOUR]; } @@ -96,7 +99,7 @@ export class RdDTimestamp { } static imgSigne(signe) { - return `${signe.label}` + return signe == undefined ? '' : `${signe.label}` } static handleTimestampEditor(html, path, consumeTimestamp = async (path, timestamp) => { }) { diff --git a/module/rdd-tmr-dialog.js b/module/rdd-tmr-dialog.js index ac450e98..9dc42f28 100644 --- a/module/rdd-tmr-dialog.js +++ b/module/rdd-tmr-dialog.js @@ -285,7 +285,12 @@ export class RdDTMRDialog extends Dialog { } /* -------------------------------------------- */ - async onActionRencontre(action, tmr) { + async onActionRencontre(action, tmr, rencontre) { + if (!this.currentRencontre){ + ui.notifications.warn("#612 Rencontre perdue, récupération en cours. Vous pouvez contacter l'équipe avec les logs pour aider à résoudre ce problème") + console.error("#612 Rencontre perdue", action, tmr, rencontre, this); + this.currentRencontre = rencontre; + } switch (action) { case 'derober': await this.derober(); @@ -589,6 +594,7 @@ export class RdDTMRDialog extends Dialog { return await game.system.rdd.rencontresTMR.getRencontreAleatoire(tmr, this.actor.isMauvaiseRencontre()) } else { this._tellToUser(myRoll + ": Pas de rencontre en " + locTMR); + return undefined; } } diff --git a/module/rdd-tmr-rencontre-dialog.js b/module/rdd-tmr-rencontre-dialog.js index 804dd160..b1a859f2 100644 --- a/module/rdd-tmr-rencontre-dialog.js +++ b/module/rdd-tmr-rencontre-dialog.js @@ -29,12 +29,13 @@ export class RdDTMRRencontreDialog extends Dialog { this.toClose = false; this.tmr = tmr; this.tmrApp = tmrApp; + this.rencontre = rencontre; this.tmrApp.minimize(); } async onButtonAction(action) { this.toClose = true; - this.tmrApp.onActionRencontre(action, this.tmr) + this.tmrApp.onActionRencontre(action, this.tmr, this.rencontre) } /* -------------------------------------------- */ diff --git a/module/rdd-utility.js b/module/rdd-utility.js index b62961df..ef8a1000 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -149,6 +149,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/actor/jeux.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/alchimie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/astrologie.html', + 'systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/non-haut-revant.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/haut-revant.html', 'systems/foundryvtt-reve-de-dragon/templates/actor/dragon-queues.html', diff --git a/system.json b/system.json index 7bfb9168..5ccab435 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.6.2", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.2.zip", + "version": "10.6.3", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.6.3.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10", diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 772f0e72..d27e5384 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -89,6 +89,7 @@ {{#if options.isObserver}}{{!-- Combat Tab --}}
{{> "systems/foundryvtt-reve-de-dragon/templates/actor/combat.html"}}
+ {{> "systems/foundryvtt-reve-de-dragon/templates/actor/chirurgie.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/blessures.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/maladies-poisons.html"}} {{> "systems/foundryvtt-reve-de-dragon/templates/actor/possessions.html"}} diff --git a/templates/actor/chirurgie.html b/templates/actor/chirurgie.html new file mode 100644 index 00000000..d53c3da1 --- /dev/null +++ b/templates/actor/chirurgie.html @@ -0,0 +1,21 @@ +

Soins

+Blessure légère +Blessure grave +Blessure critique + diff --git a/templates/actor/taches.html b/templates/actor/taches.html index 62afffc2..579d026f 100644 --- a/templates/actor/taches.html +++ b/templates/actor/taches.html @@ -1,16 +1,18 @@

Tâches

Nouvelle Tâche