summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/play.js b/play.js
index 9fa6e69..33220a5 100644
--- a/play.js
+++ b/play.js
@@ -753,14 +753,14 @@ function on_update() {
// UPDATE PLAYER INFO
if (view.is_pwr_struggle) {
- roles.Democrat.stat.textContent = `${view.democrat_power_hand} Power cards`
- roles.Communist.stat.textContent = `${view.communist_power_hand} Power cards`
+ roles.Democrat.stat.textContent = `${pluralize(view.democrat_power_hand, 'Power card')}`
+ roles.Communist.stat.textContent = `${pluralize(view.communist_power_hand, 'Power card')}`
} else {
- roles.Democrat.stat.textContent = `${view.democrat_hand} cards`
- roles.Communist.stat.innerText = `${view.communist_hand} cards`
+ roles.Democrat.stat.textContent = `${pluralize(view.democrat_hand,'card')}`
+ roles.Communist.stat.innerText = `${pluralize(view.communist_hand, 'card')}`
}
- ui.turn_info.innerText = `Strategy deck: ${view.strategy_deck} cards`
+ ui.turn_info.innerText = `Strategy deck: ${pluralize(view.strategy_deck, 'card')}`
// UPDATE TRACK MARKERS
@@ -1152,6 +1152,14 @@ function on_log(text, ix) {
return p
}
+const pluralize = (count, noun, suffix = 's') => {
+ if (Math.abs(count) === 1) {
+ return `${count} ${noun}`
+ } else {
+ return `${count} ${noun}${suffix}`
+ }
+}
+
// =========================== VISUAL FUNCTIONS ==========================================#
function on_focus_card_tip(card_number) {