Roll damage + fix
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { ROLL_TYPE, SYSTEM } from "../config/system.mjs"
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
import LethalFantasyUtils from "../utils.mjs"
|
||||
|
||||
export default class LethalFantasyRoll extends Roll {
|
||||
@ -44,14 +44,6 @@ export default class LethalFantasyRoll extends Roll {
|
||||
return this.options.actorImage
|
||||
}
|
||||
|
||||
get introText() {
|
||||
return this.options.introText
|
||||
}
|
||||
|
||||
get introTextTooltip() {
|
||||
return this.options.introTextTooltip
|
||||
}
|
||||
|
||||
get modifier() {
|
||||
return this.options.modifier
|
||||
}
|
||||
@ -96,49 +88,6 @@ export default class LethalFantasyRoll extends Roll {
|
||||
return this.options.rollTarget
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates introductory text based on the roll type.
|
||||
*
|
||||
* @returns {string} The formatted introductory text for the roll.
|
||||
*/
|
||||
_createIntroText() {
|
||||
let text
|
||||
|
||||
switch (this.type) {
|
||||
case ROLL_TYPE.SAVE:
|
||||
const saveLabel = game.i18n.localize(`LETHALFANTASY.Character.FIELDS.caracteristiques.${this.target}.valeur.label`)
|
||||
text = game.i18n.format("LETHALFANTASY.Roll.save", { save: saveLabel })
|
||||
text = text.concat("<br>").concat(`Seuil : ${this.treshold}`)
|
||||
break
|
||||
case ROLL_TYPE.RESOURCE:
|
||||
const resourceLabel = game.i18n.localize(`LETHALFANTASY.Character.FIELDS.ressources.${this.target}.valeur.label`)
|
||||
text = game.i18n.format("LETHALFANTASY.Roll.resource", { resource: resourceLabel })
|
||||
break
|
||||
case ROLL_TYPE.DAMAGE:
|
||||
const damageLabel = this.target
|
||||
text = game.i18n.format("LETHALFANTASY.Roll.damage", { item: damageLabel })
|
||||
break
|
||||
case ROLL_TYPE.ATTACK:
|
||||
const attackLabel = this.target
|
||||
text = game.i18n.format("LETHALFANTASY.Roll.attack", { item: attackLabel })
|
||||
break
|
||||
}
|
||||
return text
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an introductory text tooltip with characteristics and modifiers.
|
||||
*
|
||||
* @returns {string} A formatted string containing the value, help, hindrance, and modifier.
|
||||
*/
|
||||
_createIntroTextTooltip() {
|
||||
let tooltip = game.i18n.format("LETHALFANTASY.Tooltip.saveIntroTextTooltip", { value: this.value, aide: this.aide, gene: this.gene, modificateur: this.modificateur })
|
||||
if (this.hasTarget) {
|
||||
tooltip = tooltip.concat(`<br>Cible : ${this.targetName}`)
|
||||
}
|
||||
return tooltip
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user with a dialog to configure and execute a roll.
|
||||
*
|
||||
@ -196,6 +145,20 @@ export default class LethalFantasyRoll extends Roll {
|
||||
options.rollTarget.value = options.rollTarget.combat.defenseModifier + options.rollTarget.weaponSkillModifier
|
||||
options.rollTarget.charModifier = options.rollTarget.combat.defenseModifier
|
||||
}
|
||||
} else if (options.rollType.includes("weapon-damage")) {
|
||||
options.rollName = options.rollTarget.name
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
options.rollTarget.value = options.rollTarget.combat.damageModifier + options.rollTarget.weaponSkillModifier
|
||||
options.rollTarget.charModifier = options.rollTarget.combat.damageModifier
|
||||
if (options.rollType.includes("small")) {
|
||||
dice = options.rollTarget.weapon.system.damage.damageS
|
||||
} else {
|
||||
dice = options.rollTarget.weapon.system.damage.damageM
|
||||
}
|
||||
dice = dice.replace("E", "")
|
||||
baseFormula = dice
|
||||
maxValue = 20
|
||||
}
|
||||
|
||||
if (options.rollType === "save" && options.rollTarget.rollKey === "pain") {
|
||||
@ -342,11 +305,11 @@ export default class LethalFantasyRoll extends Roll {
|
||||
} else {
|
||||
rollTotal = diceSum + rollModifier.total
|
||||
}
|
||||
} else {
|
||||
rollTotal = diceSum
|
||||
}
|
||||
|
||||
rollBase.options.resultType = resultType
|
||||
rollBase.options.introText = rollBase._createIntroText()
|
||||
rollBase.options.introTextTooltip = rollBase._createIntroTextTooltip()
|
||||
rollBase.options.rollTotal = rollTotal
|
||||
rollBase.options.diceResults = diceResults
|
||||
rollBase.options.rollTarget = options.rollTarget
|
||||
@ -385,8 +348,10 @@ export default class LethalFantasyRoll extends Roll {
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-attack")}`
|
||||
case "weapon-defense":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-defense")}`
|
||||
case "weapon-damage":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage")}`
|
||||
case "weapon-damage-small":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage-small")}`
|
||||
case "weapon-damage-medium":
|
||||
return `${game.i18n.localize("LETHALFANTASY.Label.weapon-damage-medium")}`
|
||||
default:
|
||||
return game.i18n.localize("LETHALFANTASY.Label.titleStandard")
|
||||
}
|
||||
@ -415,8 +380,6 @@ export default class LethalFantasyRoll extends 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.
|
||||
* @property {string} introText - Introductory text for the roll.
|
||||
* @property {string} introTextTooltip - Tooltip for the introductory text.
|
||||
* @property {string} resultType - The type of result (e.g., success, failure).
|
||||
* @property {boolean} hasTarget - Indicates if the roll has a target.
|
||||
* @property {string} targetName - The name of the target.
|
||||
@ -442,8 +405,6 @@ export default class LethalFantasyRoll extends Roll {
|
||||
diceResults: this.diceResults,
|
||||
actingCharName: this.actorName,
|
||||
actingCharImg: this.actorImage,
|
||||
introText: this.introText,
|
||||
introTextTooltip: this.introTextTooltip,
|
||||
resultType: this.resultType,
|
||||
hasTarget: this.hasTarget,
|
||||
targetName: this.targetName,
|
||||
@ -470,10 +431,8 @@ export default class LethalFantasyRoll extends Roll {
|
||||
isSave: this.isSave,
|
||||
isChallenge: this.isChallenge,
|
||||
isFailure: this.resultType === "failure",
|
||||
introText: this.introText,
|
||||
rollType: this.type,
|
||||
rollTarget: this.rollTarget,
|
||||
introTextTooltip: this.introTextTooltip,
|
||||
actingCharName: this.actorName,
|
||||
actingCharImg: this.actorImage,
|
||||
hasTarget: this.hasTarget,
|
||||
|
Reference in New Issue
Block a user