summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.html19
-rw-r--r--play.js34
-rw-r--r--rules.js29
3 files changed, 49 insertions, 33 deletions
diff --git a/play.html b/play.html
index 0d1eb33..1be6ee3 100644
--- a/play.html
+++ b/play.html
@@ -68,17 +68,24 @@ body.Opposition header.your_turn { background-color: var(--opp-75); }
background-repeat: no-repeat;
}
-#log .white {
- background-image: url(images/die_black_pips.svg);
+#log .die_d4 {
+ background-image: url(images/die_white_pips.svg);
background-size: 600% 100%;
- background-color: #fff;
- border: 1px solid #444;
+ background-color: #4397D4;
+ border: 1px solid #222;
}
-#log .black {
+#log .die_d6 {
background-image: url(images/die_white_pips.svg);
background-size: 600% 100%;
- background-color: #666;
+ background-color: #DE5646;
+ border: 1px solid #222;
+}
+
+#log .die_d8 {
+ background-image: url(images/die_black_pips.svg);
+ background-size: 600% 100%;
+ background-color: white;
border: 1px solid #222;
}
diff --git a/play.js b/play.js
index 0cdc0fe..1ff0d02 100644
--- a/play.js
+++ b/play.js
@@ -525,20 +525,24 @@ function sub_us_state_name(_match, p1, _offset, _string) {
// TODO blue d4, red d6, white d8
const ICONS = {
- B0: '<span class="icon black d0"></span>',
- B1: '<span class="icon black d1"></span>',
- B2: '<span class="icon black d2"></span>',
- B3: '<span class="icon black d3"></span>',
- B4: '<span class="icon black d4"></span>',
- B5: '<span class="icon black d5"></span>',
- B6: '<span class="icon black d6"></span>',
- W0: '<span class="icon white d0"></span>',
- W1: '<span class="icon white d1"></span>',
- W2: '<span class="icon white d2"></span>',
- W3: '<span class="icon white d3"></span>',
- W4: '<span class="icon white d4"></span>',
- W5: '<span class="icon white d5"></span>',
- W6: '<span class="icon white d6"></span>',
+ B1: '<span class="icon die_d4 d1"></span>',
+ B2: '<span class="icon die_d4 d2"></span>',
+ B3: '<span class="icon die_d4 d3"></span>',
+ B4: '<span class="icon die_d4 d4"></span>',
+ D1: '<span class="icon die_d6 d1"></span>',
+ D2: '<span class="icon die_d6 d2"></span>',
+ D3: '<span class="icon die_d6 d3"></span>',
+ D4: '<span class="icon die_d6 d4"></span>',
+ D5: '<span class="icon die_d6 d5"></span>',
+ D6: '<span class="icon die_d6 d6"></span>',
+ W1: '<span class="icon die_d8 d1"></span>',
+ W2: '<span class="icon die_d8 d2"></span>',
+ W3: '<span class="icon die_d8 d3"></span>',
+ W4: '<span class="icon die_d8 d4"></span>',
+ W5: '<span class="icon die_d8 d5"></span>',
+ W6: '<span class="icon die_d8 d6"></span>',
+ // W7: '<span class="icon die_d8 d7"></span>',
+ // W8: '<span class="icon die_d8 d8"></span>',
PR: '<span class="icon purple_campaigner"></span>',
YR: '<span class="icon yellow_campaigner"></span>',
RR: '<span class="icon red_campaigner"></span>',
@@ -574,7 +578,7 @@ function on_log(text) { // eslint-disable-line no-unused-vars
text = text.replace(/\b[PYR]R\b/g, sub_icon)
text = text.replace(/\b[PYR]C|PYC\b/g, sub_icon)
text = text.replace(/\b[BC]M|GV|RX\b/g, sub_icon)
- text = text.replace(/\b[BW]\d\b/g, sub_icon)
+ text = text.replace(/\b[BDW]\d\b/g, sub_icon)
if (text.match(/^\.h1/)) {
text = text.substring(4)
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()