summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-10-07 16:55:32 +0100
committeriainp5 <iain.pearce.ip@gmail.com>2024-10-07 16:55:32 +0100
commit1fc8bfad7cfa6028180108e9103e904fdbb6a76f (patch)
tree00f02a047d60e05b919e3731bbef9657d6c337b3 /rules.js
parentb05884c4412a403a8fde4e58d30d96da14a9eee9 (diff)
download1989-dawn-of-freedom-1fc8bfad7cfa6028180108e9103e904fdbb6a76f.tar.gz
Adding Stasi update
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js386
1 files changed, 355 insertions, 31 deletions
diff --git a/rules.js b/rules.js
index 520de48..870c061 100644
--- a/rules.js
+++ b/rules.js
@@ -420,7 +420,7 @@ states.choose_card = {
view.prompt = 'No cards remaining: you must pass.'
gen_action('pass')
} else {
- view.prompt = 'Choose a card.'
+ view.prompt = 'Play a card.'
let available_cards
if (game.active === DEM) {
available_cards = game.democrat_hand
@@ -428,11 +428,62 @@ states.choose_card = {
available_cards = game.communist_hand
}
for (let card of available_cards) {
- gen_action('card_select', card)
+ //gen_action('card_event', card)
+
+ if (scoring_cards.includes(card)) {
+ /*view.prompt = 'Play for:'*/
+ gen_action('card_event', card)
+ return
+ }
+
+
+ //Check for Tiananmen Square Track awards special abilities
+ if ((game.active === DEM && cards[card].side !== 'C' && game.dem_tst_position >= 8 && game.com_tst_position < 8 && !game.tst_8) || (game.active === COM && cards[card].side !== 'D' && game.com_tst_position >= 8 && game.dem_tst_position < 8 && !game.tst_8)){
+ gen_action('card_tst_8', card)
+ }
+
+ // Check for Reformer Rehabilitated
+
+ //console.log('game.active', game.active, 'game.playable_cards[67].playable', game.playable_cards[67].playable)
+
+
+ if (card === 67 && game.playable_cards.includes(67)){
+ if (game.active === DEM && (game.dem_tst_position > game.com_tst_position)) {
+ gen_action('card_event', card)
+ }
+ if (game.active === COM && (game.dem_tst_position < game.com_tst_position)) {
+ gen_action('card_event', card)
+ }
+ }
+
+ //Continue with normal logic
+
+ //Check if it is a card with an event which is always playable
+
+ if (cards[card].playable) {
+ get_events(card)
+ }
+
+ // Resolve cards with variable events (not Reformer)
+
+ if (card !== 67 && game.playable_cards.includes(card)) {
+ get_events(card)
+ } /*
+ if ((game.active === DEM && cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable === 1) || (game.active === COM && cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1) || (cards[game.played_card].side === 'N'&& game.playable_cards[game.played_card].playable ===1)) {
+ gen_action('event')
+ } else if ((game.active === DEM && (cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1)) || game.active === COM && (cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable ===1)) {
+ gen_action('opp_event')
+ } */
+
+ gen_action('card_influence', card)
+ if (game.active === DEM && game.dem_tst_attempted_this_turn === 0 && game.dem_tst_position <=8 || game.active === COM && game.com_tst_attempted_this_turn === 0 && game.com_tst_position <= 8) {
+ gen_action('card_tst', card)
+ }
+ gen_action('card_support_check', card)
}
}
},
- card_select(card) {
+ /*card_event(card) {
push_undo()
//Check if player is at risk of losing game due to held scoring card
if (!scoring_cards.includes(card)) {
@@ -445,11 +496,111 @@ states.choose_card = {
}
}
select_card(card)
- },
+ },*/
pass() {
log('No cards remaining. Passed')
end_round()
- }
+ },
+ card_event(card) {
+ push_undo()
+ select_card(card)
+ console.log('played event, game.active', game.active, 'game.view_opp_hand', game.view_opp_hand)
+ log_gap(`Played C${cards[game.played_card].number} for the event`)
+ if (scoring_cards.includes(game.played_card)) {game.phase = 0}
+ else {game.phase = 1}
+ game.return = game.active
+ if (switch_events.includes(game.played_card)) {next_player()}
+ game.vm_event = game.played_card
+ goto_vm(game.vm_event)
+ },
+ card_opp_event(card) {
+ push_undo()
+ select_card(card)
+ log_gap(`Played C${cards[game.played_card].number} for the event`)
+ game.phase = 1 /*Do I still need this?*/
+ game.vm_infl_to_do = true
+ game.return = game.active
+ game.vm_event = game.played_card
+ if (auto_resolve_events.includes(game.played_card) || switch_events.includes(game.played_card)) {
+ goto_vm(game.vm_event)}
+ else {
+ next_player()
+ log(`C${game.vm_event}`)
+ goto_vm(game.vm_event)
+ }
+ },
+ card_influence(card) {
+ push_undo()
+ select_card(card)
+ log_gap(`Played C${cards[game.played_card].number} to place SPs`)
+
+
+ // Check if Common European Home played for influence
+ if (game.played_card === 21) {
+ if (game.active === DEM) {
+ game.vp --
+ log('-1 VP')
+ if (check_vp()) {
+ return
+ }
+ } else {
+ game.vp ++
+ log('+1 VP')
+ if (check_vp()) {
+ return
+ }
+ }
+ }
+ // Check if card is opponent card with event that needs to be resolved
+
+ if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) {
+ if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
+ //game.phase = 1 /*Do I need this? */
+ game.vm_event_to_do = true
+ }
+ }
+
+ // If ABHR - Set AHBR tracker to true
+ if (game.persistent_events.includes(58)) {
+ game.austria_hungary_border_reopened_tracker = true
+ }
+ game.state='add_influence'
+ valid_spaces_infl()
+ },
+ card_tst(card) {
+ push_undo()
+ select_card(card)
+ log_gap(`Played C${cards[game.played_card].number} to the Tiananmen Square Track`)
+ game.state='tiananmen_square_attempt'
+ },
+ card_support_check(card) {
+ push_undo()
+ select_card(card)
+ log_gap(`Played C${cards[game.played_card].number} for support checks`)
+
+ // Check if card is opponent card with event that needs to be resolved
+ /*if (game.phase === 0 && game.active === DEM && cards[game.played_card].side === "C" && game.playable_cards[game.played_card].playable === 1 || game.phase === 0 && game.active === COM && cards[game.played_card].side === "D" && game.playable_cards[game.played_card].playable === 1 ) {
+ game.vm_event_to_do = true
+ }*/
+
+ if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) {
+ if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
+ game.vm_event_to_do = true
+ }
+ }
+
+ game.available_ops = 2
+ game.state='support_check_prep'
+ valid_spaces_sc()
+ },
+ card_tst_8(card) { /*Play card for ops and event */
+ select_card(card)
+ game.vm_event_to_do = true
+ game.vm_infl_to_do = true
+ game.tst_8 = true
+ game.state = 'vm_tst_8'
+ },
+
/*done () {
game.state = 'play_card'
} */
@@ -2095,9 +2246,79 @@ states.stasi_play_card = {
gen_action('pass')
} else {
view.prompt = `Stasi: you must play ${clean_name(cards[game.stasi_card].name)}.`
- let available_cards = [game.stasi_card]
+ /*let available_cards = [game.stasi_card]
for (let card of available_cards) {
gen_action_card(card)
+ }*/
+ let available_cards
+ if (game.active === DEM) {
+ available_cards = game.democrat_hand
+ } else {
+ available_cards = game.communist_hand
+ }
+ for (let card of available_cards) {
+ //gen_action('card_event', card)
+
+ if (scoring_cards.includes(card)) {
+ /*view.prompt = 'Play for:'*/
+ gen_action('card_event', card)
+ return
+ }
+
+ //Check if Player has Common European Home in hand
+ if (game.active === DEM) {
+ if (game.democrat_hand.includes(21) && cards[card].side === "C") {
+ gen_action('card_ceh', card)
+ }
+ } else {
+ if (game.communist_hand.includes(21) && cards[card].side === "D") {
+ gen_action('card_ceh', card)
+ }
+ }
+
+ //Check for Tiananmen Square Track awards special abilities
+ if ((game.active === DEM && cards[card].side !== 'C' && game.dem_tst_position >= 8 && game.com_tst_position < 8 && !game.tst_8) || (game.active === COM && cards[card].side !== 'D' && game.com_tst_position >= 8 && game.dem_tst_position < 8 && !game.tst_8)){
+ gen_action('card_tst_8', card)
+ }
+
+ // Check for Reformer Rehabilitated
+
+ //console.log('game.active', game.active, 'game.playable_cards[67].playable', game.playable_cards[67].playable)
+
+
+ if (card === 67 && game.playable_cards.includes(67)){
+ if (game.active === DEM && (game.dem_tst_position > game.com_tst_position)) {
+ gen_action('card_event', card)
+ }
+ if (game.active === COM && (game.dem_tst_position < game.com_tst_position)) {
+ gen_action('card_event', card)
+ }
+ }
+
+ //Continue with normal logic
+
+ //Check if it is a card with an event which is always playable
+
+ if (cards[card].playable) {
+ get_events(card)
+ }
+
+ // Resolve cards with variable events (not Reformer)
+
+ if (card !== 67 && game.playable_cards.includes(card)) {
+ get_events(card)
+ } /*
+ if ((game.active === DEM && cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable === 1) || (game.active === COM && cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1) || (cards[game.played_card].side === 'N'&& game.playable_cards[game.played_card].playable ===1)) {
+ gen_action('event')
+ } else if ((game.active === DEM && (cards[game.played_card].side === 'C' && game.playable_cards[game.played_card].playable ===1)) || game.active === COM && (cards[game.played_card].side === 'D' && game.playable_cards[game.played_card].playable ===1)) {
+ gen_action('opp_event')
+ } */
+
+ gen_action('card_influence', card)
+ if (game.active === DEM && game.dem_tst_attempted_this_turn === 0 && game.dem_tst_position <=8 || game.active === COM && game.com_tst_attempted_this_turn === 0 && game.com_tst_position <= 8) {
+ gen_action('card_tst', card)
+ }
+ gen_action('card_support_check', card)
}
}
},
@@ -2109,24 +2330,7 @@ states.stasi_play_card = {
find_card = game.democrat_hand.indexOf(card);
game.democrat_hand.splice(find_card, 1);
game.available_ops = get_card_ops(card)
- /*
- //Check for events which influence 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 ++
- }
- if (game.available_ops > 1 && game.prudence.DEM !== 0) {
- log(`${pluralize(game.prudence.DEM, ' op')} from C8`)
- game.available_ops += game.prudence.DEM
- if (game.available_ops < 1) {
- game.available_ops = 1
- }
- }*/
game.stasi_card = 0
if (game.democrat_hand.includes(21)) {
game.state = 'stasi_resolve_common_european_home'
@@ -2139,6 +2343,120 @@ states.stasi_play_card = {
log('No cards remaining. Passed')
end_round()
},
+ card_ceh(card) {
+ push_undo()
+ select_card(card)
+ game.stasi_card = 0
+ log(`${clean_name(cards[game.played_card].name)} played with Common European Home`)
+ //silent_discard(21)
+ game.vm_infl_to_do = true
+ game.vm_event_to_do = false
+ game.state = 'resolve_opponent_event'
+ },
+
+ card_event(card) {
+ push_undo()
+ select_card(card)
+ game.stasi_card = 0
+ console.log('played event, game.active', game.active, 'game.view_opp_hand', game.view_opp_hand)
+ log_gap(`Played C${cards[game.played_card].number} for the event`)
+ if (scoring_cards.includes(game.played_card)) {game.phase = 0}
+ else {game.phase = 1}
+ game.return = game.active
+ if (switch_events.includes(game.played_card)) {next_player()}
+ game.vm_event = game.played_card
+ goto_vm(game.vm_event)
+ },
+ card_opp_event(card) {
+ push_undo()
+ select_card(card)
+ game.stasi_card = 0
+ log_gap(`Played C${cards[game.played_card].number} for the event`)
+ game.phase = 1 /*Do I still need this?*/
+ game.vm_infl_to_do = true
+ game.return = game.active
+ game.vm_event = game.played_card
+ if (auto_resolve_events.includes(game.played_card) || switch_events.includes(game.played_card)) {
+ goto_vm(game.vm_event)}
+ else {
+ next_player()
+ log(`C${game.vm_event}`)
+ goto_vm(game.vm_event)
+ }
+ },
+ card_influence(card) {
+ push_undo()
+ select_card(card)
+ game.stasi_card = 0
+ log_gap(`Played C${cards[game.played_card].number} to place SPs`)
+
+
+ // Check if Common European Home played for influence
+ if (game.played_card === 21) {
+ if (game.active === DEM) {
+ game.vp --
+ log('-1 VP')
+ if (check_vp()) {
+ return
+ }
+ } else {
+ game.vp ++
+ log('+1 VP')
+ if (check_vp()) {
+ return
+ }
+ }
+ }
+ // Check if card is opponent card with event that needs to be resolved
+
+ if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) {
+ if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
+ //game.phase = 1 /*Do I need this? */
+ game.vm_event_to_do = true
+ }
+ }
+
+ // If ABHR - Set AHBR tracker to true
+ if (game.persistent_events.includes(58)) {
+ game.austria_hungary_border_reopened_tracker = true
+ }
+ game.state='add_influence'
+ valid_spaces_infl()
+ },
+ card_tst(card) {
+ push_undo()
+ select_card(card)
+ game.stasi_card = 0
+ log_gap(`Played C${cards[game.played_card].number} to the Tiananmen Square Track`)
+ game.state='tiananmen_square_attempt'
+ },
+ card_support_check(card) {
+ push_undo()
+ select_card(card)
+ log_gap(`Played C${cards[game.played_card].number} for support checks`)
+
+ // Check if card is opponent card with event that needs to be resolved
+ /*if (game.phase === 0 && game.active === DEM && cards[game.played_card].side === "C" && game.playable_cards[game.played_card].playable === 1 || game.phase === 0 && game.active === COM && cards[game.played_card].side === "D" && game.playable_cards[game.played_card].playable === 1 ) {
+ game.vm_event_to_do = true
+ }*/
+
+ if (cards[game.played_card].playable || game.playable_cards.includes(game.played_card)) {
+ if ((game.active === DEM && cards[game.played_card].side === "C" ) || (game.active === COM && cards[game.played_card].side === "D")) {
+ game.vm_event_to_do = true
+ }
+ }
+
+ game.available_ops = 2
+ game.state='support_check_prep'
+ valid_spaces_sc()
+ },
+ card_tst_8(card) { /*Play card for ops and event */
+ select_card(card)
+ game.vm_event_to_do = true
+ game.vm_infl_to_do = true
+ game.tst_8 = true
+ game.state = 'vm_tst_8'
+ },
done () {
game.stasi_card = 0
if (game.democrat_hand.includes(21)) {
@@ -3253,14 +3571,14 @@ function find_event(card) {
function get_events(card){
if (cards[card].side === 'D') {
- if (game.active === DEM) {gen_action('event')}
- if (game.active === COM) {gen_action('opp_event')}
+ if (game.active === DEM) {gen_action('card_event', card)}
+ if (game.active === COM) {gen_action('card_opp_event', card)}
}
else if (cards[card].side === 'C') {
- if (game.active === COM) {gen_action('event')}
- if (game.active === DEM) {gen_action('opp_event')}
+ if (game.active === COM) {gen_action('card_event', card)}
+ if (game.active === DEM) {gen_action('card_opp_event', card)}
} else {
- gen_action('event')
+ gen_action('card_event', card)
}
}
@@ -3433,11 +3751,13 @@ function end_round() {
}
// Resolve end action round
-
+ //Stasi check
if(game.round_player === COM && game.persistent_events.includes(13)) {
game.round_player = DEM
if (game.active !== DEM) {
next_player()
+ } else {
+ log_h3('Democratic Action Round')
}
if (game.democrat_hand.includes(game.stasi_card)) {
game.state = 'stasi_play_card'
@@ -3446,11 +3766,15 @@ function end_round() {
game.state = 'choose_card'
}
return
- } else if (game.round_player === COM && game.round === 8) {
+ }
+ //Check if in extra Action Round
+ else if (game.round_player === COM && game.round === 8) {
clear_undo()
game.state = 'end_turn_4_5_4'
return
- } else if (game.round_player===COM) {
+ }
+ //Normal round end
+ else if (game.round_player===COM) {
game.round_player = DEM
if (game.active !== DEM) {
next_player()