diff options
-rw-r--r-- | play.js | 9 | ||||
-rw-r--r-- | rules.js | 170 |
2 files changed, 91 insertions, 88 deletions
@@ -1576,8 +1576,17 @@ function update_map() { action_button("next", "Next") action_button("end_activations", "End activations") + action_button("end_attrition", "End attrition") action_button("end_construction", "End construction") + action_button("end_event", "End event") + action_button("end_go_home", "End go home") + action_button("end_losses", "End losses") + action_button("end_militia", "End militia") action_button("end_move", "End move") + action_button("end_response", "End response") + action_button("end_retreat", "End retreat") + action_button("end_sortie", "End sortie") + action_button("end_withdraw", "End withdraw") action_button("undo", "Undo") } @@ -4032,7 +4032,7 @@ states.designate_inside = { let where = moving_piece_space() view.prompt = "You may withdraw leaders and units into the fortification." view.where = where - view.actions.next = 1 + view.actions.end_withdraw = 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)) { @@ -4053,7 +4053,7 @@ states.designate_inside = { } set_piece_inside(p) }, - next() { + end_withdraw() { if (is_fortress(moving_piece_space())) print_plain_summary("Withdrew into fortress", 'inside') else @@ -4465,7 +4465,7 @@ states.militia_in_battle = { if (piece_node(p) === box) gen_action_piece(p) } - view.actions.next = 1 + view.actions.end_militia = 1 }, piece(p) { push_undo() @@ -4477,7 +4477,7 @@ states.militia_in_battle = { else log(`Deployed ${piece_name(p)}.`) }, - next() { + end_militia() { print_plain_summary("Deployed", 'deploy') goto_battle_sortie() }, @@ -4526,7 +4526,7 @@ states.sortie = { } if (!done) view.actions.pick_up_all = 1 - view.actions.next = 1 + view.actions.end_sortie = 1 }, piece(p) { push_undo() @@ -4539,7 +4539,7 @@ states.sortie = { if (!game.battle.atk_pcs.includes(p)) sortie_with_piece(p) }, - next() { + end_sortie() { print_plain_summary("Sortied", 'sortie') goto_battle_attacker_events() }, @@ -4721,7 +4721,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." - view.actions.next = 1 + view.actions.end_response = 1 }, play_event(c) { push_undo() @@ -4740,10 +4740,7 @@ states.attacker_events = { break } }, - pass() { - goto_battle_defender_events() - }, - next() { + end_response() { goto_battle_defender_events() }, } @@ -4801,7 +4798,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." - view.actions.next = 1 + view.actions.end_response = 1 }, play_event(c) { push_undo() @@ -4823,10 +4820,7 @@ states.defender_events = { break } }, - pass() { - goto_battle_roll() - }, - next() { + end_response() { goto_battle_roll() }, } @@ -5123,7 +5117,7 @@ states.step_losses = { } if (done) { view.prompt = `Apply step losses \u2014 done.` - view.actions.next = 1 + view.actions.end_losses = 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).` @@ -5141,7 +5135,7 @@ states.step_losses = { remove_from_array(game.battle.units, p) } }, - next() { + end_losses() { if (game.active === game.battle.attacker) game.battle.def_caused = game.battle.def_result - game.battle.step_loss else @@ -5186,7 +5180,7 @@ states.raid_step_losses = { } } if (!can_reduce) - view.actions.next = 1 + view.actions.end_losses = 1 }, piece(p) { push_undo() @@ -5194,7 +5188,7 @@ states.raid_step_losses = { if (reduce_unit(p, false)) remove_from_array(game.raid.units, p) }, - next() { + end_losses() { flush_summary() goto_raid_leader_check() }, @@ -5654,7 +5648,7 @@ states.retreat_defender = { }) if (!can_retreat) { view.prompt += " done." - view.actions.next = 1 + view.actions.end_retreat = 1 } else { view.prompt += " select piece to retreat." if (can_all_defenders_retreat_from(from)) @@ -5670,7 +5664,7 @@ states.retreat_defender = { push_undo() game.state = 'retreat_all_defenders_to' }, - next() { + end_retreat() { let from = game.battle.where for_each_friendly_piece_in_space(from, p => { if (is_piece_unbesieged(p)) @@ -6223,7 +6217,7 @@ states.militia_against_raid = { gen_action_piece(p) } } - view.actions.next = 1 + view.actions.end_militia = 1 }, piece(p) { push_undo() @@ -6231,7 +6225,7 @@ states.militia_against_raid = { log(`Deployed ${piece_name(p)}.`) game.count -- }, - next() { + end_militia() { set_active_enemy() if (game.count === 0) goto_battle(game.raid.where, false) @@ -6450,7 +6444,7 @@ states.raiders_go_home = { } if (done) { view.prompt = `Raiders go home from ${space_name(from)} \u2014 done.` - view.actions.next = 1 + view.actions.end_go_home = 1 } else { view.prompt = `Raiders go home from ${space_name(from)}.` } @@ -6461,7 +6455,7 @@ states.raiders_go_home = { game.go_home.from = game.raid.where game.state = 'go_home_to' }, - next() { + end_go_home() { end_raiders_go_home() }, } @@ -6493,7 +6487,7 @@ states.indians_and_leaders_go_home = { } if (done) { view.prompt = "Indians and leaders go home \u2014 done." - view.actions.next = 1 + view.actions.end_go_home = 1 } else { view.prompt = "Indians and leaders go home." } @@ -6504,7 +6498,7 @@ states.indians_and_leaders_go_home = { game.go_home.from = piece_space(p) game.state = 'go_home_to' }, - next() { + end_go_home() { end_indians_and_leaders_go_home() }, } @@ -6634,7 +6628,7 @@ states.go_home_with_indians = { } if (game.count === 0) - view.actions.next = 1 + view.actions.end_go_home = 1 }, piece(p) { push_undo() @@ -6649,7 +6643,7 @@ states.go_home_with_indians = { if (!can_follow_indians_home(from)) end_go_home_to() }, - next() { + end_go_home() { push_undo() end_go_home_to() }, @@ -6773,7 +6767,7 @@ states.winter_attrition = { } if (done) { view.prompt = "Winter Attrition \u2014 done." - view.actions.next = 1 + view.actions.end_attrition = 1 } else { view.prompt = "Winter Attrition: Reduce drilled troops not in winter quarters." } @@ -6786,7 +6780,7 @@ states.winter_attrition = { reduce_unit(p, true) remove_from_array(stack.dt, p) }, - next() { + end_attrition() { end_winter_attrition() } } @@ -7232,7 +7226,7 @@ states.massacre_2 = { } if (done) { view.prompt = `Massacre! Eliminate all indians in ${space_name(s)} \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Massacre! Eliminate all indians in ${space_name(s)}.` } @@ -7240,7 +7234,7 @@ states.massacre_2 = { piece(p) { eliminate_piece(p, false) }, - next() { + end_event() { set_active_enemy() end_massacre() } @@ -7310,7 +7304,7 @@ states.provincial_regiments_dispersed_for_frontier_duty = { } if (done) { view.prompt = `Provincial Regiments Dispersed \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Provincial Regiments Dispersed: Eliminate ${game.frontier_duty.southern} southern and ${game.frontier_duty.northern} northern provincials.` } @@ -7323,7 +7317,7 @@ states.provincial_regiments_dispersed_for_frontier_duty = { game.frontier_duty.northern -- eliminate_piece(p) }, - next() { + end_event() { delete game.frontier_duty end_action_phase() }, @@ -7438,7 +7432,7 @@ states.indian_alliance = { } if (done) { view.prompt = `Indian Alliance \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Indian Alliance: Place or restore ${game.alliance.join(" or ")} indians (${game.count} left).` } @@ -7458,7 +7452,7 @@ states.indian_alliance = { restore_unit(p) game.count -= 0.5 }, - next() { + end_event() { delete game.alliance end_action_phase() }, @@ -7513,7 +7507,7 @@ states.restore_units = { } if (done) { view.prompt = `Restore all ${game.restore.name} \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Restore all ${game.restore.name}.` } @@ -7521,7 +7515,7 @@ states.restore_units = { piece(p) { restore_unit(p) }, - next() { + end_event() { end_action_phase() } } @@ -7556,7 +7550,7 @@ states.mohawks = { } if (done) { view.prompt = "Place all Mohawks not on the map with Johnson \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = "Place all Mohawks not on the map with Johnson." } @@ -7564,7 +7558,7 @@ states.mohawks = { space(s) { place_indian(s, first_mohawk, last_mohawk) }, - next() { + end_event() { goto_restore_units("Mohawks", first_mohawk, last_mohawk) }, } @@ -7600,7 +7594,7 @@ states.cherokees = { } if (done) { view.prompt = "Place all Cherokees not on the map at a British fortification in the southern dept \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = "Place all Cherokees not on the map at a British fortification in the southern dept." } @@ -7608,7 +7602,7 @@ states.cherokees = { space(s) { place_indian(s, first_cherokee, last_cherokee) }, - next() { + end_event() { goto_restore_units("Cherokees", first_cherokee, last_cherokee) }, } @@ -7651,7 +7645,7 @@ states.cherokee_uprising = { } if (done) { view.prompt = `Cherokee Uprising \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Cherokee Uprising: Eliminate ${game.uprising.regular} regulars, ${game.uprising.southern} southern provincials, and all Cherokee.` } @@ -7664,7 +7658,7 @@ states.cherokee_uprising = { game.uprising.southern -- eliminate_piece(p) }, - next() { + end_event() { delete game.uprising set_active_enemy() end_action_phase() @@ -7695,7 +7689,7 @@ states.treaty_of_easton = { } if (done) { view.prompt = "Treaty of Easton: Eliminate all unbesieged orange indians \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = "Treaty of Easton: Eliminate all unbesieged orange indians." } @@ -7703,7 +7697,7 @@ states.treaty_of_easton = { piece(p) { eliminate_piece(p) }, - next() { + end_event() { set_active_enemy() end_action_phase() } @@ -7734,7 +7728,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." - view.actions.next = 1 + view.actions.end_event = 1 } }, piece(p) { @@ -7744,7 +7738,7 @@ states.indians_desert = { eliminate_piece(p) game.count -- }, - next() { + end_event() { delete game.indians_desert end_action_phase() }, @@ -7814,7 +7808,7 @@ states.governor_vaudreuil_interferes = { } } else { view.prompt = "Governor Vaudreuil Interferes \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } }, piece(p) { @@ -7834,7 +7828,7 @@ states.governor_vaudreuil_interferes = { game.swap = p } }, - next() { + end_event() { end_action_phase() } } @@ -7983,9 +7977,9 @@ states.courier_intercepted_show = { let c = player.hand[player.hand.length-1] view.prompt = `Courier Intercepted: You stole ${card_name(c)}.` view.selected_card = c - view.actions.next = 1 + view.actions.end_event = 1 }, - next() { + end_event() { end_action_phase() }, } @@ -8072,7 +8066,7 @@ states.british_ministerial_crisis = { } } else { view.prompt = "British Ministerial Crisis \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } }, card(c) { @@ -8080,7 +8074,7 @@ states.british_ministerial_crisis = { game.count = 0 discard_card(c) }, - next() { + end_event() { set_active_enemy() end_action_phase() } @@ -8190,7 +8184,7 @@ states.stingy_provincial_assembly = { } } else { view.prompt = `Stingy Provincial Assembly \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } }, piece(p) { @@ -8198,7 +8192,7 @@ states.stingy_provincial_assembly = { game.count = 0 eliminate_piece(p) }, - next() { + end_event() { set_active_enemy() end_action_phase() }, @@ -8312,7 +8306,7 @@ states.british_colonial_politics = { } if (done) { view.prompt = `British Colonial Politics \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `British Colonial Politics: Remove provincials over limit \u2014 ${num_s}/${max_s} southern, ${num_n}/${max_n} northern.` } @@ -8321,7 +8315,7 @@ states.british_colonial_politics = { push_undo() eliminate_piece(p) }, - next() { + end_event() { set_active_enemy() end_action_phase() }, @@ -8419,7 +8413,7 @@ states.raise_provincial_regiments = { } if (done) { view.prompt = `Raise Provincial Regiments \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { if (game.did_raise) view.prompt = `Raise Provincial Regiments in ${game.department} department (${game.count} left).` @@ -8438,7 +8432,7 @@ states.raise_provincial_regiments = { game.count -- game.did_raise = 1 }, - next() { + end_event() { delete game.did_raise delete game.department end_action_phase() @@ -8511,7 +8505,7 @@ states.bastions_repaired = { }) } else { view.prompt = "Bastions Repaired \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } }, space(s) { @@ -8520,7 +8514,7 @@ states.bastions_repaired = { game.sieges[s] = 0 game.count = 0 }, - next() { + end_event() { end_action_phase() }, } @@ -8569,7 +8563,7 @@ states.colonial_recruits = { } if (done) { view.prompt = `Colonial Recruits \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Colonial Recruits: Restore ${game.count} reduced colonial recruits.` } @@ -8579,7 +8573,7 @@ states.colonial_recruits = { restore_unit(p) game.count -- }, - next() { + end_event() { end_action_phase() }, } @@ -8654,7 +8648,7 @@ states.restore_regular_or_light_infantry_units = { } if (done) { view.prompt = `Restore reduced regular or light infantry \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = `Restore ${game.count} reduced regular or light infantry.` } @@ -8664,7 +8658,7 @@ states.restore_regular_or_light_infantry_units = { restore_unit(p) game.count -- }, - next() { + end_event() { end_action_phase() }, } @@ -8724,7 +8718,7 @@ states.call_out_militias = { } if (done) { view.prompt = `Call Out Militias \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { if (game.count < 2) view.prompt = `Call Out Militias: Restore another militia to full strength.` @@ -8743,7 +8737,7 @@ states.call_out_militias = { restore_unit(p) game.count -= 1 }, - next() { + end_event() { end_action_phase() }, } @@ -8780,7 +8774,7 @@ states.rangers = { } if (done) { view.prompt = `Rangers \u2014 done.` - view.actions.next = 1 + view.actions.end_event = 1 } else { if (game.count < 2) view.prompt = `Rangers: Restore another ranger to full strength.` @@ -8799,7 +8793,7 @@ states.rangers = { restore_unit(p) game.count -= 1 }, - next() { + end_event() { end_action_phase() }, } @@ -8847,7 +8841,7 @@ states.french_regulars = { if (!has_british_units(LOUISBOURG) && !has_amphib(LOUISBOURG)) gen_action_space(LOUISBOURG) } else { - view.actions.next = 1 + view.actions.end_event = 1 } }, space(s) { @@ -8865,7 +8859,7 @@ states.french_regulars = { } game.count = 0 }, - next() { + end_event() { game.events.french_regulars = 1 delete game.leader end_action_phase() @@ -8912,7 +8906,7 @@ states.light_infantry = { } } if (game.count === 0) - view.actions.next = 1 + view.actions.end_event = 1 }, space(s) { push_undo() @@ -8930,7 +8924,7 @@ states.light_infantry = { } } }, - next() { + end_event() { end_british_reinforcement() }, } @@ -8988,7 +8982,7 @@ states.british_regulars = { gen_action_space(s) }) } else { - view.actions.next = 1 + view.actions.end_event = 1 } }, space(s) { @@ -9006,7 +9000,7 @@ states.british_regulars = { } } }, - next() { + end_event() { game.events.british_regulars = 1 end_british_reinforcement() }, @@ -9083,7 +9077,7 @@ states.highlanders = { gen_action_space(s) }) } else { - view.actions.next = 1 + view.actions.end_event = 1 } }, space(s) { @@ -9101,7 +9095,7 @@ states.highlanders = { } } }, - next() { + end_event() { end_british_reinforcement() }, } @@ -9156,7 +9150,7 @@ states.royal_americans = { if (has_unbesieged_friendly_fortress(s)) gen_action_space(s) } else { - view.actions.next = 1 + view.actions.end_event = 1 } }, space(s) { @@ -9174,7 +9168,7 @@ states.royal_americans = { } } }, - next() { + end_event() { end_british_reinforcement() }, } @@ -9252,7 +9246,7 @@ states.acadians_expelled_restore_coureurs_and_militia = { } if (done) { view.prompt = "Acadians Expelled: Restore all Coureurs and Militia \u2014 done." - view.actions.next = 1 + view.actions.end_event = 1 } else { view.prompt = "Acadians Expelled: Restore all Coureurs and Militia." } @@ -9260,7 +9254,7 @@ states.acadians_expelled_restore_coureurs_and_militia = { piece(p) { restore_unit(p) }, - next() { + end_event() { set_active(game.acadians) delete game.acadians end_action_phase() @@ -9295,7 +9289,7 @@ states.william_pitt = { } else { view.prompt = "William Pitt \u2014 done." } - view.actions.next = 1 + view.actions.end_event = 1 }, card(c) { push_undo() @@ -9304,7 +9298,7 @@ states.william_pitt = { player.hand.push(c) game.count = 0 }, - next() { + end_event() { end_action_phase() } } @@ -9337,7 +9331,7 @@ states.diplomatic_revolution = { } else { view.prompt = "Diplomatic Revolution \u2014 done." } - view.actions.next = 1 + view.actions.end_event = 1 }, card(c) { push_undo() @@ -9346,7 +9340,7 @@ states.diplomatic_revolution = { player.hand.push(c) game.count = 0 }, - next() { + end_event() { end_action_phase() } } |