From 981282d809799660d2f942624e6e1f97c0f8395e Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 27 Nov 2025 23:13:05 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20m=C3=A9thode=20getConjurations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour lister les compétences de possession/conjuration de manière homogène (tout actor doué de rêve) --- assets/actions/possession.svg | 1 + module/actor.js | 21 +++++++----- module/actor/base-actor-reve.js | 51 +++++++++++++++++++++++++--- module/actor/base-actor-sang.js | 1 + module/actor/entite.js | 7 ---- module/constants.js | 1 + module/item/arme.js | 4 +++ module/item/base-items.js | 43 ++++++++++++----------- module/rdd-possession.js | 2 +- module/roll/roll-constants.mjs | 5 +-- module/roll/roll-type-possession.mjs | 33 ++++++++++++++++++ 11 files changed, 127 insertions(+), 42 deletions(-) create mode 100644 assets/actions/possession.svg create mode 100644 module/roll/roll-type-possession.mjs diff --git a/assets/actions/possession.svg b/assets/actions/possession.svg new file mode 100644 index 00000000..95b69fa5 --- /dev/null +++ b/assets/actions/possession.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/module/actor.js b/module/actor.js index e76913cd..21bd525e 100644 --- a/module/actor.js +++ b/module/actor.js @@ -19,7 +19,7 @@ import { DialogConsommer } from "./dialog-item-consommer.js"; import { DialogFabriquerPotion } from "./dialog-fabriquer-potion.js"; import { RollDataAjustements } from "./rolldata-ajustements-v1.js"; import { RdDPossession } from "./rdd-possession.js"; -import { ACTOR_TYPES, renderTemplate, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; +import { ACTOR_TYPES, RDD_CONFIG, renderTemplate, SHOW_DICE, SYSTEM_RDD, SYSTEM_SOCKET_ID } from "./constants.js"; import { RdDConfirm } from "./rdd-confirm.js"; import { DialogRepos } from "./sommeil/dialog-repos.js"; import { RdDBaseActor } from "./actor/base-actor.js"; @@ -41,12 +41,12 @@ import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemSigneDraconique } from "./item/signedraconique.js"; import { RdDRencontre } from "./item/rencontre.js"; import { DialogSelect } from "./dialog-select.js"; -import { PAS_DE_DRACONIC, POSSESSION_SANS_DRACONIC } from "./item/base-items.js"; +import { CATEGORIES_COMPETENCES, PAS_DE_DRACONIC, POSSESSION_SANS_DRACONIC } from "./item/base-items.js"; import { RdDRollResult } from "./rdd-roll-result.js"; import { RdDInitiative } from "./initiative.mjs"; import RollDialog from "./roll/roll-dialog.mjs"; -import { OptionsAvancees, ROLL_DIALOG_V2, ROLL_DIALOG_V2_TEST } from "./settings/options-avancees.js"; +import { OptionsAvancees, ROLL_DIALOG_V2 } from "./settings/options-avancees.js"; import { ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_SORT } from "./roll/roll-constants.mjs"; import { PART_TACHE } from "./roll/roll-part-tache.mjs"; import { PART_COMP } from "./roll/roll-part-comp.mjs"; @@ -160,12 +160,15 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ getDemiReve() { return this.system.reve.tmrpos.coord } - getDraconics() { return this.itemTypes[ITEM_TYPES.competence].filter(it => it.system.categorie == 'draconic') } + getDraconics() { + return this.isHautRevant() + ? this.itemTypes[ITEM_TYPES.competence].filter(it => it.system.categorie == CATEGORIES_COMPETENCES.draconic.key) + : [] + } getBestDraconic() { return foundry.utils.duplicate([...this.getDraconics(), PAS_DE_DRACONIC].sort(Misc.descending(it => it.system.niveau)).find(it => true)) } - getDraconicOuPossession() { - return [...this.getDraconics().filter(it => it.system.niveau >= 0), POSSESSION_SANS_DRACONIC] - .sort(Misc.descending(it => it.system.niveau)) - .find(it => true) + + getConjurationNaturelle() { + return new RdDItemCompetence(POSSESSION_SANS_DRACONIC) } isForceInsuffisante(forceRequise) { @@ -688,7 +691,7 @@ export class RdDActor extends RdDBaseActorSang { const rencontre = await game.system.rdd.rencontresTMR.getReveDeDragon(force); let rollData = { actor: this, - competence: this.getDraconicOuPossession(), + competence: this.getDraconicOuPossession().find(it => true), canClose: false, rencontre: rencontre, tmr: true, diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index 6a3a0988..b9a50ff4 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -1,4 +1,4 @@ -import { renderTemplate, SHOW_DICE, SYSTEM_RDD } from "../constants.js"; +import { RDD_CONFIG, renderTemplate, SHOW_DICE, SYSTEM_RDD } from "../constants.js"; import { Grammar } from "../grammar.js"; import { Misc } from "../misc.js"; import { RdDResolutionTable } from "../rdd-resolution-table.js"; @@ -22,13 +22,15 @@ import { DialogValidationEncaissement } from "../dialog-validation-encaissement. import { RdDCombat } from "../rdd-combat.js"; import { RdDEmpoignade } from "../rdd-empoignade.js"; import { RdDPossession } from "../rdd-possession.js"; -import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, POSSESSION_SANS_DRACONIC } from "../item/base-items.js"; +import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, CATEGORIES_COMPETENCES_CREATURES } from "../item/base-items.js"; import { RollDataAjustements } from "../rolldata-ajustements-v1.js"; import { MappingCreatureArme } from "../item/mapping-creature-arme.mjs"; import RollDialog from "../roll/roll-dialog.mjs"; import { ATTAQUE_ROLL_TYPES, DEFAULT_ROLL_TYPES, DIFF, DIFFS, ROLL_TYPE_ATTAQUE, ROLL_TYPE_COMP, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE } from "../roll/roll-constants.mjs"; import { OptionsAvancees, ROLL_DIALOG_V2 } from "../settings/options-avancees.js"; import { PART_COMP } from "../roll/roll-part-comp.mjs"; +import { RdDInitiative } from "../initiative.mjs"; +import { RdDItemCompetenceCreature } from "../item-competencecreature.js"; /** * Classe de base pour les acteurs disposant de rêve (donc, pas des objets) @@ -114,6 +116,49 @@ export class RdDBaseActorReve extends RdDBaseActor { return this.system.carac[competence.system.defaut_carac].value; } + getDraconics() { return [] } + getDraconicOuPossession() { + return [ + ...this.getDraconics(), + ...this.itemTypes[ITEM_TYPES.competencecreature].filter(it => it.system.ispossession || it.system.categorie == CATEGORIES_COMPETENCES_CREATURES.possession.key), + this.getConjurationNaturelle() + ].sort(Misc.descending(it => it.system.niveau)); + } + + getConjurations() { + return this.getDraconicOuPossession() + .map(it => this.toActionConjuration(it)) + } + + getConjurationNaturelle() { + return new RdDItemCompetenceCreature({ + name: 'Sans compétence', + type: ITEM_TYPES.competencecreature, + img: RDD_CONFIG.icons.possession, + system: { + carac_value: this.getReveActuel(), + niveau: 0, + default_diffLibre: 0, + categorie: CATEGORIES_COMPETENCES_CREATURES.possession.key, + ispossession: true, + } + }) + } + + toActionConjuration(comp) { + const caracCode = this.isPersonnage() ? CARACS.REVE_ACTUEL : CARACS.REVE + const caracValue = this.getReveActuel() + const ajustement = this.getEtatGeneral() + return { + label: `Conjuration (${comp.name})`, + action: 'possession', + initOnly: false, + comp: comp, + carac: { key: caracCode, value: caracValue }, + initiative: RdDInitiative.getRollInitiative(caracValue, comp.system.niveau, ajustement) + } + } + listActions({ isAttaque = false, isEquipe = false }) { return this.itemTypes[ITEM_TYPES.competencecreature] .filter(it => it.isAttaque()) @@ -198,8 +243,6 @@ export class RdDBaseActorReve extends RdDBaseActor { return false } - getDraconicOuPossession() { return POSSESSION_SANS_DRACONIC } - getPossession(possessionId) { return this.itemTypes[ITEM_TYPES.possession].find(it => it.system.possessionid == possessionId); } diff --git a/module/actor/base-actor-sang.js b/module/actor/base-actor-sang.js index 74bcc4f5..07922963 100644 --- a/module/actor/base-actor-sang.js +++ b/module/actor/base-actor-sang.js @@ -7,6 +7,7 @@ import { RdDDice } from "../rdd-dice.js"; import { RdDItemBlessure } from "../item/blessure.js"; import { ChatUtility } from "../chat-utility.js"; import { Misc } from "../misc.js"; +import { CARACS } from "../rdd-carac.js"; /** * Classe de base pour les acteurs qui peuvent subir des blessures diff --git a/module/actor/entite.js b/module/actor/entite.js index 17eef287..a005fd28 100644 --- a/module/actor/entite.js +++ b/module/actor/entite.js @@ -41,13 +41,6 @@ export class RdDEntite extends RdDBaseActorReve { getChance() { return this.getReve() } getEnduranceMax() { return Math.max(1, this.getTaille() + this.getReve()) } - getDraconicOuPossession() { - return this.itemTypes[ITEM_TYPES.competencecreature] - .filter(it => it.system.categorie == 'possession') - .sort(Misc.descending(it => it.system.niveau)) - .find(it => true); - } - async remiseANeuf() { if (!this.isEntiteNonIncarnee()) { await this.update({ diff --git a/module/constants.js b/module/constants.js index e90ea3f1..9ec0d44b 100644 --- a/module/constants.js +++ b/module/constants.js @@ -61,6 +61,7 @@ export const RDD_CONFIG = { armesDisparates: 'systems/foundryvtt-reve-de-dragon/assets/actions/armes-disparates.svg', demiReve: 'systems/foundryvtt-reve-de-dragon/assets/actions/sort.svg', empoignade: 'systems/foundryvtt-reve-de-dragon/assets/actions/empoignade.svg', + possession: 'systems/foundryvtt-reve-de-dragon/assets/actions/possession.svg', forceWeak: 'systems/foundryvtt-reve-de-dragon/assets/actions/weak.svg', surenc: 'systems/foundryvtt-reve-de-dragon/assets/actions/surenc.svg', magique: 'systems/foundryvtt-reve-de-dragon/assets/actions/magique.svg', diff --git a/module/item/arme.js b/module/item/arme.js index 2e3ccced..204a7cd9 100644 --- a/module/item/arme.js +++ b/module/item/arme.js @@ -278,6 +278,10 @@ export class RdDItemArme extends RdDItem { return this.system.mortalite == RDD_CONFIG.encaissement.empoignade } + isPossession() { + return this.system.mortalite == RDD_CONFIG.encaissement.possession + } + isUtilisableEmpoigne() { return this.system.baseInit == 3 || this.system.baseInit == 4 || this.system.competence == "Dague" } diff --git a/module/item/base-items.js b/module/item/base-items.js index 48bd6ad6..f2ffb854 100644 --- a/module/item/base-items.js +++ b/module/item/base-items.js @@ -1,22 +1,5 @@ -export const POSSESSION_SANS_DRACONIC = { name: 'Sans draconic', type: 'competence', system: { niveau: 0, defaut_carac: "reve-actuel", }, img: 'systems/foundryvtt-reve-de-dragon/icons/entites/possession.webp' } -export const PAS_DE_DRACONIC = { name: 'Pas de draconic', type: 'competence', system: { niveau: -11, defaut_carac: "reve" }, img: 'systems/foundryvtt-reve-de-dragon/icons/entites/possession.webp' } -export const BASE_CORPS_A_CORPS = { name: 'Corps à Corps', type: 'competence', system: { niveau: -6, defaut_carac: "melee" }, img: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' } -export const BASE_ESQUIVE = { name: 'Esquive', type: 'competence', system: { niveau: -6, defaut_carac: "derobee" }, img: 'systems/foundryvtt-reve-de-dragon/icons/competence_esquive.webp' } - -export const SANS_COMPETENCE = { - name: "Sans compétence", - type: 'competence', - system: { - niveau: 0, - default_diffLibre: 0, - base: 0, - categorie: "Aucune", - description: "", - descriptionmj: "", - defaut_carac: "", - }, - img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.webp" -} +import { ITEM_TYPES, RDD_CONFIG } from "../constants.js" +import { CARACS } from "../rdd-carac.js" export const CATEGORIES_COMPETENCES = { generale: { key: 'generale', base: -4, label: "Générales" }, @@ -39,3 +22,25 @@ export const CATEGORIES_COMPETENCES_CREATURES = { lancer: { key: 'lancer', base: 0, label: "Lancer" }, possession: { key: 'possession', base: 0, label: "Possession" }, } + +export const POSSESSION_SANS_DRACONIC = { + name: 'Sans draconic', + type: ITEM_TYPES.competence, + img: RDD_CONFIG.icons.possession, + system: { niveau: 0, defaut_carac: CARACS.REVE_ACTUEL, categorie: CATEGORIES_COMPETENCES.draconic.key } +} + +export const PAS_DE_DRACONIC = { name: 'Pas de draconic', type: 'competence', system: { niveau: -11, defaut_carac: "reve" }, img: 'systems/foundryvtt-reve-de-dragon/icons/entites/possession.webp' } +export const BASE_CORPS_A_CORPS = { name: 'Corps à Corps', type: 'competence', system: { niveau: -6, defaut_carac: "melee" }, img: 'systems/foundryvtt-reve-de-dragon/icons/competence_corps_a_corps.webp' } +export const BASE_ESQUIVE = { name: 'Esquive', type: 'competence', system: { niveau: -6, defaut_carac: "derobee" }, img: 'systems/foundryvtt-reve-de-dragon/icons/competence_esquive.webp' } + +export const SANS_COMPETENCE = { + name: "Sans compétence", + type: ITEM_TYPES.competence, + img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.webp", + system: { + niveau: 0, + default_diffLibre: 0, + categorie: CATEGORIES_COMPETENCES.generale.key, + } +} diff --git a/module/rdd-possession.js b/module/rdd-possession.js index bf0b5c85..c8cade05 100644 --- a/module/rdd-possession.js +++ b/module/rdd-possession.js @@ -94,7 +94,7 @@ export class RdDPossession { } static selectCompetenceDraconicOuPossession(rollData, rollingActor) { - rollData.competence = rollingActor.getDraconicOuPossession(); + rollData.competence = rollingActor.getDraconicOuPossession().find(it => true); if (rollingActor.isCreatureOuEntite()) { const carac = rollingActor.system.carac rollData.carac = carac diff --git a/module/roll/roll-constants.mjs b/module/roll/roll-constants.mjs index d99d3760..d9733e0c 100644 --- a/module/roll/roll-constants.mjs +++ b/module/roll/roll-constants.mjs @@ -1,5 +1,6 @@ export const ROLL_TYPE_ATTAQUE = 'attaque' +export const ROLL_TYPE_POSSESSION = 'possession' export const ROLL_TYPE_COMP = 'comp' export const ROLL_TYPE_CUISINE = 'cuisine' export const ROLL_TYPE_DEFENSE = 'defense' @@ -27,8 +28,8 @@ export const DIFF = { export const DIFFS = { [DIFF.LIBRE]: { key: DIFF.LIBRE, label: "Difficulté libre", libre: true, visible: true, max: 0 }, [DIFF.ATTAQUE]: { key: DIFF.ATTAQUE, label: "Difficulté d'attaque", libre: true, visible: true, max: 0 }, - [DIFF.IMPOSEE]: { key: DIFF.IMPOSEE, label: "Diffficulté imposée", libre: false, visible: true, max: 0 }, - [DIFF.DEFENSE]: { key: DIFF.DEFENSE, label: "Diffficulté défense", libre: false, visible: true, max: 0 }, + [DIFF.IMPOSEE]: { key: DIFF.IMPOSEE, label: "Difficulté imposée", libre: false, visible: true, max: 0 }, + [DIFF.DEFENSE]: { key: DIFF.DEFENSE, label: "Difficulté défense", libre: false, visible: true, max: 0 }, [DIFF.DEFAUT]: { key: DIFF.DEFAUT, label: "Difficulté", libre: true, visible: true, max: 5 }, [DIFF.AUCUN]: { key: DIFF.AUCUN, label: "", libre: false, visible: false, max: 0 }, } diff --git a/module/roll/roll-type-possession.mjs b/module/roll/roll-type-possession.mjs new file mode 100644 index 00000000..81ba089c --- /dev/null +++ b/module/roll/roll-type-possession.mjs @@ -0,0 +1,33 @@ +import { DIFF, ROLL_TYPE_POSSESSION } from "./roll-constants.mjs" +import { RollType } from "./roll-type.mjs" + + +export const TYPE_POSSESSION = { + POSSEDER: 'posseder', + CONJURER: 'conjurer', + DEFENSE: 'defense' +} +export class RollTypePossession extends RollType { + get code() { return ROLL_TYPE_POSSESSION } + get name() { return `Posséder` } + + title(rollData) { + const isEntite = this.isEntite(rollData) + if (this.isDefense(rollData)) { + return `résiste à la ${isEntite ? 'conjuration' : 'possession'}` + } + return `tente de ${isEntite ? 'posséder' : 'conjurer'}` + } + + onSelect(rollData) { + this.setDiffType(rollData, this.isDefense(rollData) ? DIFF.DEFENSE : DIFF.ATTAQUE) + } + + isEntite(rollData) { + return rollData.active.actor.isEntiteNonIncarnee() + } + + isDefense(rollData) { + return rollData.type.possession == TYPE_POSSESSION.DEFENSE + } +} \ No newline at end of file