diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 100 |
1 files changed, 21 insertions, 79 deletions
@@ -248,7 +248,7 @@ exports.setup = function (seed, scenario, options) { undo: [], summary: [], active: null, - state: "com_init", + state: 'place_starting_infl', return: '', vm: null, vm_event: 0, @@ -290,20 +290,13 @@ exports.setup = function (seed, scenario, options) { democrat_hand: [], communist_hand: [], - pwr_struggle_in: [], is_pwr_struggle: false, dem_pwr_hand_limit: 0, com_pwr_hand_limit: 0, dem_pwr_hand: [], com_pwr_hand: [], - raised_stakes_discard: 0, - raised_stakes: 0, - raised_stakes_round: 0, - phase: 0, times_held: [0, 0, 0, 0, 0, 0], revolutions: [false, false, false, false, false, false], - remove_opponent_infl: false, - tactics_fails: '', } log_h1("1989 Dawn of Freedom") @@ -324,10 +317,8 @@ function start_game() { }) //Set starting placement ops - game.starting_infl = { - com_starting_infl: 0, - dem_starting_infl: 0 - }, + game.starting_infl = [2, 3, 3, 4, 2] + game.temp = 0 // Set variable event cards where event is playable at start of game @@ -335,9 +326,8 @@ function start_game() { draw_cards(game.strategy_deck, game.democrat_hand, game.communist_hand, game.dem_hand_limit, game.com_hand_limit) - game.valid_spaces = valid_spaces_setup() + valid_spaces_setup() game.available_ops = 2 - //game.phase = 0 /* Now redundant? */ log_h1("Place starting Support Points") log_side() } @@ -502,17 +492,17 @@ exports.action = function (state, player, action, arg) { // ============= GAME STATES ======================= -states.com_init = { +states.place_starting_infl = { inactive: 'place starting SPs.', prompt() { - if (game.starting_infl.dem_starting_infl === 2 && game.available_ops === 0 ) { + if (game.temp === 4 && game.available_ops === 0 ) { view.prompt = 'Place starting SPs: done. Start Turn 1.'; gen_action("start"); } else if (game.available_ops === 0) { view.prompt = 'Place starting SPs: done.'; gen_action("done"); return; - } else if (game.starting_infl.dem_starting_infl === 2) { + } else if (game.temp > 2) { view.prompt = `Place your last ${pluralize(game.available_ops,'starting SP')}.` } else { view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.` @@ -526,63 +516,20 @@ states.com_init = { }, done() { do_log_summary() - game.starting_infl.com_starting_infl++ - if (game.starting_infl.com_starting_infl == 1){ - game.available_ops = 3 - game.state = 'dem_init' - valid_spaces_setup() - next_player() - } else if (game.starting_infl.com_starting_infl == 2) { - game.available_ops = 4 - game.state = 'dem_init' - valid_spaces_setup() - next_player() - } else if (game.starting_infl.com_starting_infl == 3) { - delete game.starting_infl - game.state = 'start_game' - } + game.temp ++ + game.available_ops = game.starting_infl[game.temp] + next_player() + valid_spaces_setup() }, start() { do_log_summary() + delete game.starting_infl new_turn() clear_undo() game.state = 'choose_card' } } -states.dem_init = { - inactive: 'place starting SPs.', - prompt() { - if (game.available_ops == 0) { - view.prompt = 'Place starting SPs: done.'; - gen_action("done"); - return; - } else if (game.starting_infl.com_starting_infl === 2) { - view.prompt = `Place your last ${pluralize(game.available_ops,'starting SP')}.` - } else { - view.prompt = `Place ${pluralize(game.available_ops,'starting SP')}.` - } - for (let space_id of game.valid_spaces) { - gen_action_space(space_id); - } - }, - space(space) { - add_infl(space, 'available_ops') - }, - done() { - do_log_summary() - game.starting_infl.dem_starting_infl++ - if (game.starting_infl.dem_starting_infl == 1){ - game.available_ops = 3 - } else if (game.starting_infl.dem_starting_infl == 2) { - game.available_ops = 2 - } - game.state = 'com_init' - valid_spaces_setup() - next_player() - } -} - states.choose_card = { inactive: 'choose a card.', prompt() { @@ -2350,26 +2297,22 @@ function do_sc(space) { } function valid_spaces_setup() { - let valid_spaces_set = new Set(); for (let i =0 ; i < spaces.length ; i++) { let space = spaces[i] - if (game.state === 'com_init') { + if (game.active === COM) { let infl = game.demInfl[i] if (infl === 0) { - valid_spaces_set.add(space.space_id); + game.valid_spaces.push(space.space_id); } - } else if (game.state === 'dem_init') { + } else { let infl = game.comInfl[i] if (infl === 0) { - valid_spaces_set.add(space.space_id); + game.valid_spaces.push(space.space_id); } } } - // Convert the set to an array before returning - game.valid_spaces = Array.from(valid_spaces_set); - return game.valid_spaces; } function valid_spaces_sc() { @@ -3672,10 +3615,10 @@ function reset_power() { game.power_struggle_discard = [] game.dem_pwr_hand = [] game.com_pwr_hand = [] - //game.phase = 1 - game.raised_stakes_round = 0 - game.raised_stakes = 0 - game.played_power_card = 0 + delete game.phase + delete game.raised_stakes_round + delete game.raised_stakes + delete game.played_power_card delete game.tactics_fails game.view_opp_hand = false @@ -5017,6 +4960,7 @@ function vm_poszgay() { function vm_power_struggle() { game.is_pwr_struggle = true game.phase = 0 + game.raised_stakes_round = 0 game.pwr_struggle_in = countries[scoring_cards.indexOf(game.vm_event)] log_h2(`C${game.vm_event}`) @@ -5163,7 +5107,6 @@ function vm_tank_column() { return } else if (game.dem_tst_position === 4 && game.com_tst_position < 4) { - console.log('in space 4 check') game.vm_event = 204 goto_vm(game.vm_event) return @@ -7037,7 +6980,6 @@ states.vm_shock_therapy = { return `resolve ${clean_name(cards[game.played_card].name)}.` }, prompt() { - console.log('game.vm_active_country', game.vm_active_country) if (game.revolutions.every(n => n === false)) { view.prompt = 'Shock Therapy: no countries to choose.' gen_action('pass') |