summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js233
1 files changed, 80 insertions, 153 deletions
diff --git a/rules.js b/rules.js
index 6061967..51f7bec 100644
--- a/rules.js
+++ b/rules.js
@@ -2300,6 +2300,7 @@ function remove_card(card) {
}
states.action_phase = {
+ inactive: "to play a card",
prompt() {
view.prompt = "Action Phase: Play a card."
for (let i = 0; i < player.hand.length; ++i)
@@ -2373,6 +2374,7 @@ events.campaign = {
}
states.activate_individually = {
+ inactive: "activate units and leaders individually",
prompt() {
view.prompt = `Activate units and/or leaders individually${format_remain(game.count)}.`
if (game.count > 0)
@@ -2442,6 +2444,7 @@ function can_activate_force(who) {
}
states.activate_force = {
+ inactive: "activate force",
prompt() {
view.prompt = "Activate a Force."
for (let p = first_friendly_leader; p <= last_friendly_leader; ++p)
@@ -2460,7 +2463,7 @@ states.activate_force = {
}
states.select_campaign_1 = {
- inactive: "campaign",
+ inactive: "to campaign",
prompt() {
view.prompt = "Campaign: Select the first leader."
for (let p = first_friendly_leader; p <= last_friendly_leader; ++p) {
@@ -2481,7 +2484,7 @@ states.select_campaign_1 = {
}
states.select_campaign_2 = {
- inactive: "campaign",
+ inactive: "to campaign",
prompt() {
view.prompt = "Campaign: Select the second leader."
for (let p = first_friendly_leader; p <= last_friendly_leader; ++p) {
@@ -2526,6 +2529,7 @@ function goto_pick_next_move() {
}
states.pick_move = {
+ inactive: "to move",
prompt() {
view.prompt = "Pick the next activated force, leader, or unit to move."
game.activation.forEach(gen_action_piece)
@@ -2575,9 +2579,7 @@ const designate_force_reason_prompt = {
}
states.designate_force = {
- inactive() {
- inactive_prompt("designate force " + designate_force_reason_prompt[game.force.reason], game.force.commander, 0)
- },
+ inactive: "to designate force",
prompt() {
let commander = game.force.commander
let where = piece_space(commander)
@@ -2738,9 +2740,7 @@ function end_designate_force() {
}
states.designate_force_lone_ax = {
- inactive() {
- inactive_prompt("designate lone auxiliary force to intercept", game.force.commander, 0)
- },
+ inactive: "to designate force",
prompt() {
let commander = game.force.commander
let where = piece_space(commander)
@@ -2857,9 +2857,7 @@ function start_move() {
}
states.siege_or_move = {
- inactive() {
- inactive_prompt("siege or move", moving_piece(), 0)
- },
+ inactive: "to move",
prompt() {
let where = moving_piece_space()
view.who = moving_piece()
@@ -3309,9 +3307,7 @@ function apply_move(to) {
}
states.move = {
- inactive() {
- inactive_prompt("move", moving_piece(), 0)
- },
+ inactive: "to move",
prompt() {
let who = moving_piece()
let from = moving_piece_space()
@@ -3469,6 +3465,7 @@ states.move = {
}
states.lake_schooner_confirm = {
+ inactive: "to move",
prompt() {
view.prompt = "This move may be interrupted by Lake Schooner. Continue?"
view.who = moving_piece()
@@ -3484,9 +3481,7 @@ states.lake_schooner_confirm = {
}
states.drop_off = {
- inactive() {
- inactive_prompt("move", moving_piece(), 0)
- },
+ inactive: "to move",
prompt() {
let who = moving_piece()
let where = moving_piece_space()
@@ -3536,9 +3531,7 @@ function goto_retroactive_foul_weather() {
}
states.foul_weather = {
- inactive() {
- inactive_prompt("foul weather", moving_piece(), 0)
- },
+ inactive: "to play Foul Weather",
prompt() {
let p = moving_piece()
view.who = p
@@ -3595,7 +3588,8 @@ states.foul_weather = {
states.lake_schooner = {
inactive() {
- inactive_prompt("lake schooner", moving_piece(), game.move.lake_schooner)
+ inactive_prompt("to play Lake Schooner")
+ view.where = game.move.lake_schooner
},
prompt() {
let who = moving_piece()
@@ -3646,9 +3640,7 @@ states.lake_schooner = {
}
states.amphibious_landing = {
- inactive() {
- inactive_prompt("amphibious landing", moving_piece(), 0)
- },
+ inactive: "to move",
prompt() {
let who = moving_piece()
let from = moving_piece_space()
@@ -3857,6 +3849,7 @@ function goto_confirm_move(from, to) {
}
states.confirm_move = {
+ inactive: "to move",
prompt() {
let from = moving_piece_came_from()
let to = moving_piece_space()
@@ -3909,9 +3902,7 @@ function is_moving_piece_lone_ax_in_wilderness_or_mountain() {
}
states.intercept_who = {
- inactive() {
- inactive_prompt("intercept", moving_piece(), 0)
- },
+ inactive: "to intercept",
prompt() {
let where = moving_piece_space()
view.where = where
@@ -4018,9 +4009,7 @@ function goto_designate_inside() {
}
states.designate_inside = {
- inactive() {
- inactive_prompt("designate inside", moving_piece(), 0)
- },
+ inactive: "to designate inside",
prompt() {
let where = moving_piece_space()
view.prompt = "You may withdraw leaders and units into the fortification."
@@ -4078,9 +4067,7 @@ function did_piece_intercept(p) {
}
states.avoid_who = {
- inactive() {
- inactive_prompt("avoid battle", moving_piece(), 0)
- },
+ inactive: "to avoid battle",
prompt() {
let from = moving_piece_space()
view.where = from
@@ -4163,9 +4150,7 @@ function can_enemy_avoid_battle(from) {
}
states.avoid_to = {
- inactive() {
- inactive_prompt("avoid battle", moving_piece(), 0)
- },
+ inactive: "to avoid battle",
prompt() {
let from = moving_piece_space()
view.prompt = `Avoid battle from ${space_name(from)} \u2014 select where to.`
@@ -4442,9 +4427,7 @@ function goto_battle_militia() {
}
states.militia_in_battle = {
- inactive() {
- inactive_prompt("deploy militia in battle", 0, game.battle.where)
- },
+ inactive: "to deploy militia",
prompt() {
view.prompt = `You may deploy militia at ${space_name(game.battle.where)}.`
let box = department_militia(game.battle.where)
@@ -4502,9 +4485,7 @@ function sortie_with_piece(p) {
}
states.sortie = {
- inactive() {
- inactive_prompt("sortie with besieged units", 0, game.battle.where)
- },
+ inactive: "to sortie",
prompt() {
view.prompt = `You may sortie with besieged units at ${space_name(game.battle.where)}.`
view.where = game.battle.where
@@ -4662,9 +4643,7 @@ function goto_battle_defender_events() {
}
states.attacker_events = {
- inactive() {
- inactive_prompt("attacker events", 0, game.battle.where)
- },
+ inactive: "to play response cards",
prompt() {
let have = []
let dont_have = []
@@ -4739,9 +4718,7 @@ states.attacker_events = {
}
states.defender_events = {
- inactive() {
- inactive_prompt("defender events", 0, game.battle.where)
- },
+ inactive: "to play response cards",
prompt() {
let have = []
let dont_have = []
@@ -5064,12 +5041,7 @@ function goto_def_step_losses() {
}
states.step_losses = {
- inactive() {
- if (game.active === game.battle.defender)
- inactive_prompt("defender step losses", 0, game.battle.where)
- else
- inactive_prompt("attacker step losses", 0, game.battle.where)
- },
+ inactive: "to take step losses",
prompt() {
let done = true
if (game.battle.step_loss > 0) {
@@ -5150,9 +5122,7 @@ function goto_raid_step_losses() {
}
states.raid_step_losses = {
- inactive() {
- inactive_prompt("raid step losses", 0, game.raid.where)
- },
+ inactive: "to take step losses",
prompt() {
view.prompt = `Apply step losses (${game.raid.step_loss}).`
let can_reduce = false
@@ -5223,12 +5193,7 @@ function goto_def_leader_check() {
}
states.leader_check = {
- inactive() {
- if (game.active === game.battle.defender)
- inactive_prompt("defender leader check", 0, game.battle.where)
- else
- inactive_prompt("attacker leader check", 0, game.battle.where)
- },
+ inactive: "to roll for leader losses",
prompt() {
view.prompt = "Roll for leader losses."
for (let i = 0; i < game.battle.leader_check.length; ++i)
@@ -5266,9 +5231,7 @@ function goto_raid_leader_check() {
}
states.raid_leader_check = {
- inactive() {
- inactive_prompt("raider leader check", 0, game.raid.where)
- },
+ inactive: "to roll for leader losses",
prompt() {
view.prompt = "Roll for leader losses."
for (let i = 0; i < game.raid.leader_check.length; ++i)
@@ -5488,9 +5451,7 @@ function retreat_attacker(from, to) {
}
states.retreat_attacker = {
- inactive() {
- inactive_prompt("attacker retreat", 0, game.retreat.from)
- },
+ inactive: "to retreat",
prompt() {
let from = game.retreat.from
let to = game.retreat.to
@@ -5625,9 +5586,7 @@ function can_any_defenders_retreat_inside(from) {
}
states.retreat_defender = {
- inactive() {
- inactive_prompt("defender retreat", 0, game.battle.where)
- },
+ inactive: "to retreat",
prompt() {
let from = game.battle.where
view.prompt = "Retreat losing leaders and units \u2014"
@@ -5671,9 +5630,7 @@ states.retreat_defender = {
}
states.retreat_defender_to = {
- inactive() {
- inactive_prompt("defender retreat", 0, game.battle.where)
- },
+ inactive: "to retreat",
prompt() {
let from = game.battle.where
let who = game.battle.who
@@ -5708,9 +5665,7 @@ states.retreat_defender_to = {
}
states.retreat_all_defenders_to = {
- inactive() {
- inactive_prompt("defender retreat", 0, game.battle.where)
- },
+ inactive: "to retreat",
prompt() {
let from = game.battle.where
view.prompt = "Retreat all losing leaders and units \u2014 select where to."
@@ -5785,9 +5740,7 @@ function pick_unbesieged_leader(s) {
}
states.retreat_lone_leader = {
- inactive() {
- inactive_prompt("retreat lone leader", game.move ? moving_piece() : 0, game.retreat.where)
- },
+ inactive: "to retreat lone leader",
prompt() {
let from = game.retreat.from
let who = pick_unbesieged_leader(from)
@@ -5912,9 +5865,7 @@ function goto_siege(space) {
}
states.siege_coehorns_attacker = {
- inactive() {
- inactive_prompt("attacker siege coehorns", 0, game.siege_where)
- },
+ inactive: "to play Coehorns & Howitzvers",
prompt() {
if (player.hand.includes(COEHORNS)) {
view.prompt = `Siege at ${space_name(game.siege_where)}. You may play "Coehorns & Howitzers".`
@@ -5943,9 +5894,7 @@ function end_siege_coehorns_attacker() {
}
states.siege_coehorns_defender = {
- inactive() {
- inactive_prompt("defender siege coehorns", 0, game.siege_where)
- },
+ inactive: "to play Coehorns & Howitzvers",
prompt() {
if (player.hand.includes(COEHORNS)) {
view.prompt = `Siege at ${space_name(game.siege_where)}. You may play "Coehorns & Howitzers".`
@@ -5978,9 +5927,7 @@ function end_siege_coehorns_defender() {
}
states.siege_surrender = {
- inactive() {
- inactive_prompt("siege surrender", 0, game.siege_where)
- },
+ inactive: "to play Surrender",
prompt() {
if (player.hand.includes(SURRENDER)) {
view.prompt = `Siege at ${space_name(game.siege_where)}. You may play "Surrender!"`
@@ -6031,9 +5978,7 @@ function goto_surrender_place() {
}
states.surrender = {
- inactive() {
- inactive_prompt("surrender", 0, game.siege_where)
- },
+ inactive: "to play Surrender",
prompt() {
view.prompt = "Surrender! Place defenders at the closest unbesieged fortification."
view.where = game.siege_where
@@ -6115,9 +6060,7 @@ function goto_assault_possible(where) {
}
states.assault_possible = {
- inactive() {
- inactive_prompt("assault is possible", 0, game.assault_possible)
- },
+ inactive: "to assault",
prompt() {
view.prompt = `You may assault at ${space_name(game.assault_possible)}.`
gen_action_space(game.assault_possible)
@@ -6160,7 +6103,7 @@ function goto_pick_raid() {
}
states.pick_raid = {
- inactive: "pick raid",
+ inactive: "to raid",
prompt() {
view.prompt = "Pick the next raid space."
for (let i=0; i < game.raid.list.length; ++i)
@@ -6192,9 +6135,7 @@ function goto_raid_militia() {
}
states.militia_against_raid = {
- inactive() {
- inactive_prompt("deploy militia against raid", 0, game.raid.where)
- },
+ inactive: "to deploy militia",
prompt() {
view.prompt = `You may deploy one militia against the raid at ${space_name(game.raid.where)}.`
view.where = game.raid.where
@@ -6242,9 +6183,7 @@ function goto_raid_events() {
}
states.raid_blockhouses = {
- inactive() {
- inactive_prompt("raid blockhouses", 0, game.raid.where)
- },
+ inactive: "to play Blockhouses",
prompt() {
if (player.hand.includes(BLOCKHOUSES)) {
view.prompt = `Raid at ${space_name(game.raid.where)}. You may play "Blockhouses".`
@@ -6404,9 +6343,7 @@ function end_indians_and_leaders_go_home() {
}
states.raiders_go_home = {
- inactive() {
- inactive_prompt("raiders go home", 0, game.raid.where)
- },
+ inactive: "to go home",
prompt() {
let from = game.raid.where
let done = true
@@ -6454,7 +6391,7 @@ states.raiders_go_home = {
}
states.indians_and_leaders_go_home = {
- inactive: "indians and leaders go home",
+ inactive: "to go home with indians and leaders",
prompt() {
let done = true
for (let p = first_friendly_piece; p <= last_friendly_piece; ++p) {
@@ -6497,12 +6434,7 @@ states.indians_and_leaders_go_home = {
}
states.go_home_to = {
- inactive() {
- if (game.go_home.reason === 'late_season')
- inactive_prompt("indians and leaders go home", 0, 0)
- else
- inactive_prompt("raiders go home", 0, game.raid.where)
- },
+ inactive: "to go home",
prompt() {
let who = game.go_home.who
let from = game.go_home.from
@@ -6590,12 +6522,7 @@ states.go_home_to = {
}
states.go_home_with_indians = {
- inactive() {
- if (game.go_home.reason === 'late_season')
- inactive_prompt("indians and leaders go home", 0, 0)
- else
- inactive_prompt("raiders go home", 0, game.raid.where)
- },
+ inactive: "to go home",
prompt() {
let from = game.go_home.from
let to = game.go_home.to
@@ -6739,7 +6666,7 @@ function end_winter_attrition() {
}
states.winter_attrition = {
- inactive: "winter attrition",
+ inactive: "to take winter attrition",
prompt() {
let done = true
for (let s in game.winter_attrition) {
@@ -6927,7 +6854,7 @@ function end_demolish() {
}
states.demolish_fort = {
- inactive: "demolish fort",
+ inactive: "to demolish fort",
prompt() {
view.prompt = "Demolish an unbesieged friendly fort."
for (let s of player.forts)
@@ -6954,7 +6881,7 @@ states.demolish_fort = {
}
states.demolish_stockade = {
- inactive: "demolish stockade",
+ inactive: "to demolish stockade",
prompt() {
view.prompt = "Demolish a friendly stockade."
for (let s of player.stockades)
@@ -6971,7 +6898,7 @@ states.demolish_stockade = {
}
states.demolish_fieldworks = {
- inactive: "demolish fieldworks",
+ inactive: "to demolish fieldworks",
prompt() {
view.prompt = "Demolish friendly fieldworks."
for (let s of game.fieldworks)
@@ -7001,7 +6928,7 @@ function goto_construct_stockades(card) {
}
states.construct_stockades = {
- inactive: "construct stockades",
+ inactive: "to construct stockades",
prompt() {
view.prompt = `Construct Stockades${format_remain(game.count)}.`
gen_action("end_construction")
@@ -7052,7 +6979,7 @@ function goto_construct_forts(card) {
}
states.construct_forts = {
- inactive: "construct forts",
+ inactive: "to construct forts",
prompt() {
view.prompt = `Construct Forts${format_remain(game.count)}.`
gen_action("end_construction")
@@ -7122,7 +7049,6 @@ function end_british_reinforcement() {
}
states.max_two_7_command_leaders_in_play = {
- inactive: "remove a 7 command leader",
prompt() {
if (count_7_command_leaders_in_play() > 2) {
view.prompt = `Remove a 7 command leader from play.`
@@ -7180,9 +7106,7 @@ function end_massacre() {
}
states.massacre_1 = {
- inactive() {
- inactive_prompt("massacre", moving_piece(), 0)
- },
+ inactive: "to play Massacre",
prompt() {
if (player.hand.includes(MASSACRE)) {
view.prompt = `You may play "Massacre!"`
@@ -7205,9 +7129,7 @@ states.massacre_1 = {
}
states.massacre_2 = {
- inactive() {
- inactive_prompt("massacre", moving_piece(), 0)
- },
+ inactive: "to play Massacre",
prompt() {
let s = moving_piece_space()
let done = true
@@ -7784,7 +7706,6 @@ events.governor_vaudreuil_interferes = {
}
states.governor_vaudreuil_interferes = {
- inactive: "governor Vaudreuil interferes",
prompt() {
if (game.count > 0) {
if (game.swap) {
@@ -7871,9 +7792,6 @@ states.small_pox_roll = {
}
states.small_pox_eliminate_steps = {
- inactive() {
- inactive_prompt("small pox", 0, game.small_pox)
- },
prompt() {
let done = true
if (game.count > 0) {
@@ -7912,9 +7830,6 @@ states.small_pox_eliminate_steps = {
}
states.small_pox_remove_indians = {
- inactive() {
- inactive_prompt("small pox", 0, game.small_pox)
- },
prompt() {
view.prompt = `Small Pox at ${space_name(game.small_pox)}: Remove all indians.`
for_each_unit_in_space(game.small_pox, p => {
@@ -8214,7 +8129,6 @@ events.british_colonial_politics = {
}
states.british_colonial_politics_1f = {
- inactive: "British colonial politics",
prompt() {
view.prompt = `British Colonial Politics: Slide Provincial Assemblies marker to ${pa_name(game.pa-1)}.`
if (game.pa === 2)
@@ -8235,7 +8149,6 @@ states.british_colonial_politics_1f = {
}
states.british_colonial_politics_1b = {
- inactive: "British colonial politics",
prompt() {
view.prompt = `British Colonial Politics: Slide Provincial Assemblies marker to ${pa_name(game.pa+1)}.`
if (game.pa === 0)
@@ -8274,7 +8187,6 @@ function goto_british_colonial_politics() {
}
states.british_colonial_politics = {
- inactive: "British colonial politics",
prompt() {
let num_s = count_southern_provincials()
let num_n = count_northern_provincials()
@@ -9178,7 +9090,6 @@ events.acadians_expelled = {
}
states.acadians_expelled_place_regulars = {
- inactive: 'Acadians expelled (place regulars)',
prompt() {
view.prompt = "Acadians Expelled: Place two Regulars at Halifax."
gen_action_space(HALIFAX)
@@ -9195,7 +9106,6 @@ states.acadians_expelled_place_regulars = {
}
states.acadians_expelled_place_coureurs = {
- inactive: 'Acadians expelled (place coureurs)',
prompt() {
view.prompt = "Acadians Expelled: Place a Coureurs unit at Québec or Louisbourg."
let quebec = has_british_units(QUEBEC) || has_amphib(QUEBEC)
@@ -9222,7 +9132,6 @@ states.acadians_expelled_place_coureurs = {
}
states.acadians_expelled_restore_coureurs_and_militia = {
- inactive: 'Acadians expelled (restore coureurs and militia)',
prompt() {
let done = true
for (let p = first_french_militia; p <= last_french_militia; ++p) {
@@ -9339,6 +9248,7 @@ states.diplomatic_revolution = {
}
states.discard_to_draw_regulars = {
+ inactive: "to exchange random card for regulars",
prompt() {
view.prompt = `Exchange random card with British Regulars or Highlanders from discard?`
view.actions.exchange = 1
@@ -9354,6 +9264,7 @@ states.discard_to_draw_regulars = {
}
states.draw_regulars = {
+ inactive: "to exchange random card for regulars",
prompt() {
view.prompt = `Draw one British Regulars or Highlanders from the discard.`
view.hand = game.discard
@@ -9980,12 +9891,8 @@ exports.query = function (state, current, q) {
return null
}
-function inactive_prompt(name, who, where) {
- view.prompt = `Waiting for ${game.active} \u2014 ${name}...`
- if (who)
- view.who = who
- if (where)
- view.where = where
+function inactive_prompt(text) {
+ view.prompt = `Waiting for ${game.active} ${text}.`
}
exports.view = function(state, current) {
@@ -10054,11 +9961,27 @@ exports.view = function(state, current) {
if (current === 'Observer' || game.active !== current) {
let inactive = states[game.state].inactive
if (typeof inactive === 'function')
- states[game.state].inactive()
+ inactive()
else if (typeof inactive === 'string')
inactive_prompt(inactive)
else
- inactive_prompt(game.state.replace(/_/g, " "))
+ inactive_prompt("to execute event")
+
+ // hacks to set who/where for inactive player
+ if (game.move)
+ view.who = game.move.moving
+ else if (game.battle)
+ view.where = game.battle.where
+ else if (game.raid)
+ view.where = game.raid.where
+ else if (game.retreat)
+ view.where = game.retreat.from
+ else if (game.siege_where)
+ view.where = game.siege_where
+ else if (game.assault_possible)
+ view.where = game.assault_possible
+ else if (game.small_pox)
+ view.where = game.small_pox
} else {
view.actions = {}
states[game.state].prompt()
@@ -10164,3 +10087,7 @@ function object_copy(original) {
return copy
}
}
+
+/* ASSERTS */
+
+// for (let s in states) if (states[s].inactive === undefined) console.log("STATE MISSING INACTIVE: " + s)