v13 #771

Merged
uberwald merged 3 commits from VincentVk/foundryvtt-reve-de-dragon:v13 into v13 2025-09-26 10:54:39 +02:00
69 changed files with 580 additions and 480 deletions

View File

@@ -3,19 +3,24 @@
## 13.0.9 - Le combat d'Illysis ## 13.0.9 - Le combat d'Illysis
- Fix - Fix
- La montée en TMR fonctionne - La montée en TMR fonctionne
- ajout d'un status "Force insuffisante"
- clarification des maladresses à l'attaque (en demi surprise, ou à cause d'un échec total)
- Nouvelle fenêtre de jets de dés - Nouvelle fenêtre de jets de dés
- ajout du statut "Force insuffisante" aux acteurs si la
force est insuffisante pour l'arme
- avancement du mode attaque - avancement du mode attaque
- choix de tactique - choix de tactique
- choix des dommages mortel/non-mortel, affichage - choix mortel/non-mortel pour les dommages
- affichage des dommages ajustés delon les choix
- affichage du statut de surprise de l'attaquant - affichage du statut de surprise de l'attaquant
- affichage du statut de surprise du défenseur - affichage du statut de surprise du défenseur
- prise en compte des significatives (force insuffisante, demi-surprises) - prise en compte des significatives (demi-surprises)
- avancement du mode défense - avancement du mode défense
- sélection esquive/parade - sélection esquive/parade
- affichage du statut de surprise du défenseur - affichage du statut de surprise du défenseur
- prise en compte des significatives (demi-surprises, armes disparates, - prise en compte des significatives (demi-surprises, armes disparates,
force insuffisante, particulière en finesse) particulière en finesse)
- impossible de faire un jet "actif" en surprise totale (attaque, parade, ...)
## 13.0.8 - Le renouveau d'Illysis ## 13.0.8 - Le renouveau d'Illysis

View File

