Initial release
This commit is contained in:
@ -53,7 +53,7 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
/**
|
||||
* Prepare an array of form header tabs.
|
||||
* @returns {Record<string, Partial<ApplicationTab>>}
|
||||
*/
|
||||
*/
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
skills: { id: "skills", group: "sheet", icon: "fa-solid fa-shapes", label: "CTHULHUETERNAL.Label.skills" },
|
||||
@ -185,9 +185,10 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
async _onRoll(event, target) {
|
||||
const rollType = $(event.currentTarget).data("roll-type")
|
||||
let item
|
||||
let li
|
||||
// Debug : console.log(">>>>", event, target, rollType)
|
||||
// Deprecated : if (this.isEditMode) return
|
||||
switch(rollType) {
|
||||
switch (rollType) {
|
||||
case "char":
|
||||
let charId = $(event.currentTarget).data("char-id")
|
||||
item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
|
||||
@ -195,7 +196,12 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
item.targetScore = item.value * 5
|
||||
break
|
||||
case "skill":
|
||||
const li = $(event.currentTarget).parents(".item");
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
break
|
||||
case "weapon":
|
||||
case "damage":
|
||||
li = $(event.currentTarget).parents(".item");
|
||||
item = this.actor.items.get(li.data("item-id"));
|
||||
break
|
||||
default:
|
||||
|
@ -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)
|
||||
|
||||
|
@ -155,25 +155,13 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
|
||||
/**
|
||||
* Rolls a dice for a character.
|
||||
* @param {("save"|"resource|damage")} rollType The type of the roll.
|
||||
* @param {number} rollTarget The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
|
||||
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
|
||||
* @param {number} rollItem The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
|
||||
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
|
||||
*/
|
||||
async roll(rollType, rollTarget, rollAdvantage = "=") {
|
||||
let rollValue
|
||||
async roll(rollType, rollItem) {
|
||||
let opponentTarget
|
||||
switch (rollType) {
|
||||
default:
|
||||
// Handle other cases or do nothing
|
||||
break
|
||||
}
|
||||
await this._roll(rollType, rollTarget, rollValue, opponentTarget, rollAdvantage)
|
||||
}
|
||||
|
||||
/** Main roll function
|
||||
*/
|
||||
async _roll(rollType, rollItem, opponentTarget = undefined) {
|
||||
const hasTarget = opponentTarget !== undefined
|
||||
|
||||
let roll = await CthulhuEternalRoll.prompt({
|
||||
rollType,
|
||||
rollItem,
|
||||
|
@ -12,6 +12,7 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel
|
||||
schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.diceEvolved = new fields.BooleanField({ required: true, initial: true })
|
||||
schema.rollFailed = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.isAdversary = new fields.BooleanField({ required: true, initial: false })
|
||||
|
||||
return schema
|
||||
}
|
||||
|
Reference in New Issue
Block a user