Initial release
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
|
||||
import { SYSTEM } from "../config/system.mjs"
|
||||
export default class CthulhuEternalRoll extends Roll {
|
||||
/**
|
||||
* The HTML template path used to render dice checks of this type
|
||||
@ -74,6 +75,10 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
return this.options.realDamage
|
||||
}
|
||||
|
||||
get weapon() {
|
||||
return this.options.weapon
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt the user with a dialog to configure and execute a roll.
|
||||
*
|
||||
@ -98,6 +103,32 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
case "char":
|
||||
options.initialScore = options.rollItem.targetScore
|
||||
break
|
||||
case "damage":
|
||||
let formula = options.rollItem.system.damage
|
||||
let damageRoll = new Roll(formula)
|
||||
await damageRoll.evaluate()
|
||||
await damageRoll.toMessage({
|
||||
flavor: `${options.rollItem.name} - Damage Roll`
|
||||
});
|
||||
let isLethal = false
|
||||
if (options.rollItem.system.lethality > 0 ) {
|
||||
let lethalityRoll = new Roll("1d100")
|
||||
await lethalityRoll.evaluate()
|
||||
isLethal = (lethalityRoll.total <= options.rollItem.system.lethality)
|
||||
await lethalityRoll.toMessage({
|
||||
flavor: `${options.rollItem.name} - Lethality Roll : ${lethalityRoll.total} <= ${options.rollItem.system.lethality} => ${isLethal}`
|
||||
});
|
||||
}
|
||||
return
|
||||
case "weapon":
|
||||
let era = game.settings.get("fvtt-cthulhu-eternal", "settings-era")
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
let actor = game.actors.get(options.actorId)
|
||||
options.weapon = options.rollItem
|
||||
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
console.log("WEAPON", skillName, era, options.rollItem)
|
||||
break
|
||||
default:
|
||||
options.initialScore = 50
|
||||
break
|
||||
@ -114,7 +145,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
"-10": "-10",
|
||||
"-20": "-20",
|
||||
"-40": "-40",
|
||||
0: "0",
|
||||
"0": "0",
|
||||
"+10": "+10",
|
||||
"+20": "+20",
|
||||
"+40": "+40",
|
||||
@ -128,6 +159,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
let dialogContext = {
|
||||
rollType: options.rollType,
|
||||
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
|
||||
weapon: options?.weapon,
|
||||
initialScore: options.initialScore,
|
||||
targetScore: options.initialScore,
|
||||
isLowWP: options.isLowWP,
|
||||
@ -201,12 +233,12 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
if (roll.total <= rollData.targetScore) {
|
||||
resultType = "success"
|
||||
// Detect if decimal == unit in the dire total result
|
||||
if (dec === unit || roll.total == 1) {
|
||||
if (dec === unit || roll.total === 1) {
|
||||
resultType = "successCritical"
|
||||
}
|
||||
} else {
|
||||
// Detect if decimal == unit in the dire total result
|
||||
if (dec === unit || roll.total == 100) {
|
||||
if (dec === unit || roll.total === 100) {
|
||||
resultType = "failureCritical"
|
||||
}
|
||||
}
|
||||
@ -234,9 +266,11 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
static createTitle(type, target) {
|
||||
switch (type) {
|
||||
case "skill":
|
||||
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleSkill")}`
|
||||
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleSkill")}`
|
||||
case "weapon":
|
||||
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleWeapon")}`
|
||||
default:
|
||||
return game.i18n.localize("CTHULHUETERNAL.Dialog.titleStandard")
|
||||
return game.i18n.localize("CTHULHUETERNAL.Label.titleStandard")
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,6 +321,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
cardData.targetArmor = this.targetArmor
|
||||
cardData.realDamage = this.realDamage
|
||||
cardData.isPrivate = isPrivate
|
||||
cardData.weapon = this.weapon
|
||||
|
||||
console.log(cardData)
|
||||
|
||||
|
Reference in New Issue
Block a user