Some granted dice/favor fixes
All checks were successful
Release Creation / build (release) Successful in 2m48s
All checks were successful
Release Creation / build (release) Successful in 2m48s
This commit is contained in:
@@ -246,7 +246,6 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
|
||||
async _onRoll(event, target) {
|
||||
if (this.isEditMode) return
|
||||
console.log("Roll event", event)
|
||||
const rollType = event.target.dataset.rollType
|
||||
let rollKey = event.target.dataset.rollKey;
|
||||
let rollDice = event.target.dataset?.rollDice;
|
||||
|
||||
@@ -104,6 +104,18 @@ export const SPELL_LETHARGY_DICE = [
|
||||
{ dice: "D20", value: "20", level: "21-25", maxLevel: 25 }
|
||||
]
|
||||
|
||||
export const GRANTED_DICE_CHOICES = {
|
||||
"0": { label: "None", value: "0" },
|
||||
"D2": { label: "D2", value: "D2" },
|
||||
"D3": { label: "D3", value: "D3" },
|
||||
"D4": { label: "D4", value: "D4" },
|
||||
"D6": { label: "D6", value: "D6" },
|
||||
"D8": { label: "D8", value: "D8" },
|
||||
"D10": { label: "D10", value: "D10" },
|
||||
"D12": { label: "D12", value: "D12" },
|
||||
"D20": { label: "D20", value: "D20" }
|
||||
}
|
||||
|
||||
export const INITIATIVE_DICE_CHOICES_PER_CLASS = {
|
||||
"untrained": [
|
||||
{ "name": "Asleep or totally distracted (2D12)", "value": "2D12" },
|
||||
@@ -310,5 +322,6 @@ export const SYSTEM = {
|
||||
MORTAL_CHOICES,
|
||||
SPELL_CRITICAL,
|
||||
MIRACLE_TYPES,
|
||||
SPELL_LETHARGY_DICE
|
||||
SPELL_LETHARGY_DICE,
|
||||
GRANTED_DICE_CHOICES
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ export default class LethalFantasyRoll extends Roll {
|
||||
],
|
||||
actions: {
|
||||
"selectGranted": (event, button, dialog) => {
|
||||
hasGrantedDice = true
|
||||
hasGrantedDice = event.target.checked
|
||||
},
|
||||
"selectBeyondSkill": (event, button, dialog) => {
|
||||
beyondSkill = button.checked
|
||||
@@ -502,15 +502,17 @@ export default class LethalFantasyRoll extends Roll {
|
||||
if (rollContext.favor === "favor") {
|
||||
rollFavor = new this(baseFormula, options.data, rollData)
|
||||
await rollFavor.evaluate()
|
||||
console.log("Rolling with favor", rollFavor)
|
||||
if (game?.dice3d) {
|
||||
game.dice3d.showForRoll(rollFavor, game.user, true)
|
||||
}
|
||||
if (rollFavor.result > rollBase.result) {
|
||||
if (Number(rollFavor.result) > Number(rollBase.result)) {
|
||||
badResult = rollBase.result
|
||||
rollBase = rollFavor
|
||||
} else {
|
||||
badResult = rollFavor.result
|
||||
}
|
||||
rollFavor = null
|
||||
}
|
||||
|
||||
if (rollContext.favor === "disfavor") {
|
||||
@@ -519,12 +521,13 @@ export default class LethalFantasyRoll extends Roll {
|
||||
if (game?.dice3d) {
|
||||
game.dice3d.showForRoll(rollFavor, game.user, true)
|
||||
}
|
||||
if (rollFavor.result < rollBase.result) {
|
||||
if (Number(rollFavor.result) < Number(rollBase.result)) {
|
||||
badResult = rollBase.result
|
||||
rollBase = rollFavor
|
||||
} else {
|
||||
badResult = rollFavor.result
|
||||
}
|
||||
rollFavor = null
|
||||
}
|
||||
|
||||
if (hasD30) {
|
||||
@@ -535,7 +538,7 @@ export default class LethalFantasyRoll extends Roll {
|
||||
options.D30result = rollD30.total
|
||||
}
|
||||
|
||||
let rollTotal = -1
|
||||
let rollTotal = 0
|
||||
let diceResults = []
|
||||
let resultType
|
||||
let diceSum = 0
|
||||
@@ -560,7 +563,8 @@ export default class LethalFantasyRoll extends Roll {
|
||||
}
|
||||
}
|
||||
|
||||
if (hasGrantedDice) {
|
||||
if (hasGrantedDice && options.rollTarget.grantedDice && options.rollTarget.grantedDice !== "") {
|
||||
titleFormula += ` + ${options.rollTarget.grantedDice.toUpperCase()}`
|
||||
let grantedRoll = new Roll(options.rollTarget.grantedDice)
|
||||
await grantedRoll.evaluate()
|
||||
if (game?.dice3d) {
|
||||
@@ -573,12 +577,12 @@ export default class LethalFantasyRoll extends Roll {
|
||||
if (fullModifier !== 0) {
|
||||
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
|
||||
if (fullModifier < 0) {
|
||||
rollTotal = Math.max(diceSum - rollModifier.total, 0)
|
||||
rollTotal += Math.max(diceSum - rollModifier.total, 0)
|
||||
} else {
|
||||
rollTotal = diceSum + rollModifier.total
|
||||
rollTotal += diceSum + rollModifier.total
|
||||
}
|
||||
} else {
|
||||
rollTotal = diceSum
|
||||
rollTotal += diceSum
|
||||
}
|
||||
|
||||
rollBase.options.resultType = resultType
|
||||
|
||||
@@ -90,9 +90,9 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
current: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
|
||||
})
|
||||
schema.granted = new fields.SchemaField({
|
||||
attackDice: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
defenseDice: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
damageDice: new fields.StringField({ required: true, nullable: false, initial: "" })
|
||||
attackDice: new fields.StringField({ required: true, nullable: false, initial: "0", choices: SYSTEM.GRANTED_DICE_CHOICES }),
|
||||
defenseDice: new fields.StringField({ required: true, nullable: false, initial: "0", choices: SYSTEM.GRANTED_DICE_CHOICES }),
|
||||
damageDice: new fields.StringField({ required: true, nullable: false, initial: "0", choices: SYSTEM.GRANTED_DICE_CHOICES })
|
||||
})
|
||||
|
||||
schema.movement = new fields.SchemaField({
|
||||
@@ -293,7 +293,6 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
|
||||
let wisDef = SYSTEM.CHARACTERISTICS_TABLES.wis.find((c) => c.value === this.characteristics.wis.value)
|
||||
let maxInit = Number(wisDef.init_cap) || 1000
|
||||
console.log("Rolling initiative for", this)
|
||||
|
||||
let roll = await LethalFantasyRoll.promptInitiative({
|
||||
actorId: this.parent.id,
|
||||
|
||||
Reference in New Issue
Block a user