summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-11-07 19:48:01 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2024-11-07 19:48:01 +0000
commit35c85d97671d2c1e2fe703973755fb2866d43ca0 (patch)
tree616aa04bd64755d45901ea41ad68cd8cf405bf08 /rules.js
parent1b364f8186a92b28b8d44226f8451fc60a6a751b (diff)
download1989-dawn-of-freedom-35c85d97671d2c1e2fe703973755fb2866d43ca0.tar.gz
Pluralize nouns endning in y
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/rules.js b/rules.js
index dbd1beb..94f4c92 100644
--- a/rules.js
+++ b/rules.js
@@ -627,10 +627,8 @@ states.play_card ={
game.return = game.active
game.vm_event = game.played_card
if (is_auto_resolve(game.played_card) || switch_events.includes(game.played_card)) {
- console.log('resolved automatically')
goto_vm(game.vm_event)}
else {
- console.log('resolved normally')
next_player()
log(`C${game.vm_event}`)
goto_vm(game.vm_event)
@@ -1656,9 +1654,10 @@ states.final_scoring_held = {
gen_action('bonus')
},
bonus() {
+ push_undo()
const held_countries = game.revolutions.filter(value => value === false).length
let vp_gain = 4*held_countries
- log(`Communist holds ${held_countries} countries: -${vp_gain} VP`)
+ log(`Communist holds power in ${pluralize(held_countries, 'country', 's')}: -${vp_gain} VP`)
game.vp -= 4*held_countries
game.temp = {'East_Germany': false, 'Poland': false, 'Czechoslovakia': false, 'Hungary': false, 'Romania': false, 'Bulgaria': false}
game.state = 'final_scoring'
@@ -2111,7 +2110,6 @@ function remove_infl(space, ops) {
function do_sc(space) {
clear_undo()
log_gap(`Support check: %${space}`)
-
// Continue with Support Check Logic
let roll = roll_d6()
@@ -3318,7 +3316,6 @@ function end_round() {
if (check_duplicates(card_check)) {
console.log('duplicate cards: card check', card_check)
- console.log('view.actions', view.actions)
const duplicates = find_duplicates(card_check)
console.log('game.strategy_deck', game.strategy_deck, 'game.strategy_discard', game.strategy_discard, 'game.strategy_removed', game.strategy_removed, 'game.persistent_events', game.persistent_events, 'game.communist_hand', game.communist_hand, 'game.democrat_hand', game.democrat_hand)
throw new Error(`Duplicate cards detected: ${duplicates.join(', ')}`)
@@ -3749,8 +3746,16 @@ function this_card() {
return game.vm_event > 0 ? game.vm_event : game.played_card
}
-const pluralize = (count, noun, suffix = 's') =>
- `${count} ${noun}${Math.abs(count) !== 1 ? suffix : ''}`
+const pluralize = (count, noun, suffix = 's') => {
+ if (Math.abs(count) === 1) {
+ return `${count} ${noun}`
+ } else {
+ if (noun.endsWith('y') && !/[aeiou]y$/.test(noun)) {
+ noun = noun.slice(0, -1) + 'ie'
+ }
+ return `${count} ${noun}${suffix}`
+ }
+}
function clean_name(str) {
if (str && str.slice(-1) === '*') {
@@ -4066,7 +4071,6 @@ function vm_return() {
delete game.vm_influence_added
delete game.communist_hand_red
- console.log('in vm_return, game.active', game.active)
game.vm_event = 0 /*Reset to 0 now that event has been completed. Hopefully this doesn't cause issues! */
if (game.persistent_events.includes(C_AUSTRIA_HUNGARY_BORDER_REOPENED)) {
reset_austria_hungary_border_reopened()
@@ -5765,7 +5769,6 @@ states.vm_remove_all_infl = {
states.vm_support_check_prep = {
inactive: 'do support checks.',
prompt () {
- console.log('in vm_support_check_prep', game.valid_spaces)
if (game.valid_spaces.length === 0) {
view.prompt = `${clean_name(cards[this_card()].name)}: no valid targets for support check.`
gen_action('done')
@@ -5899,7 +5902,6 @@ states.vm_1_support_check_prep = {
states.vm_do_support_check = {
inactive: 'do support checks.',
prompt () {
- console.log('in vm_do_support_check')
view.prompt = `Support check: ${spaces[game.selected_space].name_unique}. Roll a die.`
gen_action('roll')
},
@@ -6947,10 +6949,10 @@ states.vm_new_years_eve_party = {
log('Chooses to end the game. There will be no final scoring')
let power = game.revolutions.filter(value => value === false).length
if (power > 3) {
- log(`Communist holds power in ${power} countries. -3 VP`)
+ log(`Communist holds power in ${pluralize(power, 'country', 's')}. -3 VP`)
game.vp -= 3
} else {
- log(`Communist holds power in ${power} countries. +3 VP`)
+ log(`Communist holds power in ${pluralize(power, 'country', 's')}. +3 VP`)
game.vp += 3
}
if (check_vp()) {