From 3c1ae85c4614cabbc84d2aa515885028c3e5bb0b Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 5 Nov 2024 23:17:46 +0100 Subject: Pragmatic Army to England event. --- rules.js | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 83 insertions(+), 21 deletions(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 3718544..9fa3eef 100644 --- a/rules.js +++ b/rules.js @@ -1,18 +1,5 @@ "use strict" -/* - -TODO: confirm stacking when re-entering Arenberg on Flanders map? -TODO: stacking order (supreme) when re-entering generals. - -OPTIMIZE: fewer/smarter/smaller lists, smarter power control checks -OPTIMIZE: range checks instead of set checks - -UI: show TC modifiers in banner -UI: show objectives captured in banner - -*/ - const R_LOUIS_XV = "Louis XV" const R_FREDERICK = "Frederick" const R_MARIA_THERESA = "Maria Theresa" @@ -4877,7 +4864,10 @@ function goto_france_minus_tc_this_turn() { } function goto_pragmatic_general_to_england() { - throw "TODO" + log("Pragmatic Army -1 TC until game end.") + set_active_to_power(P_PRAGMATIC) + game.selected = ENGLAND + game.state = "send_expeditionary_corps_off_map" } /* POLITICAL TRACKS */ @@ -5046,13 +5036,25 @@ states.bring_expeditionary_corps_on_map = { if (can_move_piece_to(game.selected, ELIMINATED, entry)) gen_action_space(entry) else - for (let s of search_nearest_city(entry)) + for (let s of search_nearest_city(game.selected, entry)) gen_action_space(s) }, space(s) { + push_undo() log(`Expeditionary corps P${game.selected} from S${game.pos[game.selected]} to S${s}.`) enter_piece_at(game.selected, s) game.selected = -1 + game.state = "bring_expeditionary_corps_on_map_done" + }, +} + +states.bring_expeditionary_corps_on_map_done = { + inactive: "bring expeditionary corps onto map", + prompt() { + prompt("Bring expeditionary corps onto map done.") + view.actions.next = 1 + }, + next() { goto_expeditionary_corps() }, } @@ -5066,19 +5068,79 @@ states.send_expeditionary_corps_off_map = { gen_action_piece(p) }, piece(p) { + push_undo() + log(`Expeditionary corps P${p} from S${game.pos[p]} to S${game.selected}.`) - if (game.troops[p] === 0) - throw "TODO - pay for 2 troops minimum" game.pos[p] = game.selected game.selected = -1 - goto_expeditionary_corps() + + if (game.troops[p] === 0) { + game.recruit = { + pool: [], + used: [], + } + game.selected = p + game.state = "recruit_for_expeditionary_corps" + } else { + game.state = "send_expeditionary_corps_off_map_done" + } + }, +} + +states.send_expeditionary_corps_off_map_done = { + inactive: "send expeditionary corps off map", + prompt() { + prompt("Send expeditionary corps off map done.") + view.actions.next = 1 + }, + next() { + if (game.power === P_PRAGMATIC) + next_execute_political_card() + else + goto_expeditionary_corps() + }, +} + +states.recruit_for_expeditionary_corps = { + inactive: "send expeditionary corps off map", + prompt() { + prompt("Recruit 2 troops for expeditionary corps at a price of 8 TC-points.") + view.draw = game.recruit.pool + if (sum_card_values(game.recruit.pool) >= 8) + view.actions.next = 1 + else + gen_cards_in_hand() + }, + card(c) { + push_undo() + remove_card_in_hand(c) + set_add(game.recruit.pool, c) + }, + next() { + push_undo() + + spend_card_value(game.recruit.pool, game.recruit.used, 8) + + log(power_name[game.power] + " spent " + game.recruit.used.map(format_card).join(", ") + ".") + + // put back into hand unused cards + for (let c of game.recruit.pool) + set_add(game.hand2[game.power], c) + + delete game.recruit + + game.troops[game.selected] = 2 + game.selected = -1 + if (game.power === P_PRAGMATIC) + next_execute_political_card() + else + goto_expeditionary_corps() }, } /* SAXONY'S DEFECTION */ -function search_nearest_city(p) { - let from = game.pos[p] +function search_nearest_city(p, from) { let result = [] let min_dist = 1000 @@ -5288,7 +5350,7 @@ states.saxony_move_general = { prompt() { prompt("Move " + format_selected() + " to the nearest empty city.") view.selected = game.selected - for (let s of search_nearest_city(game.selected)) + for (let s of search_nearest_city(game.selected, game.pos[game.selected])) gen_action_space(s) }, space(s) { -- cgit v1.2.3