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

@ -62,16 +62,19 @@ The Artificer comes with a few supplemental commands to the main rolling command
* Parameters for rolling: * Parameters for rolling:
| Paramater | Required? | Repeatable? | Description | | Paramater | Required? | Repeatable? | Description |
|---------------|-------------|---------------|------------------------------------------------------------------------------------------------------------------------------------| |---------------|-------------|---------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| x | Optional | No | number of dice to roll, if omitted, 1 is used | | x | Optional | No | number of dice to roll, if omitted, 1 is used |
| dy | Required | No | size of dice to roll, d20 = 20 sided die | | dy | Required | No | size of dice to roll, d20 = 20 sided die |
| dz or dlz | Optional | No | drops the lowest z dice, cannot be used any other drop or keep options | | dz or dlz | Optional | No | drops the lowest z dice, cannot be used with any other drop or keep options |
| kz or khz | Optional | No | keeps the highest z dice, cannot be used any other drop or keep options | | kz or khz | Optional | No | keeps the highest z dice, cannot be used with any other drop or keep options |
| dhz | Optional | No | drops the highest z dice, cannot be used any other drop or keep options | | dhz | Optional | No | drops the highest z dice, cannot be used with any other drop or keep options |
| klz | Optional | No | keeps the lowest z dice, cannot be used any other drop or keep options | | klz | Optional | No | keeps the lowest z dice, cannot be used with any other drop or keep options |
| ra | Optional | Yes | rerolls any rolls that match a, r3 will reroll any dice that land on 3, throwing out old rolls | | ra or r=a | Optional | Yes | rerolls any rolls that match a, r3 will reroll every die that land on 3, throwing out old rolls, cannot be used with ro |
| r<a | Optional | Yes | 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 | | r<a | Optional | Yes | 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 |
| r>a | Optional | Yes | 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 | | r>a | Optional | Yes | 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 |
| roa or ro=a | Optional | Yes | rerolls any rolls that match a, r3 will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with r |
| ro<a | Optional | Yes | rerolls any rolls that are less than or equal to a, r3 will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with r |
| ro>a | Optional | Yes | rerolls any rolls that are greater than or equal to a, r3 will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with r |
| csq or cs=q | Optional | Yes | changes crit score to q | | csq or cs=q | Optional | Yes | changes crit score to q |
| cs<q | Optional | Yes | changes crit score to be less than or equal to q | | cs<q | Optional | Yes | changes crit score to be less than or equal to q |
| cs>q | Optional | Yes | changes crit score to be greater than or equal to q | | cs>q | Optional | Yes | changes crit score to be greater than or equal to q |

View File

@ -249,15 +249,27 @@ export const constantCmds = {
inline: true inline: true
}, { }, {
name: "`ra` or `r=q` [Optional]", 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 inline: true
}, { }, {
name: "`r<q` [Optional]", 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 inline: true
}, { }, {
name: "`r>q` [Optional]", 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 inline: true
}, { }, {
name: "`csq` or `cs=q` [Optional]", name: "`csq` or `cs=q` [Optional]",

View File

@ -59,6 +59,7 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
}, },
reroll: { reroll: {
on: false, on: false,
once: false,
nums: <number[]>[] nums: <number[]>[]
}, },
critScore: { critScore: {
@ -146,12 +147,19 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
rollConf.keepLow.on = true; rollConf.keepLow.on = true;
rollConf.keepLow.count = tNum; rollConf.keepLow.count = tNum;
break; break;
case "ro":
case "ro=":
rollConf.reroll.once = true;
// falls through as ro/ro= functions the same as r
case "r": case "r":
case "r=": case "r=":
// Configure Reroll (this can happen multiple times) // Configure Reroll (this can happen multiple times)
rollConf.reroll.on = true; rollConf.reroll.on = true;
rollConf.reroll.nums.push(tNum); rollConf.reroll.nums.push(tNum);
break; break;
case "ro>":
rollConf.reroll.once = true;
// falls through as ro> functions the same as r
case "r>": case "r>":
// Configure reroll for all numbers greater than or equal to tNum (this could happen multiple times, but why) // Configure reroll for all numbers greater than or equal to tNum (this could happen multiple times, but why)
rollConf.reroll.on = true; rollConf.reroll.on = true;
@ -160,8 +168,11 @@ export const roll = (rollStr: string, maximiseRoll: boolean, nominalRoll: boolea
rollConf.reroll.nums.push(i); rollConf.reroll.nums.push(i);
} }
break; break;
case "ro<":
rollConf.reroll.once = true;
// falls through as ro< functions the same as r
case "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; rollConf.reroll.on = true;
for (let i = 1; i <= tNum; i++) { for (let i = 1; i <= tNum; i++) {
log(LT.LOG, `Handling roll ${rollStr} | Parsing r< ${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 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; rollSet[i].rerolled = true;
// Copy the template to fill out for this iteration // Copy the template to fill out for this iteration