Ranged defense fixes again
All checks were successful
Release Creation / build (release) Successful in 43s
All checks were successful
Release Creation / build (release) Successful in 43s
This commit is contained in:
@@ -143,7 +143,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
|
||||
// Handle different data types
|
||||
if (data.type === "Item") {
|
||||
if (data.type === "Item") {
|
||||
const item = await fromUuid(data.uuid)
|
||||
return this._onDropItem(item)
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ export default class LethalFantasyRoll extends Roll {
|
||||
let hasGrantedDice = false
|
||||
let pointBlank = false
|
||||
let letItFly = false
|
||||
let saveSpell = false
|
||||
let beyondSkill = false
|
||||
let hasStaticModifier = false
|
||||
let hasExplode = true
|
||||
@@ -368,6 +369,9 @@ export default class LethalFantasyRoll extends Roll {
|
||||
"selectLetItFly": (event, button, dialog) => {
|
||||
letItFly = button.checked
|
||||
},
|
||||
"saveSpellCheck": (event, button, dialog) => {
|
||||
saveSpell = button.checked
|
||||
},
|
||||
"gotoToken": (event, button, dialog) => {
|
||||
let tokenId = $(button).data("tokenId")
|
||||
let token = canvas.tokens?.get(tokenId)
|
||||
@@ -384,6 +388,7 @@ export default class LethalFantasyRoll extends Roll {
|
||||
// If the user cancels the dialog, exit
|
||||
if (rollContext === null) return
|
||||
console.log("rollContext", rollContext, hasGrantedDice)
|
||||
rollContext.saveSpell = saveSpell // Update fucking flag
|
||||
|
||||
let fullModifier = 0
|
||||
let titleFormula = ""
|
||||
@@ -405,7 +410,6 @@ export default class LethalFantasyRoll extends Roll {
|
||||
if (hasStaticModifier) {
|
||||
modifierFormula += ` + ${options.rollTarget.staticModifier}`
|
||||
}
|
||||
// modifierFormula += ` + ${options.rollTarget.charModifier}`
|
||||
let sign = fullModifier < 0 ? "-" : "+"
|
||||
if (hasExplode) {
|
||||
titleFormula = `${dice}E ${sign} ${modifierFormula}`
|
||||
@@ -440,10 +444,11 @@ export default class LethalFantasyRoll extends Roll {
|
||||
}
|
||||
|
||||
// Specific pain/poison/contagion case
|
||||
if (options.rollType === "save" && (options.rollTarget.rollKey === "pain" || options.rollTarget.rollKey === "paincourage" || options.rollTarget.rollKey === "poison" || options.rollTarget.rollKey === "contagion")) {
|
||||
if (options.rollType === "save" && (options.rollTarget.rollKey === "poison" || options.rollTarget.rollKey === "contagion")) {
|
||||
hasD30 = false
|
||||
hasStaticModifier = true
|
||||
modifierFormula = ` + ${Math.abs(fullModifier)}`
|
||||
titleFormula = `${dice}E + ${Math.abs(fullModifier)}`
|
||||
}
|
||||
|
||||
if (letItFly) {
|
||||
@@ -622,7 +627,6 @@ export default class LethalFantasyRoll extends Roll {
|
||||
fieldRollMode,
|
||||
rollModes
|
||||
}
|
||||
console.log("CTX", dialogContext)
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/roll-initiative-dialog.hbs", dialogContext)
|
||||
|
||||
@@ -657,7 +661,6 @@ export default class LethalFantasyRoll extends Roll {
|
||||
let combat = game.combats.get(options.combatId)
|
||||
combat.updateEmbeddedDocuments("Combatant", [{ _id: options.combatantId, initiative: initRoll.total, 'system.progressionCount': 0 }]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ***********************************************************/
|
||||
@@ -920,9 +923,9 @@ export default class LethalFantasyRoll extends Roll {
|
||||
}
|
||||
|
||||
/* ***********************************************************/
|
||||
static async promptRangedDefense(rollTarget) {
|
||||
static async promptRangedDefense(options = {}) {
|
||||
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes); // v12 : Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
|
||||
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes);
|
||||
const fieldRollMode = new foundry.data.fields.StringField({
|
||||
choices: rollModes,
|
||||
blank: false,
|
||||
@@ -937,13 +940,12 @@ export default class LethalFantasyRoll extends Roll {
|
||||
attackerAimChoices: SYSTEM.ATTACKER_AIM_CHOICES,
|
||||
movement: "none",
|
||||
moveDirection: "none",
|
||||
size: "medium",
|
||||
size: "+5",
|
||||
range: "short",
|
||||
attackerAim: "simple",
|
||||
fieldRollMode,
|
||||
rollModes
|
||||
}
|
||||
console.log("CTX", dialogContext)
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate("systems/fvtt-lethal-fantasy/templates/range-defense-dialog.hbs", dialogContext)
|
||||
|
||||
@@ -990,18 +992,18 @@ export default class LethalFantasyRoll extends Roll {
|
||||
Number(rollContext.size) +
|
||||
Number(rollContext.range) +
|
||||
Number(rollContext?.attackerAim || 0)
|
||||
console.log("Modifier", fullModifier, rollContext)
|
||||
|
||||
let modifierFormula
|
||||
if (fullModifier === 0) {
|
||||
modifierFormula = "0"
|
||||
} else {
|
||||
let modAbs = Math.abs(fullModifier)
|
||||
modifierFormula = `D${modAbs+1} -1`
|
||||
modifierFormula = `D${modAbs + 1} -1`
|
||||
}
|
||||
|
||||
let rollData = { ...rollContext }
|
||||
let options = { ...rollContext }
|
||||
// Merge rollContext object into options object
|
||||
options = { ...options, ...rollContext }
|
||||
options.rollName = "Ranged Defense"
|
||||
|
||||
const rollBase = new this(rollContext.movement, options.data, rollData)
|
||||
@@ -1011,13 +1013,15 @@ export default class LethalFantasyRoll extends Roll {
|
||||
let rollD30 = await new Roll("1D30").evaluate()
|
||||
options.D30result = rollD30.total
|
||||
|
||||
let badResult = 0
|
||||
if (rollContext.movement.includes("kh")) {
|
||||
rollData.favor = "favor"
|
||||
badResult = Math.min(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 20)
|
||||
}
|
||||
if (rollContext.movement.includes("kl")) {
|
||||
rollData.favor = "disfavor"
|
||||
badResult = Math.max(rollBase.terms[0].results[0].result, rollBase.terms[0].results[1]?.result || 1)
|
||||
}
|
||||
|
||||
let dice = rollContext.movement
|
||||
let maxValue = 20 // As per latest changes (was : Number(dice.match(/\d+$/)[0])
|
||||
let rollTotal = -1
|
||||
@@ -1043,14 +1047,15 @@ export default class LethalFantasyRoll extends Roll {
|
||||
} else {
|
||||
rollTotal = diceSum
|
||||
}
|
||||
|
||||
rollBase.options = { ...rollBase.options, ...options }
|
||||
rollBase.options.resultType = resultType
|
||||
rollBase.options.rollTotal = rollTotal
|
||||
rollBase.options.diceResults = diceResults
|
||||
rollBase.options.rollTarget = options.rollTarget
|
||||
rollBase.options.titleFormula = `${dice}E + ${modifierFormula}`
|
||||
rollBase.options.titleFormula = `1D20E + ${modifierFormula}`
|
||||
rollBase.options.D30result = options.D30result
|
||||
rollBase.options.rollName = "Ranged Defense"
|
||||
rollBase.options.badResult = badResult
|
||||
rollBase.options.rollData = foundry.utils.duplicate(rollData)
|
||||
/**
|
||||
* A hook event that fires after the roll has been made.
|
||||
|
||||
Reference in New Issue
Block a user