diff options
author | iainp5 <iain.pearce.ip@gmail.com> | 2024-09-28 15:53:09 +0100 |
---|---|---|
committer | iainp5 <iain.pearce.ip@gmail.com> | 2024-09-28 15:53:09 +0100 |
commit | 59216b5bf35893809b75d96a42ed57aad43c7b57 (patch) | |
tree | 12e40ece568751849bada9dd8f1b7f987ee13103 | |
parent | bc4cad21ece173e7d6ece988cf2e8fef14905af9 (diff) | |
download | 1989-dawn-of-freedom-59216b5bf35893809b75d96a42ed57aad43c7b57.tar.gz |
Add held scoring card warning
-rw-r--r-- | rules.js | 183 |
1 files changed, 113 insertions, 70 deletions
@@ -424,70 +424,15 @@ states.choose_card = { },
card(card) {
push_undo()
- game.played_card = card
- let find_card
- if (game.active === COM) {
- find_card = game.communist_hand.indexOf(card)
- game.communist_hand.splice(find_card, 1)
- } else {
- find_card = game.democrat_hand.indexOf(card)
- game.democrat_hand.splice(find_card, 1)
- }
- game.available_ops = cards[card].ops
-
- //Check events which affect game ops
- if (game.persistent_events['perestroika'] && game.active === COM) {
- log('+1 op from C25')
- game.available_ops ++
- }
- if (game.persistent_events['sinatra_doctrine'] && game.active === DEM) {
- log('+1 op from C50')
- game.available_ops ++
- }
-
- if ((game.active === DEM && game.dem_tst_position >= 2 && game.com_tst_position <= 1 && cards[card].ops === 1) || (game.active === COM && game.com_tst_position >=2 && game.dem_tst_position <= 1 && cards[card].ops === 1)) {
- log('+1 op from Tiananmen Square Track')
- game.available_ops ++
- }
-
- console.log('prudence:', game.persistent_events['prudence'])
- if ((game.active === DEM && game.persistent_events['prudence'].DEM !== 0)) {
- if (game.available_ops > 2) {
- log(`${pluralize(game.persistent_events['prudence'].DEM,'op')} from C8`)
- } else {
- if (game.available_ops > 1) {
- log(`-1 op from C8`)
- }
- }
- game.available_ops += game.persistent_events['prudence'].DEM
- if (game.available_ops < 1) {
- game.available_ops = 1
- }
- }
-
- if (game.active === COM && game.persistent_events['prudence'].COM !== 0) {
- if (game.available_ops > 2) {
- log(`${pluralize(game.persistent_events['prudence'].COM,'op')} from C8`)
- } else if (game.available_ops > 1) {
- log(`-1 op from C8`)
- }
- game.available_ops += game.persistent_events['prudence'].COM
- if (game.available_ops < 1) {
- game.available_ops = 1
- }
- }
+ game.persistent_events['the_crowd_turns_against_ceausescu'] = true
+ //Check if player is at risk of losing game due to held scoring card
+ let scoring_cards_count = count_scoring_cards()
- //Check Ligachev
- if (game.active === DEM && game.persistent_events['ligachev'] && card !== 14) {
- log('-3 VP from C99')
- game.vp -= 3
- if (check_vp()) {
- return
- }
- game.persistent_events['ligachev'] = false
+ if (scoring_cards_count >= (8-game.round)){
+ game.state = 'confirm_card'
+ return
}
- game.state = 'play_card'
- console.log('game.state', game.state)
+ select_card(card)
},
pass() {
log('No cards remaining. Passed')
@@ -498,6 +443,18 @@ states.choose_card = { } */
}
+states.confirm_card = {
+ inactive: 'choose a card.',
+ prompt() {
+ let scoring_cards_count = count_scoring_cards()
+ view.prompt = `${pluralize(scoring_cards_count,'scoring card')} in hand with ${8-game.round} standard turns remaining. Scoring cards may not be held. Continue?`
+ gen_action('continue')
+ },
+ continue() {
+ select_card()
+ }
+}
+
states.play_card ={
get inactive() {
return `play ${clean_name(cards[game.played_card].name)}.`
@@ -3083,6 +3040,84 @@ function check_reformer() { console.log('game.playable_cards[67].playable', game.playable_cards[67].playable)
}
+function count_scoring_cards() {
+ let scoring_check
+ if (game.active === DEM) {
+ scoring_check = game.democrat_hand.filter(card => scoring_cards.includes(card)).length
+ } else {
+ scoring_check = game.democrat_hand.filter(card => scoring_cards.includes(card)).length
+ }
+ return scoring_check
+}
+
+function select_card(card){
+ game.played_card = card
+ game.temp = 0
+ let find_card
+ if (game.active === COM) {
+ find_card = game.communist_hand.indexOf(card)
+ game.communist_hand.splice(find_card, 1)
+ } else {
+ find_card = game.democrat_hand.indexOf(card)
+ game.democrat_hand.splice(find_card, 1)
+ }
+ game.available_ops = cards[card].ops
+
+ //Check events which affect game ops
+ if (game.persistent_events['perestroika'] && game.active === COM) {
+ log('+1 op from C25')
+ game.available_ops ++
+ }
+ if (game.persistent_events['sinatra_doctrine'] && game.active === DEM) {
+ log('+1 op from C50')
+ game.available_ops ++
+ }
+
+ if ((game.active === DEM && game.dem_tst_position >= 2 && game.com_tst_position <= 1 && cards[card].ops === 1) || (game.active === COM && game.com_tst_position >=2 && game.dem_tst_position <= 1 && cards[card].ops === 1)) {
+ log('+1 op from Tiananmen Square Track')
+ game.available_ops ++
+ }
+
+ console.log('prudence:', game.persistent_events['prudence'])
+ if ((game.active === DEM && game.persistent_events['prudence'].DEM !== 0)) {
+ if (game.available_ops > 2) {
+ log(`${pluralize(game.persistent_events['prudence'].DEM,'op')} from C8`)
+ } else {
+ if (game.available_ops > 1) {
+ log(`-1 op from C8`)
+ }
+ }
+ game.available_ops += game.persistent_events['prudence'].DEM
+ if (game.available_ops < 1) {
+ game.available_ops = 1
+ }
+ }
+
+ if (game.active === COM && game.persistent_events['prudence'].COM !== 0) {
+ if (game.available_ops > 2) {
+ log(`${pluralize(game.persistent_events['prudence'].COM,'op')} from C8`)
+ } else if (game.available_ops > 1) {
+ log(`-1 op from C8`)
+ }
+ game.available_ops += game.persistent_events['prudence'].COM
+ if (game.available_ops < 1) {
+ game.available_ops = 1
+ }
+ }
+
+ //Check Ligachev
+ if (game.active === DEM && game.persistent_events['ligachev'] && card !== 14) {
+ log('-3 VP from C99')
+ game.vp -= 3
+ if (check_vp()) {
+ return
+ }
+ game.persistent_events['ligachev'] = false
+ }
+ game.state = 'play_card'
+ console.log('game.state', game.state)
+}
+
// =========== MOVING THROUGH TURNS ============
function end_round() {
@@ -3201,12 +3236,17 @@ function end_round() { // Resolve end action round
- if(game.round_player === COM && game.stasi_card > 0 ) {
+ if(game.round_player === COM && game.persistent_events['stasi'] ) {
game.round_player = DEM
if (game.active !== DEM) {
next_player()
}
- game.state = 'stasi_play_card'
+ if (game.democrat_hand.includes(game.stasi_card)) {
+ game.state = 'stasi_play_card'
+ } else {
+ game.stasi_card = 0
+ game.state = 'choose_card'
+ }
return
} else if (game.round_player === COM && game.round === 8) {
clear_undo()
@@ -3592,7 +3632,7 @@ function reset_power() { if (game.persistent_events['the_crowd_turns_against_ceausescu'] && game.pwr_struggle_in === 'Romania'){
permanently_remove(54)
//game.table_cards = game.table_cards.filter(card => card !== 54)
- game.persistent_events['the_crowd_turns_against_ceausescu'] = false
+ //game.persistent_events['the_crowd_turns_against_ceausescu'] = false
}
if (game.pwr_struggle_in === 'Romania' && game.persistent_events['securitate']){
permanently_remove(70)
@@ -3958,7 +3998,7 @@ function vm_return() { }
//game.view_opp_hand = false
- console.log('in vm_return, game.vm_return:', game.vm_return, 'game.return_state:', game.return_state, 'game.vm_infl_to_do', game.vm_infl_to_do, 'game.vm_event_to_do', game.vm_event_to_do)
+ console.log('in vm_return, game.return:', game.return, 'game.return_state:', game.return_state, 'game.vm_infl_to_do', game.vm_infl_to_do, 'game.vm_event_to_do', game.vm_event_to_do)
/*if (!game.vm_infl_to_do && !game.vm_event_to_do) {
if (game.round_player !== game.active) {
change_player()
@@ -6150,7 +6190,7 @@ states.vm_play_event_from_discard = { game.vm_event = card
game.vm_available_ops = cards[card].ops
game.discard = false
- game.return = game.active
+ //game.return = game.active Does turning this off cause problems?
console.log('card:', card)
if (switch_events.includes(card)) {next_player()}
goto_vm(card)
@@ -6652,6 +6692,7 @@ states.vm_kremlin_coup_choose_country = { vm_kremlin_coup_elite()
},
done() {
+ game.temp = 0
vm_next()
}
}
@@ -6662,10 +6703,10 @@ states.vm_kremlin_coup_take_control = { },
prompt() {
if (game.valid_spaces.length === 0){
- view.prompt = 'Kremlin Coup. Elite space controlled: done.'
+ view.prompt = `Kremlin Coup! ${country_name(game.vm_active_country)}'s Elite space is already controlled.`
gen_action('done')
} else {
- view.prompt = `Kremlin Coup: Take control of the Elite space in ${country_name(game.vm_active_country)}.`
+ view.prompt = `Kremlin Coup! Take control of the Elite space in ${country_name(game.vm_active_country)}.`
for (let space_id of game.valid_spaces) {
gen_action_infl(spaces[space_id].name_unique);
}
@@ -6673,6 +6714,8 @@ states.vm_kremlin_coup_take_control = { },
infl(space) {
vm_take_control(space)
+ game.state = 'vm_kremlin_coup_sc_prep'
+ return
},
done() {
if (game.vm_active_country === 'East_Germany') {game.selected_space = 3 }
@@ -8054,7 +8097,7 @@ CODE[35] = [ // Heal our Bleeding Wounds* CODE[36] = [ // Dash for the West*
[ vm_permanently_remove ],
- [ vm_prompt, 'select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately.' ],
+ [ vm_prompt, 'Dash for the West: select any Democratic event with an asterix(*) from the discard pile. Event occurs immediately.' ],
[ vm_dash_for_the_west ],
[ vm_return ],
]
|