diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-11-05 23:17:46 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-11-06 01:45:34 +0100 |
commit | 3c1ae85c4614cabbc84d2aa515885028c3e5bb0b (patch) | |
tree | b89669543bdccef73320ce63b232e18cebf577a3 | |
parent | 2d5bf7aca72ba2758f49c36b0bc3e71710dff073 (diff) | |
download | maria-3c1ae85c4614cabbc84d2aa515885028c3e5bb0b.tar.gz |
Pragmatic Army to England event.
-rw-r--r-- | play.js | 10 | ||||
-rw-r--r-- | rules.js | 104 |
2 files changed, 90 insertions, 24 deletions
@@ -1227,10 +1227,12 @@ function layout_electoral_college(ix, pow) { function update_favicon() { let favicon = document.querySelector('link[rel="icon"]') switch (params.role) { - case "Louis XV": favicon.href = "favicon/louis.png"; break - case "Frederick": favicon.href = "favicon/fritz.png"; break + case R_PLAYER_A: + case R_LOUIS_XV: favicon.href = "favicon/louis.png"; break + case R_FREDERICK: favicon.href = "favicon/fritz.png"; break default: - case "Maria Theresa": favicon.href = "favicon/maria.png"; break + case R_PLAYER_B: + case R_MARIA_THERESA: favicon.href = "favicon/maria.png"; break } } @@ -1609,6 +1611,8 @@ function sub_piece(match, p1) { function sub_space(match, p1) { let x = p1 | 0 + if (x === ELIMINATED) + return "eliminated" let n = data.cities.name[x] return `<span class="city_tip" onclick="on_click_city_tip(${x})" onmouseenter="on_focus_city_tip(${x})" onmouseleave="on_blur_city_tip(${x})">${n}</span>` } @@ -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) { |