diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-10-23 10:11:36 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-23 10:11:36 +0200 |
commit | 14c925654ffbd4442422527374a20d7d79dc2e70 (patch) | |
tree | 0abaff4a697339713b09f50a41344bf2c8fec906 | |
parent | dbd210967deeccc035b5b1ac713917ab37a9a08a (diff) | |
download | maria-14c925654ffbd4442422527374a20d7d79dc2e70.tar.gz |
saxony stuff
-rw-r--r-- | cards.js | 2 | ||||
-rw-r--r-- | play.css | 50 | ||||
-rw-r--r-- | rules.js | 187 |
3 files changed, 172 insertions, 67 deletions
@@ -27,7 +27,7 @@ def_pol_card(1741, ) def_pol_card(1741, - "Military Aid?", + "Military Aid", [ P_PRUSSIA, P_FRANCE, P_AUSTRIA ], "FLAVOR", [ @@ -550,31 +550,31 @@ body.shift span.value.deck_4 { background-color: #f002 } .card.tc.reverse.deck_3 { background-image: url(cards/Maria.TC.reverse.deck_3.075.jpg) } .card.tc.reverse.deck_4 { background-image: url(cards/Maria.TC.reverse.deck_4.075.jpg) } -.card.polcard.c1 { background-image: url(cards/Maria.PolCard.01.075.jpg) } -.card.polcard.c2 { background-image: url(cards/Maria.PolCard.02.075.jpg) } -.card.polcard.c3 { background-image: url(cards/Maria.PolCard.03.075.jpg) } -.card.polcard.c4 { background-image: url(cards/Maria.PolCard.04.075.jpg) } -.card.polcard.c5 { background-image: url(cards/Maria.PolCard.05.075.jpg) } -.card.polcard.c6 { background-image: url(cards/Maria.PolCard.06.075.jpg) } -.card.polcard.c7 { background-image: url(cards/Maria.PolCard.07.075.jpg) } -.card.polcard.c8 { background-image: url(cards/Maria.PolCard.08.075.jpg) } -.card.polcard.c9 { background-image: url(cards/Maria.PolCard.09.075.jpg) } -.card.polcard.c10 { background-image: url(cards/Maria.PolCard.10.075.jpg) } -.card.polcard.c11 { background-image: url(cards/Maria.PolCard.11.075.jpg) } -.card.polcard.c12 { background-image: url(cards/Maria.PolCard.12.075.jpg) } -.card.polcard.c13 { background-image: url(cards/Maria.PolCard.13.075.jpg) } -.card.polcard.c14 { background-image: url(cards/Maria.PolCard.14.075.jpg) } -.card.polcard.c15 { background-image: url(cards/Maria.PolCard.15.075.jpg) } -.card.polcard.c16 { background-image: url(cards/Maria.PolCard.16.075.jpg) } -.card.polcard.c17 { background-image: url(cards/Maria.PolCard.17.075.jpg) } -.card.polcard.c18 { background-image: url(cards/Maria.PolCard.18.075.jpg) } -.card.polcard.c19 { background-image: url(cards/Maria.PolCard.19.075.jpg) } -.card.polcard.c20 { background-image: url(cards/Maria.PolCard.20.075.jpg) } -.card.polcard.c21 { background-image: url(cards/Maria.PolCard.21.075.jpg) } -.card.polcard.c22 { background-image: url(cards/Maria.PolCard.22.075.jpg) } -.card.polcard.c23 { background-image: url(cards/Maria.PolCard.23.075.jpg) } -.card.polcard.c24 { background-image: url(cards/Maria.PolCard.24.075.jpg) } -.card.polcard.c25 { background-image: url(cards/Maria.PolCard.ImpElection.075.jpg) } +.card.polcard.c0 { background-image: url(cards/Maria.PolCard.01.075.jpg) } +.card.polcard.c1 { background-image: url(cards/Maria.PolCard.02.075.jpg) } +.card.polcard.c2 { background-image: url(cards/Maria.PolCard.03.075.jpg) } +.card.polcard.c3 { background-image: url(cards/Maria.PolCard.04.075.jpg) } +.card.polcard.c4 { background-image: url(cards/Maria.PolCard.05.075.jpg) } +.card.polcard.c5 { background-image: url(cards/Maria.PolCard.06.075.jpg) } +.card.polcard.c6 { background-image: url(cards/Maria.PolCard.07.075.jpg) } +.card.polcard.c7 { background-image: url(cards/Maria.PolCard.08.075.jpg) } +.card.polcard.c8 { background-image: url(cards/Maria.PolCard.09.075.jpg) } +.card.polcard.c9 { background-image: url(cards/Maria.PolCard.10.075.jpg) } +.card.polcard.c10 { background-image: url(cards/Maria.PolCard.11.075.jpg) } +.card.polcard.c11 { background-image: url(cards/Maria.PolCard.12.075.jpg) } +.card.polcard.c12 { background-image: url(cards/Maria.PolCard.13.075.jpg) } +.card.polcard.c13 { background-image: url(cards/Maria.PolCard.14.075.jpg) } +.card.polcard.c14 { background-image: url(cards/Maria.PolCard.15.075.jpg) } +.card.polcard.c15 { background-image: url(cards/Maria.PolCard.16.075.jpg) } +.card.polcard.c16 { background-image: url(cards/Maria.PolCard.17.075.jpg) } +.card.polcard.c17 { background-image: url(cards/Maria.PolCard.18.075.jpg) } +.card.polcard.c18 { background-image: url(cards/Maria.PolCard.19.075.jpg) } +.card.polcard.c19 { background-image: url(cards/Maria.PolCard.20.075.jpg) } +.card.polcard.c20 { background-image: url(cards/Maria.PolCard.21.075.jpg) } +.card.polcard.c21 { background-image: url(cards/Maria.PolCard.22.075.jpg) } +.card.polcard.c22 { background-image: url(cards/Maria.PolCard.23.075.jpg) } +.card.polcard.c23 { background-image: url(cards/Maria.PolCard.24.075.jpg) } +.card.polcard.c24 { background-image: url(cards/Maria.PolCard.ImpElection.075.jpg) } .card.polcard.reverse.deck_1 { background-image: url(cards/Maria.PolCard.reverse.deck_1.075.jpg) } .card.polcard.reverse.deck_2 { background-image: url(cards/Maria.PolCard.reverse.deck_2.075.jpg) } @@ -91,7 +91,8 @@ const F_ITALY_FRANCE = 4 const F_ITALY_AUSTRIA = 8 const F_SILESIA_ANNEXED = 16 const F_IMPERIAL_ELECTION = 32 // imperial election card revealed! -const F_WAR_OF_JENKINS_EAR = 64 +const F_WAR_OF_JENKINS_EAR = 64 // -1 France TC for one turn +const F_SAXONY_TC_ONCE = 128 // only draw TCs once per turn const SPADES = 0 const CLUBS = 1 @@ -373,15 +374,21 @@ const all_powers_bavaria_saxony = [ P_BAVARIA, P_SAXONY ] function coop_major_power(pow) { if (pow === P_BAVARIA) return P_FRANCE - if (pow === P_SAXONY) - return P_PRUSSIA + if (pow === P_SAXONY) { + if (is_saxony_prussian()) + return P_PRUSSIA + if (is_saxony_austrian()) + return P_AUSTRIA + } return pow } function coop_minor_power(pow) { if (pow === P_FRANCE) return P_BAVARIA - if (pow === P_PRUSSIA) + if (pow === P_PRUSSIA && is_saxony_prussian()) + return P_SAXONY + if (pow === P_AUSTRIA && is_saxony_austrian()) return P_SAXONY return pow } @@ -742,6 +749,32 @@ function tc_per_turn() { ++n } + // Saxony track + if (game.power === P_SAXONY) { + if (game.saxony > 4) + ++n + } + + // Russia track + if (game.power === P_PRUSSIA) { + if (game.russia <= 2) + ++n + if (game.russia >= 8) + --n + if (game.russia >= 9) + --n + } + + // Italy track + if (game.power === P_AUSTRIA) { + if (game.italy <= 3) + --n + } + if (game.power === P_FRANCE) { + if (game.italy >= 7) + --n + } + // Jacobite Rising if (game.power === P_PRAGMATIC) { for (let p of all_power_generals[P_PRAGMATIC]) @@ -751,10 +784,8 @@ function tc_per_turn() { // War of Jenkins' Ear if (game.power === P_FRANCE) { - if (game.flags & F_WAR_OF_JENKINS_EAR) { - game.flags &= ~F_WAR_OF_JENKINS_EAR + if (game.flags & F_WAR_OF_JENKINS_EAR) --n - } } return n @@ -977,6 +1008,10 @@ function goto_start_turn() { game.selected = -1 + // clear per turn flags + game.flags &= ~F_SAXONY_TC_ONCE + game.flags &= ~F_WAR_OF_JENKINS_EAR + if (game.turn % 4 === 0) { goto_winter_turn() } else { @@ -991,8 +1026,6 @@ function goto_action_stage() { log(title_from_action_stage[game.stage]) - // TODO: minor powers controlled at the same time - goto_tactical_cards() } @@ -1194,7 +1227,8 @@ function draw_tc(n, verbose = true) { function goto_tactical_cards() { // TODO: pause to decide subsidy (france/bavaria) - // TODO: no TC (even subsidy) if major fortress is enemy controlled + if (game.power === P_SAXONY) + game.flags |= F_SAXONY_TC_ONCE if (game.power === P_BAVARIA && is_enemy_controlled_fortress(MUNCHEN)) { log("S" + MUNCHEN + " is enemy controlled.") @@ -1226,25 +1260,22 @@ function end_tactical_cards() { set_add(game.hand[game.power], c) delete game.draw - // MARIA: supply is before movement - - if (game.power === P_FRANCE) { - set_active_to_power(P_BAVARIA) + // draw minor power's cards after major power + let minor = coop_minor_power(game.power) + if (minor === P_SAXONY && (game.flags & F_SAXONY_TC_ONCE)) + minor = game.power + if (minor !== game.power) { + set_active_to_power(minor) goto_tactical_cards() return } - if (game.power === P_BAVARIA) - set_active_to_power(P_FRANCE) - if (game.power === P_PRUSSIA) { - set_active_to_power(P_SAXONY) - goto_tactical_cards() - return - } - if (game.power === P_SAXONY) - set_active_to_power(P_PRUSSIA) + // back to major power after minor power + let major = coop_major_power(game.power) + if (major !== game.power) + set_active_to_power(major) - // TODO: draw pragmatic cards before austria moves + // TODO: draw austria and pragmatic cards at the same time goto_supply() } @@ -3149,12 +3180,8 @@ function lose_vp(pow, n) { } function finish_combat() { - let n = 0 - if (game.lost_troops >= 6) - n = 2 - else if (game.lost_troops >= 3) - n = 1 - else if (game.lost_generals > 0) + let n = game.lost_troops / 3 | 0 + if (n < 0 && game.lost_generals > 0) n = 1 if (n > 0) { @@ -3165,6 +3192,13 @@ function finish_combat() { delete game.lost_generals delete game.lost_troops + if (game.loser_power === P_PRUSSIA && n > 0 && game.saxony < 5) { + game.count = n + set_active_to_power(P_AUSTRIA) + game.state = "saxony_shift" + return + } + next_combat() } @@ -3295,6 +3329,8 @@ function goto_politics() { game.political.push(pc) } + game.save_saxony = game.saxony + if (game.winner_power >= 0) { set_active_to_power(game.winner_power) game.state = "determine_trump_suit" @@ -3463,6 +3499,7 @@ states.political_card_discard_or_execute = { inactive: "select a political card", prompt() { prompt(`Execute or discard "${political_cards[game.pc].title}".`) + view.pc = game.pc view.actions.execute = 1 view.actions.discard = 1 }, @@ -3489,6 +3526,10 @@ function end_politics() { } } + goto_adjust_political_tracks() +} + +function end_adjust_political_tracks() { if (check_instant_victory()) return @@ -3515,7 +3556,7 @@ const event_shift = { "Saxony -1 if allied with Prussia": { track: "saxony", amount: [ -1 ], - condition: () => is_saxony_allied_with_prussia(), + condition: () => game.saxony < 3, }, } @@ -3575,7 +3616,7 @@ function end_execute_political_card() { array_remove_item(game.political, game.pc) delete game.pc delete game.pcx - goto_adjust_political_tracks() + goto_select_political_card() } const TRACK_NAME = { saxony: "Saxony marker", russia: "Russia marker", italy: "Italy marker" } @@ -3610,9 +3651,12 @@ states.political_shift = { states.political_troop_power = { inactive: "execute political card", prompt() { - let fx = current_political_effect() - let info = event_troops[fx] - prompt(fx) + let info = event_troops[current_political_effect()] + let powers = info.power().map(pow => power_name[pow]).join(" or ") + if (info.tcs > 0) + prompt(powers + " receives 1 TC and " + info.troops + " troops.") + else + prompt(powers + " receives " + info.troops + ".") view.pc = game.pc view.actions.power = info.power() view.actions.pass = 1 @@ -3660,9 +3704,9 @@ states.political_troops_place = { prompt() { let info = event_troops[current_political_effect()] if (game.count > 1) - prompt("Add " + game.count + " troops.") + prompt("Recieve " + game.count + " troops.") else if (game.count === 1) - prompt("Add 1 troop.") + prompt("Recieve 1 troop.") if (game.count > 0) { for (let p of all_power_generals[game.power]) { @@ -3706,15 +3750,76 @@ function goto_france_minus_tc_this_turn() { /* POLITICAL TRACKS */ +function is_saxony_neutral() { + return game.saxony > 2 && game.saxony < 5 +} + +function is_saxony_prussian() { + return game.saxony <= 2 +} + +function is_saxony_austrian() { + // Austrian control, but neutral + return game.saxony >= 3 +} + +function is_saxony_austrian_ally() { + return game.saxony === 5 +} + +states.saxony_shift = { + inactive: "shift Saxony marker", + prompt() { + prompt("Shift Saxony marker ${game.count} to the right.") + view.actions.shift = [ 1 ] + view.actions.pass = 1 + }, + shift(_) { + log("Saxony marker shifted " + game.count + " right.") + let save_saxony = game.saxony + game.saxony = Math.max(1, Math.min(5, game.saxony + game.count)) + game.count = 0 + + // Saxony defection + if (save_saxony < 3 && is_saxony_neutral()) + throw "TODO Saxony became neutral!" + else if (save_saxony < 5 && is_saxony_austrian_ally()) + throw "TODO Saxony became austrian!" + else + next_combat() + }, + pass() { + log("Saxony marker not shifted.") + game.count = 0 + next_combat() + }, +} + function goto_adjust_political_tracks() { // clamp final values to track game.saxony = Math.max(1, Math.min(5, game.saxony)) game.russia = Math.max(1, Math.min(9, game.russia)) game.italy = Math.max(1, Math.min(9, game.italy)) - // TODO: handle expeditionary corps - // TODO: handle victory points (italy) - // TODO: handle saxony alliance - goto_select_political_card() + + // TODO: log italy vp change + if (game.italy <= 2) game.flags |= F_ITALY_FRANCE + if (game.italy <= 5) game.flags &= ~F_ITALY_AUSTRIA + if (game.italy >= 5) game.flags &= ~F_ITALY_FRANCE + if (game.italy >= 8) game.flags |= F_ITALY_AUSTRIA + + // Expeditionary corps + // TODO + + // Saxony defection + let save_saxony = game.save_saxony + delete game.save_saxony + + if (save_saxony < 3 && is_saxony_neutral()) + throw "TODO Saxony became neutral!" + else if (save_saxony < 5 && is_saxony_austrian_ally()) + throw "TODO Saxony became austrian!" + + end_adjust_political_tracks() } /* SETUP */ |