From 0d3bc033f8ebf9f9700f190fe00217ee36ce883f Mon Sep 17 00:00:00 2001
From: Mischa Untaga <99098079+MischaU8@users.noreply.github.com>
Date: Sat, 25 Nov 2023 16:37:01 +0100
Subject: die colors
---
play.html | 19 +++++++++++++------
play.js | 34 +++++++++++++++++++---------------
rules.js | 29 +++++++++++++++++------------
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: '',
- B1: '',
- B2: '',
- B3: '',
- B4: '',
- B5: '',
- B6: '',
- W0: '',
- W1: '',
- W2: '',
- W3: '',
- W4: '',
- W5: '',
- W6: '',
+ B1: '',
+ B2: '',
+ B3: '',
+ B4: '',
+ D1: '',
+ D2: '',
+ D3: '',
+ D4: '',
+ D5: '',
+ D6: '',
+ W1: '',
+ W2: '',
+ W3: '',
+ W4: '',
+ W5: '',
+ W6: '',
+ // W7: '',
+ // W8: '',
PR: '',
YR: '',
RR: '',
@@ -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()
--
cgit v1.2.3