Fix challenge rolls
This commit is contained in:
@@ -550,6 +550,7 @@
|
|||||||
},
|
},
|
||||||
"Roll": {
|
"Roll": {
|
||||||
"save": "Save roll {save}",
|
"save": "Save roll {save}",
|
||||||
|
"changeDice": "Change dice",
|
||||||
"damage": "Jet de dégâts <br> {item}",
|
"damage": "Jet de dégâts <br> {item}",
|
||||||
"attack": "Jet d'attaque <br> {item}",
|
"attack": "Jet d'attaque <br> {item}",
|
||||||
"roll": "Roll",
|
"roll": "Roll",
|
||||||
|
|||||||
@@ -67,6 +67,51 @@ export const DEFENSE_DICE_VALUES = {
|
|||||||
"d10": "D10"
|
"d10": "D10"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const CHOICE_DICE = {
|
||||||
|
"D4": "D4",
|
||||||
|
"D6": "D6",
|
||||||
|
"D8": "D8",
|
||||||
|
"D10": "D10"
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CHOICE_MODIFIERS = {
|
||||||
|
"-9": "-9",
|
||||||
|
"-8": "-8",
|
||||||
|
"-7": "-7",
|
||||||
|
"-6": "-6",
|
||||||
|
"-5": "-5",
|
||||||
|
"-4": "-4",
|
||||||
|
"-3": "-3",
|
||||||
|
"-2": "-2",
|
||||||
|
"-1": "-1",
|
||||||
|
"+0": "0",
|
||||||
|
"+1": "+1",
|
||||||
|
"+2": "+2",
|
||||||
|
"+3": "+3",
|
||||||
|
"+4": "+4",
|
||||||
|
"+5": "+5",
|
||||||
|
"+6": "+6",
|
||||||
|
"+7": "+7",
|
||||||
|
"+8": "+8",
|
||||||
|
"+9": "+9",
|
||||||
|
"+10": "+10",
|
||||||
|
"+11": "+11",
|
||||||
|
"+12": "+12",
|
||||||
|
"+13": "+13",
|
||||||
|
"+14": "+14",
|
||||||
|
"+15": "+15",
|
||||||
|
"+16": "+16",
|
||||||
|
"+17": "+17",
|
||||||
|
"+18": "+18",
|
||||||
|
"+19": "+19",
|
||||||
|
"+20": "+20",
|
||||||
|
"+21": "+21",
|
||||||
|
"+22": "+22",
|
||||||
|
"+23": "+23",
|
||||||
|
"+24": "+24",
|
||||||
|
"+25": "+25"
|
||||||
|
}
|
||||||
|
|
||||||
export const ASCII = `
|
export const ASCII = `
|
||||||
······················································································································
|
······················································································································
|
||||||
: :
|
: :
|
||||||
@@ -101,5 +146,7 @@ export const SYSTEM = {
|
|||||||
MONEY,
|
MONEY,
|
||||||
ASCII,
|
ASCII,
|
||||||
ROLL_TYPE,
|
ROLL_TYPE,
|
||||||
|
CHOICE_MODIFIERS,
|
||||||
|
CHOICE_DICE,
|
||||||
DEV_MODE,
|
DEV_MODE,
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-43
@@ -1,4 +1,4 @@
|
|||||||
import { ROLL_TYPE } from "../config/system.mjs"
|
import { ROLL_TYPE, SYSTEM } from "../config/system.mjs"
|
||||||
import LethalFantasyUtils from "../utils.mjs"
|
import LethalFantasyUtils from "../utils.mjs"
|
||||||
|
|
||||||
export default class LethalFantasyRoll extends Roll {
|
export default class LethalFantasyRoll extends Roll {
|
||||||
@@ -165,16 +165,20 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
||||||
*/
|
*/
|
||||||
static async prompt(options = {}) {
|
static async prompt(options = {}) {
|
||||||
let dice = "1d20"
|
let dice = "1D20"
|
||||||
let maxValue = 20
|
let maxValue = 20
|
||||||
let formula = "1d20"
|
let formula = "1D20"
|
||||||
|
let hasModifier = true
|
||||||
|
let hasChangeDice = false
|
||||||
if (options.rollType === "challenge") {
|
if (options.rollType === "challenge") {
|
||||||
if ( options.rollTarget.rollKey === "dying") {
|
if ( options.rollTarget.rollKey === "dying") {
|
||||||
dice = options.rollTarget.value
|
dice = options.rollTarget.value
|
||||||
maxValue = Number(options.rollTarget.value.match(/\d+/)[0])
|
maxValue = Number(options.rollTarget.value.match(/\d+/)[0])
|
||||||
formula = `${dice}`
|
formula = `${dice}`
|
||||||
|
hasModifier = false
|
||||||
|
hasChangeDice = true
|
||||||
} else {
|
} else {
|
||||||
dice = "1d20"
|
dice = "1D20"
|
||||||
maxValue = 20
|
maxValue = 20
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,43 +190,9 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
default: "public",
|
default: "public",
|
||||||
})
|
})
|
||||||
|
|
||||||
const choiceModifier = {
|
|
||||||
"-9": "-9",
|
const choiceModifier = SYSTEM.CHOICE_MODIFIERS
|
||||||
"-8": "-8",
|
const choiceDice = SYSTEM.CHOICE_DICE
|
||||||
"-7": "-7",
|
|
||||||
"-6": "-6",
|
|
||||||
"-5": "-5",
|
|
||||||
"-4": "-4",
|
|
||||||
"-3": "-3",
|
|
||||||
"-2": "-2",
|
|
||||||
"-1": "-1",
|
|
||||||
"+0": "0",
|
|
||||||
"+1": "+1",
|
|
||||||
"+2": "+2",
|
|
||||||
"+3": "+3",
|
|
||||||
"+4": "+4",
|
|
||||||
"+5": "+5",
|
|
||||||
"+6": "+6",
|
|
||||||
"+7": "+7",
|
|
||||||
"+8": "+8",
|
|
||||||
"+9": "+9",
|
|
||||||
"+10": "+10",
|
|
||||||
"+11": "+11",
|
|
||||||
"+12": "+12",
|
|
||||||
"+13": "+13",
|
|
||||||
"+14": "+14",
|
|
||||||
"+15": "+15",
|
|
||||||
"+16": "+16",
|
|
||||||
"+17": "+17",
|
|
||||||
"+18": "+18",
|
|
||||||
"+19": "+19",
|
|
||||||
"+20": "+20",
|
|
||||||
"+21": "+21",
|
|
||||||
"+22": "+22",
|
|
||||||
"+23": "+23",
|
|
||||||
"+24": "+24",
|
|
||||||
"+25": "+25"
|
|
||||||
}
|
|
||||||
|
|
||||||
let modifier = "+0"
|
let modifier = "+0"
|
||||||
let targetName
|
let targetName
|
||||||
@@ -232,8 +202,13 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
isChallenge: options.rollType === "challenge",
|
isChallenge: options.rollType === "challenge",
|
||||||
rollTarget: options.rollTarget,
|
rollTarget: options.rollTarget,
|
||||||
rollModes,
|
rollModes,
|
||||||
|
hasModifier,
|
||||||
|
hasChangeDice,
|
||||||
|
baseValue: options.rollTarget.value,
|
||||||
|
changeDice: `${dice}`,
|
||||||
fieldRollMode,
|
fieldRollMode,
|
||||||
choiceModifier,
|
choiceModifier,
|
||||||
|
choiceDice,
|
||||||
formula,
|
formula,
|
||||||
dice,
|
dice,
|
||||||
hasTarget: options.hasTarget,
|
hasTarget: options.hasTarget,
|
||||||
@@ -268,8 +243,10 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
|
|
||||||
let treshold
|
let treshold
|
||||||
let fullModifier = 0
|
let fullModifier = 0
|
||||||
|
dice = rollContext.changeDice || dice
|
||||||
if (options.rollType === "challenge") {
|
if (options.rollType === "challenge") {
|
||||||
let bonus = (options.rollTarget.rollKey === "dying") ? 0 : options.rollTarget.bonus
|
if (hasModifier) {
|
||||||
|
let bonus = (options.rollTarget.rollKey === "dying") ? 0 : Number(options.rollTarget.value)
|
||||||
fullModifier = rollContext.modifier === "" ? 0 : parseInt(rollContext.modifier, 10) + bonus
|
fullModifier = rollContext.modifier === "" ? 0 : parseInt(rollContext.modifier, 10) + bonus
|
||||||
if (fullModifier < 0) {
|
if (fullModifier < 0) {
|
||||||
let modAbs = Math.abs(fullModifier)
|
let modAbs = Math.abs(fullModifier)
|
||||||
@@ -279,7 +256,12 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
} else {
|
} else {
|
||||||
formula = `${dice} + 1d0`
|
formula = `${dice} + 1d0`
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fullModifier = 0
|
||||||
|
formula = `${dice}`
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
maxValue = Number(dice.match(/\d+/)[0])
|
||||||
|
|
||||||
const rollData = {
|
const rollData = {
|
||||||
type: options.rollType,
|
type: options.rollType,
|
||||||
@@ -319,10 +301,13 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
diceResults.push( {dice: `${dice}-1`, value: d20result-1})
|
diceResults.push( {dice: `${dice}-1`, value: d20result-1})
|
||||||
d20sum += (d20result - 1)
|
d20sum += (d20result - 1)
|
||||||
}
|
}
|
||||||
|
if (hasModifier) {
|
||||||
let minus1 = (fullModifier === 0) ? 0 : 1
|
let minus1 = (fullModifier === 0) ? 0 : 1
|
||||||
diceResults.push({ dice: `${roll.dice[1].formula}-${minus1}`, value: roll.dice[1].results[0].result - minus1 })
|
diceResults.push({ dice: `${roll.dice[1].formula}-${minus1}`, value: roll.dice[1].results[0].result - minus1 })
|
||||||
rollTotal = Math.max(d20sum + roll.dice[1].results[0].result - minus1, 0)
|
rollTotal = Math.max(d20sum + roll.dice[1].results[0].result - minus1, 0)
|
||||||
|
} else {
|
||||||
|
rollTotal = d20sum
|
||||||
|
}
|
||||||
} else if (options.rollType === ROLL_TYPE.RESOURCE) {
|
} else if (options.rollType === ROLL_TYPE.RESOURCE) {
|
||||||
//resultType = roll.total === 1 || roll.total === 2 ? "failure" : "success"
|
//resultType = roll.total === 1 || roll.total === 2 ? "failure" : "success"
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"download": "#{DOWNLOAD}#",
|
"download": "#{DOWNLOAD}#",
|
||||||
"url": "#{URL}#",
|
"url": "#{URL}#",
|
||||||
"license": "LICENSE",
|
"license": "LICENSE",
|
||||||
"version": "12.0.9",
|
"version": "12.0.10",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Uberwald",
|
"name": "Uberwald",
|
||||||
|
|||||||
@@ -4,9 +4,14 @@
|
|||||||
{{#if isChallenge}}
|
{{#if isChallenge}}
|
||||||
<fieldSet>
|
<fieldSet>
|
||||||
<legend>{{localize "LETHALFANTASY.Label.challenge"}}</legend>
|
<legend>{{localize "LETHALFANTASY.Label.challenge"}}</legend>
|
||||||
{{log this}}
|
{{#if hasModifier}}
|
||||||
|
<div class="dialog-save">{{upperCase rollTarget.rollKey}} : {{formula}} + {{baseValue}}</div>
|
||||||
|
{{else}}
|
||||||
<div class="dialog-save">{{upperCase rollTarget.rollKey}} : {{formula}}</div>
|
<div class="dialog-save">{{upperCase rollTarget.rollKey}} : {{formula}}</div>
|
||||||
|
{{/if}}
|
||||||
</fieldSet>
|
</fieldSet>
|
||||||
|
|
||||||
|
{{#if hasModifier}}
|
||||||
<fieldSet class="dialog-modifier">
|
<fieldSet class="dialog-modifier">
|
||||||
<legend>{{localize "LETHALFANTASY.Roll.modifier"}}</legend>
|
<legend>{{localize "LETHALFANTASY.Roll.modifier"}}</legend>
|
||||||
<select name="modifier" data-tooltip-direction="UP">
|
<select name="modifier" data-tooltip-direction="UP">
|
||||||
@@ -14,6 +19,17 @@
|
|||||||
</select>
|
</select>
|
||||||
</fieldSet>
|
</fieldSet>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if hasChangeDice}}
|
||||||
|
<fieldSet class="dialog-modifier">
|
||||||
|
<legend>{{localize "LETHALFANTASY.Roll.changeDice"}}</legend>
|
||||||
|
<select name="changeDice" data-tooltip-direction="UP">
|
||||||
|
{{selectOptions choiceDice selected=changeDice}}
|
||||||
|
</select>
|
||||||
|
</fieldSet>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
<fieldSet>
|
<fieldSet>
|
||||||
<legend>{{localize "LETHALFANTASY.Roll.visibility"}}</legend>
|
<legend>{{localize "LETHALFANTASY.Roll.visibility"}}</legend>
|
||||||
<select name="visibility">
|
<select name="visibility">
|
||||||
|
|||||||
Reference in New Issue
Block a user