1
1
mirror of https://github.com/Burn-E99/TheArtificer.git synced 2026-01-08 21:37:54 -05:00

Added Reroll Once option, which cannot be used with the standard reroll option

This commit is contained in:
Ean Milligan (Bastion)
2022-05-17 01:09:01 -04:00
parent 54a6a900d3
commit 0cafda573f
3 changed files with 50 additions and 23 deletions

View File

@ -249,15 +249,27 @@ export const constantCmds = {
inline: true
}, {
name: "`ra` or `r=q` [Optional]",
value: "Rerolls any rolls that match `a`, `r3` will reroll any dice that land on 3, throwing out old rolls",
value: "Rerolls any rolls that match `a`, `r3` will reroll every die that land on 3, throwing out old rolls, cannot be used with `ro`",
inline: true
}, {
name: "`r<q` [Optional]",
value: "Rerolls any rolls that are less than or equal to `a`, `r3` will reroll any dice that land on 3, 2, or 1, throwing out old rolls",
value: "Rerolls any rolls that are less than or equal to `a`, `r3` will reroll every die that land on 3, 2, or 1, throwing out old rolls, cannot be used with `ro`",
inline: true
}, {
name: "`r>q` [Optional]",
value: "Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll any dice that land on 3 or greater, throwing out old rolls",
value: "Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`",
inline: true
}, {
name: "`roa` or `ro=q` [Optional]",
value: "Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`",
inline: true
}, {
name: "`ro<q` [Optional]",
value: "Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`",
inline: true
}, {
name: "`ro>q` [Optional]",
value: "Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`",
inline: true
}, {
name: "`csq` or `cs=q` [Optional]",

View File

@ -59,6 +59,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
},
reroll: {
on: false,
once: false,
nums: <number[]>[]
},
critScore: {
@ -146,12 +147,19 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
rollConf.keepLow.on = true;
rollConf.keepLow.count = tNum;
break;
case "ro":
case "ro=":
rollConf.reroll.once = true;
// falls through as ro/ro= functions the same as r
case "r":
case "r=":
// Configure Reroll (this can happen multiple times)
rollConf.reroll.on = true;
rollConf.reroll.nums.push(tNum);
break;
case "ro>":
rollConf.reroll.once = true;
// falls through as ro> functions the same as r
case "r>":
// Configure reroll for all numbers greater than or equal to tNum (this could happen multiple times, but why)
rollConf.reroll.on = true;
@ -160,8 +168,11 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
rollConf.reroll.nums.push(i);
}
break;
case "ro<":
rollConf.reroll.once = true;
// falls through as ro< functions the same as r
case "r<":
// Configure CritScore for all numbers less than or equal to tNum (this could happen multiple times, but why)
// Configure reroll for all numbers less than or equal to tNum (this could happen multiple times, but why)
rollConf.reroll.on = true;
for (let i = 1; i <= tNum; i++) {
log(LT.LOG, `Handling roll ${rollStr} | Parsing r< ${i}`);
@ -342,7 +353,8 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
}
// If we need to reroll this roll, flag its been replaced and...
if (rollConf.reroll.on && rollConf.reroll.nums.indexOf(rollSet[i].roll) >= 0) {
// This big boolean statement first checks if reroll is on, if the roll is within the reroll range, and finally if ro is ON, make sure we haven't already rerolled the roll
if (rollConf.reroll.on && rollConf.reroll.nums.indexOf(rollSet[i].roll) >= 0 && (!rollConf.reroll.once || rollConf.reroll.once && !rollSet[i ? (i - 1) : i].rerolled)) {
rollSet[i].rerolled = true;
// Copy the template to fill out for this iteration