summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriainp5 <iain.pearce.ip@gmail.com>2024-11-01 22:09:44 +0000
committeriainp5 <iain.pearce.ip@gmail.com>2024-11-01 22:09:44 +0000
commit859c41f4e1c6682f07e2ee5f16899e8dadf161f9 (patch)
tree7f759197ad0a140a810b8792c654ca058cfa79c5
parentf9512f66f3fbca1fb3f92549588e84f410deb77a (diff)
download1989-dawn-of-freedom-859c41f4e1c6682f07e2ee5f16899e8dadf161f9.tar.gz
Remove table cards
-rw-r--r--rules.js76
1 files changed, 21 insertions, 55 deletions
diff --git a/rules.js b/rules.js
index 50df92b..40d58b3 100644
--- a/rules.js
+++ b/rules.js
@@ -225,6 +225,7 @@ const switch_events = [6, 20, 71]
const one_turn_events = [ 8, 13, 25, 50, 63, 74, 49, 58, 59, 100, 101 ]
const PC_TACTIC_FAILS = 52
+const THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED = 540
// COUNTRY CONSTANTS
@@ -254,7 +255,6 @@ exports.setup = function (seed, scenario, options) {
vm_event: 0,
played_card: 0,
- table_cards: [],
available_ops: 0,
vm_available_ops: 0,
valid_spaces: [],
@@ -340,7 +340,6 @@ exports.view = function(state, player) {
actions: null,
played_card: game.played_card,
- table_cards: game.table_cards,
valid_spaces: game.valid_spaces,
valid_cards: game.valid_cards,
@@ -1040,7 +1039,6 @@ states.draw_power_cards = {
log(`Democrat receives 2 cards from Communist due to C${C_ROUNDTABLE_TALKS}`)
game.dem_pwr_hand_limit += 2
game.com_pwr_hand_limit -= 2
- discard_from_table(C_ROUNDTABLE_TALKS)
game.persistent_events = game.persistent_events.filter(n => n !== C_ROUNDTABLE_TALKS)
}
@@ -1081,13 +1079,13 @@ states.draw_power_cards = {
log(`Democrat: ${game.dem_pwr_hand.length} cards`)
//Check if The Crowd Turns Against Ceausescu occurs
- if (game.table_cards.includes(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU) && game.pwr_struggle_in === 'Romania') {
+ if (game.persistent_events.includes(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU) && !game.persistent_events.includes(THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED) && game.pwr_struggle_in === 'Romania') {
if (game.active === COM) {
game.return = COM
next_player()
}
log_h3(`C${C_THE_CROWD_TURNS_AGAINST_CEAUSESCU}`)
- game.persistent_events.push(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)
+ game.persistent_events.push(THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED)
game.state = 'the_crowd_turns_against_ceausescu_prep'
} else {
log_h2('Raise the Stakes')
@@ -1428,18 +1426,7 @@ states.power_struggle = {
game.phase = 1
next_player()
do_valid_cards()
- },
- /*done () {
- if (game.phase === 7) {
- game.phase = 0
- log_msg_gap('Takes initiative')
- do_valid_cards()
- } else {
- game.phase = 0
- next_player()
- do_valid_cards()
- }
- }*/
+ }
}
states.support_loss ={
@@ -1532,7 +1519,9 @@ states.vp_roll = {
score_country(game.pwr_struggle_in)
//Check if The Tyrant is Gone occurs
- if (game.table_cards.includes(97) && game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(54)) {
+ if (game.persistent_events.includes(C_THE_TYRANT_IS_GONE) && game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED)) {
+ game.persistent_events = game.persistent_events.filter (c => c !== C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)
+ game.persistent_events = game.persistent_events.filter (c => c !== THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED)
game.return_state = 'finish_scoring'
if (game.active !== DEM) {
next_player()
@@ -1572,7 +1561,7 @@ states.choose_power = {
score_country(game.pwr_struggle_in)
//Check if The Tyrant is Gone occurs
- if (game.table_cards.includes(97) && game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(54)) {
+ if (game.persistent_events.includes(C_THE_TYRANT_IS_GONE) && game.pwr_struggle_in === 'Romania' && game.persistent_events.includes(THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED)) {
game.return_state = 'finish_scoring'
if (game.active !== DEM) {
next_player()
@@ -1599,7 +1588,7 @@ states.the_tyrant_is_gone ={
} else {
game.return = DEM
}
- log_h3(`C97`)
+ log_h3(`C${C_THE_TYRANT_IS_GONE}`)
game.vm_event = C_THE_TYRANT_IS_GONE
goto_vm(game.vm_event)
}
@@ -2861,20 +2850,15 @@ function get_aftermath_roll() {
function add_to_persistent_events(card) {
game.persistent_events.push(card)
- game.table_cards.push(card)
remove_from_discard(card)
log(`C${card} in effect`)
}
function permanently_remove(card) {
- discard_from_table(card)
remove_from_discard(card)
- if (game.strategy_removed.includes(card)) {return}
- let card_index = game.table_cards.indexOf(card)
- if (card_index !== -1) {
- game.table_cards.splice(card_index, 1)
+ if (!game.strategy_removed.includes(card)) {
+ game.strategy_removed.push(card)
}
- game.strategy_removed.push(card)
}
function check_vp() {
@@ -3186,8 +3170,8 @@ function end_round() {
if (game.state === 'game_over') {
return}
- //Check if the card has been removed or played to table, and if a card has been not been played. If not, discard.
- if (!game.strategy_removed.includes(game.played_card) && !game.table_cards.includes(game.played_card) && game.played_card > 0) {
+ //Check if the card needs to be discarded.
+ if (!game.strategy_removed.includes(game.played_card) && game.played_card > 0) {
game.strategy_discard.push(game.played_card)
}
@@ -3213,9 +3197,9 @@ function end_round() {
// Check for duplicate card entries
let card_check
if (game.samizdat_card > 0) {
- card_check = [...game.strategy_deck, ...game.strategy_discard, ...game.strategy_removed, ...game.table_cards, ...game.communist_hand, ... game.democrat_hand, game.samizdat_card];
+ card_check = [...game.strategy_deck, ...game.strategy_discard, ...game.strategy_removed, ...game.persistent_events, ...game.communist_hand, ... game.democrat_hand, game.samizdat_card];
} else {
- card_check = [...game.strategy_deck, ...game.strategy_discard, ...game.strategy_removed, ...game.table_cards, ...game.communist_hand, ... game.democrat_hand];
+ card_check = [...game.strategy_deck, ...game.strategy_discard, ...game.strategy_removed, ...game.persistent_events, ...game.communist_hand, ... game.democrat_hand];
}
function check_duplicates(array) {
@@ -3227,12 +3211,12 @@ function end_round() {
return [...new Set(duplicates)];
}
- console.log('game.strategy_deck', game.strategy_deck, 'game.strategy_discard', game.strategy_discard, 'game.strategy_removed', game.strategy_removed, 'game.table_cards', game.table_cards, 'game.communist_hand', game.communist_hand, 'game.democrat_hand', game.democrat_hand)
+ 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)
if (check_duplicates(card_check)) {
console.log('card check', card_check)
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.table_cards', game.table_cards, 'game.communist_hand', game.communist_hand, 'game.democrat_hand', game.democrat_hand)
+ 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(', ')}`)
}
//console.log('cards in game', card_check.length)
@@ -3445,7 +3429,6 @@ function new_turn() {
function end_one_turn_event(event) {
game.persistent_events = game.persistent_events.filter(n => n !== event)
- discard_from_table(event)
log_summary(`C${event}`)
}
@@ -3598,17 +3581,6 @@ function discard_card(hand) {
return discarded_card
}
-function discard_from_table(card) {
- let find_card = game.table_cards.indexOf(card)
- if (find_card !== -1) {
- game.table_cards.splice(find_card, 1)
- if (cards[card].remove === 1) {
- if (!game.strategy_removed.includes(card)) {
- game.strategy_removed.push(card) }
- } else {game.strategy_discard.push(card) }
- }
-}
-
function add_midyear() {
for (let c = first_strategy_card; c <= last_strategy_card; ++c)
if (cards[c].period === 2)
@@ -3644,7 +3616,6 @@ function reset_power() {
game.persistent_events = game.persistent_events.filter(n => n !== C_SECURITATE)
} else if (game.persistent_events.includes(e)) {
permanently_remove(e)
- game.table_cards = game.table_cards.filter(card => card !== e)
game.persistent_events = game.persistent_events.filter(n => n !== e)
}
}
@@ -4511,7 +4482,7 @@ function vm_adamec() {
function vm_army_backs_revolution() {
game.persistent_events = game.persistent_events.filter(n => n !== C_SECURITATE)
game.playable_cards = game.playable_cards.filter(n => n !== C_SECURITATE)
- game.table_cards.push(C_ARMY_BACKS_REVOLUTION)
+ add_to_persistent_events(C_ARMY_BACKS_REVOLUTION)
vm_next()
}
@@ -5012,7 +4983,6 @@ function vm_reformer_rehabilitated () {
for (let card of game.strategy_discard) {
if (!event_is_playable(card)) continue
if (card === game.played_card) continue
- if (game.table_cards.includes(card)) continue
if (scoring_cards.includes(card)) continue
game.valid_cards.push(card)
@@ -5022,7 +4992,6 @@ function vm_reformer_rehabilitated () {
function vm_roundtable_talks() {
add_to_persistent_events(C_ROUNDTABLE_TALKS)
-
vm_next()
}
@@ -5151,8 +5120,7 @@ function vm_the_chinese_solution() {
}
function vm_the_crowd_turns_against_ceausescu() {
- game.table_cards.push(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)
- remove_from_discard(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)
+ add_to_persistent_events(C_THE_CROWD_TURNS_AGAINST_CEAUSESCU)
game.playable_cards.push(C_THE_TYRANT_IS_GONE)
vm_next()
}
@@ -5186,8 +5154,7 @@ function vm_the_tyrant_is_gone() {
}
function vm_the_tyrant_is_gone_prep() {
- game.table_cards.push(C_THE_TYRANT_IS_GONE)
- remove_from_discard(C_THE_TYRANT_IS_GONE)
+ add_to_persistent_events(C_THE_TYRANT_IS_GONE)
vm_next()
}
@@ -7238,7 +7205,6 @@ states.vm_the_tyrant_is_gone = {
log(`The Ceausescus flee to %${space}`)
game.the_tyrant_is_gone = space
game.valid_spaces = []
- game.persistent_events.push(C_THE_TYRANT_IS_GONE)
},
done () {
vm_next()
@@ -8503,7 +8469,7 @@ CODE[96] = [ // The Chinese Solution*
]
CODE[97] = [ // The Tyrant is Gone*
- [ vm_if, ()=>game.persistent_events.includes(54) ],
+ [ vm_if, ()=>game.persistent_events.includes(THE_CROWD_TURNS_AGAINST_CEAUSESCU_OCCURRED) ],
[ vm_valid_spaces_com, 'Cluj-Napoca' ],
[ vm_prompt, 'the Romanian Elite Space' ],
[ vm_remove_x_opp_infl, 4 ],