diff --git a/module/actor.js b/module/actor.js index 6b0c44e4..20467b8a 100644 --- a/module/actor.js +++ b/module/actor.js @@ -163,10 +163,10 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ getDemiReve() { return this.system.reve.tmrpos.coord } - getDraconicList() { return this.itemTypes[ITEM_TYPES.competence].filter(it => it.system.categorie == 'draconic') } - getBestDraconic() { return foundry.utils.duplicate([...this.getDraconicList(), PAS_DE_DRACONIC].sort(Misc.descending(it => it.system.niveau)).find(it => true)) } + getDraconics() { return this.itemTypes[ITEM_TYPES.competence].filter(it => it.system.categorie == 'draconic') } + getBestDraconic() { return foundry.utils.duplicate([...this.getDraconics(), PAS_DE_DRACONIC].sort(Misc.descending(it => it.system.niveau)).find(it => true)) } getDraconicOuPossession() { - return [...this.getDraconicList().filter(it => it.system.niveau >= 0), POSSESSION_SANS_DRACONIC] + return [...this.getDraconics().filter(it => it.system.niveau >= 0), POSSESSION_SANS_DRACONIC] .sort(Misc.descending(it => it.system.niveau)) .find(it => true) } @@ -703,11 +703,12 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ async combattreReveDeDragon(force) { + const rencontre = await game.system.rdd.rencontresTMR.getReveDeDragon(force); let rollData = { actor: this, competence: this.getDraconicOuPossession(), canClose: false, - rencontre: await game.system.rdd.rencontresTMR.getReveDeDragon(force), + rencontre: rencontre, tmr: true, use: { libre: false, conditions: false }, forceCarac: { 'reve-actuel': { label: "Rêve Actuel", value: this.getReveActuel() } } @@ -1688,7 +1689,7 @@ export class RdDActor extends RdDBaseActorSang { /* -------------------------------------------- */ computeDraconicAndSortIndex(sortList) { - let draconicList = this.getDraconicList(); + let draconicList = this.getDraconics(); for (let sort of sortList) { let draconicsSort = RdDItemSort.getDraconicsSort(draconicList, sort).map(it => it.name); for (let index = 0; index < draconicList.length && sort.system.listIndex == undefined; index++) { @@ -2114,7 +2115,7 @@ export class RdDActor extends RdDBaseActorSang { ui.notifications.info(`Aucun signe draconiques en ${coord} !`); return; } - let draconicList = this.getDraconicList() + let draconicList = this.getDraconics() .map(draconic => { let draconicLecture = foundry.utils.duplicate(draconic); draconicLecture.system.defaut_carac = "intellect"; @@ -2395,7 +2396,7 @@ export class RdDActor extends RdDBaseActorSang { return } if (mode != 'visu' && this.isDemiReve()) { - ui.notifications.warn("Les personnage est déjà dans les Terres Médianes, elles s'affichent en visualisation") + ui.notifications.warn("Le personnage est déjà dans les Terres Médianes, elles s'affichent en visualisation") mode = "visu"; // bascule le mode en visu automatiquement } if (mode == 'visu') { @@ -2434,7 +2435,7 @@ export class RdDActor extends RdDBaseActorSang { let tmrFormData = { mode: mode, fatigue: RdDUtility.calculFatigueHtml(fatigue, endurance), - draconic: this.getDraconicList(), + draconic: this.getDraconics(), sort: this.itemTypes['sort'], signes: this.itemTypes['signedraconique'], caracReve: parseInt(this.system.carac.reve.value), diff --git a/module/item/rencontre.js b/module/item/rencontre.js index ecc3e27b..f532d424 100644 --- a/module/item/rencontre.js +++ b/module/item/rencontre.js @@ -6,8 +6,8 @@ const tableEffets = [ { code: "passeur", resultat: "succes", description: "Déplacer le demi-rêve à (force) cases", method: EffetsRencontre.passeur}, { code: "reve+f", resultat: "succes", description: "Gain de (force) points de rêve" , method: EffetsRencontre.reve_plus_force}, { code: "teleport", resultat: "succes", description: "Déplacer le demi-rêve (même type)", method: EffetsRencontre.teleportation_typecase }, - { code: "part+tete", resultat: "succes", description: "Tête de dragon sur réussite particulière", method: EffetsRencontre.rdd_part_tete }, - { code: "part+xp", resultat: "succes", description: "Expérience sur réussite particulière", method: EffetsRencontre.experience_particuliere }, + { code: "part+tete", resultat: "succes", description: "Tête de dragon sur particulière", method: EffetsRencontre.rdd_part_tete }, + { code: "part+xp", resultat: "succes", description: "Expérience sur particulière", method: EffetsRencontre.experience_particuliere }, { code: "seuil", resultat: "succes", description: "Récupération de seuil de rêve", method: EffetsRencontre.regain_seuil }, { code: "reve-1", resultat: "echec", description: "Perte de 1 point de rêve", method: EffetsRencontre.reve_moins_1 }, @@ -19,7 +19,7 @@ const tableEffets = [ { code: "aleatoire", resultat: "echec", description: "Déplacement aléatoire", method: EffetsRencontre.deplacement_aleatoire }, { code: "sort-aleatoire", resultat: "echec", description: "Déclenche un sort en réserve aléatoire", method: EffetsRencontre.sort_aleatoire }, { code: "rompu", resultat: "echec", description: "Demi-rêve interrompu", method: EffetsRencontre.demireve_rompu }, - { code: "echec-queue", resultat: "echec", description: "Queue(s) de dragon sur échec", method: EffetsRencontre.rdd_echec_queue }, + { code: "echec-queue", resultat: "echec", description: "Queue(s) de dragon", method: EffetsRencontre.rdd_echec_queue }, { code: "reve+1", resultat: "succes", description: "Gain de 1 point de rêve", method: EffetsRencontre.reve_plus_1 }, { code: "vie-f", resultat: "echec", description: "Perte de (force) points de vie", method: EffetsRencontre.vie_moins_force }, diff --git a/module/roll/chat-roll-result.mjs b/module/roll/chat-roll-result.mjs index 69bfbbbf..db107157 100644 --- a/module/roll/chat-roll-result.mjs +++ b/module/roll/chat-roll-result.mjs @@ -98,7 +98,8 @@ export default class ChatRollResult { async buildRollHtml(roll) { const template = `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${roll.type.current}.hbs` - return await renderTemplate(template, roll) + const html = await renderTemplate(template, roll) + return await RdDTextEditor.enrichHTML(html, undefined, { showLink: false }) } async chatListeners(html) { diff --git a/module/roll/roll-constants.mjs b/module/roll/roll-constants.mjs index 7b5f54f9..7eedf6d5 100644 --- a/module/roll/roll-constants.mjs +++ b/module/roll/roll-constants.mjs @@ -1,10 +1,10 @@ export const ROLL_TYPE_ATTAQUE = 'attaque' export const ROLL_TYPE_COMP = 'comp' +export const ROLL_TYPE_CUISINE = 'cuisine' export const ROLL_TYPE_DEFENSE = 'defense' export const ROLL_TYPE_JEU = 'jeu' export const ROLL_TYPE_MEDITATION = 'meditation' -export const ROLL_TYPE_CUISINE = 'cuisine' export const ROLL_TYPE_OEUVRE = 'oeuvre' export const ROLL_TYPE_SORT = 'sort' export const ROLL_TYPE_TACHE = 'tache' @@ -12,11 +12,10 @@ export const ROLL_TYPE_TACHE = 'tache' export const ATTAQUE_ROLL_TYPES = [ROLL_TYPE_ATTAQUE] export const COMBAT_ROLL_TYPES = [ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE] export const DEMIREVE_ROLL_TYPES = [ROLL_TYPE_SORT] -export const DEFAULT_ROLL_TYPES = [ROLL_TYPE_COMP, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_CUISINE, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE] +export const DEFAULT_ROLL_TYPES = [ROLL_TYPE_COMP, ROLL_TYPE_TACHE, ROLL_TYPE_MEDITATION, ROLL_TYPE_CUISINE, ROLL_TYPE_OEUVRE, ROLL_TYPE_JEU] export const ALL_ROLL_TYPES = [...DEFAULT_ROLL_TYPES, ...COMBAT_ROLL_TYPES, ...DEMIREVE_ROLL_TYPES] - export const DIFF = { LIBRE: 'libre', ATTAQUE: 'attaque', diff --git a/module/roll/roll-dialog-adapter.mjs b/module/roll/roll-dialog-adapter.mjs index ba3e432f..3ee47722 100644 --- a/module/roll/roll-dialog-adapter.mjs +++ b/module/roll/roll-dialog-adapter.mjs @@ -67,7 +67,7 @@ export class RollDialogAdapter { if (rollData.ajustements == undefined) { rollData.ajustements = {} } - rollData.selectedCarac = rollData.active.actor.system.carac[rollData.current.carac.key] + rollData.selectedCarac = rollData.active.actor.getCaracByName(rollData.current.carac.key) const compKey = rollData.current.comp?.key if (compKey) { diff --git a/module/roll/roll-part-comp.mjs b/module/roll/roll-part-comp.mjs index 2057c889..d788682d 100644 --- a/module/roll/roll-part-comp.mjs +++ b/module/roll/roll-part-comp.mjs @@ -21,10 +21,9 @@ export class RollPartComp extends RollPartSelect { refs.all = this.$getActorComps(rollData) .filter(comp => !selected.forced || (selected.key ? - Grammar.includesLowerCaseNoAccent(comp.name, selected.key) - : comp.key == '') + Grammar.includesLowerCaseNoAccent(comp.name, selected.key) + : comp.key == '') ) - refs.comps = refs.all this.$selectComp(rollData) } @@ -52,12 +51,16 @@ export class RollPartComp extends RollPartSelect { } } - filterComps(rollData, allowed = []) { + filterComps(rollData, allowed = [], sorting = undefined) { + const sans = allowed.includes('') allowed = allowed.filter(it => it != undefined) const refs = this.getRefs(rollData) refs.comps = allowed.length > 0 - ? refs.all.filter(it => allowed.includes(it.label)) + ? refs.all.filter(it => allowed.includes(it.label) || (sans && it.key == '')) : refs.all + if (sorting && refs.comps.length > 0) { + refs.comps.sort(sorting) + } this.$selectComp(rollData) } diff --git a/module/roll/roll-part-diff.mjs b/module/roll/roll-part-diff.mjs index 680dd9e8..d54fb4f2 100644 --- a/module/roll/roll-part-diff.mjs +++ b/module/roll/roll-part-diff.mjs @@ -1,10 +1,15 @@ -import { DIFF, DIFFS, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_SORT, ROLL_TYPE_TACHE } from "./roll-constants.mjs"; +import { DIFF, DIFFS, ROLL_TYPE_CUISINE, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_SORT, ROLL_TYPE_TACHE } from "./roll-constants.mjs"; import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"; import { Misc } from "../misc.js"; export const PART_DIFF = "diff" -const EXCLUDED_ROLL_TYPES = [ROLL_TYPE_TACHE, ROLL_TYPE_MEDITATION, ROLL_TYPE_SORT, ROLL_TYPE_OEUVRE] +const EXCLUDED_ROLL_TYPES = [ + ROLL_TYPE_TACHE, + ROLL_TYPE_MEDITATION, + ROLL_TYPE_SORT, + ROLL_TYPE_CUISINE, + ROLL_TYPE_OEUVRE] export class RollPartDiff extends RollPart { @@ -53,8 +58,8 @@ export class RollPartDiff extends RollPart { setDiff(rollData, diff) { const current = this.getCurrent(rollData) - current.value = diff.diff - current.type = diff.type + current.value = diff.diff ?? current.value + current.type = diff.type ?? current.type } getAjustements(rollData) { diff --git a/module/roll/roll-part-select.mjs b/module/roll/roll-part-select.mjs index 6427983d..c681fb65 100644 --- a/module/roll/roll-part-select.mjs +++ b/module/roll/roll-part-select.mjs @@ -27,7 +27,7 @@ export class RollPartSelect extends RollPart { const current = this.getCurrent(rollData) const newChoice = (choices.length == 0) ? { key: '', value: defValue } - : this.$getSelectedChoice(choices, key ?? current?.key ?? refs?.key ?? '') + : this.$getSelectedChoice(choices, key ?? current?.key ?? refs?.key ?? choices[0].key) this.setCurrent(rollData, newChoice) return newChoice } diff --git a/module/roll/roll-part-sort.mjs b/module/roll/roll-part-sort.mjs index 2ce4776c..ffef526e 100644 --- a/module/roll/roll-part-sort.mjs +++ b/module/roll/roll-part-sort.mjs @@ -11,9 +11,11 @@ import { CARACS } from "../rdd-carac.js" export const PART_SORT = "sort" export class RollPartSort extends RollPartSelect { + onReady() { // TODO: utiliser un hook pour écouter les déplacements dans les TMRs? } + get code() { return PART_SORT } get section() { return ROLLDIALOG_SECTION.CHOIX } @@ -23,7 +25,7 @@ export class RollPartSort extends RollPartSelect { loadRefs(rollData) { const refs = this.getRefs(rollData) const coord = rollData.active.actor.system.reve.tmrpos.coord - const draconics = rollData.active.actor.getDraconicList() + const draconics = rollData.active.actor.getDraconics() const sorts = rollData.active.actor.itemTypes[ITEM_TYPES.sort] .map(s => RollPartSort.$extractSort(s, coord, draconics)) diff --git a/module/roll/roll-type-comp.mjs b/module/roll/roll-type-comp.mjs index 6505dc0d..5dddc40b 100644 --- a/module/roll/roll-type-comp.mjs +++ b/module/roll/roll-type-comp.mjs @@ -1,4 +1,4 @@ -import { ROLL_TYPE_COMP } from "./roll-constants.mjs" +import { DIFF, ROLL_TYPE_COMP } from "./roll-constants.mjs" import { RollType } from "./roll-type.mjs" export class RollTypeComp extends RollType { @@ -7,4 +7,9 @@ export class RollTypeComp extends RollType { title(rollData) { return `fait un jet ${rollData.type.opposed ? ' contre ' : ''}` } + + onSelect(rollData) { + this.setDiffType(rollData, DIFF.LIBRE) + } + } \ No newline at end of file diff --git a/module/tmr-rencontres.js b/module/tmr-rencontres.js index 2281517e..c6212a7f 100644 --- a/module/tmr-rencontres.js +++ b/module/tmr-rencontres.js @@ -2,7 +2,6 @@ import { renderTemplate } from "./constants.js"; import { Grammar } from "./grammar.js"; import { Misc } from "./misc.js"; import { RdDDice } from "./rdd-dice.js"; -import { RdDUtility } from "./rdd-utility.js"; import { SystemCompendiums, CompendiumTable, CompendiumTableHelpers } from "./settings/system-compendiums.js"; import { TMRUtility } from "./tmr-utility.js"; diff --git a/module/tmr/effets-rencontres.js b/module/tmr/effets-rencontres.js index 675218a4..43959ec0 100644 --- a/module/tmr/effets-rencontres.js +++ b/module/tmr/effets-rencontres.js @@ -28,16 +28,7 @@ export class EffetsRencontre { static reve_plus_1 = async (dialog, context) => { await EffetsRencontre.$reve_plus(context.actor, 1) } static reve_moins_force = async (dialog, context) => { await EffetsRencontre.$reve_plus(context.actor, -context.rencontre.system.force) } static reve_moins_1 = async (dialog, context) => { await EffetsRencontre.$reve_plus(context.actor, -1) } - static $reve_plus = async (actor, reve) => { - if (!ReglesOptionnelles.isUsing("recuperation-reve") && reve < 0) { - ChatMessage.create({ - whisper: ChatUtility.getOwners(actor), - content: `Pas de récupération de rêve (${reve} points ignorés)` - }); - return - } - await actor.reveActuelIncDec(reve) - } + static $reve_plus = async (actor, reve) => { await actor.reveActuelIncDec(reve) } static vie_moins_1 = async (dialog, context) => { await EffetsRencontre.$vie_plus(context.actor, -1) } static vie_moins_force = async (dialog, context) => { await EffetsRencontre.$vie_plus(context.actor, -context.rencontre.system.force) } diff --git a/package.json b/package.json index 51faf4a9..0f0777c8 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "gulp": "gulp", "run": "npx vite serve", "packCompendiumsToDist": "node ./tools/packCompendiumsToDist.mjs", - "packCompendiumsToPublic": "node ./tools/packCompendiumsToPublic.mjs", "unpackCompendiumsFromPublic": "node ./tools/unpackCompendiumsFromPublic.mjs" }, "devDependencies": { diff --git a/packs_src/rencontres/rencontre_R_ve_de_Dragon_dWKuUc29ysrlPZFg.yml b/packs_src/rencontres/rencontre_R_ve_de_Dragon_dWKuUc29ysrlPZFg.yml index 7cbc311b..8ffecb54 100644 --- a/packs_src/rencontres/rencontre_R_ve_de_Dragon_dWKuUc29ysrlPZFg.yml +++ b/packs_src/rencontres/rencontre_R_ve_de_Dragon_dWKuUc29ysrlPZFg.yml @@ -1,6 +1,6 @@ name: Rêve de Dragon type: rencontre -img: systems/foundryvtt-reve-de-dragon/assets/rdd_pause.webp +img: systems/foundryvtt-reve-de-dragon/assets/ui/rdd_pause.webp system: description: '' descriptionmj: '' diff --git a/templates/roll/result/chat-cuisine.hbs b/templates/roll/result/chat-cuisine.hbs index 3b17db80..3cc6126a 100644 --- a/templates/roll/result/chat-cuisine.hbs +++ b/templates/roll/result/chat-cuisine.hbs @@ -23,6 +23,7 @@ {{> 'partial-info-appel-moral'}} {{> "systems/foundryvtt-reve-de-dragon/templates/chat-description.hbs" current.cuisine.recette.system}} +
diff --git a/templates/roll/result/chat-jeu.hbs b/templates/roll/result/chat-jeu.hbs index e69de29b..da18ab17 100644 --- a/templates/roll/result/chat-jeu.hbs +++ b/templates/roll/result/chat-jeu.hbs @@ -0,0 +1,30 @@ ++ {{active.name}} + {{#if rolled.isSuccess}}réussit son interprétation avec + {{else}}manque d'inspiration, son interprétation a + {{/if}} + une qualité de {{result.qualite}}. +
+ {{> 'partial-info-appel-moral'}} + {{> "systems/foundryvtt-reve-de-dragon/templates/chat-description.hbs" current.oeuvre.oeuvre.system}} +- {{log 'tache' this }} {{#if rolled.isSuccess}} {{active.name}} a obtenu {{rolled.ptTache}} point{{~#unless (eq rolled.ptTache 1)}}s{{/unless}} de tâche, {{else if (or rolled.isETotal rolled.isEPart)}} @@ -53,5 +52,6 @@