summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-25 16:37:01 +0100
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-11-25 16:37:01 +0100
commit0d3bc033f8ebf9f9700f190fe00217ee36ce883f (patch)
treeb60ce863129ce8bbcfdc5d7383e07f3ad4c2feba /rules.js
parent5870c99e1c54b49f6f18d4396f341137572c66f7 (diff)
downloadvotes-for-women-0d3bc033f8ebf9f9700f190fe00217ee36ce883f.tar.gz
die colors
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js29
1 files changed, 17 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index 5050d6f..aef5cb9 100644
--- a/rules.js
+++ b/rules.js
@@ -1233,7 +1233,7 @@ states.final_voting_roll = {
},
reroll() {
decrease_player_buttons(1)
- game.roll = roll_ndx(game.count, game.dice, "B", "Re-rolled")
+ game.roll = roll_ndx(game.count, game.dice, "Re-rolled")
},
next() {
next_player()
@@ -1251,7 +1251,7 @@ states.final_voting_opponent = {
},
reroll() {
decrease_player_buttons(1)
- game.opponent_roll = roll_ndx(1, game.opponent_dice, "B", "Re-rolled")
+ game.opponent_roll = roll_ndx(1, game.opponent_dice, "Re-rolled")
},
next() {
goto_final_voting_result()
@@ -1370,7 +1370,7 @@ states.campaigning = {
},
reroll() {
decrease_player_buttons(1)
- game.roll = roll_ndx_list(game.count, game.dice, "B", "Re-rolled")
+ game.roll = roll_ndx_list(game.count, game.dice, "Re-rolled")
},
next() {
goto_campaigning_assign()
@@ -2539,33 +2539,39 @@ states.vm_remove_congress = {
}
}
-function roll_ndx(n, x, color="B", prefix="Rolled") {
+const DICE_COLOR = {
+ [D4]: "B", // blue
+ [D6]: "D", // red
+ [D8]: "W", // white
+}
+
+function roll_ndx(n, x, prefix="Rolled") {
clear_undo()
let result = 0
let summary = []
for (let i = 0; i < n; ++i) {
let roll = random(x) + 1
result += roll
- summary.push(color + roll)
+ summary.push(DICE_COLOR[x] + roll)
}
log(prefix + " " + summary.join(" "))
return result
}
-function roll_ndx_list(n, x, color="B", prefix="Rolled") {
+function roll_ndx_list(n, x, prefix="Rolled") {
clear_undo()
let result = []
let summary = []
for (let i = 0; i < n; ++i) {
let roll = random(x) + 1
result.push(roll)
- summary.push(color + roll)
+ summary.push(DICE_COLOR[x] + roll)
}
log(prefix + " " + summary.join(" "))
return result
}
-function roll_ndx_count_success(n, x, color="B", prefix="Rolled") {
+function roll_ndx_count_success(n, x, prefix="Rolled") {
clear_undo()
let result = 0
let summary = []
@@ -2573,8 +2579,7 @@ function roll_ndx_count_success(n, x, color="B", prefix="Rolled") {
let roll = random(x) + 1
if (roll >= 6)
result += 1
- // TODO color for success?
- summary.push(color + roll)
+ summary.push(DICE_COLOR[x] + roll)
}
log(prefix + " " + summary.join(" "))
return result
@@ -2610,9 +2615,9 @@ states.vm_roll = {
reroll() {
decrease_player_buttons(1)
if (game.vm.roll_list)
- game.vm.roll = roll_ndx_list(game.vm.count, game.vm.d, "B", "Re-rolled")
+ game.vm.roll = roll_ndx_list(game.vm.count, game.vm.d, "Re-rolled")
else
- game.vm.roll = roll_ndx(game.vm.count, game.vm.d, "B", "Re-rolled")
+ game.vm.roll = roll_ndx(game.vm.count, game.vm.d, "Re-rolled")
},
next() {
vm_next()