@@ -424,7 +424,7 @@ select,
.system-foundryvtt-reve-de-dragon .roll-dialog { .system-foundryvtt-reve-de-dragon .roll-dialog {
font-family: CaslonAntique; font-family: CaslonAntique;
display: grid; display: grid;
grid-template-areas: "header header header header header header header" "action action action action action action action" "mode separation separation separation separation separation separation" "mode carac carac carac comp comp resume" "mode choix choix choix choix choix modifiers" "mode resolution resolution resolution resolution resolution modifiers" "mode chances chances chances chances chances buttons" "footer footer footer footer footer footer footer"; grid-template-areas: "header header header header header header header" "action action action action action action action" "type separation separation separation separation separation separation" "type carac carac carac comp comp resume" "type choix choix choix choix choix modifiers" "type resolution resolution resolution resolution resolution modifiers" "type chances chances chances chances chances buttons" "footer footer footer footer footer footer footer";
grid-template-columns: 2rem 1rem 1fr 1fr 2fr 2fr 3fr; grid-template-columns: 2rem 1rem 1fr 1fr 2fr 2fr 3fr;
gap: 0.2rem; gap: 0.2rem;
} }
@@ -461,26 +461,26 @@ select,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-buttons { .system-foundryvtt-reve-de-dragon .roll-dialog roll-buttons {
grid-area: buttons; grid-area: buttons;
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type {
grid-area: mode; grid-area: type;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button[data-checked="true"], .system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button[data-checked="true"],
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode button[data-checked="true"] { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type button[data-checked="true"] {
background-color: var(--color-text-selection-bg); background-color: var(--color-text-selection-bg);
color: var(--color-controls); color: var(--color-controls);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button[data-checked="true"] i, .system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button[data-checked="true"] i,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode button[data-checked="true"] i { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type button[data-checked="true"] i {
filter: invert(0.8); filter: invert(0.8);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button[data-checked="true"] img, .system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button[data-checked="true"] img,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode button[data-checked="true"] img { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type button[data-checked="true"] img {
filter: invert(0.2); filter: invert(0.2);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button, .system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode button { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type button {
height: 1.8rem; height: 1.8rem;
width: 1.8rem; width: 1.8rem;
gap: 0.5rem; gap: 0.5rem;
@@ -489,11 +489,11 @@ select,
color: var(--color-controls); color: var(--color-controls);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button i, .system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button i,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode button i { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type button i {
filter: invert(0.2); filter: invert(0.2);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button img, .system-foundryvtt-reve-de-dragon .roll-dialog roll-conditions roll-section[name="rollmode"] button img,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-mode button img { .system-foundryvtt-reve-de-dragon .roll-dialog roll-type button img {
filter: invert(0.8); filter: invert(0.8);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog :is(roll-carac, roll-comp) { .system-foundryvtt-reve-de-dragon .roll-dialog :is(roll-carac, roll-comp) {
@@ -564,6 +564,9 @@ select,
.system-foundryvtt-reve-de-dragon .roll-dialog roll-choix roll-section roll-part-detail subline span.status-surprise img { .system-foundryvtt-reve-de-dragon .roll-dialog roll-choix roll-section roll-part-detail subline span.status-surprise img {
filter: invert(0.8); filter: invert(0.8);
} }
.system-foundryvtt-reve-de-dragon .roll-dialog roll-choix roll-section roll-part-detail subline label {
align-content: center;
}
.system-foundryvtt-reve-de-dragon .roll-dialog roll-section selected-numeric-value { .system-foundryvtt-reve-de-dragon .roll-dialog roll-section selected-numeric-value {
display: flow; display: flow;
width: 2.5rem; width: 2.5rem;

View File

@@ -4,11 +4,11 @@
grid-template-areas: grid-template-areas:
"header header header header header header header" "header header header header header header header"
"action action action action action action action" "action action action action action action action"
"mode separation separation separation separation separation separation" "type separation separation separation separation separation separation"
"mode carac carac carac comp comp resume" "type carac carac carac comp comp resume"
"mode choix choix choix choix choix modifiers" "type choix choix choix choix choix modifiers"
"mode resolution resolution resolution resolution resolution modifiers" "type resolution resolution resolution resolution resolution modifiers"
"mode chances chances chances chances chances buttons" "type chances chances chances chances chances buttons"
"footer footer footer footer footer footer footer"; "footer footer footer footer footer footer footer";
grid-template-columns: 2rem 1rem 1fr 1fr 2fr 2fr 3fr; grid-template-columns: 2rem 1rem 1fr 1fr 2fr 2fr 3fr;
gap: 0.2rem; gap: 0.2rem;
@@ -27,13 +27,13 @@
roll-resume { grid-area: resume; } roll-resume { grid-area: resume; }
roll-buttons { grid-area: buttons; } roll-buttons { grid-area: buttons; }
roll-mode { roll-type {
grid-area: mode; grid-area: type;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
roll-conditions roll-section[name="rollmode"], roll-conditions roll-section[name="rollmode"],
roll-mode { roll-type {
button[data-checked="true"] { button[data-checked="true"] {
background-color: var(--color-text-selection-bg); background-color: var(--color-text-selection-bg);
color: var(--color-controls); color: var(--color-controls);
@@ -95,7 +95,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
grid-area: img; grid-area: img;
img{ img {
border: 0; border: 0;
padding: 1px; padding: 1px;
max-height: 3rem; max-height: 3rem;
@@ -126,6 +126,9 @@
filter: invert(0.8); filter: invert(0.8);
} }
} }
label {
align-content: center;
}
} }
} }
} }

View File

@@ -3053,11 +3053,11 @@ export class RdDActor extends RdDBaseActorSang {
const oeuvre = this.items.get(oeuvreId) const oeuvre = this.items.get(oeuvreId)
const rollData = { const rollData = {
title: `Interpretation de ${oeuvre.name} par ${this.name}`, title: `Interpretation de ${oeuvre.name} par ${this.name}`,
mode: { type: {
allowed: ["oeuvre"] allowed: ["oeuvre"],
current: "oeuvre",
}, },
selected: { selected: {
mode: "oeuvre",
oeuvre: { key: oeuvre.id }, oeuvre: { key: oeuvre.id },
}, },
ids: { ids: {
@@ -3065,9 +3065,9 @@ export class RdDActor extends RdDBaseActorSang {
} }
} }
await RollDialog.create(rollData, { await RollDialog.create(rollData, {
onRoll: (dialog) => { onRollDone: (dialog) => {
this._onCloseRollDialog(), this._onCloseRollDialog()
dialog.close() dialog.close()
}, },
customChatMessage: true, customChatMessage: true,
callbacks: [callbackAction] callbacks: [callbackAction]

View File

@@ -19,6 +19,7 @@ import RollDialog from "./roll/roll-dialog.mjs";
import { PART_DEFENSE } from "./roll/roll-part-defense.mjs"; import { PART_DEFENSE } from "./roll/roll-part-defense.mjs";
import { PART_ATTAQUE } from "./roll/roll-part-attaque.mjs"; import { PART_ATTAQUE } from "./roll/roll-part-attaque.mjs";
import { RollDialogAdapter } from "./roll/roll-dialog-adapter.mjs"; import { RollDialogAdapter } from "./roll/roll-dialog-adapter.mjs";
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll/roll-constants.mjs";
/* -------------------------------------------- */ /* -------------------------------------------- */
const premierRoundInit = [ const premierRoundInit = [
@@ -559,27 +560,42 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isEchecTotal(rollData) { static isEchecTotal(rollData) {
if (!rollData.attackerRoll && rollData.ajustements.surprise.used) { if (rollData.ids /* roll V2*/) {
return rollData.rolled.isEchec && rollData.rolled.code != 'notSign'; // TODO: en cas de demi-surprise à l'attaque, tout échec est un echec total.
// TODO: en cas de demi-surprise en défense, pas de changement à la règle de base
return rollData.rolled.isETotal
} }
return rollData.rolled.isETotal; if (rollData.mode == ROLL_TYPE_ATTAQUE && rollData.surprise == 'demi') {
// échec normal à l'attaque en demi surprise
return rollData.rolled.isEchec && rollData.rolled.code != 'notSign'
}
return rollData.rolled.isETotal
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isParticuliere(rollData) { static isParticuliere(rollData) {
if (!rollData.attackerRoll && rollData.ajustements.surprise.used) { if (rollData.ids /* roll V2*/) {
return false; return rollData.rolled.isPart
} }
return rollData.rolled.isPart; if (rollData.attackerRoll || !rollData.ajustements.surprise.used) {
return rollData.rolled.isPart
}
return false
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isReussite(rollData) { static isReussite(rollData) {
switch (rollData.ajustements.surprise.used) { if (rollData.ids /* roll V2*/) {
case 'totale': return false; return rollData.rolled.isSuccess
case 'demi': return rollData.rolled.isSign;
} }
return rollData.rolled.isSuccess; if (!rollData.ajustements.surprise.used) {
return rollData.rolled.isSuccess
}
switch (rollData.ajustements.surprise.used) {
case 'totale': return false
case 'demi': return rollData.rolled.isSign
}
return rollData.rolled.isSuccess
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@@ -686,6 +702,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
_prepareAttaque(competence, arme) { _prepareAttaque(competence, arme) {
let rollData = { let rollData = {
mode: ROLL_TYPE_ATTAQUE,
alias: this.attacker?.getAlias(), alias: this.attacker?.getAlias(),
passeArme: foundry.utils.randomID(16), passeArme: foundry.utils.randomID(16),
mortalite: arme?.system.mortalite, mortalite: arme?.system.mortalite,
@@ -883,6 +900,7 @@ export class RdDCombat {
const choixEchecTotal = await ChatMessage.create({ const choixEchecTotal = await ChatMessage.create({
whisper: ChatUtility.getOwners(this.attacker), whisper: ChatUtility.getOwners(this.attacker),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', { content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-etotal.hbs', {
rolled: attackerRoll.rolled,
attackerId: this.attackerId, attackerId: this.attackerId,
attacker: this.attacker, attacker: this.attacker,
attackerToken: this.attackerToken, attackerToken: this.attackerToken,
@@ -961,25 +979,20 @@ export class RdDCombat {
opponentTokenId: this.attackerTokenId, opponentTokenId: this.attackerTokenId,
opponentId: this.attackerId, opponentId: this.attackerId,
}, },
mode: { type: { allowed: ['defense'], current: 'defense' },
allowed: ['defense'],
current: 'defense'
},
attaque: RollDialogAdapter.mapActionAttaque(attackerRoll), attaque: RollDialogAdapter.mapActionAttaque(attackerRoll),
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
} }
await RollDialog.create(rollData, { await RollDialog.create(rollData, {
onRoll: (dialog) => { onRollDone: (dialog) => { dialog.close() },
this._onCloseRollDialog(),
dialog.close()
},
customChatMessage: true, customChatMessage: true,
callbacks: [async (actor, rd) => { callbacks: [async (roll) => {
this.removeChatMessageActionsPasseArme(rd.passeArme) this.removeChatMessageActionsPasseArme(roll.passeArme)
// defense: esquive / arme de parade / competence de défense // defense: esquive / arme de parade / competence de défense
await rd.active.actor.incDecItemUse(rd.current[PART_DEFENSE].defense?.id, !RdDCombat.isParticuliere(rd)) if (!RdDCombat.isParticuliere(roll))
await this._onDefenseV2(rd) await roll.active.actor.incDecItemUse(roll.current[PART_DEFENSE].defense?.id,)
await this._onDefense(roll)
}] }]
}) })
} }
@@ -988,6 +1001,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
_prepareParade(attackerRoll, armeParade, competenceParade) { _prepareParade(attackerRoll, armeParade, competenceParade) {
let defenderRoll = { let defenderRoll = {
mode: ROLL_TYPE_DEFENSE,
alias: this.defender?.getAlias(), alias: this.defender?.getAlias(),
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,
@@ -1010,17 +1024,63 @@ export class RdDCombat {
return defenderRoll; return defenderRoll;
} }
async _onParade(defenderRoll) { async _onDefense(rollData) {
if (RdDCombat.isReussite(defenderRoll)) { if (RdDCombat.isReussite(rollData)) {
await this._onParadeNormale(defenderRoll) await this._onDefenseNormale(rollData)
if (RdDCombat.isParticuliere(defenderRoll)) { if (RdDCombat.isParticuliere(rollData)) {
await this._onParadeParticuliere(defenderRoll) await this._onDefenseParticuliere(rollData)
} }
return
} }
await this._onParadeEchec(defenderRoll) else {
await this._onDefenseEchec(dialog, rollData)
}
} }
async _onDefenseV2(defenderRoll) {
async _onDefenseParticuliere(rollData) {
console.log("RdDCombat._onDefenseParticuliere >>>", rollData);
if (/*TODO: parade?*/!rollData.attackerRoll?.isPart) {
// TODO: attaquant doit jouer résistance et peut être désarmé p132
ChatUtility.createChatWithRollMode(
{ content: `(à gérer) L'attaquant doit jouer résistance et peut être désarmé (p132)` },
this.defender)
}
ChatUtility.createChatWithRollMode(
{ content: "<strong>Vous pouvez esquiver une deuxième fois!</strong>" },
this.defender);
}
async _onDefenseNormale(rollData) {
console.log("RdDCombat._onDefenseNormale >>>", rollData);
// console.log("RdDCombat._onEsquiveNormal >>>", rollData);
// await RdDRollResult.displayRollData(rollData, this.defender, 'chat-resultat-esquive.hbs');
// this.removeChatMessageActionsPasseArme(rollData.passeArme);
//TODO
await this.computeRecul(rollData);
await this.computeDeteriorationArme(rollData);
await RdDRollResult.displayRollData(rollData, this.defender, 'chat-resultat-parade.hbs');
this.removeChatMessageActionsPasseArme(rollData.passeArme);
}
async _onDefenseEchec(rollData) {
console.log("RdDCombat._onDefenseEchec >>>", rollData);
// console.log("RdDCombat._onEsquiveEchec >>>", rollData);
// await RdDRollResult.displayRollData(rollData, this.defender, 'chat-resultat-esquive.hbs');
// this.removeChatMessageActionsPasseArme(rollData.passeArme);
// this._sendMessageDefense(rollData.attackerRoll, rollData, { defense: true })
await RdDRollResult.displayRollData(rollData, this.defender, 'chat-resultat-parade.hbs');
this.removeChatMessageActionsPasseArme(rollData.passeArme);
this._sendMessageDefense(rollData.attackerRoll, rollData, { defense: true });
}
async _onParade(defenderRoll) {
if (RdDCombat.isReussite(defenderRoll)) { if (RdDCombat.isReussite(defenderRoll)) {
await this._onParadeNormale(defenderRoll) await this._onParadeNormale(defenderRoll)
if (RdDCombat.isParticuliere(defenderRoll)) { if (RdDCombat.isParticuliere(defenderRoll)) {
@@ -1090,6 +1150,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
_prepareEsquive(attackerRoll, competence) { _prepareEsquive(attackerRoll, competence) {
let rollData = { let rollData = {
mode: ROLL_TYPE_DEFENSE,
alias: this.defender.getAlias(), alias: this.defender.getAlias(),
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,

View File

@@ -184,47 +184,15 @@ export class RdDResolutionTable {
return Math.max(Math.floor(carac * (diff + 10) / 2), 1); return Math.max(Math.floor(carac * (diff + 10) / 2), 1);
} }
/* -------------------------------------------- */
static isEchec(rollData) {
switch (rollData.surprise) {
case 'demi': return !rollData.rolled.isSign;
case 'totale': return true;
}
return rollData.rolled.isEchec;
}
/* -------------------------------------------- */
static isEchecTotal(rollData) {
if (rollData.arme && rollData.surprise == 'demi') {
return rollData.rolled.isEchec;
}
return rollData.rolled.isETotal;
}
/* -------------------------------------------- */
static isParticuliere(rollData) {
if (rollData.arme && rollData.surprise) {
return false;
}
return rollData.rolled.isPart;
}
/* -------------------------------------------- */
static isReussite(rollData) {
switch (rollData.surprise) {
case 'demi': return rollData.rolled.isSign;
case 'totale': return false;
}
return rollData.rolled.isSuccess;
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeReussite(chances, roll, diviseur) { static computeReussite(chances, roll, diviseur) {
const reussite = reussites.find(x => x.condition(chances, roll)); const reussite = reussites.find(x => x.condition(chances, roll))
if (diviseur > 1 && reussite.code == 'norm') { if (diviseur > 1 && reussite.isSuccess) {
return reussiteInsuffisante; if (chances > roll * diviseur){
return reussiteInsuffisante
}
} }
return reussite; return reussite
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@@ -1,4 +1,8 @@
import { ActorToken } from "../actor-token.mjs" import { ActorToken } from "../actor-token.mjs"
import { StatusEffects } from "../settings/status-effects.js"
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { PART_ATTAQUE } from "./roll-part-attaque.mjs"
import { PART_DEFENSE } from "./roll-part-defense.mjs"
export class RollBasicParts { export class RollBasicParts {
@@ -6,23 +10,46 @@ export class RollBasicParts {
rollData.ids.sceneId = rollData.ids.sceneId ?? canvas.scene.id rollData.ids.sceneId = rollData.ids.sceneId ?? canvas.scene.id
rollData.active = RollBasicParts.$getActor(rollData) rollData.active = RollBasicParts.$getActor(rollData)
rollData.opponent = RollBasicParts.$getOpponent(rollData) rollData.opponent = RollBasicParts.$getOpponent(rollData)
if (rollData.mode.opposed == undefined) { if (rollData.type.opposed == undefined) {
rollData.mode.opposed = rollData.opponent != null rollData.type.opposed = rollData.opponent != null
}
}
loadSurprises(rollData, type) {
if (!rollData.type.passif) {
this.loadSurprise(rollData.active, this.getForceRequiseActiveActor(rollData, type))
this.loadSurprise(rollData.opponent, 0)
}
}
loadSurprise(who, forceRequise) {
if (who?.actor) {
foundry.utils.mergeObject(who,
StatusEffects.getActorEffetSurprise(who.actor, forceRequise),
{ overwrite: true, inPlace: true })
}
}
getForceRequiseActiveActor(rollData, type) {
switch (type) {
case ROLL_TYPE_ATTAQUE: return rollData.current[PART_ATTAQUE].attaque.forceRequise
case ROLL_TYPE_DEFENSE: return rollData.current[PART_DEFENSE].forceRequise
default: return 0
} }
} }
initFrom(rollData) { initFrom(rollData) {
return { return {
selected: {}, selected: {},
mode: { type: {
current: rollData.mode.current current: rollData.type.current
}, },
ids: { ids: {
sceneId: rollData.ids.sceneId, sceneId: rollData.ids.sceneId,
actorId: rollData.active.id, actorId: rollData.active.id,
actorTokenId: rollData.active.tokenId, actorTokenId: rollData.active.tokenId,
opponentId: rollData.mode.opposed ? rollData.opponent.id : undefined, opponentId: rollData.type.opposed ? rollData.opponent.id : undefined,
opponentTokenId: rollData.mode.opposed ? rollData.opponent.tokenId : undefined, opponentTokenId: rollData.type.opposed ? rollData.opponent.tokenId : undefined,
} }
} }
} }

View File

@@ -0,0 +1,15 @@
export class RollChatResult {
constructor(rollType) {
this.rollType = rollType
}
async display(rollData) {
const template = this.rollType.chatResultTemplate()
const chatContent = await renderTemplate(template, rollData)
ChatMessage.create({
whisper: ChatUtility.getOwners(this),
content: chatContent
})
}
}

View File

@@ -1,14 +1,14 @@
export const ROLL_MODE_ATTAQUE = 'attaque' export const ROLL_TYPE_ATTAQUE = 'attaque'
export const ROLL_MODE_COMP = 'comp' export const ROLL_TYPE_COMP = 'comp'
export const ROLL_MODE_DEFENSE = 'defense' export const ROLL_TYPE_DEFENSE = 'defense'
export const ROLL_MODE_JEU = 'jeu' export const ROLL_TYPE_JEU = 'jeu'
export const ROLL_MODE_MEDITATION = 'meditation' export const ROLL_TYPE_MEDITATION = 'meditation'
export const ROLL_MODE_OEUVRE = 'oeuvre' export const ROLL_TYPE_OEUVRE = 'oeuvre'
export const ROLL_MODE_SORT = 'sort' export const ROLL_TYPE_SORT = 'sort'
export const ROLL_MODE_TACHE = 'tache' export const ROLL_TYPE_TACHE = 'tache'
export const DIFF_MODE = { export const DIFF = {
LIBRE: 'libre', LIBRE: 'libre',
ATTAQUE: 'attaque', ATTAQUE: 'attaque',
IMPOSEE: 'imposee', IMPOSEE: 'imposee',
@@ -17,12 +17,12 @@ export const DIFF_MODE = {
AUCUN: 'aucun' AUCUN: 'aucun'
} }
export const DIFF_MODES = { export const DIFFS = {
[DIFF_MODE.LIBRE]: { key: DIFF_MODE.LIBRE, label: "Difficulté libre", libre: true, visible: true, max: 0 }, [DIFF.LIBRE]: { key: DIFF.LIBRE, label: "Difficulté libre", libre: true, visible: true, max: 0 },
[DIFF_MODE.ATTAQUE]: { key: DIFF_MODE.ATTAQUE, label: "Difficulté d'attaque", libre: true, visible: true, max: 0 }, [DIFF.ATTAQUE]: { key: DIFF.ATTAQUE, label: "Difficulté d'attaque", libre: true, visible: true, max: 0 },
[DIFF_MODE.IMPOSEE]: { key: DIFF_MODE.IMPOSEE, label: "Diffficulté imposée", libre: false, visible: true, max: 0 }, [DIFF.IMPOSEE]: { key: DIFF.IMPOSEE, label: "Diffficulté imposée", libre: false, visible: true, max: 0 },
[DIFF_MODE.DEFENSE]: { key: DIFF_MODE.DEFENSE, label: "Diffficulté défense", libre: false, visible: true, max: 0 }, [DIFF.DEFENSE]: { key: DIFF.DEFENSE, label: "Diffficulté défense", libre: false, visible: true, max: 0 },
[DIFF_MODE.DEFAUT]: { key: DIFF_MODE.DEFAUT, label: "Difficulté", libre: true, visible: true, max: 5 }, [DIFF.DEFAUT]: { key: DIFF.DEFAUT, label: "Difficulté", libre: true, visible: true, max: 5 },
[DIFF_MODE.AUCUN]: { key: DIFF_MODE.AUCUN, label: "", libre: false, visible: false, max: 0 }, [DIFF.AUCUN]: { key: DIFF.AUCUN, label: "", libre: false, visible: false, max: 0 },
} }

View File

@@ -4,8 +4,9 @@ import { PART_COMP } from "./roll-part-comp.mjs";
import { RdDResolutionTable } from "../rdd-resolution-table.js"; import { RdDResolutionTable } from "../rdd-resolution-table.js";
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"; import { ReglesOptionnelles } from "../settings/regles-optionnelles.js";
import { PART_OEUVRE } from "./roll-part-oeuvre.mjs"; import { PART_OEUVRE } from "./roll-part-oeuvre.mjs";
import { ATTAQUE_TYPE, RdDItemArme } from "../item/arme.js"; import { RdDItemArme } from "../item/arme.js";
import { RdDBonus } from "../rdd-bonus.js"; import { RdDBonus } from "../rdd-bonus.js";
import { ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RollDialogAdapter { export class RollDialogAdapter {
@@ -36,7 +37,9 @@ export class RollDialogAdapter {
} }
async rollChances(rollData, chances) { async rollChances(rollData, chances) {
const rolled = await RdDResolutionTable.rollChances(chances, rollData.current.sign, rollData.current.resultat) const rolled = await RdDResolutionTable.rollChances(chances,
rollData.current.sign,
rollData.current.resultat)
rolled.caracValue = rollData.current.carac.value rolled.caracValue = rollData.current.carac.value
rolled.finalLevel = rollData.current.totaldiff rolled.finalLevel = rollData.current.totaldiff
rolled.bonus = rollData.current.bonus ?? 0 rolled.bonus = rollData.current.bonus ?? 0
@@ -59,7 +62,7 @@ export class RollDialogAdapter {
const compKey = rollData.current.comp?.key const compKey = rollData.current.comp?.key
if (compKey) { if (compKey) {
rollData.competence = rollData.refs[PART_COMP].all.find(it => it.key == compKey)?.comp rollData.competence = rollData.refs[PART_COMP].all.find(it => it.key == compKey)?.comp
rollData.jetResistance = rollData.mode.jetResistance rollData.jetResistance = rollData.type.jetResistance
} }
const oeuvreKey = rollData.current.oeuvre?.key const oeuvreKey = rollData.current.oeuvre?.key
if (oeuvreKey) { if (oeuvreKey) {

View File

@@ -1,18 +1,18 @@
import { Misc } from "../misc.js"; import { Misc } from "../misc.js";
import { RollModeComp } from "./roll-mode-comp.mjs"; import { RollTypeComp } from "./roll-type-comp.mjs";
import { RollModeTache } from "./roll-mode-tache.mjs"; import { RollTypeTache } from "./roll-type-tache.mjs";
import { RollModeAttaque } from "./roll-mode-attaque.mjs"; import { RollTypeAttaque } from "./roll-type-attaque.mjs";
import { RollModeDefense } from "./roll-mode-defense.mjs"; import { RollTypeDefense } from "./roll-type-defense.mjs";
import { RollModeMeditation } from "./roll-mode-meditation.mjs"; import { RollTypeMeditation } from "./roll-type-meditation.mjs";
import { RollModeSort } from "./roll-mode-sort.mjs"; import { RollTypeSort } from "./roll-type-sort.mjs";
import { RollModeOeuvre } from "./roll-mode-oeuvre.mjs"; import { RollTypeOeuvre } from "./roll-type-oeuvre.mjs";
import { RollModeJeu } from "./roll-mode-jeu.mjs"; import { RollTypeJeu } from "./roll-type-jeu.mjs";
import { RollPartAction } from "./roll-part-action.mjs"; import { RollPartAction } from "./roll-part-action.mjs";
import { RollPartActor } from "./roll-part-actor.mjs"; import { RollPartActor } from "./roll-part-actor.mjs";
import { RollPartAppelMoral } from "./roll-part-appelmoral.mjs"; import { RollPartAppelMoral } from "./roll-part-appelmoral.mjs";
import { RollPartAstrologique } from "./roll-part-astrologique.mjs"; import { RollPartAstrologique } from "./roll-part-astrologique.mjs";
import { RollPartCarac } from "./roll-part-carac.mjs"; import { PART_CARAC, RollPartCarac } from "./roll-part-carac.mjs";
import { RollPartCoeur } from "./roll-part-coeur.mjs"; import { RollPartCoeur } from "./roll-part-coeur.mjs";
import { PART_COMP, RollPartComp } from "./roll-part-comp.mjs"; import { PART_COMP, RollPartComp } from "./roll-part-comp.mjs";
import { RollPartConditions } from "./roll-part-conditions.mjs"; import { RollPartConditions } from "./roll-part-conditions.mjs";
@@ -37,23 +37,22 @@ import { RollPartAttaque } from "./roll-part-attaque.mjs";
import { RollPartDefense } from "./roll-part-defense.mjs"; import { RollPartDefense } from "./roll-part-defense.mjs";
import { RollDialogAdapter } from "./roll-dialog-adapter.mjs"; import { RollDialogAdapter } from "./roll-dialog-adapter.mjs";
import { ROLLDIALOG_SECTION } from "./roll-part.mjs"; import { ROLLDIALOG_SECTION } from "./roll-part.mjs";
import { ROLL_MODE_COMP } from "./roll-constants.mjs"; import { ROLL_TYPE_COMP } from "./roll-constants.mjs";
import { RollChatResult } from "./roll-chat-result.mjs";
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api
const doNothing = (dialog) => { } const doNothing = (dialog) => { }
const ROLL_MODE_TABS = [ const ALL_ROLL_TYPES = [
new RollModeComp(), new RollTypeComp(),
new RollModeTache(), new RollTypeTache(),
new RollModeAttaque(), new RollTypeAttaque(),
new RollModeDefense(), new RollTypeDefense(),
// new RollModeParade?? // new RollTypeResistance ??
// new RollModeEsquive?? new RollTypeSort(),
// new RollModeResistance ?? new RollTypeMeditation(),
new RollModeSort(), new RollTypeOeuvre(),
new RollModeMeditation(), new RollTypeJeu(),
new RollModeOeuvre(),
new RollModeJeu(),
] ]
const BASIC_PARTS = new RollBasicParts() const BASIC_PARTS = new RollBasicParts()
@@ -95,7 +94,7 @@ const ROLL_PARTS = [
* @extends {Dialog} * @extends {Dialog}
* # Principes * # Principes
* - une seule fenêtre de dialogue (classe RollDialog) * - une seule fenêtre de dialogue (classe RollDialog)
* - plusieurs modes de fonctionnement (classe RollMode) * - plusieurs "types"s de fonctionnement (classe RollType)
* - gestion uniforme des modificateurs (classe RollPart) * - gestion uniforme des modificateurs (classe RollPart)
* - un objet rollData contient les informations liées à un jet de dés * - un objet rollData contient les informations liées à un jet de dés
* - un rollData doit pouvoir être "réduit" pour fournir les informations significatives * - un rollData doit pouvoir être "réduit" pour fournir les informations significatives
@@ -106,15 +105,15 @@ const ROLL_PARTS = [
* - TODO: une classe de base RollChatMessage gerera les messages correspondant aux résultats du dés * - TODO: une classe de base RollChatMessage gerera les messages correspondant aux résultats du dés
* - TODO: réfléchir aux messages supplémentaires gérés par RdDCombat ? * - TODO: réfléchir aux messages supplémentaires gérés par RdDCombat ?
* *
* ## Modes de fonctionnement - RollMode * ## Types de fonctionnement - RollType
* *
* Un mode de fonctionnement (RollMode) détermine quelles parties (RollPart) de la * Un type de fonctionnement (RollType) détermine quelles parties (RollPart) de la
* fenêtre RollDialog sont actives, mais aussi quels sont les effets du jet. * fenêtre RollDialog sont actives, mais aussi quels sont les effets du jet.
* *
* - chaque mode de fonctionnement peut impacter les RollPart utilisés, les données * - chaque type de fonctionnement peut impacter les RollPart utilisés, les données
* attendues et ajoutées au rollData. * attendues et ajoutées au rollData.
* - chaque mode de fonctionnement peut définir le template de ChatMessage correspondant * - chaque type de fonctionnement peut définir le template de ChatMessage correspondant
* - Le mode de fonctionnement détermine aussi quelles sont les effets du jet: * - Le type de fonctionnement détermine aussi quelles sont les effets du jet:
* - quelle ChatMessage afficher dans le tchat? * - quelle ChatMessage afficher dans le tchat?
* - en cas d'attaque/de défense, quelles sont les suites à donner? * - en cas d'attaque/de défense, quelles sont les suites à donner?
* - en cas de lancement de sort, réduire les points de rêve * - en cas de lancement de sort, réduire les points de rêve
@@ -176,14 +175,14 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
foundry.applications.handlebars.loadTemplates({ foundry.applications.handlebars.loadTemplates({
'roll-section': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-section.hbs', 'roll-section': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-section.hbs',
'roll-mode': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-mode.hbs', 'roll-type': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-type.hbs',
'roll-table': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-table.hbs', 'roll-table': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-table.hbs',
'roll-ajustements': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-ajustements.hbs', 'roll-ajustements': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-ajustements.hbs',
'roll-chances': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-chances.hbs', 'roll-chances': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-chances.hbs',
'roll-button': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-button.hbs', 'roll-button': 'systems/foundryvtt-reve-de-dragon/templates/roll/roll-button.hbs',
}) })
foundry.applications.handlebars.loadTemplates(ROLL_MODE_TABS.map(m => m.template)) foundry.applications.handlebars.loadTemplates(ALL_ROLL_TYPES.map(m => m.template))
foundry.applications.handlebars.loadTemplates(ROLL_PARTS.map(p => p.template)) foundry.applications.handlebars.loadTemplates(ROLL_PARTS.map(p => p.template))
ROLL_PARTS.forEach(p => p.onReady()) ROLL_PARTS.forEach(p => p.onReady())
@@ -250,17 +249,14 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
constructor(rollData, rollOptions) { constructor(rollData, rollOptions) {
super() super()
this.rollData = rollData this.rollData = rollData
// const callbacks = this.rollOptions.callbacks.map(c =>
// r => r.activve.actor Promise.all(this.rollOptions.callbacks.map(async callback => await callback(rollData.active.actor, rollData)))
// )
this.rollOptions = { this.rollOptions = {
callbacks: [ callbacks: [
async (actor, r) => await actor.appliquerAjoutExperience(r), async r => await r.active.actor.appliquerAjoutExperience(r),
async (actor, r) => await actor.appliquerAppelMoral(r), async r => await r.active.actor.appliquerAppelMoral(r),
...(rollOptions.callbacks ?? []) ...(rollOptions.callbacks ?? [])
], ],
customChatMessage: rollOptions.customChatMessage, customChatMessage: rollOptions.customChatMessage,
onRoll: rollOptions.onRoll ?? doNothing onRollDone: rollOptions.onRollDone ?? doNothing
} }
this.$loadParts() this.$loadParts()
} }
@@ -270,17 +266,17 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
const rollData = this.rollData; const rollData = this.rollData;
rollData.current = rollData.current ?? {} rollData.current = rollData.current ?? {}
rollData.selected = rollData.selected ?? {} rollData.selected = rollData.selected ?? {}
rollData.mode = rollData.mode ?? {} rollData.type = rollData.type ?? {}
rollData.mode.retry = rollData.mode.retry ?? false rollData.type.retry = rollData.type.retry ?? false
BASIC_PARTS.restore(rollData) BASIC_PARTS.restore(rollData)
const loadedMode = ROLL_MODE_TABS.find(m => m.code == rollData.mode?.current)?.code const loadedType = ALL_ROLL_TYPES.find(m => m.code == rollData.type?.current)?.code
const allowedModes = ROLL_MODE_TABS.filter(m => m.isAllowed(rollData) && m.visible(rollData)).map(m => m.code) const allowedTypes = ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData)).map(m => m.code)
rollData.mode.allowed = rollData.mode.retry ? [loadedMode] : rollData.mode.allowed ?? ROLL_MODE_TABS.map(m => m.code) rollData.type.allowed = rollData.type.retry ? [loadedType] : rollData.type.allowed ?? ALL_ROLL_TYPES.map(m => m.code)
rollData.mode.current = allowedModes.find(m => m == rollData.mode?.current) ?? (allowedModes.length > 0 ? allowedModes[0] : ROLL_MODE_COMP) rollData.type.current = allowedTypes.find(m => m == rollData.type?.current) ?? (allowedTypes.length > 0 ? allowedTypes[0] : ROLL_TYPE_COMP)
this.getSelectedMode().setRollDataMode(rollData) this.getSelectedType().setRollDataType(rollData)
rollData.refs = this.$prepareRefs(rollData) rollData.refs = this.$prepareRefs(rollData)
rollData.options = rollData.options ?? { showDice: true, rollMode: game.settings.get("core", "rollMode") } rollData.options = rollData.options ?? { showDice: true, rollMode: game.settings.get("core", "rollMode") }
@@ -292,13 +288,17 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
p.loadRefs(rollData) p.loadRefs(rollData)
p.prepareContext(rollData) p.prepareContext(rollData)
}) })
this.selectMode(); this.selectType();
} }
selectMode() { selectType() {
this.rollData.mode.label = this.getSelectedMode().title(this.rollData) const selectedType = this.getSelectedType();
this.getSelectedMode().setRollDataMode(this.rollData) this.rollData.type.label = selectedType.title(this.rollData)
this.getSelectedMode().onSelect(this.rollData); selectedType.setRollDataType(this.rollData)
selectedType.onSelect(this.rollData)
ROLL_PARTS.find(it => it.code == PART_CARAC).filterCaracs(this.rollData)
ROLL_PARTS.find(it => it.code == PART_COMP).filterComps(this.rollData)
} }
$prepareRefs(rollData) { $prepareRefs(rollData) {
@@ -329,12 +329,12 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
this.roll() this.roll()
} }
) )
const buttonsMode = this.element.querySelectorAll(`button[name="roll-mode"]`) const buttonsType = this.element.querySelectorAll(`button[name="roll-type"]`)
buttonsMode?.forEach(it => it.addEventListener( buttonsType?.forEach(it => it.addEventListener(
"click", e => { "click", e => {
e.preventDefault() e.preventDefault()
this.rollData.mode.current = e.currentTarget.dataset.mode this.rollData.type.current = e.currentTarget.dataset.type
this.selectMode() this.selectType()
this.render() this.render()
} }
)) ))
@@ -355,14 +355,14 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
return await foundry.applications.handlebars.renderTemplate('roll-table', { carac, diff }) return await foundry.applications.handlebars.renderTemplate('roll-table', { carac, diff })
} }
async _prepareContext() { async _prepareContext() {
const rollData = this.rollData const rollData = this.rollData
const modes = ROLL_MODE_TABS.filter(m => m.isAllowed(rollData) && m.visible(rollData)) const types = ALL_ROLL_TYPES.filter(m => m.isAllowed(rollData) && m.visible(rollData))
.map(m => m.toModeData(rollData)) .map(m => m.toTypeData(rollData))
this.setModeTitle() BASIC_PARTS.loadSurprises(this.rollData, this.getSelectedType().code)
this.rollData.type.label = this.getSelectedType()?.title(this.rollData)
//TOCHECK: set type.label ?
const visibleRollParts = this.getActiveParts() const visibleRollParts = this.getActiveParts()
visibleRollParts.forEach(p => p.applyExternalImpacts(visibleRollParts, rollData)) visibleRollParts.forEach(p => p.applyExternalImpacts(visibleRollParts, rollData))
@@ -376,7 +376,7 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
const context = await super._prepareContext() const context = await super._prepareContext()
return foundry.utils.mergeObject( return foundry.utils.mergeObject(
{ {
modes: modes, types: types,
templates: templates, templates: templates,
rollData: rollData, rollData: rollData,
}, context) }, context)
@@ -401,12 +401,8 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
.reduce(Misc.sum(), 0) .reduce(Misc.sum(), 0)
} }
setModeTitle() { getSelectedType() {
this.rollData.mode.label = this.getSelectedMode()?.title(this.rollData) return ALL_ROLL_TYPES.find(m => m.code == this.rollData.type.current)
}
getSelectedMode() {
return ROLL_MODE_TABS.find(m => m.code == this.rollData.mode.current)
} }
async roll() { async roll() {
@@ -415,11 +411,13 @@ export default class RollDialog extends HandlebarsApplicationMixin(ApplicationV2
console.info('Roll parts:', this.$saveParts()) console.info('Roll parts:', this.$saveParts())
const rolled = await this.$rollDice(rollData) const rolled = await this.$rollDice(rollData)
rollData.rolled = rolled rollData.rolled = rolled
Promise.all(this.rollOptions.callbacks.map(async callback => await callback(rollData.active.actor, rollData))) Promise.all(this.rollOptions.callbacks.map(async callback => await callback(rollData)))
if (!this.rollOptions.customChatMessage) { if (!this.rollOptions.customChatMessage) {
const rollChatResult = new RollChatResult(this.getSelectedType())
await rollChatResult.display(this.rollData)
rollData.active.actor.$onRollCompetence(this.rollData) rollData.active.actor.$onRollCompetence(this.rollData)
} }
this.rollOptions.onRoll(this) this.rollOptions.onRollDone(this)
} }

View File

@@ -1,13 +0,0 @@
import { DIFF_MODE, ROLL_MODE_ATTAQUE } from "./roll-constants.mjs"
import { RollMode } from "./roll-mode.mjs"
export class RollModeAttaque extends RollMode {
get code() { return ROLL_MODE_ATTAQUE }
get name() { return `Attaquer` }
title(rollData) { return `attaque` }
onSelect(rollData) {
this.setDiffMode(rollData, DIFF_MODE.ATTAQUE)
}
}

View File

@@ -1,9 +0,0 @@
import { ROLL_MODE_COMP } from "./roll-constants.mjs"
import { RollMode } from "./roll-mode.mjs"
export class RollModeComp extends RollMode {
get code() { return ROLL_MODE_COMP }
get name() { return `Jet de caractéristique / compétence` }
title(rollData) { return `fait un jet ${rollData.mode.opposed ? ' contre ' : ''}` }
}

View File

@@ -1,17 +0,0 @@
import { DIFF_MODE, ROLL_MODE_DEFENSE } from "./roll-constants.mjs"
import { RollMode } from "./roll-mode.mjs"
export class RollModeDefense extends RollMode {
get code() { return ROLL_MODE_DEFENSE }
get name() { return `Se défendre` }
title(rollData) { return `se défend${rollData.opponent ? ' de' : ''}` }
getOpponent(rollData) {
return rollData.attacker
}
onSelect(rollData) {
this.setDiffMode(rollData, DIFF_MODE.DEFENSE)
}
}

View File

@@ -1,15 +0,0 @@
import { DIFF_MODE, ROLL_MODE_SORT } from "./roll-constants.mjs"
import { RollMode } from "./roll-mode.mjs"
import { PART_SORT } from "./roll-part-sort.mjs"
export class RollModeSort extends RollMode {
get code() { return ROLL_MODE_SORT }
get name() { return `lancer un sort` }
visible(rollData) { return rollData.active.actor.isHautRevant() }
title(rollData) { return `lance le sort:` }
onSelect(rollData) {
this.setDiffMode(rollData, DIFF_MODE.AUCUN)
}
}

View File

@@ -1,54 +0,0 @@
import { DIFF_MODE } from "./roll-constants.mjs"
import { PART_DIFF } from "./roll-part-diff.mjs"
const DEFAULT_DIFF_MODES = [DIFF_MODE.LIBRE, DIFF_MODE.IMPOSEE, DIFF_MODE.DEFAUT]
export class RollMode {
onReady() { }
get code() { throw new Error(`Pas de code défini pour ${this}`) }
get name() { return this.code }
get icon() { return `systems/foundryvtt-reve-de-dragon/assets/actions/${this.code}.svg` }
toModeData(rollData) {
return { code: this.code, name: this.name, icon: this.icon, section: 'mode', template: this.template, selected: this.isSelected(rollData) }
}
isAllowed(rollData) { return rollData.mode.allowed == undefined || rollData.mode.allowed.includes(this.code) }
visible(rollData) { return true }
title(rollData) { return this.code }
isSelected(rollData) { return rollData.mode.current == this.code }
setRollDataMode(rollData) {
rollData.mode.opposed = rollData.opponent != undefined
rollData.mode.resistance = false /** TODO */
}
onSelect(rollData) {
const mode = [
rollData.current[PART_DIFF].mode,
this.modeFromOpponents(rollData),
rollData.selected[PART_DIFF].mode].find(m => DEFAULT_DIFF_MODES.includes(m))
this.setDiffMode(rollData, mode ??
DIFF_MODE.DEFAUT)
}
modeFromOpponents(rollData) {
if (rollData.mode.opposed) {
if (rollData.mode.resistance) {
return DIFF_MODE.IMPOSEE
}
return DIFF_MODE.LIBRE
}
return undefined
}
setDiffMode(rollData, mode) {
rollData.current[PART_DIFF].mode = mode
this.setRollDataMode(rollData)
}
}

View File

@@ -8,12 +8,12 @@ export class RollPartAction extends RollPart {
get section() { return ROLLDIALOG_SECTION.ACTION } get section() { return ROLLDIALOG_SECTION.ACTION }
title(rollData) { title(rollData) {
return rollData.mode.label return rollData.type.label
} }
prepareContext(rollData) { prepareContext(rollData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
current.verb = rollData.mode.label current.verb = rollData.type.label
} }
} }

View File

@@ -10,10 +10,8 @@ export class RollPartAstrologique extends RollPartCheckbox {
get useCheckboxTemplate() { return false } get useCheckboxTemplate() { return false }
visible(rollData) { visible(rollData) {
return this.$isUsingAstrologie() && ( return this.$isUsingAstrologie()
this.isJetChance(rollData) && (this.isJetChance(rollData) || this.isLancementRituel(rollData))
|| this.isLancementRituel(rollData)
)
} }
isLancementRituel(rollData) { isLancementRituel(rollData) {

View File

@@ -1,6 +1,6 @@
import { RdDBonus } from "../rdd-bonus.js" import { RdDBonus } from "../rdd-bonus.js"
import { StatusEffects } from "../settings/status-effects.js" import { StatusEffects } from "../settings/status-effects.js"
import { ROLL_MODE_ATTAQUE } from "./roll-constants.mjs" import { ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs" import { RollPartSelect } from "./roll-part-select.mjs"
@@ -16,7 +16,7 @@ export class RollPartAttaque extends RollPartSelect {
get code() { return PART_ATTAQUE } get code() { return PART_ATTAQUE }
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_ATTAQUE) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_ATTAQUE) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
@@ -41,25 +41,25 @@ export class RollPartAttaque extends RollPartSelect {
prepareContext(rollData) { prepareContext(rollData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
current.defenseur = StatusEffects.getActorEffetSurprise(rollData.opponent?.actor, 0)
current.attaquant = StatusEffects.getActorEffetSurprise(rollData.active.actor, current.attaque.forceRequise)
current.dmg = this.$dmgRollV2(rollData, current) current.dmg = this.$dmgRollV2(rollData, current)
} }
$dmgRollV2(rollData, current) { $dmgRollV2(rollData, current) {
const actor = rollData.active.actor const actor = rollData.active.actor
const defender = rollData.opponent?.actor const attaque = current.attaque
const dmgArme = RdDBonus.dmgArme(current.attaque.arme, current.attaque.dommagesArme) const arme = attaque.arme
const dmgArme = RdDBonus.dmgArme(arme, attaque.dommagesArme)
const dmg = { const dmg = {
total: 0, total: 0,
dmgArme: dmgArme, dmgArme: dmgArme,
penetration: current.attaque.arme.penetration(), penetration: arme.penetration(),
dmgTactique: current.tactique?.dmg ?? 0, dmgTactique: current.tactique?.dmg ?? 0,
dmgParticuliere: 0, // TODO RdDBonus._dmgParticuliere(rollData), dmgParticuliere: 0, // TODO RdDBonus._dmgParticuliere(rollData),
dmgSurprise: current.surpriseDefenseur?.dmg ?? 0, dmgSurprise: rollData.opponent?.surprise?.dmg ?? 0,
mortalite: RdDBonus.mortalite(current.dmg?.mortalite, current.attaque.arme.system.mortalite, defender?.isEntite()), mortalite: RdDBonus.mortalite(current.dmg?.mortalite, arme.system.mortalite, rollData.opponent?.actor?.isEntite()),
dmgActor: RdDBonus.bonusDmg(actor, current.attaque.carac.key, dmgArme, current.attaque.forceRequise), dmgActor: RdDBonus.bonusDmg(actor, attaque.carac.key, dmgArme, attaque.forceRequise),
dmgForceInsuffisante: Math.min(0, actor.getForce() - current.attaque.forceRequise) dmgForceInsuffisante: Math.min(0, actor.getForce() - attaque.forceRequise)
} }
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere + dmg.dmgForceInsuffisante dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere + dmg.dmgForceInsuffisante
return dmg return dmg
@@ -71,8 +71,8 @@ export class RollPartAttaque extends RollPartSelect {
if (current.tactique) { if (current.tactique) {
ajustements.push({ label: current.tactique.label, diff: current.tactique.attaque }) ajustements.push({ label: current.tactique.label, diff: current.tactique.attaque })
} }
if (current.surpriseDefenseur) { if (rollData.opponent?.surprise) {
ajustements.push({ label: current.surpriseDefenseur.label, diff: current.surpriseDefenseur.attaque }) ajustements.push({ label: rollData.opponent.surprise.label, diff: rollData.opponent.surprise.attaque })
} }
return ajustements return ajustements
} }
@@ -92,7 +92,6 @@ export class RollPartAttaque extends RollPartSelect {
const selectOptions = e.currentTarget.options const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectAttaque(rollDialog.rollData, selectOptions[index]?.value) this.$selectAttaque(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.setModeTitle()
rollDialog.render() rollDialog.render()
}) })
@@ -115,7 +114,6 @@ export class RollPartAttaque extends RollPartSelect {
switch (part.code) { switch (part.code) {
case PART_CARAC: return part.filterCaracs(rollData, [current.attaque.carac.key]) case PART_CARAC: return part.filterCaracs(rollData, [current.attaque.carac.key])
case PART_COMP: return part.filterComps(rollData, [current.attaque.comp?.name]) case PART_COMP: return part.filterComps(rollData, [current.attaque.comp?.name])
case PART_SIGN: return part.setArme(rollData, current.attaque.forceRequise, false)
} }
} }
return undefined return undefined

View File

@@ -36,7 +36,7 @@ export class RollPartCarac extends RollPartSelect {
} }
} }
filterCaracs(rollData, allowed) { filterCaracs(rollData, allowed = []) {
allowed = allowed.filter(it => it != undefined) allowed = allowed.filter(it => it != undefined)
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
refs.caracs = allowed.length > 0 refs.caracs = allowed.length > 0

View File

@@ -45,7 +45,7 @@ export class RollPartComp extends RollPartSelect {
} }
} }
filterComps(rollData, allowed) { filterComps(rollData, allowed = []) {
allowed = allowed.filter(it => it != undefined) allowed = allowed.filter(it => it != undefined)
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
refs.comps = allowed.length > 0 refs.comps = allowed.length > 0

View File

@@ -4,7 +4,7 @@ import { ATTAQUE_TYPE, RdDItemArme } from "../item/arme.js"
import { RdDBonus } from "../rdd-bonus.js" import { RdDBonus } from "../rdd-bonus.js"
import { CARACS } from "../rdd-carac.js" import { CARACS } from "../rdd-carac.js"
import { StatusEffects } from "../settings/status-effects.js" import { StatusEffects } from "../settings/status-effects.js"
import { DIFF_MODE, ROLL_MODE_DEFENSE } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { PART_DIFF } from "./roll-part-diff.mjs" import { PART_DIFF } from "./roll-part-diff.mjs"
@@ -18,7 +18,7 @@ export class RollPartDefense extends RollPartSelect {
get code() { return PART_DEFENSE } get code() { return PART_DEFENSE }
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_DEFENSE) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_DEFENSE) }
static getDiffAttaque(attackerRoll) { static getDiffAttaque(attackerRoll) {
// TODO: rollDataV2? // TODO: rollDataV2?
@@ -47,6 +47,7 @@ export class RollPartDefense extends RollPartSelect {
img: esquive.img, img: esquive.img,
// TODO: carac pour créatures // TODO: carac pour créatures
carac: defenseur.isPersonnage() ? CARACS.DEROBEE : esquive.name, carac: defenseur.isPersonnage() ? CARACS.DEROBEE : esquive.name,
verb: "esquive",
comp: esquive comp: esquive
} }
} }
@@ -61,6 +62,7 @@ export class RollPartDefense extends RollPartSelect {
img: armeDefense.img, img: armeDefense.img,
// TODO: carac pour créatures // TODO: carac pour créatures
carac: defenseur.isPersonnage() ? CARACS.MELEE : comp.name, carac: defenseur.isPersonnage() ? CARACS.MELEE : comp.name,
verb: "pare",
comp: comp, comp: comp,
arme: armeDefense, arme: armeDefense,
forceRequise: armeDefense ? RdDItemArme.valeurMain(armeDefense.system.force ?? 0, RdDItemArme.getMainAttaque(comp)) : 0, forceRequise: armeDefense ? RdDItemArme.valeurMain(armeDefense.system.force ?? 0, RdDItemArme.getMainAttaque(comp)) : 0,
@@ -69,9 +71,6 @@ export class RollPartDefense extends RollPartSelect {
} }
prepareContext(rollData) { prepareContext(rollData) {
const current = this.getCurrent(rollData)
current.defenseur = StatusEffects.getActorEffetSurprise(rollData.active.actor, current.forceRequise)
// current.dmg = this.$dmgRollV2(rollData, current) // current.dmg = this.$dmgRollV2(rollData, current)
} }
@@ -92,7 +91,6 @@ export class RollPartDefense extends RollPartSelect {
const selectOptions = e.currentTarget.options const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectDefense(rollDialog.rollData, selectOptions[index]?.value) this.$selectDefense(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.setModeTitle()
rollDialog.render() rollDialog.render()
}) })
} }
@@ -104,7 +102,7 @@ export class RollPartDefense extends RollPartSelect {
case PART_CARAC: return part.filterCaracs(rollData, [current.carac]) case PART_CARAC: return part.filterCaracs(rollData, [current.carac])
case PART_COMP: return part.filterComps(rollData, [current.comp?.name]) case PART_COMP: return part.filterComps(rollData, [current.comp?.name])
case PART_DIFF: return part.setDiff(rollData, this.getDiffDefense(rollData)) case PART_DIFF: return part.setDiff(rollData, this.getDiffDefense(rollData))
case PART_SIGN: return part.setArme(rollData, current.forceRequise, this.isArmeDisparate(rollData)) case PART_SIGN: return part.setArmeDisparate(rollData, this.isArmeDisparate(rollData))
} }
} }
return undefined return undefined
@@ -122,12 +120,12 @@ export class RollPartDefense extends RollPartSelect {
getDiffDefense(rollData) { getDiffDefense(rollData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
if (refs.isDistance) { if (refs.isDistance || !rollData.attaque) {
// Déterminer la difficulté de parade // Déterminer la difficulté de parade
return { diff: 0, mode: DIFF_MODE.LIBRE } return { diff: 0, type: DIFF.LIBRE }
} }
else { else {
return { diff: rollData.attaque.diff, mode: DIFF_MODE.DEFENSE } return { diff: rollData.attaque.diff ?? 0, type: DIFF.DEFENSE }
} }
} }
} }

View File

@@ -1,9 +1,9 @@
import { DIFF_MODE, DIFF_MODES, ROLL_MODE_MEDITATION, ROLL_MODE_OEUVRE, ROLL_MODE_SORT, ROLL_MODE_TACHE } from "./roll-constants.mjs"; import { DIFF, DIFFS, 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 { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs";
export const PART_DIFF = "diff" export const PART_DIFF = "diff"
const EXCLUDED_ROLL_MODES = [ROLL_MODE_TACHE, ROLL_MODE_MEDITATION, ROLL_MODE_SORT, ROLL_MODE_OEUVRE] const EXCLUDED_ROLL_TYPES = [ROLL_TYPE_TACHE, ROLL_TYPE_MEDITATION, ROLL_TYPE_SORT, ROLL_TYPE_OEUVRE]
export class RollPartDiff extends RollPart { export class RollPartDiff extends RollPart {
@@ -14,37 +14,37 @@ export class RollPartDiff extends RollPart {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
const saved = this.getSaved(rollData) const saved = this.getSaved(rollData)
current.value = saved?.value ?? current.value ?? 0 current.value = saved?.value ?? current.value ?? 0
current.mode = saved?.mode ?? current.mode current.type = saved?.type ?? current.type
} }
store(rollData, targetData) { store(rollData, targetData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
this.setSaved(targetData, { this.setSaved(targetData, {
value: current.value, value: current.value,
mode: current.mode type: current.type
}) })
} }
visible(rollData) { visible(rollData) {
if (EXCLUDED_ROLL_MODES.includes(rollData.mode.current)) { if (EXCLUDED_ROLL_TYPES.includes(rollData.type.current)) {
return false return false
} }
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
/* TODO: affiner les cas où afficher ou non. devrait s'afficher pour les jets basiques (même si pas d'opposant sélectionné)*/ /* TODO: affiner les cas où afficher ou non. devrait s'afficher pour les jets basiques (même si pas d'opposant sélectionné)*/
return Object.values(DIFF_MODE).includes(current.mode) return Object.values(DIFF).includes(current.type)
} }
prepareContext(rollData) { prepareContext(rollData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
const diffMode = DIFF_MODES[current.mode] ?? DIFF_MODES[DIFF_MODE.AUCUN] const diffType = DIFFS[current.type] ?? DIFFS[DIFF.AUCUN]
foundry.utils.mergeObject(current, foundry.utils.mergeObject(current,
{ {
mode: diffMode.key, type: diffType.key,
label: diffMode?.label ?? '', label: diffType?.label ?? '',
value: current.value ?? 0, value: current.value ?? 0,
disabled: !diffMode.libre, disabled: !diffType.libre,
min: -10, min: -10,
max: diffMode.max max: diffType.max
}, },
{ inplace: true } { inplace: true }
) )
@@ -53,7 +53,7 @@ export class RollPartDiff extends RollPart {
setDiff(rollData, diffDefense) { setDiff(rollData, diffDefense) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
current.value = diffDefense.diff current.value = diffDefense.diff
current.mode = diffDefense.mode current.type = diffDefense.type
} }
getAjustements(rollData) { getAjustements(rollData) {

View File

@@ -1,7 +1,7 @@
import { Grammar } from "../grammar.js" import { Grammar } from "../grammar.js"
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES } from "../constants.js"
import { CARACS } from "../rdd-carac.js" import { CARACS } from "../rdd-carac.js"
import { ROLL_MODE_JEU } from "./roll-constants.mjs" import { ROLL_TYPE_JEU } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs" import { RollPartSelect } from "./roll-part-select.mjs"
@@ -17,7 +17,7 @@ export class RollPartJeu extends RollPartSelect {
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
isValid(rollData) { return rollData.active.actor.isPersonnage() } isValid(rollData) { return rollData.active.actor.isPersonnage() }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_JEU) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_JEU) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
@@ -68,8 +68,8 @@ export class RollPartJeu extends RollPartSelect {
prepareContext(rollData) { prepareContext(rollData) {
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
if (rollData.mode.current == ROLL_MODE_JEU && current) { if (rollData.type.current == ROLL_TYPE_JEU && current) {
rollData.mode.opposed = true rollData.type.opposed = true
} }
} }
@@ -86,7 +86,6 @@ export class RollPartJeu extends RollPartSelect {
const selectOptions = e.currentTarget.options const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectJeu(rollDialog.rollData, selectOptions[index]?.value) this.$selectJeu(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.setModeTitle()
rollDialog.render() rollDialog.render()
}) })
} }

View File

@@ -3,7 +3,7 @@ import { Grammar } from "../grammar.js"
import { CARACS, RdDCarac } from "../rdd-carac.js" import { CARACS, RdDCarac } from "../rdd-carac.js"
import { RdDTimestamp } from "../time/rdd-timestamp.js" import { RdDTimestamp } from "../time/rdd-timestamp.js"
import { TMRUtility } from "../tmr-utility.js" import { TMRUtility } from "../tmr-utility.js"
import { ROLL_MODE_MEDITATION } from "./roll-constants.mjs" import { ROLL_TYPE_MEDITATION } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs" import { RollPartSelect } from "./roll-part-select.mjs"
@@ -17,7 +17,7 @@ export class RollPartMeditation extends RollPartSelect {
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
isValid(rollData) { return rollData.active.actor.isPersonnage() && rollData.active.actor.isHautRevant() } isValid(rollData) { return rollData.active.actor.isPersonnage() && rollData.active.actor.isHautRevant() }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_MEDITATION) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_MEDITATION) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
@@ -86,7 +86,6 @@ export class RollPartMeditation extends RollPartSelect {
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectMeditation(rollDialog.rollData, selectOptions[index]?.value) this.$selectMeditation(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.render() rollDialog.render()
rollDialog.setModeTitle()
}) })
this.setupListenerCondition(rollDialog, 'isComportement') this.setupListenerCondition(rollDialog, 'isComportement')

View File

@@ -2,7 +2,7 @@ import { ITEM_TYPES } from "../constants.js"
import { Grammar } from "../grammar.js" import { Grammar } from "../grammar.js"
import { Misc } from "../misc.js" import { Misc } from "../misc.js"
import { CARACS } from "../rdd-carac.js" import { CARACS } from "../rdd-carac.js"
import { ROLL_MODE_OEUVRE } from "./roll-constants.mjs" import { ROLL_TYPE_OEUVRE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs" import { RollPartSelect } from "./roll-part-select.mjs"
@@ -38,7 +38,7 @@ export class RollPartOeuvre extends RollPartSelect {
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
isValid(rollData) { return rollData.active.actor.isPersonnage() } isValid(rollData) { return rollData.active.actor.isPersonnage() }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_OEUVRE) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_OEUVRE) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
@@ -80,7 +80,6 @@ export class RollPartOeuvre extends RollPartSelect {
const selectOptions = e.currentTarget.options const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectOeuvre(rollDialog.rollData, selectOptions[index]?.value) this.$selectOeuvre(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.setModeTitle()
rollDialog.render() rollDialog.render()
}) })
} }

View File

@@ -7,6 +7,6 @@ export class RollPartOpponent extends RollPart {
get code() { return OPPONENT } get code() { return OPPONENT }
get section() { return ROLLDIALOG_SECTION.ACTION } get section() { return ROLLDIALOG_SECTION.ACTION }
visible(rollData) { return rollData.mode.opposed } visible(rollData) { return rollData.type.opposed }
title(rollData) { return rollData.opponent?.name ?? '' } title(rollData) { return rollData.opponent?.name ?? '' }
} }

View File

@@ -1,7 +1,7 @@
import { Misc } from "../misc.js" import { Misc } from "../misc.js"
import { ReglesOptionnelles } from "../settings/regles-optionnelles.js" import { ReglesOptionnelles } from "../settings/regles-optionnelles.js"
import { StatusEffects } from "../settings/status-effects.js" import { StatusEffects } from "../settings/status-effects.js"
import { ROLL_MODE_ATTAQUE, ROLL_MODE_DEFENSE } from "./roll-constants.mjs" import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs" import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs"
export const PART_SIGN = "sign" export const PART_SIGN = "sign"
@@ -24,7 +24,7 @@ export class RollPartSign extends RollPart {
} }
isCombat(rollData) { isCombat(rollData) {
return [ROLL_MODE_ATTAQUE, ROLL_MODE_DEFENSE].includes(rollData.mode.current) || rollData.mode.isCombat return [ROLL_TYPE_ATTAQUE, ROLL_TYPE_DEFENSE].includes(rollData.type.current) || rollData.type.isCombat
} }
prepareContext(rollData) { prepareContext(rollData) {
@@ -32,15 +32,14 @@ export class RollPartSign extends RollPart {
} }
setFromState(rollData) { setFromState(rollData) {
if (rollData.mode.retry) { if (rollData.type.retry) {
return return
} }
const actor = rollData.active.actor; const actor = rollData.active.actor;
const isCombat = this.isCombat(rollData) const isCombat = this.isCombat(rollData)
const current = this.getCurrent(rollData) const current = this.getCurrent(rollData)
current.armeDisparate = isCombat && current.armeDisparate current.armeDisparate = isCombat && current.armeDisparate
current.forceRequise = current.forceRequise ?? 0 current.surprise = actor.getSurprise(isCombat) // TODO: could be from rollData.active.surprise??
current.surprise = actor.getSurprise(isCombat)
current.reasons = actor.getEffects(it => StatusEffects.niveauSurprise(it) > 0).map(it => it.name) current.reasons = actor.getEffects(it => StatusEffects.niveauSurprise(it) > 0).map(it => it.name)
current.diviseur = 1 current.diviseur = 1
if (current.surprise == 'demi') { if (current.surprise == 'demi') {
@@ -53,10 +52,6 @@ export class RollPartSign extends RollPart {
current.diviseur *= 2 current.diviseur *= 2
current.reasons.push('Armes disparates') current.reasons.push('Armes disparates')
} }
if (this.isForceInsuffisante(actor, current)) {
current.diviseur *= 2
current.reasons.push('Force insuffisante')
}
if (this.isAttaqueFinesse(rollData)) { if (this.isAttaqueFinesse(rollData)) {
current.diviseur *= 2 current.diviseur *= 2
current.reasons.push('Particulière en finesse') current.reasons.push('Particulière en finesse')
@@ -70,16 +65,7 @@ export class RollPartSign extends RollPart {
} }
isAttaqueFinesse(rollData) { isAttaqueFinesse(rollData) {
return ROLL_MODE_DEFENSE == rollData.mode.current && rollData.attaque.particuliere == 'finesse' return ROLL_TYPE_DEFENSE == rollData.type.current && rollData.attaque?.particuliere == 'finesse'
}
isForceInsuffisante(actor, current) {
if (actor?.isPersonnage()) {
const requise = current.forceRequise
const force = parseInt(actor.system.carac.force.value)
return requise > force
}
return false
} }
isParadeArmeDisparate(current) { isParadeArmeDisparate(current) {
@@ -106,9 +92,7 @@ export class RollPartSign extends RollPart {
}) })
} }
setArme(rollData, forceRequise, armeDisparate) { setArmeDisparate(rollData, armeDisparate) {
const current = this.getCurrent(rollData) this.getCurrent(rollData).armeDisparate = armeDisparate
current.armeDisparate = armeDisparate
current.forceRequise = forceRequise
} }
} }

View File

@@ -1,5 +1,5 @@
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES } from "../constants.js"
import { ROLL_MODE_SORT } from "./roll-constants.mjs" import { ROLL_TYPE_SORT } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { ROLLDIALOG_SECTION } from "./roll-part.mjs" import { ROLLDIALOG_SECTION } from "./roll-part.mjs"
@@ -18,7 +18,7 @@ export class RollPartSort extends RollPartSelect {
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
isValid(rollData) { return rollData.active.actor.isPersonnage() && rollData.active.actor.isHautRevant() } isValid(rollData) { return rollData.active.actor.isPersonnage() && rollData.active.actor.isHautRevant() }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_SORT) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_SORT) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
@@ -98,7 +98,6 @@ export class RollPartSort extends RollPartSelect {
const selectOptions = e.currentTarget.options const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectSort(rollDialog.rollData, selectOptions[index]?.value) this.$selectSort(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.setModeTitle()
rollDialog.render() rollDialog.render()
}) })

View File

@@ -1,6 +1,6 @@
import { ITEM_TYPES } from "../constants.js" import { ITEM_TYPES } from "../constants.js"
import { Grammar } from "../grammar.js" import { Grammar } from "../grammar.js"
import { ROLL_MODE_TACHE } from "./roll-constants.mjs" import { ROLL_TYPE_TACHE } from "./roll-constants.mjs"
import { PART_CARAC } from "./roll-part-carac.mjs" import { PART_CARAC } from "./roll-part-carac.mjs"
import { PART_COMP } from "./roll-part-comp.mjs" import { PART_COMP } from "./roll-part-comp.mjs"
import { RollPartSelect } from "./roll-part-select.mjs" import { RollPartSelect } from "./roll-part-select.mjs"
@@ -14,7 +14,7 @@ export class RollPartTache extends RollPartSelect {
get section() { return ROLLDIALOG_SECTION.CHOIX } get section() { return ROLLDIALOG_SECTION.CHOIX }
isValid(rollData) { return rollData.active.actor.isPersonnage() } isValid(rollData) { return rollData.active.actor.isPersonnage() }
visible(rollData) { return this.isRollMode(rollData, ROLL_MODE_TACHE) } visible(rollData) { return this.isRollType(rollData, ROLL_TYPE_TACHE) }
loadRefs(rollData) { loadRefs(rollData) {
const refs = this.getRefs(rollData) const refs = this.getRefs(rollData)
@@ -48,7 +48,6 @@ export class RollPartTache extends RollPartSelect {
const selectOptions = e.currentTarget.options const selectOptions = e.currentTarget.options
const index = selectOptions.selectedIndex const index = selectOptions.selectedIndex
this.$selectTache(rollDialog.rollData, selectOptions[index]?.value) this.$selectTache(rollDialog.rollData, selectOptions[index]?.value)
rollDialog.setModeTitle()
rollDialog.render() rollDialog.render()
}) })
} }

View File

@@ -60,7 +60,7 @@ export class RollPart {
* @returns une chaîne vide si rien ne doit être affiché * @returns une chaîne vide si rien ne doit être affiché
*/ */
title() { return '' } title() { return '' }
isRollMode(rollData, mode) { return rollData.mode.current == mode } isRollType(rollData, type) { return rollData.type.current == type }
isActive(rollData) { return this.isValid(rollData) && this.visible(rollData) } isActive(rollData) { return this.isValid(rollData) && this.visible(rollData) }
isValid(rollData) { return true } isValid(rollData) { return true }

View File

@@ -0,0 +1,13 @@
import { DIFF, ROLL_TYPE_ATTAQUE } from "./roll-constants.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeAttaque extends RollType {
get code() { return ROLL_TYPE_ATTAQUE }
get name() { return `Attaquer` }
title(rollData) { return `attaque` }
onSelect(rollData) {
this.setDiffType(rollData, DIFF.ATTAQUE)
}
}

View File

@@ -0,0 +1,10 @@
import { ROLL_TYPE_COMP } from "./roll-constants.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeComp extends RollType {
get code() { return ROLL_TYPE_COMP }
get name() { return `Jet de caractéristique / compétence` }
title(rollData) { return `fait un jet ${rollData.type.opposed ? ' contre ' : ''}` }
}

View File

@@ -0,0 +1,17 @@
import { DIFF, ROLL_TYPE_DEFENSE } from "./roll-constants.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeDefense extends RollType {
get code() { return ROLL_TYPE_DEFENSE }
get name() { return `Se défendre` }
title(rollData) { return `se défend${rollData.opponent ? ' de' : ''}` }
getOpponent(rollData) {
return rollData.attacker
}
onSelect(rollData) {
this.setDiffType(rollData, DIFF.DEFENSE)
}
}

View File

@@ -1,9 +1,9 @@
import { PART_JEU } from "./roll-part-jeu.mjs" import { PART_JEU } from "./roll-part-jeu.mjs"
import { RollMode } from "./roll-mode.mjs" import { RollType } from "./roll-type.mjs"
import { ROLL_MODE_JEU } from "./roll-constants.mjs" import { ROLL_TYPE_JEU } from "./roll-constants.mjs"
export class RollModeJeu extends RollMode { export class RollTypeJeu extends RollType {
get code() { return ROLL_MODE_JEU } get code() { return ROLL_TYPE_JEU }
get name() { return `Jouer` } get name() { return `Jouer` }
visible(rollData) { return rollData.active.actor.isPersonnage() } visible(rollData) { return rollData.active.actor.isPersonnage() }

View File

@@ -1,9 +1,9 @@
import { DIFF_MODE, ROLL_MODE_MEDITATION } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_MEDITATION } from "./roll-constants.mjs"
import { PART_MEDITATION } from "./roll-part-meditation.mjs" import { PART_MEDITATION } from "./roll-part-meditation.mjs"
import { RollMode } from "./roll-mode.mjs" import { RollType } from "./roll-type.mjs"
export class RollModeMeditation extends RollMode { export class RollTypeMeditation extends RollType {
get code() { return ROLL_MODE_MEDITATION } get code() { return ROLL_TYPE_MEDITATION }
get name() { return `Méditation draconique` } get name() { return `Méditation draconique` }
visible(rollData) { return rollData.active.actor.isHautRevant() } visible(rollData) { return rollData.active.actor.isHautRevant() }
@@ -14,6 +14,6 @@ export class RollModeMeditation extends RollMode {
} }
onSelect(rollData) { onSelect(rollData) {
this.setDiffMode(rollData, DIFF_MODE.AUCUN) this.setDiffType(rollData, DIFF.AUCUN)
} }
} }

View File

@@ -1,9 +1,9 @@
import { DIFF_MODE, ROLL_MODE_OEUVRE } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_OEUVRE } from "./roll-constants.mjs"
import { PART_OEUVRE } from "./roll-part-oeuvre.mjs" import { PART_OEUVRE } from "./roll-part-oeuvre.mjs"
import { RollMode } from "./roll-mode.mjs" import { RollType } from "./roll-type.mjs"
export class RollModeOeuvre extends RollMode { export class RollTypeOeuvre extends RollType {
get code() { return ROLL_MODE_OEUVRE } get code() { return ROLL_TYPE_OEUVRE }
get name() { return `Interpréter une oeuvre` } get name() { return `Interpréter une oeuvre` }
visible(rollData) { return rollData.active.actor.isPersonnage() } visible(rollData) { return rollData.active.actor.isPersonnage() }
@@ -13,7 +13,7 @@ export class RollModeOeuvre extends RollMode {
} }
onSelect(rollData) { onSelect(rollData) {
this.setDiffMode(rollData, DIFF_MODE.AUCUN) this.setDiffType(rollData, DIFF.AUCUN)
} }
} }

View File

@@ -0,0 +1,14 @@
import { DIFF, ROLL_TYPE_SORT } from "./roll-constants.mjs"
import { RollType } from "./roll-type.mjs"
export class RollTypeSort extends RollType {
get code() { return ROLL_TYPE_SORT }
get name() { return `lancer un sort` }
visible(rollData) { return rollData.active.actor.isHautRevant() }
title(rollData) { return `lance le sort:` }
onSelect(rollData) {
this.setDiffType(rollData, DIFF.AUCUN)
}
}

View File

@@ -1,9 +1,9 @@
import { DIFF_MODE, ROLL_MODE_TACHE } from "./roll-constants.mjs" import { DIFF, ROLL_TYPE_TACHE } from "./roll-constants.mjs"
import { PART_TACHE } from "./roll-part-tache.mjs" import { PART_TACHE } from "./roll-part-tache.mjs"
import { RollMode } from "./roll-mode.mjs" import { RollType } from "./roll-type.mjs"
export class RollModeTache extends RollMode { export class RollTypeTache extends RollType {
get code() { return ROLL_MODE_TACHE } get code() { return ROLL_TYPE_TACHE }
get name() { return `Travailler à une tâche` } get name() { return `Travailler à une tâche` }
visible(rollData) { return rollData.active.actor.isPersonnage() } visible(rollData) { return rollData.active.actor.isPersonnage() }
@@ -14,6 +14,6 @@ export class RollModeTache extends RollMode {
} }
onSelect(rollData) { onSelect(rollData) {
this.setDiffMode(rollData, DIFF_MODE.AUCUN) this.setDiffType(rollData, DIFF.AUCUN)
} }
} }

55
module/roll/roll-type.mjs Normal file
View File

@@ -0,0 +1,55 @@
import { DIFF } from "./roll-constants.mjs"
import { PART_DIFF } from "./roll-part-diff.mjs"
const DEFAULT_DIFF_TYPES = [DIFF.LIBRE, DIFF.IMPOSEE, DIFF.DEFAUT]
export class RollType {
onReady() { }
get code() { throw new Error(`Pas de code défini pour ${this}`) }
get name() { return this.code }
get icon() { return `systems/foundryvtt-reve-de-dragon/assets/actions/${this.code}.svg` }
get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${this.code}.hbs` }
toTypeData(rollData) {
return { code: this.code, name: this.name, icon: this.icon, section: 'type', template: this.template, selected: this.isSelected(rollData) }
}
isAllowed(rollData) { return rollData.type.allowed == undefined || rollData.type.allowed.includes(this.code) }
visible(rollData) { return true }
title(rollData) { return this.code }
isSelected(rollData) { return rollData.type.current == this.code }
setRollDataType(rollData) {
rollData.type.opposed = rollData.opponent != undefined
rollData.type.resistance = false /** TODO */
}
onSelect(rollData) {
const possibleTypes = [
rollData.current[PART_DIFF].type,
this.typeFromOpponents(rollData),
rollData.selected[PART_DIFF].type
]
const type = possibleTypes.find(m => DEFAULT_DIFF_TYPES.includes(m)) ??DIFF.DEFAUT
this.setDiffType(rollData, type)
}
typeFromOpponents(rollData) {
if (rollData.type.opposed) {
if (rollData.type.resistance) {
return DIFF.IMPOSEE
}
return DIFF.LIBRE
}
return undefined
}
setDiffType(rollData, type) {
rollData.current[PART_DIFF].type = type
this.setRollDataType(rollData)
}
}

View File

@@ -1,5 +1,11 @@
<div data-passearme="{{passeArme}}"> <div data-passearme="{{passeArme}}">
<h4 class="rdd-roll-etotal"><strong>Echec total en attaque</strong></h4> <h4 class="rdd-roll-etotal">Maladresse à l'attaque:<br>échec
{{#if rolled.isETotal}}
total
{{else}}
en demi-surprise
{{/if}}
</h4>
<br> <br>
{{#if (eq attacker.type 'personnage')}} {{#if (eq attacker.type 'personnage')}}
{{#unless essais.attaqueChance}} {{#unless essais.attaqueChance}}

View File

@@ -49,45 +49,46 @@
{{/if}} {{/if}}
</a> </a>
<br> <br>
{{/if}} {{else}}
{{#each armes as |arme key|}} {{#each armes as |arme key|}}
<a class='chat-card-button parer-button' <a class='chat-card-button parer-button'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-armeid='{{arme._id}}'> data-armeid='{{arme._id}}'>
Parer avec {{arme.name}} Parer avec {{arme.name}}
{{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}} {{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}}
(difficulté à déterminer) (difficulté à déterminer)
{{else}}à {{../diffLibre }} {{else}}à {{../diffLibre }}
{{/if}} {{/if}}
{{#if (eq arme.typeParade 'sign')}} {{#if (eq arme.typeParade 'sign')}}
<span class="rdd-diviseur">&times;&frac12;</span> <span class="rdd-diviseur">&times;&frac12;</span>
{{/if}} {{/if}}
{{#if arme.nbUsage}}(Utilisations : {{arme.nbUsage}}){{/if}} {{#if arme.nbUsage}}(Utilisations : {{arme.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/each}} {{/each}}
{{#if mainsNues}} {{#if mainsNues}}
<a class='chat-card-button parer-button' <a class='chat-card-button parer-button'
data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderToken.id}}' data-attackerTokenId='{{attackerToken.id}}'
data-armeid='{{arme._id}}' data-competence='{{arme.system.competence}}'> data-armeid='{{arme._id}}' data-competence='{{arme.system.competence}}'>
Parer à mains nues à {{diffLibre}}{{#if arme.nbUsage}} (Utilisations : {{arme.nbUsage}}){{/if}} Parer à mains nues à {{diffLibre}}{{#if arme.nbUsage}} (Utilisations : {{arme.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/if}} {{/if}}
{{#if (ne attaqueCategorie 'tir')}} {{#if (ne attaqueCategorie 'tir')}}
{{#each esquives as |esquive key|}} {{#each esquives as |esquive key|}}
<a class='chat-card-button esquiver-button' <a class='chat-card-button esquiver-button'
data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderToken.id}}' data-attackerTokenId='{{../attackerToken.id}}'
data-compid='{{esquive._id}}' data-competence='{{esquive.name}}'> data-compid='{{esquive._id}}' data-competence='{{esquive.name}}'>
{{esquive.name}} {{esquive.name}}
{{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}} {{#if (or (eq ../attaqueCategorie 'tir') (eq ../attaqueCategorie 'lancer'))}}
(difficulté à déterminer) (difficulté à déterminer)
{{else}}à {{../diffLibre }} {{else}}à {{../diffLibre }}
{{/if}} {{/if}}
{{#if esquive.nbUsage}}(Utilisations : {{esquive.nbUsage}}){{/if}} {{#if esquive.nbUsage}}(Utilisations : {{esquive.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/each}} {{/each}}
{{/if}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/unless}} {{/unless}}

View File

@@ -2,7 +2,6 @@
<span {{#if ajustements}}class="tooltip-overflow tooltip-dotted" {{/if}}> <span {{#if ajustements}}class="tooltip-overflow tooltip-dotted" {{/if}}>
<span> <span>
<span>{{rolled.caracValue}} à {{plusMoins rolled.finalLevel}}</span> <span>{{rolled.caracValue}} à {{plusMoins rolled.finalLevel}}</span>
{{log rolled}}
{{#if (and rolled.factorHtml (gt rolled.factorHtml 1))}} {{#if (and rolled.factorHtml (gt rolled.factorHtml 1))}}
<span class="rdd-diviseur">&times;{{{rolled.factorHtml}}}</span> <span class="rdd-diviseur">&times;{{{rolled.factorHtml}}}</span>
<span>= {{rolled.score}}%</span> <span>= {{rolled.score}}%</span>

View File

View File

@@ -0,0 +1,31 @@
<h4>
{{log this}}
<img class="chat-icon" src="{{competence.img}}" data-tooltip="{{competence.name}}" />
{{alias}} esquive une attaque à {{diffLibre}}</h4>
<p>{{selectedCarac.label}}{{#unless (eq selectedCarac.label competence.name)}} / {{competence.name}}{{/unless}}</p>
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.hbs"}}
<hr>
<p>
{{#if rolled.isSuccess}}
<span>Attaque esquivée!</span>
{{#if rolled.isPart}}
<!-- TODO: cas de parade à mains nues, texte à modifier -->
<span><strong>{{alias}} peut faire une deuxième esquive!</strong></span>
{{/if}}
{{else}}
<span>L'esquive de {{alias}} a échoué!</span>
{{/if}}
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-info-appel-au-moral.hbs"}}
</p>
{{#if attackerRoll.tactique}}
<p>
{{#if (eq attackerRoll.tactique 'charge')}}
<img class="chat-icon" src="icons/svg/thrust.svg" data-tooltip="charge" height="32" width="32" />
C'était une charge, les parades de l'adversaire de {{alias}} auront un -4 et il ne pourra pas esquiver!
{{ else if (eq attackerRoll.tactique 'feinte')}}
<img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd06.svg" data-tooltip="feinte" height="32" width="32" />
C'était une feinte!
{{/if}}
</p>
{{/if}}

View File

View File

View File

View File

View File

@@ -1,6 +1,14 @@
{{#if (or rollData.type.passif (ne rollData.active.surprise.key 'totale'))}}
<button name="roll-dialog-button">Lancer <button name="roll-dialog-button">Lancer
{{rollData.current.carac.value}} à {{plusMoins rollData.current.totaldiff}} {{rollData.current.carac.value}} à {{plusMoins rollData.current.totaldiff}}
{{#if rollData.current.significative.used}} {{#if rollData.current.significative.used}}
<span class="rdd-diviseur">&times;{{{rollData.current.significative.label}}}</span> <span class="rdd-diviseur">&times;{{{rollData.current.significative.label}}}</span>
{{/if}} {{/if}}
</button> </button>
{{else}}
<button name="roll-dialog-button" disabled>
<i class="fa-solid fa-ban"></i>
Surprise totale!
<i class="fa-solid fa-ban"></i>
</button>
{{/if}}

View File

@@ -1,10 +1,6 @@
<form class="roll-dialog"> <form class="roll-dialog">
<roll-header></roll-header> <roll-header></roll-header>
<roll-mode> <roll-type>{{> 'roll-type' types=types}}</roll-type>
{{#each modes as |mode|}}
{{> 'roll-mode' mode}}
{{/each}}
</roll-mode>
<roll-action>{{#each templates as |template|}}{{> 'roll-section' rollData=@root.rollData currentsection='action'}}{{/each}}</roll-action> <roll-action>{{#each templates as |template|}}{{> 'roll-section' rollData=@root.rollData currentsection='action'}}{{/each}}</roll-action>
<roll-carac>{{#each templates as |template|}}{{> 'roll-section' rollData=@root.rollData currentsection='carac'}}{{/each}}</roll-carac> <roll-carac>{{#each templates as |template|}}{{> 'roll-section' rollData=@root.rollData currentsection='carac'}}{{/each}}</roll-carac>
<roll-comp>{{#each templates as |template|}}{{> 'roll-section' rollData=@root.rollData currentsection='comp'}}{{/each}}</roll-comp> <roll-comp>{{#each templates as |template|}}{{> 'roll-section' rollData=@root.rollData currentsection='comp'}}{{/each}}</roll-comp>

View File

@@ -1,3 +0,0 @@
<button name="roll-mode" data-tooltip="{{name}}" data-mode="{{code}}" data-checked="{{selected}}">
<img src="{{icon}}">
</button>

View File

@@ -1,2 +1,2 @@
<input name="{{code}}" type="checkbox" {{#if current.checked}}checked{{/if}}/> <input name="{{code}}" type="checkbox" {{#if current.checked}}checked{{/if}}/>
<label for="{{code}}">{{current.label}}</label> <label for="{{code}}">{{refs.label}}</label>

View File

@@ -1,5 +1,5 @@
<subline> <subline>
<select name="select-attaque" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-attaque" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.attaques selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.attaques selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
</subline> </subline>
@@ -11,7 +11,7 @@
<roll-part-detail> <roll-part-detail>
<subline> <subline>
<label for="select-tactique">Tactique:</label> <label for="select-tactique">Tactique:</label>
<select name="select-tactique" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-tactique" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.tactiques selected=current.tactique.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.tactiques selected=current.tactique.key valueAttr="key" labelAttr="label"}}
</select> </select>
</subline> </subline>
@@ -28,22 +28,22 @@
</label> </label>
{{/if}} {{/if}}
</subline> </subline>
{{#if current.attaquant.effets}} {{#if rollData.active.effets}}
<subline> <subline>
<span class="status-surprise"> <span class="status-surprise">
Attaquant en&nbsp;<strong>{{lowerFirst current.attaquant.surprise.label}}</strong>:&nbsp; Attaquant en&nbsp;<strong>{{lowerFirst rollData.active.surprise.label}}</strong>:&nbsp;
{{#each current.attaquant.effets as |effect|}} {{#each rollData.active.effets as |effect|}}
{{localize effect.name}} {{localize effect.name}}
<img class="button-effect-img" src="{{effect.img}}" data-tooltip="{{localize effect.name}}" data-effect="{{effect.id}}"/> <img class="button-effect-img" src="{{effect.img}}" data-tooltip="{{localize effect.name}}" data-effect="{{effect.id}}"/>
{{/each}} {{/each}}
</span> </span>
</subline> </subline>
{{/if}} {{/if}}
{{#if current.defenseur.surprise}} {{#if rollData.opponent.surprise}}
<subline> <subline>
<span class="status-surprise"> <span class="status-surprise">
Defenseur en&nbsp;<strong>{{lowerFirst current.defenseur.surprise.label}}</strong>:&nbsp; Defenseur en&nbsp;<strong>{{lowerFirst rollData.opponent.surprise.label}}</strong>:&nbsp;
{{#each current.defenseur.effets as |effect|}} {{#each rollData.opponent.effets as |effect|}}
{{localize effect.name}} {{localize effect.name}}
<img class="button-effect-img" src="{{effect.img}}" data-tooltip="{{localize effect.name}}" data-effect="{{effect.id}}"/> <img class="button-effect-img" src="{{effect.img}}" data-tooltip="{{localize effect.name}}" data-effect="{{effect.id}}"/>
{{/each}} {{/each}}

View File

@@ -1,4 +1,4 @@
<select name="select-carac" {{#if (or rollData.mode.retry (eq refs.caracs.length 1))}}disabled{{/if}}> <select name="select-carac" {{#if (or rollData.type.retry (eq refs.caracs.length 1))}}disabled{{/if}}>
{{selectOptions refs.caracs selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.caracs selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
<selected-numeric-value>{{current.value}}</selected-numeric-value> <selected-numeric-value>{{current.value}}</selected-numeric-value>

View File

@@ -1,5 +1,5 @@
<label for="{{code}}">Coeur</label> <label for="{{code}}">Coeur</label>
<select name="{{code}}" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="{{code}}" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.amoureux selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.amoureux selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
{{#if current.amour}} {{#if current.amour}}

View File

@@ -1,4 +1,4 @@
<select name="select-comp" {{#if (or rollData.mode.retry (eq refs.comps.length 1))}}disabled{{/if}}> <select name="select-comp" {{#if (or rollData.type.retry (eq refs.comps.length 1))}}disabled{{/if}}>
{{selectOptions refs.comps selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.comps selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value> <selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>

View File

@@ -4,5 +4,5 @@
step=1 step=1
min=current.min min=current.min
max=current.max max=current.max
disabled=rollData.mode.retry disabled=rollData.type.retry
}} }}

View File

@@ -3,15 +3,15 @@
</roll-part-img> </roll-part-img>
<roll-part-detail> <roll-part-detail>
<subline> <subline>
<select name="select-defense" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-defense" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.defenses selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.defenses selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
</subline> </subline>
{{#if current.defenseur.effets}} {{#if rollData.active.effets}}
<subline> <subline>
<span class="status-surprise"> <span class="status-surprise">
Defense en&nbsp;<strong>{{lowerFirst current.defenseur.surprise.label}}</strong>:&nbsp; Defense en&nbsp;<strong>{{lowerFirst rollData.active.surprise.label}}</strong>:&nbsp;
{{#each current.defenseur.effets as |effect|}} {{#each rollData.active.effets as |effect|}}
{{localize effect.name}} {{localize effect.name}}
<img class="button-effect-img" src="{{effect.img}}" data-tooltip="{{localize effect.name}}" data-effect="{{effect.id}}"/> <img class="button-effect-img" src="{{effect.img}}" data-tooltip="{{localize effect.name}}" data-effect="{{effect.id}}"/>
{{/each}} {{/each}}

View File

@@ -5,6 +5,6 @@
step=1 step=1
min=current.min min=current.min
max=current.max max=current.max
disabled=(or rollData.mode.retry current.disabled) disabled=(or rollData.type.retry current.disabled)
}} }}
</subline> </subline>

View File

@@ -9,5 +9,5 @@
step=1 step=1
min=-30 min=-30
max=0 max=0
disabled=rollData.mode.retry disabled=rollData.type.retry
}} }}

View File

@@ -3,7 +3,7 @@
</roll-part-img> </roll-part-img>
<roll-part-detail> <roll-part-detail>
<subline> <subline>
<select name="select-jeu" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-jeu" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.jeux selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.jeux selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value> <selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>

View File

@@ -6,7 +6,7 @@
Rêve actuel: {{rollData.active.actor.system.reve.reve.value}} Rêve actuel: {{rollData.active.actor.system.reve.reve.value}}
</subline> </subline>
<subline> <subline>
<select name="select-meditation" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-meditation" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.meditations selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.meditations selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
{{#if current.meditation.system.malus}} {{#if current.meditation.system.malus}}
@@ -28,14 +28,14 @@
<subline>Durée:&nbsp;60 minutes</subline> <subline>Durée:&nbsp;60 minutes</subline>
<hr> <hr>
<subline> <subline>
<input class="conditionMeditation" type="checkbox" name="isComportement" {{#if current.isComportement}}checked{{/if}} {{#if rollData.mode.retry}}disabled{{/if}}/> <input class="conditionMeditation" type="checkbox" name="isComportement" {{#if current.isComportement}}checked{{/if}} {{#if rollData.type.retry}}disabled{{/if}}/>
<label for="isComportement">Comportement:&nbsp; <label for="isComportement">Comportement:&nbsp;
<span name="comportement">{{current.meditation.system.comportement}}</span> <span name="comportement">{{current.meditation.system.comportement}}</span>
</label> </label>
</subline> </subline>
<subline> <subline>
<input class="conditionMeditation" type="checkbox" name="isHeure" {{#if current.isHeure}}checked{{/if}} {{#if rollData.mode.retry}}disabled{{/if}}/> <input class="conditionMeditation" type="checkbox" name="isHeure" {{#if current.isHeure}}checked{{/if}} {{#if rollData.type.retry}}disabled{{/if}}/>
<label for="isHeure">Heure:&nbsp; <label for="isHeure">Heure:&nbsp;
{{#with current.meditation.system.heure as |heure|}} {{#with current.meditation.system.heure as |heure|}}
<span name="heure">{{timestamp-label heure}}</span> <span name="heure">{{timestamp-label heure}}</span>
@@ -45,13 +45,13 @@
</subline> </subline>
<subline> <subline>
<input class="conditionMeditation" type="checkbox" name="isPurification" {{#if current.isPurification}}checked{{/if}} {{#if rollData.mode.retry}}disabled{{/if}}/> <input class="conditionMeditation" type="checkbox" name="isPurification" {{#if current.isPurification}}checked{{/if}} {{#if rollData.type.retry}}disabled{{/if}}/>
<label for="isPurification">Purification:&nbsp; <label for="isPurification">Purification:&nbsp;
<span name="purification">{{current.meditation.system.purification}}</span></label> <span name="purification">{{current.meditation.system.purification}}</span></label>
</subline> </subline>
<subline> <subline>
<input class="conditionMeditation" type="checkbox" name="isVeture" {{#if current.isVeture}}checked{{/if}} {{#if rollData.mode.retry}}disabled{{/if}}/> <input class="conditionMeditation" type="checkbox" name="isVeture" {{#if current.isVeture}}checked{{/if}} {{#if rollData.type.retry}}disabled{{/if}}/>
<label for="isVeture">Vêture:&nbsp; <label for="isVeture">Vêture:&nbsp;
<span name="veture">{{current.meditation.system.veture}}</span> <span name="veture">{{current.meditation.system.veture}}</span>
</label> </label>

View File

@@ -3,7 +3,7 @@
</roll-part-img> </roll-part-img>
<roll-part-detail> <roll-part-detail>
<subline> <subline>
<select name="select-oeuvre" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-oeuvre" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.oeuvres selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.oeuvres selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
{{#if current.oeuvre}} {{#if current.oeuvre}}

View File

@@ -4,7 +4,7 @@
<roll-part-detail> <roll-part-detail>
<subline>TMR actuelle: {{caseTmr-label rollData.active.actor.system.reve.tmrpos.coord}} {{rollData.active.actor.system.reve.tmrpos.coord}}</subline> <subline>TMR actuelle: {{caseTmr-label rollData.active.actor.system.reve.tmrpos.coord}} {{rollData.active.actor.system.reve.tmrpos.coord}}</subline>
<subline> <subline>
<select name="select-sort" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-sort" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.sorts selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.sorts selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
{{#if current.isDiffVariable}} {{#if current.isDiffVariable}}
@@ -13,7 +13,7 @@
step=1 step=1
min=-20 min=-20
max=-1 max=-1
disabled=rollData.mode.retry disabled=rollData.type.retry
}} }}
{{else}} {{else}}
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value> <selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
@@ -28,7 +28,7 @@
step=1 step=1
min=1 min=1
max=30 max=30
disabled=rollData.mode.retry disabled=rollData.type.retry
}} }}
{{/if}} {{/if}}
<span>&nbsp;(actuel: {{rollData.active.actor.system.reve.reve.value}})</span> <span>&nbsp;(actuel: {{rollData.active.actor.system.reve.reve.value}})</span>
@@ -37,7 +37,7 @@
{{#if current.sort.system.isrituel}} {{#if current.sort.system.isrituel}}
<i class="fa-solid fa-book-sparkles"></i>&nbsp; Rituel <i class="fa-solid fa-book-sparkles"></i>&nbsp; Rituel
{{else}} {{else}}
<input type="checkbox" name="reserve" {{#if current.isReserve}}checked{{/if}} {{#if rollData.mode.retry}}disabled{{/if}}/> <input type="checkbox" name="reserve" {{#if current.isReserve}}checked{{/if}} {{#if rollData.type.retry}}disabled{{/if}}/>
<label for="reserve"><i class="fa-solid fa-sparkles"></i>&nbsp; Mettre en réserve</label> <label for="reserve"><i class="fa-solid fa-sparkles"></i>&nbsp; Mettre en réserve</label>
{{/if}} {{/if}}
</subline> </subline>

View File

@@ -3,7 +3,7 @@
</roll-part-img> </roll-part-img>
<roll-part-detail> <roll-part-detail>
<subline> <subline>
<select name="select-tache" {{#if rollData.mode.retry}}disabled{{/if}}> <select name="select-tache" {{#if rollData.type.retry}}disabled{{/if}}>
{{selectOptions refs.taches selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.taches selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value> <selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>

View File

@@ -0,0 +1,5 @@
{{#each types as |type|}}
<button name="roll-type" data-tooltip="{{name}}" data-type="{{code}}" data-checked="{{selected}}">
<img src="{{icon}}">
</button>
{{/each}}