|
|
|
@ -22,10 +22,6 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
return this.options.value
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get treshold() {
|
|
|
|
|
return this.options.treshold
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get actorId() {
|
|
|
|
|
return this.options.actorId
|
|
|
|
|
}
|
|
|
|
@ -46,20 +42,16 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
return this.options.introTextTooltip
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get aide() {
|
|
|
|
|
return this.options.aide
|
|
|
|
|
get help() {
|
|
|
|
|
return this.options.help
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get gene() {
|
|
|
|
|
return this.options.gene
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get modificateur() {
|
|
|
|
|
return this.options.modificateur
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get avantages() {
|
|
|
|
|
return this.options.avantages
|
|
|
|
|
get modifier() {
|
|
|
|
|
return this.options.modifier
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get resultType() {
|
|
|
|
@ -90,10 +82,6 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
return this.options.realDamage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get rollAdvantage() {
|
|
|
|
|
return this.options.rollAdvantage
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates introductory text based on the roll type.
|
|
|
|
|
*
|
|
|
|
@ -103,23 +91,11 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
let text
|
|
|
|
|
|
|
|
|
|
switch (this.type) {
|
|
|
|
|
case ROLL_TYPE.SAVE:
|
|
|
|
|
const saveLabel = game.i18n.localize(`CTHULHUETERNAL.Character.FIELDS.caracteristiques.${this.target}.valeur.label`)
|
|
|
|
|
text = game.i18n.format("CTHULHUETERNAL.Roll.save", { save: saveLabel })
|
|
|
|
|
case "skill":
|
|
|
|
|
const skillLabel = game.i18n.localize(`CTHULHUETERNAL.Character.FIELDS.caracteristiques.${this.target}.valeur.label`)
|
|
|
|
|
text = game.i18n.format("CTHULHUETERNAL.Roll.skill", { skill: "skill" })
|
|
|
|
|
text = text.concat("<br>").concat(`Seuil : ${this.treshold}`)
|
|
|
|
|
break
|
|
|
|
|
case ROLL_TYPE.RESOURCE:
|
|
|
|
|
const resourceLabel = game.i18n.localize(`CTHULHUETERNAL.Character.FIELDS.ressources.${this.target}.valeur.label`)
|
|
|
|
|
text = game.i18n.format("CTHULHUETERNAL.Roll.resource", { resource: resourceLabel })
|
|
|
|
|
break
|
|
|
|
|
case ROLL_TYPE.DAMAGE:
|
|
|
|
|
const damageLabel = this.target
|
|
|
|
|
text = game.i18n.format("CTHULHUETERNAL.Roll.damage", { item: damageLabel })
|
|
|
|
|
break
|
|
|
|
|
case ROLL_TYPE.ATTACK:
|
|
|
|
|
const attackLabel = this.target
|
|
|
|
|
text = game.i18n.format("CTHULHUETERNAL.Roll.attack", { item: attackLabel })
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
return text
|
|
|
|
|
}
|
|
|
|
@ -130,9 +106,9 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
* @returns {string} A formatted string containing the value, help, hindrance, and modifier.
|
|
|
|
|
*/
|
|
|
|
|
_createIntroTextTooltip() {
|
|
|
|
|
let tooltip = game.i18n.format("CTHULHUETERNAL.Tooltip.saveIntroTextTooltip", { value: this.value, aide: this.aide, gene: this.gene, modificateur: this.modificateur })
|
|
|
|
|
let tooltip = game.i18n.format("CTHULHUETERNAL.Tooltip.saveIntroTextTooltip", { value: this.value, help: this.help, gene: this.gene, modifier: this.modifier })
|
|
|
|
|
if (this.hasTarget) {
|
|
|
|
|
tooltip = tooltip.concat(`<br>Cible : ${this.targetName}`)
|
|
|
|
|
tooltip = tooltip.concat(`<br>Target : ${this.targetName}`)
|
|
|
|
|
}
|
|
|
|
|
return tooltip
|
|
|
|
|
}
|
|
|
|
@ -141,29 +117,29 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
* Prompt the user with a dialog to configure and execute a roll.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} options Configuration options for the roll.
|
|
|
|
|
* @param {string} options.rollType The type of roll being performed (e.g., RESOURCE, DAMAGE, ATTACK, SAVE).
|
|
|
|
|
* @param {string} options.rollValue The initial value or formula for the roll.
|
|
|
|
|
* @param {string} options.rollType The type of roll being performed.
|
|
|
|
|
* @param {string} options.rollTarget The target of the roll.
|
|
|
|
|
* @param {"="|"+"|"++"|"-"|"--"} options.rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
|
|
|
|
|
* @param {string} options.actorId The ID of the actor performing the roll.
|
|
|
|
|
* @param {string} options.actorName The name of the actor performing the roll.
|
|
|
|
|
* @param {string} options.actorImage The image of the actor performing the roll.
|
|
|
|
|
* @param {boolean} options.hasTarget Whether the roll has a target.
|
|
|
|
|
* @param {Object} options.target The target of the roll, if any.
|
|
|
|
|
* @param {Object} options.data Additional data for the roll.
|
|
|
|
|
*
|
|
|
|
|
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
|
|
|
|
*/
|
|
|
|
|
static async prompt(options = {}) {
|
|
|
|
|
let formula = options.rollValue
|
|
|
|
|
|
|
|
|
|
// Formula for a resource roll
|
|
|
|
|
if (options.rollType === ROLL_TYPE.RESOURCE) {
|
|
|
|
|
let ressource = game.i18n.localize(`CTHULHUETERNAL.Character.FIELDS.ressources.${options.rollTarget}.valeur.label`)
|
|
|
|
|
if (formula === "0" || formula === "") {
|
|
|
|
|
ui.notifications.warn(game.i18n.format("CTHULHUETERNAL.Warning.plusDeRessource", { ressource: ressource }))
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
let formula = "1d100"
|
|
|
|
|
switch (options.rollType) {
|
|
|
|
|
case "skill":
|
|
|
|
|
console.log(options.rollItem)
|
|
|
|
|
options.targetScore = options.rollItem.system.computeScore()
|
|
|
|
|
break
|
|
|
|
|
case "characteristic":
|
|
|
|
|
options.targetScore = options.rollItem.value * 5
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
|
options.targetScore = 50
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
|
|
|
@ -173,94 +149,33 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
default: "public",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const choiceAide = foundry.utils.mergeObject({ 0: "0" }, options.rollValue <= 10 ? { 1: "1" } : { 1: "1", 2: "2" })
|
|
|
|
|
const choiceGene = {
|
|
|
|
|
0: "0",
|
|
|
|
|
"-1": "-1",
|
|
|
|
|
"-2": "-2",
|
|
|
|
|
"-3": "-3",
|
|
|
|
|
"-4": "-4",
|
|
|
|
|
"-5": "-5",
|
|
|
|
|
"-6": "-6",
|
|
|
|
|
"-7": "-7",
|
|
|
|
|
"-8": "-8",
|
|
|
|
|
"-9": "-9",
|
|
|
|
|
const choiceModifier = {
|
|
|
|
|
"-10": "-10",
|
|
|
|
|
}
|
|
|
|
|
const choiceAvantage = { normal: "Normal", avantage: "Avantage", desavantage: "Désavantage", doubleAvantage: "Double avantage", doubleDesavantage: "Double désavantage" }
|
|
|
|
|
const choiceModificateur = {
|
|
|
|
|
"-20": "-20",
|
|
|
|
|
"-40": "-40",
|
|
|
|
|
0: "0",
|
|
|
|
|
"-1": "-1",
|
|
|
|
|
"-2": "-2",
|
|
|
|
|
"-3": "-3",
|
|
|
|
|
"-4": "-4",
|
|
|
|
|
"-5": "-5",
|
|
|
|
|
"-6": "-6",
|
|
|
|
|
"-7": "-7",
|
|
|
|
|
"-8": "-8",
|
|
|
|
|
"-9": "-9",
|
|
|
|
|
"-10": "-10",
|
|
|
|
|
"+10": "+10",
|
|
|
|
|
"+20": "+20",
|
|
|
|
|
"+40": "+40",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let damageDice
|
|
|
|
|
let damageDiceMax
|
|
|
|
|
let damageDiceFinal
|
|
|
|
|
let damageDiceLowered
|
|
|
|
|
|
|
|
|
|
// Damage roll : check the roll is not above the maximum damage
|
|
|
|
|
if (options.rollType === ROLL_TYPE.DAMAGE) {
|
|
|
|
|
damageDice = options.rollValue
|
|
|
|
|
damageDiceMax = game.actors.get(options.actorId).system.dmax.valeur
|
|
|
|
|
damageDiceFinal = CthulhuEternalUtils.maxDamage(damageDice, damageDiceMax)
|
|
|
|
|
damageDiceLowered = damageDiceFinal !== damageDice
|
|
|
|
|
// Récupération du nom de l'objet si c'est un jet depuis la fiche de l'acteur
|
|
|
|
|
// Si c'est via une macro le nom est connu
|
|
|
|
|
options.rollTarget = game.actors.get(options.actorId).items.get(options.rollTarget).name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.rollType === ROLL_TYPE.ATTACK) {
|
|
|
|
|
damageDice = options.rollValue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let malus = "0"
|
|
|
|
|
let modifier = "0"
|
|
|
|
|
let targetMalus = "0"
|
|
|
|
|
let targetName
|
|
|
|
|
let targetArmor
|
|
|
|
|
const displayOpponentMalus = game.settings.get("tenebris", "displayOpponentMalus")
|
|
|
|
|
|
|
|
|
|
if (options.rollType === ROLL_TYPE.SAVE && options.hasTarget && options.target.document.actor.type === "opponent") {
|
|
|
|
|
targetName = options.target.document.actor.name
|
|
|
|
|
if (displayOpponentMalus) malus = options.target.document.actor.system.malus.toString()
|
|
|
|
|
else targetMalus = options.target.document.actor.system.malus.toString()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (options.rollType === ROLL_TYPE.DAMAGE && options.hasTarget && options.target.document.actor.type === "opponent") {
|
|
|
|
|
targetName = options.target.document.actor.name
|
|
|
|
|
targetArmor = options.target.document.actor.system.armure.toString()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let dialogContext = {
|
|
|
|
|
isSave: options.rollType === ROLL_TYPE.SAVE,
|
|
|
|
|
isResource: options.rollType === ROLL_TYPE.RESOURCE,
|
|
|
|
|
isDamage: options.rollType === ROLL_TYPE.DAMAGE,
|
|
|
|
|
isAttack: options.rollType === ROLL_TYPE.ATTACK,
|
|
|
|
|
rollType: options.rollType,
|
|
|
|
|
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
|
|
|
|
|
targetScore: options.targetScore,
|
|
|
|
|
rollModes,
|
|
|
|
|
fieldRollMode,
|
|
|
|
|
choiceAide,
|
|
|
|
|
choiceGene,
|
|
|
|
|
choiceAvantage,
|
|
|
|
|
choiceModificateur,
|
|
|
|
|
damageDice,
|
|
|
|
|
damageDiceMax,
|
|
|
|
|
damageDiceFinal,
|
|
|
|
|
damageDiceLowered,
|
|
|
|
|
choiceModifier,
|
|
|
|
|
formula,
|
|
|
|
|
hasTarget: options.hasTarget,
|
|
|
|
|
malus,
|
|
|
|
|
modifier,
|
|
|
|
|
targetName,
|
|
|
|
|
targetArmor,
|
|
|
|
|
rollAdvantage: this._convertAvantages(options.rollAdvantage),
|
|
|
|
|
rangeAdvantage: this._convertRollAdvantageToRange(options.rollAdvantage),
|
|
|
|
|
targetArmor
|
|
|
|
|
}
|
|
|
|
|
const content = await renderTemplate("systems/fvtt-cthulhu-eternal/templates/roll-dialog.hbs", dialogContext)
|
|
|
|
|
|
|
|
|
@ -278,89 +193,21 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
if (input.name) obj[input.name] = input.value
|
|
|
|
|
return obj
|
|
|
|
|
}, {})
|
|
|
|
|
// Avantages
|
|
|
|
|
switch (output.avantages) {
|
|
|
|
|
case "1":
|
|
|
|
|
output.avantages = "doubleDesavantage"
|
|
|
|
|
break
|
|
|
|
|
case "2":
|
|
|
|
|
output.avantages = "desavantage"
|
|
|
|
|
break
|
|
|
|
|
case "3":
|
|
|
|
|
output.avantages = "normal"
|
|
|
|
|
break
|
|
|
|
|
case "4":
|
|
|
|
|
output.avantages = "avantage"
|
|
|
|
|
break
|
|
|
|
|
case "5":
|
|
|
|
|
output.avantages = "doubleAvantage"
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
return output
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
rejectClose: false, // Click on Close button will not launch an error
|
|
|
|
|
render: (event, dialog) => {
|
|
|
|
|
const rangeInput = dialog.querySelector('input[name="avantages"]')
|
|
|
|
|
if (rangeInput) {
|
|
|
|
|
rangeInput.addEventListener("change", (event) => {
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
event.stopPropagation()
|
|
|
|
|
const readOnly = dialog.querySelector('input[name="selectAvantages"]')
|
|
|
|
|
readOnly.value = this._convertAvantages(event.target.value)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// If the user cancels the dialog, exit
|
|
|
|
|
if (rollContext === null) return
|
|
|
|
|
|
|
|
|
|
let treshold
|
|
|
|
|
|
|
|
|
|
if (options.rollType === ROLL_TYPE.SAVE) {
|
|
|
|
|
const aide = rollContext.aide === "" ? 0 : parseInt(rollContext.aide, 10)
|
|
|
|
|
const gene = rollContext.gene === "" ? 0 : parseInt(rollContext.gene, 10)
|
|
|
|
|
const modificateur = rollContext.modificateur === "" ? 0 : parseInt(rollContext.modificateur, 10)
|
|
|
|
|
|
|
|
|
|
if (options.rollType === ROLL_TYPE.SAVE) {
|
|
|
|
|
let dice = "1d20"
|
|
|
|
|
switch (rollContext.avantages) {
|
|
|
|
|
case "avantage":
|
|
|
|
|
dice = "2d20kl"
|
|
|
|
|
break
|
|
|
|
|
case "desavantage":
|
|
|
|
|
dice = "2d20kh"
|
|
|
|
|
break
|
|
|
|
|
case "doubleAvantage":
|
|
|
|
|
dice = "3d20kl"
|
|
|
|
|
break
|
|
|
|
|
case "doubleDesavantage":
|
|
|
|
|
dice = "3d20kh"
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
formula = `${dice}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
treshold = options.rollValue + aide + gene + modificateur
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Formula for a damage roll
|
|
|
|
|
if (options.rollType === ROLL_TYPE.DAMAGE) {
|
|
|
|
|
formula = damageDiceFinal
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Formula for an attack roll
|
|
|
|
|
if (options.rollType === ROLL_TYPE.ATTACK) {
|
|
|
|
|
formula = damageDice
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rollData = {
|
|
|
|
|
type: options.rollType,
|
|
|
|
|
target: options.rollTarget,
|
|
|
|
|
value: options.rollValue,
|
|
|
|
|
treshold: treshold,
|
|
|
|
|
rollType: options.rollType,
|
|
|
|
|
rollItem: options.rollItem,
|
|
|
|
|
actorId: options.actorId,
|
|
|
|
|
actorName: options.actorName,
|
|
|
|
|
actorImage: options.actorImage,
|
|
|
|
@ -372,48 +219,30 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
...rollContext,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update target score
|
|
|
|
|
rollData.targetScore = options.targetScore + Number(rollData.modifier)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A hook event that fires before the roll is made.
|
|
|
|
|
* @function tenebris.preRoll
|
|
|
|
|
* @memberof hookEvents
|
|
|
|
|
* @param {Object} options Options for the roll.
|
|
|
|
|
* @param {Object} rollData All data related to the roll.
|
|
|
|
|
* @returns {boolean} Explicitly return `false` to prevent roll to be made.
|
|
|
|
|
*/
|
|
|
|
|
if (Hooks.call("tenebris.preRoll", options, rollData) === false) return
|
|
|
|
|
if (Hooks.call("fvtt-cthulhu-eternal.preRoll", options, rollData) === false) return
|
|
|
|
|
|
|
|
|
|
const roll = new this(formula, options.data, rollData)
|
|
|
|
|
|
|
|
|
|
await roll.evaluate()
|
|
|
|
|
|
|
|
|
|
let resultType
|
|
|
|
|
if (options.rollType === ROLL_TYPE.SAVE) {
|
|
|
|
|
resultType = roll.total <= treshold ? "success" : "failure"
|
|
|
|
|
} else if (options.rollType === ROLL_TYPE.RESOURCE) {
|
|
|
|
|
resultType = roll.total === 1 || roll.total === 2 ? "failure" : "success"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let realDamage
|
|
|
|
|
if (options.rollType === ROLL_TYPE.DAMAGE) {
|
|
|
|
|
realDamage = Math.max(0, roll.total - parseInt(targetArmor, 10))
|
|
|
|
|
let resultType = "failure"
|
|
|
|
|
if (roll.total <= rollData.targetScore) {
|
|
|
|
|
resultType = "success"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
roll.options.resultType = resultType
|
|
|
|
|
roll.options.treshold = treshold
|
|
|
|
|
roll.options.introText = roll._createIntroText()
|
|
|
|
|
roll.options.introTextTooltip = roll._createIntroTextTooltip()
|
|
|
|
|
roll.options.realDamage = realDamage
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A hook event that fires after the roll has been made.
|
|
|
|
|
* @function tenebris.Roll
|
|
|
|
|
* @memberof hookEvents
|
|
|
|
|
* @param {Object} options Options for the roll.
|
|
|
|
|
* @param {Object} rollData All data related to the roll.
|
|
|
|
|
@param {CthulhuEternalRoll} roll The resulting roll.
|
|
|
|
|
* @returns {boolean} Explicitly return `false` to prevent roll to be made.
|
|
|
|
|
*/
|
|
|
|
|
if (Hooks.call("tenebris.Roll", options, rollData, roll) === false) return
|
|
|
|
|
if (Hooks.call("fvtt-cthulhu-eternal.Roll", options, rollData, roll) === false) return
|
|
|
|
|
|
|
|
|
|
return roll
|
|
|
|
|
}
|
|
|
|
@ -427,14 +256,8 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
*/
|
|
|
|
|
static createTitle(type, target) {
|
|
|
|
|
switch (type) {
|
|
|
|
|
case ROLL_TYPE.SAVE:
|
|
|
|
|
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleSave")} : ${game.i18n.localize(`CTHULHUETERNAL.Manager.${target}`)}`
|
|
|
|
|
case ROLL_TYPE.RESOURCE:
|
|
|
|
|
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleResource")} : ${game.i18n.localize(`CTHULHUETERNAL.Manager.${target}`)}`
|
|
|
|
|
case ROLL_TYPE.DAMAGE:
|
|
|
|
|
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleDamage")} : ${target}`
|
|
|
|
|
case ROLL_TYPE.ATTACK:
|
|
|
|
|
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleAttack")} : ${target}`
|
|
|
|
|
case "skill":
|
|
|
|
|
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleSkill")}`
|
|
|
|
|
default:
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Dialog.titleStandard")
|
|
|
|
|
}
|
|
|
|
@ -457,11 +280,7 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
* @property {boolean} isGM - Indicates if the user is a Game Master.
|
|
|
|
|
* @property {string} formula - The formula used for the roll.
|
|
|
|
|
* @property {number} total - The total result of the roll.
|
|
|
|
|
* @property {boolean} isSave - Indicates if the roll is a saving throw.
|
|
|
|
|
* @property {boolean} isResource - Indicates if the roll is related to a resource.
|
|
|
|
|
* @property {boolean} isDamage - Indicates if the roll is for damage.
|
|
|
|
|
* @property {boolean} isFailure - Indicates if the roll is a failure.
|
|
|
|
|
* @property {Array} avantages - Advantages associated with the roll.
|
|
|
|
|
* @property {string} actorId - The ID of the actor performing the roll.
|
|
|
|
|
* @property {string} actingCharName - The name of the character performing the roll.
|
|
|
|
|
* @property {string} actingCharImg - The image of the character performing the roll.
|
|
|
|
@ -482,13 +301,12 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
data: this.data,
|
|
|
|
|
diceTotal: this.dice.reduce((t, d) => t + d.total, 0),
|
|
|
|
|
isGM: game.user.isGM,
|
|
|
|
|
rollItem: this.options.rollItem,
|
|
|
|
|
targetScore: this.options.targetScore,
|
|
|
|
|
rollType: this.options.rollType,
|
|
|
|
|
formula: this.formula,
|
|
|
|
|
total: this.total,
|
|
|
|
|
isSave: this.isSave,
|
|
|
|
|
isResource: this.isResource,
|
|
|
|
|
isDamage: this.isDamage,
|
|
|
|
|
isFailure: this.isFailure,
|
|
|
|
|
avantages: this.avantages,
|
|
|
|
|
actorId: this.actorId,
|
|
|
|
|
actingCharName: this.actorName,
|
|
|
|
|
actingCharImg: this.actorImage,
|
|
|
|
@ -501,6 +319,7 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
realDamage: this.realDamage,
|
|
|
|
|
isPrivate: isPrivate,
|
|
|
|
|
}
|
|
|
|
|
console.log(cardData)
|
|
|
|
|
cardData.cssClass = cardData.css.join(" ")
|
|
|
|
|
cardData.tooltip = isPrivate ? "" : await this.getTooltip()
|
|
|
|
|
return cardData
|
|
|
|
@ -518,12 +337,8 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
async toMessage(messageData = {}, { rollMode, create = true } = {}) {
|
|
|
|
|
super.toMessage(
|
|
|
|
|
{
|
|
|
|
|
isSave: this.isSave,
|
|
|
|
|
isResource: this.isResource,
|
|
|
|
|
isDamage: this.isDamage,
|
|
|
|
|
isFailure: this.resultType === "failure",
|
|
|
|
|
avantages: this.avantages,
|
|
|
|
|
introText: this.introText,
|
|
|
|
|
introText: this.introText,
|
|
|
|
|
introTextTooltip: this.introTextTooltip,
|
|
|
|
|
actingCharName: this.actorName,
|
|
|
|
|
actingCharImg: this.actorImage,
|
|
|
|
@ -538,45 +353,4 @@ export default class CthulhuEternalRoll extends Roll {
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Used in the avantages select and with the rollAdvantage parameter: convert the selected value to the corresponding string
|
|
|
|
|
static _convertAvantages(value) {
|
|
|
|
|
switch (value) {
|
|
|
|
|
case "1":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.doubleDesavantage")
|
|
|
|
|
case "2":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.desavantage")
|
|
|
|
|
case "3":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.normal")
|
|
|
|
|
case "4":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.avantage")
|
|
|
|
|
case "5":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.doubleAvantage")
|
|
|
|
|
case "--":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.doubleDesavantage")
|
|
|
|
|
case "-":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.desavantage")
|
|
|
|
|
case "=":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.normal")
|
|
|
|
|
case "+":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.avantage")
|
|
|
|
|
case "++":
|
|
|
|
|
return game.i18n.localize("CTHULHUETERNAL.Roll.doubleAvantage")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Used in the rollAdvantage parameter: convert the selected value to the corresponding range value
|
|
|
|
|
static _convertRollAdvantageToRange(value) {
|
|
|
|
|
switch (value) {
|
|
|
|
|
case "--":
|
|
|
|
|
return 1
|
|
|
|
|
case "-":
|
|
|
|
|
return 2
|
|
|
|
|
case "=":
|
|
|
|
|
return 3
|
|
|
|
|
case "+":
|
|
|
|
|
return 4
|
|
|
|
|
case "++":
|
|
|
|
|
return 5
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|