diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 208 |
1 files changed, 98 insertions, 110 deletions
@@ -2311,7 +2311,7 @@ states.action_phase = { for (let i = 0; i < player.hand.length; ++i) gen_card_menu(player.hand[i]) if (player.hand.length === 1 && !player.held) - gen_action_pass() + view.actions.pass = 1 }, play_event(card) { push_undo() @@ -2381,7 +2381,7 @@ events.campaign = { states.activate_individually = { prompt() { view.prompt = `Activate units and/or leaders individually${format_remain(game.count)}.` - gen_action_next() + view.actions.next = 1 if (game.count >= 1) { for (let p = first_friendly_leader; p <= last_friendly_leader; ++p) { if (is_piece_on_map(p) && !game.activation.includes(p)) { @@ -2633,24 +2633,24 @@ states.designate_force = { }) if (can_pick_up) - gen_action('pick_up_all') + view.actions.pick_up_all = 1 switch (game.force.reason) { case 'campaign_1': case 'campaign_2': case 'move': // Campaign and normal activations can activate leaders without forces. - gen_action_next() + view.actions.activate = 1 break case 'intercept': // Must be a force to proceed (leader + at least one unit) if (count_units_in_force(commander) > 0) - gen_action('intercept') + view.actions.intercept = 1 break case 'avoid': // Must be a force to proceed (leader + at least one unit) if (count_units_in_force(commander) > 0) - gen_action('avoid') + view.actions.avoid = 1 break } }, @@ -2697,7 +2697,7 @@ states.designate_force = { move_piece_to(p, leader_box(commander)) }, - next() { + activate() { push_undo() if (game.force.reason === 'move' && count_units_in_force(game.force.commander) === 0) game.state = 'confirm_designate_force' @@ -2719,7 +2719,7 @@ states.confirm_designate_force = { prompt() { view.prompt = `You have not picked up any units \u2014 are you sure you want to continue?` view.who = game.force.commander - gen_action('next') + view.actions.next = 1 }, next() { end_designate_force() @@ -2793,7 +2793,7 @@ states.designate_force_lone_ax = { }) if (n === 1) - gen_action('intercept') + view.actions.intercept = 1 }, piece(p) { @@ -2882,12 +2882,12 @@ states.siege_or_move = { } else { view.prompt = `You may assault at ${space_name(where)} or move.` } - gen_action('assault') + view.actions.assault = 1 } else { view.prompt = `You may siege at ${space_name(where)} or move.` - gen_action('siege') + view.actions.siege = 1 } - gen_action('move') + view.actions.move = 1 }, siege() { push_undo() @@ -3361,9 +3361,9 @@ states.move = { if (game.move.used === 0) { if (game.events.foul_weather && can_moving_force_siege_or_assault()) { if (is_assault_possible(from)) - gen_action('assault') + view.actions.assault = 1 else - gen_action('siege') + view.actions.siege = 1 } if (game.active === BRITAIN && player.hand.includes(GEORGE_CROGHAN)) { if (force_has_drilled_troops(who)) @@ -3372,7 +3372,7 @@ states.move = { if (piece_can_naval_move_from(who, from)) { if (game.move.type !== 'naval') { - gen_action('naval_move') + view.actions.naval_move = 1 } else { if (!game.events.no_amphib) { if (game.active === BRITAIN && has_amphibious_arrow(from)) { @@ -3393,11 +3393,11 @@ states.move = { if (game.move.infiltrated) { if (!has_unbesieged_enemy_fort_or_fortress(from)) - gen_action('stop') + view.actions.stop = 1 else if (game.move.used === 9) - gen_action('end_move') + view.actions.end_move = 1 } else { - gen_action('end_move') + view.actions.end_move = 1 } if (game.move.used < max_movement_cost(game.move.type)) { @@ -3409,7 +3409,7 @@ states.move = { if (game.move.used < 9 && !game.move.infiltrated) { if (is_leader(who) && count_pieces_in_force(who) > 1) - gen_action('drop_off') + view.actions.drop_off = 1 } }, play_event(card) { @@ -3485,7 +3485,7 @@ states.drop_off = { view.who = who view.where = where - gen_action_next() + view.actions.next = 1 for_each_leader_in_force(who, p => { if (p !== who && can_drop_off_leader(who, p)) @@ -3517,7 +3517,7 @@ states.confirm_end_move = { prompt() { view.prompt = `You have not moved yet \u2014 are you sure you want to pass?` view.who = moving_piece() - gen_action('end_move') + view.actions.end_move = 1 }, end_move() { end_move() @@ -3553,10 +3553,10 @@ states.foul_weather = { } else { view.prompt = `${piece_name_and_place(p)} is about to move. You don't have "Foul Weather".` } - gen_action('pass_fw_season') + view.actions.pass_fw_season = 1 if (game.activation && game.activation.length > 0) - gen_action('pass_fw_action') - gen_action_pass() + view.actions.pass_fw_action = 1 + view.actions.pass = 1 }, play_event(c) { if (game.options.retroactive) { @@ -3613,7 +3613,7 @@ states.lake_schooner = { } else { view.prompt = `${piece_name(who)} is about to move from ${space_name(from)} to ${space_name(to)}. You don't have "Lake Schooner".` } - gen_action_pass() + view.actions.pass = 1 }, play_event(c) { play_card(c) @@ -3892,10 +3892,10 @@ states.intercept_who = { if (game.move.intercepting) { view.prompt = `Intercept into ${space_name(where)} with ${piece_name(game.move.intercepting)}.` view.who = game.move.intercepting - gen_action('intercept') + view.actions.intercept = 1 } else { view.prompt = "You may select a force or unit to intercept into " + space_name(where) + "." - gen_action_pass() + view.actions.pass = 1 gen_intercept() } }, @@ -3999,7 +3999,7 @@ states.designate_inside = { let where = moving_piece_space() view.prompt = "You may withdraw leaders and units into the fortification." view.where = where - gen_action_next() + view.actions.next = 1 let n = count_friendly_units_inside(where) for_each_friendly_piece_in_space(where, p => { if (is_piece_unbesieged(p) && !did_piece_intercept(p)) { @@ -4061,10 +4061,10 @@ states.avoid_who = { if (game.move.avoiding) { view.prompt = `Avoid battle from ${space_name(from)} with ${piece_name(game.move.avoiding)}.` view.who = game.move.avoiding - gen_action('avoid') + view.actions.avoid = 1 } else { view.prompt = "You may select a force or unit to avoid battle from " + space_name(from) + "." - gen_action_pass() + view.actions.pass = 1 for_each_friendly_piece_in_space(from, p => { if (!did_piece_intercept(p) && is_piece_unbesieged(p)) gen_action_piece(p) @@ -4432,7 +4432,7 @@ states.militia_in_battle = { if (piece_node(p) === box) gen_action_piece(p) } - gen_action_next() + view.actions.next = 1 }, piece(p) { push_undo() @@ -4492,8 +4492,8 @@ states.sortie = { } } if (!done) - gen_action('pick_up_all') - gen_action_next() + view.actions.pick_up_all = 1 + view.actions.next = 1 }, piece(p) { push_undo() @@ -4688,7 +4688,7 @@ states.attacker_events = { view.prompt += " You don't have " + dont_have.join(" or ") + "." if (have.length === 0 && dont_have.length === 0) view.prompt += " You have no more response events." - gen_action_next() + view.actions.next = 1 }, play_event(c) { push_undo() @@ -4768,7 +4768,7 @@ states.defender_events = { view.prompt += " You don't have " + dont_have.join(" or ") + "." if (have.length === 0 && dont_have.length === 0) view.prompt += " You have no more response events." - gen_action_next() + view.actions.next = 1 }, play_event(c) { push_undo() @@ -5090,7 +5090,7 @@ states.step_losses = { } if (done) { view.prompt = `Apply step losses \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { if (game.battle.dt_loss > 0) view.prompt = `Apply step losses (${game.battle.step_loss} left, ${game.battle.dt_loss} from drilled troops).` @@ -5153,7 +5153,7 @@ states.raid_step_losses = { } } if (!can_reduce) - gen_action_next() + view.actions.next = 1 }, piece(p) { push_undo() @@ -5621,11 +5621,11 @@ states.retreat_defender = { }) if (!can_retreat) { view.prompt += " done." - gen_action_next() + view.actions.next = 1 } else { view.prompt += " select piece to retreat." if (can_all_defenders_retreat_from(from)) - gen_action('pick_up_all') + view.actions.pick_up_all = 1 } }, piece(piece) { @@ -5794,7 +5794,7 @@ states.retreat_lone_leader = { } }) if (!can_retreat) - gen_action('eliminate') + view.actions.eliminate = 1 }, eliminate() { let from = game.retreat.from @@ -5902,7 +5902,7 @@ states.siege_coehorns_attacker = { } else { view.prompt = `Siege at ${space_name(game.siege_where)}. You don't have "Coehorns & Howitzers".` } - gen_action_pass() + view.actions.pass = 1 }, play_event(c) { play_card(c) @@ -5933,7 +5933,7 @@ states.siege_coehorns_defender = { } else { view.prompt = `Siege at ${space_name(game.siege_where)}. You don't have "Coehorns & Howitzers".` } - gen_action_pass() + view.actions.pass = 1 }, play_event(c) { play_card(c) @@ -5968,7 +5968,7 @@ states.siege_surrender = { } else { view.prompt = `Siege at ${space_name(game.siege_where)}. You don't have "Surrender!"` } - gen_action_pass() + view.actions.pass = 1 }, play_event(c) { play_card(c) @@ -6020,7 +6020,7 @@ states.surrender = { for (let i=0; i < game.surrender.length; ++i) gen_action_space(game.surrender[i]) if (game.surrender.length === 0) - gen_action('eliminate') + view.actions.eliminate = 1 }, space(s) { for (let p = first_friendly_piece; p <= last_friendly_piece; ++p) @@ -6101,8 +6101,8 @@ states.assault_possible = { prompt() { view.prompt = `You may assault at ${space_name(game.assault_possible)}.` gen_action_space(game.assault_possible) - gen_action('assault') - gen_action('pass') + view.actions.assault = 1 + view.actions.pass = 1 }, space() { let where = game.assault_possible @@ -6190,7 +6190,7 @@ states.militia_against_raid = { gen_action_piece(p) } } - gen_action_next() + view.actions.next = 1 }, piece(p) { push_undo() @@ -6232,8 +6232,8 @@ states.raid_blockhouses = { } else { view.prompt = `Raid at ${space_name(game.raid.where)}. You don't have "Blockhouses".` } - gen_action('pass_bh_season') - gen_action_pass() + view.actions.pass_bh_season = 1 + view.actions.pass = 1 }, play_event(c) { play_card(c) @@ -6417,7 +6417,7 @@ states.raiders_go_home = { } if (done) { view.prompt = `Raiders go home from ${space_name(from)} \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Raiders go home from ${space_name(from)}.` } @@ -6460,7 +6460,7 @@ states.indians_and_leaders_go_home = { } if (done) { view.prompt = "Indians and leaders go home \u2014 done." - gen_action_next() + view.actions.next = 1 } else { view.prompt = "Indians and leaders go home." } @@ -6521,7 +6521,7 @@ states.go_home_to = { } if (!can_go_home || is_cherokee(who)) - gen_action('eliminate') + view.actions.eliminate = 1 }, space(to) { let who = game.go_home.who @@ -6601,7 +6601,7 @@ states.go_home_with_indians = { } if (game.count === 0) - gen_action_next() + view.actions.next = 1 }, piece(p) { push_undo() @@ -6740,7 +6740,7 @@ states.winter_attrition = { } if (done) { view.prompt = "Winter Attrition \u2014 done." - gen_action_next() + view.actions.next = 1 } else { view.prompt = "Winter Attrition: Reduce drilled troops not in winter quarters." } @@ -6865,19 +6865,19 @@ states.game_over = { function gen_action_demolish() { for (let s of player.forts) { if (is_space_unbesieged(s)) { - gen_action('demolish_fort') + view.actions.demolish_fort = 1 break } } if (player.forts_uc.length > 0) { - gen_action('demolish_fort') + view.actions.demolish_fort = 1 } if (player.stockades.length > 0) { - gen_action('demolish_stockade') + view.actions.demolish_stockade = 1 } for (let s of game.fieldworks) { if (is_friendly_controlled_space(s) || has_unbesieged_friendly_units(s)) { - gen_action('demolish_fieldworks') + view.actions.demolish_fieldworks = 1 break } } @@ -7112,7 +7112,7 @@ states.max_two_7_command_leaders_in_play = { if (!game.seven.includes(LOUDOUN)) gen_action_piece(LOUDOUN) } else { view.prompt = `Remove a 7 command leader from play \u2014 done.` - gen_action_next() + view.actions.next = 1 } }, piece(p) { @@ -7170,7 +7170,7 @@ states.massacre_1 = { } else { view.prompt = `You don't have "Massacre!"` } - gen_action_pass() + view.actions.pass = 1 }, play_event(c) { play_card(c) @@ -7199,7 +7199,7 @@ states.massacre_2 = { } if (done) { view.prompt = `Massacre! Eliminate all indians in ${space_name(s)} \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Massacre! Eliminate all indians in ${space_name(s)}.` } @@ -7277,7 +7277,7 @@ states.provincial_regiments_dispersed_for_frontier_duty = { } if (done) { view.prompt = `Provincial Regiments Dispersed \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Provincial Regiments Dispersed: Eliminate ${game.frontier_duty.southern} southern and ${game.frontier_duty.northern} northern provincials.` } @@ -7405,7 +7405,7 @@ states.indian_alliance = { } if (done) { view.prompt = `Indian Alliance \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Indian Alliance: Place or restore ${game.alliance.join(" or ")} indians (${game.count} left).` } @@ -7480,7 +7480,7 @@ states.restore_units = { } if (done) { view.prompt = `Restore all ${game.restore.name} \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Restore all ${game.restore.name}.` } @@ -7523,7 +7523,7 @@ states.mohawks = { } if (done) { view.prompt = "Place all Mohawks not on the map with Johnson \u2014 done." - gen_action_next() + view.actions.next = 1 } else { view.prompt = "Place all Mohawks not on the map with Johnson." } @@ -7567,7 +7567,7 @@ states.cherokees = { } if (done) { view.prompt = "Place all Cherokees not on the map at a British fortification in the southern dept \u2014 done." - gen_action_next() + view.actions.next = 1 } else { view.prompt = "Place all Cherokees not on the map at a British fortification in the southern dept." } @@ -7618,7 +7618,7 @@ states.cherokee_uprising = { } if (done) { view.prompt = `Cherokee Uprising \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Cherokee Uprising: Eliminate ${game.uprising.regular} regulars, ${game.uprising.southern} southern provincials, and all Cherokee.` } @@ -7662,7 +7662,7 @@ states.treaty_of_easton = { } if (done) { view.prompt = "Treaty of Easton: Eliminate all unbesieged orange indians \u2014 done." - gen_action_next() + view.actions.next = 1 } else { view.prompt = "Treaty of Easton: Eliminate all unbesieged orange indians." } @@ -7701,7 +7701,7 @@ states.indians_desert = { view.prompt = `Indians Desert: Eliminate two indians from one space (${game.count} left).` } else { view.prompt = "Indians Desert: Eliminate two indians from one space \u2014 done." - gen_action_next() + view.actions.next = 1 } }, piece(p) { @@ -7781,7 +7781,7 @@ states.governor_vaudreuil_interferes = { } } else { view.prompt = "Governor Vaudreuil Interferes \u2014 done." - gen_action_next() + view.actions.next = 1 } }, piece(p) { @@ -7872,7 +7872,7 @@ states.small_pox_eliminate_steps = { } if (done) { view.prompt = `Small Pox at ${space_name(game.small_pox)} \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Small Pox at ${space_name(game.small_pox)}: Eliminate steps \u2014 ${game.count} left.` } @@ -8035,11 +8035,11 @@ states.british_ministerial_crisis = { for (let i = 0; i < player.hand.length; ++i) { let c = player.hand[i] if (set_has(british_ministerial_crisis_cards, c)) - gen_action_discard(c) + gen_action('card', c) } } else { view.prompt = "British Ministerial Crisis \u2014 done." - gen_action_next() + view.actions.next = 1 } }, card(c) { @@ -8124,8 +8124,8 @@ events.stingy_provincial_assembly = { states.stingy_provincial_assembly_department = { prompt() { view.prompt = "Stingy Provincial Assembly: Choose a department." - gen_action('northern') - gen_action('southern') + view.actions.northern = 1 + view.actions.southern = 1 }, northern() { goto_stingy_provincial_assembly('northern') @@ -8157,7 +8157,7 @@ states.stingy_provincial_assembly = { } } else { view.prompt = `Stingy Provincial Assembly \u2014 done.` - gen_action_next() + view.actions.next = 1 } }, piece(p) { @@ -8279,7 +8279,7 @@ states.british_colonial_politics = { } if (done) { view.prompt = `British Colonial Politics \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `British Colonial Politics: Remove provincials over limit \u2014 ${num_s}/${max_s} southern, ${num_n}/${max_n} northern.` } @@ -8325,9 +8325,9 @@ states.raise_provincial_regiments_where = { prompt() { view.prompt = "Raise Provincial Regiments in which department?" if (can_raise_northern_provincial_regiments() || can_restore_northern_provincial_regiments()) - gen_action('northern') + view.actions.northern = 1 if (can_raise_southern_provincial_regiments() || can_restore_southern_provincial_regiments()) - gen_action('southern') + view.actions.southern = 1 }, northern() { push_undo() @@ -8359,11 +8359,11 @@ states.raise_provincial_regiments = { if (!game.did_raise) { if (game.department === 'northern' && can_restore_northern_provincial_regiments()) { done = false - gen_action('restore') + view.actions.restore = 1 } if (game.department === 'southern' && can_restore_southern_provincial_regiments()) { done = false - gen_action('restore') + view.actions.restore = 1 } } if (game.count > 0) { @@ -8386,7 +8386,7 @@ states.raise_provincial_regiments = { } if (done) { view.prompt = `Raise Provincial Regiments \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { if (game.did_raise) view.prompt = `Raise Provincial Regiments in ${game.department} department (${game.count} left).` @@ -8478,7 +8478,7 @@ states.bastions_repaired = { }) } else { view.prompt = "Bastions Repaired \u2014 done." - gen_action_next() + view.actions.next = 1 } }, space(s) { @@ -8536,7 +8536,7 @@ states.colonial_recruits = { } if (done) { view.prompt = `Colonial Recruits \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Colonial Recruits: Restore ${game.count} reduced colonial recruits.` } @@ -8621,7 +8621,7 @@ states.restore_regular_or_light_infantry_units = { } if (done) { view.prompt = `Restore reduced regular or light infantry \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { view.prompt = `Restore ${game.count} reduced regular or light infantry.` } @@ -8691,7 +8691,7 @@ states.call_out_militias = { } if (done) { view.prompt = `Call Out Militias \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { if (game.count < 2) view.prompt = `Call Out Militias: Restore another militia to full strength.` @@ -8747,7 +8747,7 @@ states.rangers = { } if (done) { view.prompt = `Rangers \u2014 done.` - gen_action_next() + view.actions.next = 1 } else { if (game.count < 2) view.prompt = `Rangers: Restore another ranger to full strength.` @@ -8814,7 +8814,7 @@ states.french_regulars = { if (!has_british_units(LOUISBOURG) && !has_amphib(LOUISBOURG)) gen_action_space(LOUISBOURG) } else { - gen_action_next() + view.actions.next = 1 } }, space(s) { @@ -8879,7 +8879,7 @@ states.light_infantry = { } } if (game.count === 0) - gen_action_next() + view.actions.next = 1 }, space(s) { push_undo() @@ -8955,7 +8955,7 @@ states.british_regulars = { gen_action_space(s) }) } else { - gen_action_next() + view.actions.next = 1 } }, space(s) { @@ -9050,7 +9050,7 @@ states.highlanders = { gen_action_space(s) }) } else { - gen_action_next() + view.actions.next = 1 } }, space(s) { @@ -9123,7 +9123,7 @@ states.royal_americans = { if (has_unbesieged_friendly_fortress(s)) gen_action_space(s) } else { - gen_action_next() + view.actions.next = 1 } }, space(s) { @@ -9185,7 +9185,7 @@ states.acadians_expelled_place_coureurs = { if (!louisbourg) gen_action_space(LOUISBOURG) if (quebec && louisbourg) - gen_action_pass() + view.actions.pass = 1 }, space(s) { push_undo() @@ -9219,7 +9219,7 @@ states.acadians_expelled_restore_coureurs_and_militia = { } if (done) { view.prompt = "Acadians Expelled: Restore all Coureurs and Militia \u2014 done." - gen_action_next() + view.actions.next = 1 } else { view.prompt = "Acadians Expelled: Restore all Coureurs and Militia." } @@ -9262,7 +9262,7 @@ states.william_pitt = { } else { view.prompt = "William Pitt \u2014 done." } - gen_action_next() + view.actions.next = 1 }, card(c) { push_undo() @@ -9304,7 +9304,7 @@ states.diplomatic_revolution = { } else { view.prompt = "Diplomatic Revolution \u2014 done." } - gen_action_next() + view.actions.next = 1 }, card(c) { push_undo() @@ -9321,8 +9321,8 @@ states.diplomatic_revolution = { states.discard_to_draw_regulars = { prompt() { view.prompt = `Exchange random card with British Regulars or Highlanders from discard?` - gen_action('exchange') - gen_action('pass') + view.actions.exchange = 1 + view.actions.pass = 1 }, exchange() { push_undo() @@ -9914,14 +9914,6 @@ function gen_action(action, argument) { } } -function gen_action_next() { - gen_action('next') -} - -function gen_action_pass() { - gen_action('pass') -} - function gen_action_space(s) { gen_action('space', s) } @@ -9930,10 +9922,6 @@ function gen_action_piece(p) { gen_action('piece', p) } -function gen_action_discard(c) { - gen_action('card', c) -} - function load_game_state(state) { game = state update_active_aliases() |