From 4dce510c91dd1b98780d1ec0434e785218e4287d Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 18 Dec 2024 17:26:28 +0100 Subject: [PATCH] =?UTF-8?q?Calcul=20automatique=20du=20niveau=20des=20enti?= =?UTF-8?q?t=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- changelog.md | 3 ++ module/actor/base-actor-reve.js | 22 +++++----- module/actor/entite-sheet.js | 6 +-- module/actor/entite.js | 13 ++++++ module/rdd-carac.js | 64 +++++++++++++-------------- styles/simple.css | 3 ++ templates/actor-creature-sheet.html | 2 + templates/actor-entite-sheet.html | 2 + templates/actor-sheet.html | 2 + templates/actor/carac-creature.html | 9 ++-- templates/actor/carac-entitee.html | 17 +++++--- templates/actor/carac-main.html | 68 ++++++++++++++--------------- templates/actor/comp-creature.html | 7 ++- 13 files changed, 120 insertions(+), 98 deletions(-) diff --git a/changelog.md b/changelog.md index 381a5488..9c8669f0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # 12.0 +## 12.0.30 - le cauchemar d'Astrobazzarh +- calcul automatique du niveau des entités selon leur rêve + ## 12.0.29 - L'indexation d'Astrobazzarh - les liens dans la descriptions des sorts pointent vers les sorts du compendium - la description du chrasme contient le lien vers son venin plutôt qu'un tableau diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index 01388832..69777d32 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -37,6 +37,15 @@ export class RdDBaseActorReve extends RdDBaseActor { this.system.sante.endurance.value = Math.min(this.system.sante.endurance.value, this.system.sante.endurance.max) } + getCarac() { + return foundry.utils.mergeObject(this.system.carac, + { + 'reve-actuel': this.getCaracReveActuel(), + 'chance-actuelle': this.getCaracChanceActuelle() + }, + { inplace: false }) + } + getCaracChanceActuelle() { return { label: 'Chance actuelle', @@ -53,7 +62,6 @@ export class RdDBaseActorReve extends RdDBaseActor { }; } - getTaille() { return Misc.toInt(this.system.carac.taille?.value) } getConstitution() { return this.getReve() } getForce() { return this.getReve() } @@ -306,16 +314,6 @@ export class RdDBaseActorReve extends RdDBaseActor { }); } - getCarac() { - // TODO: le niveau d'une entité de cauchemar devrait être exclu... - return foundry.utils.mergeObject(this.system.carac, - { - 'reve-actuel': this.getCaracReveActuel(), - 'chance-actuelle': this.getCaracChanceActuelle() - }, - { inplace: false }) - } - /* -------------------------------------------- */ async rollCarac(caracName, jetResistance = undefined) { if (Grammar.equalsInsensitive(caracName, 'taille')) { @@ -499,7 +497,7 @@ export class RdDBaseActorReve extends RdDBaseActor { || entite.isEntiteAccordee(this)) { return true; } - const rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.system.carac.niveau.value)); + const rolled = await RdDResolutionTable.roll(this.getReveActuel(), - Number(entite.getNiveau())); const rollData = { alias: this.getAlias(), rolled: rolled, diff --git a/module/actor/entite-sheet.js b/module/actor/entite-sheet.js index 6d1a7bc7..4f213768 100644 --- a/module/actor/entite-sheet.js +++ b/module/actor/entite-sheet.js @@ -15,6 +15,8 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet { async getData() { let formData = await super.getData(); + formData.niveau = this.actor.getNiveau() + delete formData.system.carac.niveau formData.resonances = this.actor.system.sante.resonnance.actors.map(actorId => game.actors.get(actorId)) .map(actor => { return { id: actor.id, name: actor.name, img: actor.img } }) return formData @@ -33,10 +35,6 @@ export class RdDActorEntiteSheet extends RdDBaseActorReveSheet { let compName = event.currentTarget.attributes.compname.value; this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value)); }); - this.html.find('.creature-niveau').change(async event => { - let compName = event.currentTarget.attributes.compname.value; - this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value)); - }) this.html.find('.creature-dommages').change(async event => { let compName = event.currentTarget.attributes.compname.value; this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value)); diff --git a/module/actor/entite.js b/module/actor/entite.js index d72935c9..ef11b95a 100644 --- a/module/actor/entite.js +++ b/module/actor/entite.js @@ -1,6 +1,7 @@ import { ENTITE_INCARNE, ENTITE_NONINCARNE } from "../constants.js"; import { ITEM_TYPES } from "../item.js"; import { Misc } from "../misc.js"; +import { RdDCarac } from "../rdd-carac.js"; import { RdDEncaisser } from "../rdd-roll-encaisser.js"; import { STATUSES } from "../settings/status-effects.js"; import { RdDBaseActorReve } from "./base-actor-reve.js"; @@ -18,12 +19,23 @@ export class RdDEntite extends RdDBaseActorReve { isEntite(typeentite = []) { return (typeentite.length == 0 || typeentite.includes(this.system.definition.typeentite)); } + isNonIncarnee() { return this.isEntite([ENTITE_NONINCARNE]) } getReveActuel() { return Misc.toInt(this.system.carac.reve?.value) } + getCarac() { + const carac = super.getCarac() + delete carac.niveau + return carac + } + + getNiveau() { + const reve = this.getReve() + return RdDCarac.getCaracDerivee(reve).niveau + } getForce() { return this.getReve() } getAgilite() { return this.getReve() } getChance() { return this.getReve() } @@ -64,6 +76,7 @@ export class RdDEntite extends RdDBaseActorReve { } return {} } + async encaisser() { if (this.isNonIncarnee()) { return diff --git a/module/rdd-carac.js b/module/rdd-carac.js index 272f0869..f8678370 100644 --- a/module/rdd-carac.js +++ b/module/rdd-carac.js @@ -3,38 +3,38 @@ import { Misc } from "./misc.js"; const TABLE_CARACTERISTIQUES_DERIVEES = { // xp: coût pour passer du niveau inférieur à ce niveau - 1: { xp: 3, poids: "moins de 1kg", poidsMin: 0, poidsMax: 1, plusdom: -5, sconst: 0.5, sust: 0.1 }, - 2: { xp: 3, poids: "1-5", poidsMin: 1, poidsMax: 5, plusdom: -4, sconst: 0.5, sust: 0.3 }, - 3: { xp: 4, poids: "6-10", poidsMin: 6, poidsMax: 10, plusdom: -3, sconst: 1, sust: 0.5, beaute: 'hideux' }, - 4: { xp: 4, poids: "11-20", poidsMin: 11, poidsMax: 20, plusdom: -3, sconst: 1, sust: 1, beaute: 'repoussant' }, - 5: { xp: 5, poids: "21-30", poidsMin: 21, poidsMax: 30, plusdom: -2, sconst: 1, sust: 1, beaute: 'franchement très laid' }, - 6: { xp: 5, poids: "31-40", poidsMin: 31, poidsMax: 40, plusdom: -1, sconst: 2, sust: 2, beaute: 'laid' }, - 7: { xp: 6, poids: "41-50", poidsMin: 41, poidsMax: 50, plusdom: -1, sconst: 2, sust: 2, beaute: 'très désavantagé' }, - 8: { xp: 6, poids: "51-60", poidsMin: 51, poidsMax: 60, plusdom: 0, sconst: 2, sust: 2, beaute: 'désavantagé' }, - 9: { xp: 7, poids: "61-65", poidsMin: 61, poidsMax: 65, plusdom: 0, sconst: 3, sust: 2, beaute: 'pas terrible' }, - 10: { xp: 7, poids: "66-70", poidsMin: 66, poidsMax: 70, plusdom: 0, sconst: 3, sust: 3, beaute: 'commun' }, - 11: { xp: 8, poids: "71-75", poidsMin: 71, poidsMax: 75, plusdom: 0, sconst: 3, sust: 3, beaute: 'pas mal' }, - 12: { xp: 8, poids: "76-80", poidsMin: 76, poidsMax: 80, plusdom: +1, sconst: 4, sust: 3, beaute: 'avantagé' }, - 13: { xp: 9, poids: "81-90", poidsMin: 81, poidsMax: 90, plusdom: +1, sconst: 4, sust: 3, beaute: 'mignon' }, - 14: { xp: 9, poids: "91-100", poidsMin: 91, poidsMax: 100, plusdom: +2, sconst: 4, sust: 4, beaute: 'beau' }, - 15: { xp: 10, poids: "101-110", poidsMin: 101, poidsMax: 110, plusdom: +2, sconst: 5, sust: 4, beaute: 'très beau' }, - 16: { xp: 20, poids: "111-120", poidsMin: 111, poidsMax: 120, plusdom: +3, sconst: 5, sust: 4, beaute: 'éblouissant' }, - 17: { xp: 30, poids: "121-131", poidsMin: 121, poidsMax: 131, plusdom: +3, sconst: 5, sust: 5 }, - 18: { xp: 40, poids: "131-141", poidsMin: 131, poidsMax: 141, plusdom: +4, sconst: 6, sust: 5 }, - 19: { xp: 50, poids: "141-150", poidsMin: 141, poidsMax: 150, plusdom: +4, sconst: 6, sust: 5 }, - 20: { xp: 60, poids: "151-160", poidsMin: 151, poidsMax: 160, plusdom: +4, sconst: 6, sust: 6 }, - 21: { xp: 70, poids: "161-180", poidsMin: 161, poidsMax: 180, plusdom: +5, sconst: 7, sust: 6 }, - 22: { xp: 80, poids: "181-200", poidsMin: 181, poidsMax: 200, plusdom: +5, sconst: 7, sust: 7 }, - 23: { xp: 90, poids: "201-300", poidsMin: 201, poidsMax: 300, plusdom: +6, sconst: 7, sust: 8 }, - 24: { xp: 100, poids: "301-400", poidsMin: 301, poidsMax: 400, plusdom: +6, sconst: 8, sust: 9 }, - 25: { xp: 110, poids: "401-500", poidsMin: 401, poidsMax: 500, plusdom: +7, sconst: 8, sust: 10 }, - 26: { xp: 120, poids: "501-600", poidsMin: 501, poidsMax: 600, plusdom: +7, sconst: 8, sust: 11 }, - 27: { xp: 130, poids: "601-700", poidsMin: 601, poidsMax: 700, plusdom: +8, sconst: 9, sust: 12 }, - 28: { xp: 140, poids: "701-800", poidsMin: 701, poidsMax: 800, plusdom: +8, sconst: 9, sust: 13 }, - 29: { xp: 150, poids: "801-900", poidsMin: 801, poidsMax: 900, plusdom: +9, sconst: 9, sust: 14 }, - 30: { xp: 160, poids: "901-1000", poidsMin: 901, poidsMax: 1000, plusdom: +9, sconst: 10, sust: 15 }, - 31: { xp: 170, poids: "1001-1500", poidsMin: 1001, poidsMax: 1500, plusdom: +10, sconst: 10, sust: 16 }, - 32: { xp: 180, poids: "1501-2000", poidsMin: 1501, poidsMax: 2000, plusdom: +11, sconst: 10, sust: 17 } + 1: { xp: 3, niveau: -5, poids: "moins de 1kg", poidsMin: 0, poidsMax: 1, plusdom: -5, sconst: 0.5, sust: 0.1 }, + 2: { xp: 3, niveau: -4, poids: "1-5", poidsMin: 1, poidsMax: 5, plusdom: -4, sconst: 0.5, sust: 0.3 }, + 3: { xp: 4, niveau: -3, poids: "6-10", poidsMin: 6, poidsMax: 10, plusdom: -3, sconst: 1, sust: 0.5, beaute: 'hideux' }, + 4: { xp: 4, niveau: -2, poids: "11-20", poidsMin: 11, poidsMax: 20, plusdom: -3, sconst: 1, sust: 1, beaute: 'repoussant' }, + 5: { xp: 5, niveau: -1, poids: "21-30", poidsMin: 21, poidsMax: 30, plusdom: -2, sconst: 1, sust: 1, beaute: 'franchement très laid' }, + 6: { xp: 5, niveau: 0, poids: "31-40", poidsMin: 31, poidsMax: 40, plusdom: -1, sconst: 2, sust: 2, beaute: 'laid' }, + 7: { xp: 6, niveau: 0, poids: "41-50", poidsMin: 41, poidsMax: 50, plusdom: -1, sconst: 2, sust: 2, beaute: 'très désavantagé' }, + 8: { xp: 6, niveau: 0, poids: "51-60", poidsMin: 51, poidsMax: 60, plusdom: 0, sconst: 2, sust: 2, beaute: 'désavantagé' }, + 9: { xp: 7, niveau: 0, poids: "61-65", poidsMin: 61, poidsMax: 65, plusdom: 0, sconst: 3, sust: 2, beaute: 'pas terrible' }, + 10: { xp: 7, niveau: 0, poids: "66-70", poidsMin: 66, poidsMax: 70, plusdom: 0, sconst: 3, sust: 3, beaute: 'commun' }, + 11: { xp: 8, niveau: 1, poids: "71-75", poidsMin: 71, poidsMax: 75, plusdom: 0, sconst: 3, sust: 3, beaute: 'pas mal' }, + 12: { xp: 8, niveau: 1, poids: "76-80", poidsMin: 76, poidsMax: 80, plusdom: +1, sconst: 4, sust: 3, beaute: 'avantagé' }, + 13: { xp: 9, niveau: 2, poids: "81-90", poidsMin: 81, poidsMax: 90, plusdom: +1, sconst: 4, sust: 3, beaute: 'mignon' }, + 14: { xp: 9, niveau: 2, poids: "91-100", poidsMin: 91, poidsMax: 100, plusdom: +2, sconst: 4, sust: 4, beaute: 'beau' }, + 15: { xp: 10, niveau: 3, poids: "101-110", poidsMin: 101, poidsMax: 110, plusdom: +2, sconst: 5, sust: 4, beaute: 'très beau' }, + 16: { xp: 20, niveau: 3, poids: "111-120", poidsMin: 111, poidsMax: 120, plusdom: +3, sconst: 5, sust: 4, beaute: 'éblouissant' }, + 17: { xp: 30, niveau: 4, poids: "121-131", poidsMin: 121, poidsMax: 131, plusdom: +3, sconst: 5, sust: 5 }, + 18: { xp: 40, niveau: 4, poids: "131-141", poidsMin: 131, poidsMax: 141, plusdom: +4, sconst: 6, sust: 5 }, + 19: { xp: 50, niveau: 5, poids: "141-150", poidsMin: 141, poidsMax: 150, plusdom: +4, sconst: 6, sust: 5 }, + 20: { xp: 60, niveau: 5, poids: "151-160", poidsMin: 151, poidsMax: 160, plusdom: +4, sconst: 6, sust: 6 }, + 21: { xp: 70, niveau: 6, poids: "161-180", poidsMin: 161, poidsMax: 180, plusdom: +5, sconst: 7, sust: 6 }, + 22: { xp: 80, niveau: 6, poids: "181-200", poidsMin: 181, poidsMax: 200, plusdom: +5, sconst: 7, sust: 7 }, + 23: { xp: 90, niveau: 7, poids: "201-300", poidsMin: 201, poidsMax: 300, plusdom: +6, sconst: 7, sust: 8 }, + 24: { xp: 100, niveau: 7, poids: "301-400", poidsMin: 301, poidsMax: 400, plusdom: +6, sconst: 8, sust: 9 }, + 25: { xp: 110, niveau: 8, poids: "401-500", poidsMin: 401, poidsMax: 500, plusdom: +7, sconst: 8, sust: 10 }, + 26: { xp: 120, niveau: 8, poids: "501-600", poidsMin: 501, poidsMax: 600, plusdom: +7, sconst: 8, sust: 11 }, + 27: { xp: 130, niveau: 9, poids: "601-700", poidsMin: 601, poidsMax: 700, plusdom: +8, sconst: 9, sust: 12 }, + 28: { xp: 140, niveau: 9, poids: "701-800", poidsMin: 701, poidsMax: 800, plusdom: +8, sconst: 9, sust: 13 }, + 29: { xp: 150, niveau: 10, poids: "801-900", poidsMin: 801, poidsMax: 900, plusdom: +9, sconst: 9, sust: 14 }, + 30: { xp: 160, niveau: 10, poids: "901-1000", poidsMin: 901, poidsMax: 1000, plusdom: +9, sconst: 10, sust: 15 }, + 31: { xp: 170, niveau: 11, poids: "1001-1500", poidsMin: 1001, poidsMax: 1500, plusdom: +10, sconst: 10, sust: 16 }, + 32: { xp: 180, niveau: 11, poids: "1501-2000", poidsMin: 1501, poidsMax: 2000, plusdom: +11, sconst: 10, sust: 17 } }; export class RdDCarac { diff --git a/styles/simple.css b/styles/simple.css index 6b1949fe..78b2d63e 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -797,6 +797,9 @@ input:is(.blessure-premiers_soins, .blessure-soins_complets) { padding: 0; overflow-y: auto; } +.item-list-title{ + flex: 0; +} .foundryvtt-reve-de-dragon .item-list .item-header { font-weight: bold; diff --git a/templates/actor-creature-sheet.html b/templates/actor-creature-sheet.html index 215fbf10..5ac324ed 100644 --- a/templates/actor-creature-sheet.html +++ b/templates/actor-creature-sheet.html @@ -47,8 +47,10 @@
+
    {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-main.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.html"}} +
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/comp-creature.html"}} diff --git a/templates/actor-entite-sheet.html b/templates/actor-entite-sheet.html index 3c8535b9..89de5e74 100644 --- a/templates/actor-entite-sheet.html +++ b/templates/actor-entite-sheet.html @@ -33,8 +33,10 @@
+
    {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-main.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-entitee.html"}} +
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 9e772304..c7a4a023 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -41,8 +41,10 @@
+
    {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-main.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-total.html"}} +
{{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-derivee.html"}} diff --git a/templates/actor/carac-creature.html b/templates/actor/carac-creature.html index e16b56f3..85fa140c 100644 --- a/templates/actor/carac-creature.html +++ b/templates/actor/carac-creature.html @@ -1,21 +1,20 @@ -
    {{#each system.attributs as |attr key|}} {{#if (and (eq key 'plusdom') (eq @root.system.definition.typeentite 'nonincarne'))}} {{else}}
  1. {{attr.label}} {{#if (actor-default @root.type 'attributs' key 'derivee')}} - {{else}} {{/if}} +
  2. {{/if}} {{/each}} -
diff --git a/templates/actor/carac-entitee.html b/templates/actor/carac-entitee.html index b177c5ff..28b8f9d8 100644 --- a/templates/actor/carac-entitee.html +++ b/templates/actor/carac-entitee.html @@ -1,16 +1,21 @@ -
  1. - Catégorie : + Niveau + +
  2. + {{>"systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.html"}} +
  3. + Catégorie +
  4. - Type d'entité : + Type d'entité +
  5. -
- -{{> "systems/foundryvtt-reve-de-dragon/templates/actor/carac-creature.html"}} diff --git a/templates/actor/carac-main.html b/templates/actor/carac-main.html index 2ed701db..3dc5adc3 100644 --- a/templates/actor/carac-main.html +++ b/templates/actor/carac-main.html @@ -1,39 +1,37 @@ -
    - {{#each system.carac as |carac key|}} - {{#if (and (eq key 'taille') (eq @root.system.definition.typeentite 'nonincarne'))}} - {{else}} -
  • - {{#if (eq key 'taille')}} - {{carac.label}} - -
  • + {{#if (eq key 'taille')}} + {{carac.label}} + +
  • {{/if}} - {{/each}} -
+ + {{/if}} +{{/each}} diff --git a/templates/actor/comp-creature.html b/templates/actor/comp-creature.html index c982a448..c22297f8 100644 --- a/templates/actor/comp-creature.html +++ b/templates/actor/comp-creature.html @@ -1,14 +1,13 @@ -

Compétences{{#if @root.options.vueDetaillee}} +

Compétences{{#if @root.options.vueDetaillee}} {{/if}}

-
    +
      {{#each (trier competences) as |comp key|}}
    • {{comp.name}} - @@ -32,4 +31,4 @@ {{/if}}
    • {{/each}} -
+