summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js1
-rw-r--r--rules.js48
2 files changed, 38 insertions, 11 deletions
diff --git a/play.js b/play.js
index e2e966d..998f81b 100644
--- a/play.js
+++ b/play.js
@@ -666,6 +666,7 @@ function on_update() {
action_button("event", "Event")
action_button("campaign", "Campaign")
+ action_button("landing_party", "Landing Party")
action_button("pickup_french_cu", "Take French CU")
action_button("pickup_british_cu", "Take CU")
diff --git a/rules.js b/rules.js
index 2cf429c..fd69ba7 100644
--- a/rules.js
+++ b/rules.js
@@ -1797,25 +1797,21 @@ function goto_ops_general(c) {
states.ops_general_who = {
prompt() {
- if (game.campaign && !has_flag(F_LANDING_PARTY))
+ let land = can_use_landing_party()
+ if (land)
view.prompt = "Campaign: Activate a general or use a landing party. " + game.campaign + " left."
else if (game.campaign)
view.prompt = "Campaign: Activate a general. " + game.campaign + " left."
else
view.prompt = "Activate a general with strategy rating " + game.count + " or lower."
- if (has_flag(F_LANDING_PARTY))
- gen_landing_party()
+ if (land)
+ view.actions.landing_party = 1
gen_activate_general()
view.actions.pass = 1
},
- space(where) {
+ landing_party() {
push_undo()
- clear_flag(F_LANDING_PARTY)
- if (has_american_pc())
- flip_pc(where)
- else
- place_british_pc(where)
- end_strategy_card()
+ game.state = "landing_party"
},
general(g) {
push_undo()
@@ -1829,6 +1825,36 @@ states.ops_general_who = {
},
}
+states.landing_party = {
+ prompt() {
+ view.prompt = "Campaign: Flip or place a PC in a port."
+ gen_landing_party()
+ },
+ space(where) {
+ clear_flag(F_LANDING_PARTY)
+ if (has_american_pc())
+ flip_pc(where)
+ else
+ place_british_pc(where)
+ // uses one campaign activation
+ end_strategy_card()
+ },
+}
+
+function can_use_landing_party() {
+ if (game.campaign && has_flag(F_LANDING_PARTY)) {
+ for (let space of all_spaces) {
+ if (!is_fortified_port(space) && is_non_blockaded_port(space)) {
+ if (has_american_pc(space) && has_no_american_unit(space))
+ return true
+ if (has_no_pc(space) && has_no_american_unit(space) && has_no_british_playing_piece(space))
+ return true
+ }
+ }
+ }
+ return false
+}
+
function gen_landing_party() {
for (let space of all_spaces) {
if (!is_fortified_port(space) && is_non_blockaded_port(space)) {
@@ -2224,7 +2250,7 @@ function gen_move_general() {
gen_action_space(to)
}
}
- if (game.active === P_BRITAIN && game.count === 4) {
+ if (game.active === P_BRITAIN && game.move.count === 4) {
if (is_non_blockaded_port(from)) {
for (let to of all_spaces) {
if (to !== from) {