summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js187
1 files changed, 146 insertions, 41 deletions
diff --git a/rules.js b/rules.js
index 5df7f6a..8ec72f9 100644
--- a/rules.js
+++ b/rules.js
@@ -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 */