summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js109
1 files changed, 109 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index 138d5bb..d0b8338 100644
--- a/rules.js
+++ b/rules.js
@@ -310,6 +310,18 @@ const EAST_PRUSSIA = find_city("East Prussia")
const AUSTRIAN_ITALY_BOX = data.sectors.ItalyA[0]
const FRENCH_ITALY_BOX = data.sectors.ItalyF[0]
+const all_electoral_colleges = [
+ // find_city("England"),
+ find_city("Prag"),
+ find_city("Mainz"),
+ find_city("Trier"),
+ find_city("Köln"),
+ find_city("Mannheim"),
+ find_city("München"),
+ find_city("Dresden"),
+ find_city("Berlin"),
+]
+
const all_pieces = [ ...all_power_generals.flat(), ...all_power_trains.flat() ]
const all_trains = [ ...all_power_trains.flat() ]
const all_generals = [ ...all_power_generals.flat() ]
@@ -1125,6 +1137,11 @@ function set_active_to_current_winter_stage() {
}
function goto_end_turn() {
+ if (game.flags & F_IMPERIAL_ELECTION) {
+ goto_imperial_election()
+ return
+ }
+
goto_start_turn()
}
@@ -4717,6 +4734,98 @@ states.france_reduces_military_objectives = {
},
}
+/* IMPERIAL ELECTION */
+
+const POWER_FROM_IMPERIAL_ELECTION_STAGE = [
+ P_AUSTRIA,
+ P_FRANCE,
+ P_PRAGMATIC,
+ P_PRUSSIA
+]
+
+function goto_imperial_election() {
+ log("# Imperial Election")
+ game.count = 0
+
+ game.state = "imperial_election"
+ game.stage = 0
+ set_active_to_power(P_AUSTRIA)
+ log(power_name[game.power])
+}
+
+function next_imperial_election() {
+ if (game.power === P_FRANCE) {
+ set_active_to_power(P_BAVARIA)
+ } else if (coop_major_power(P_SAXONY) === game.power) {
+ set_active_to_power(P_SAXONY)
+ } else {
+ if (++game.stage === 4) {
+ end_imperial_election()
+ return
+ }
+ set_active_to_power(POWER_FROM_IMPERIAL_ELECTION_STAGE[game.stage])
+ }
+ log(power_name[game.power])
+}
+
+states.imperial_election = {
+ inactive: "vote in the imperial election",
+ prompt() {
+ let n = 0
+ if (game.power === P_PRAGMATIC)
+ ++n
+ for (let s of all_electoral_colleges)
+ if (is_power_controlled_fortress(game.power, s))
+ ++n
+ if (n === 0)
+ prompt("Cast no votes in the Imperial Election.")
+ else if (n === 1)
+ prompt("Cast your vote in the Imperial Election.")
+ else
+ prompt("Cast " + n + " votes in the Imperial Election.")
+ if (n === 0)
+ view.actions.pass = 1
+ else {
+ if (game.power === P_AUSTRIA || game.power === P_PRAGMATIC)
+ view.actions.power = [ P_AUSTRIA ]
+ else
+ view.actions.power = [ P_FRANCE, P_AUSTRIA ]
+ }
+ },
+ power(pow) {
+ if (game.power === P_PRAGMATIC) {
+ log(">Hannover for Austria")
+ ++game.count
+ }
+
+ for (let s of all_electoral_colleges) {
+ if (is_power_controlled_fortress(game.power, s)) {
+ log(">S" + s + " for " + power_name[pow])
+ if (pow === P_AUSTRIA)
+ ++game.count
+ }
+ }
+
+ next_imperial_election()
+ },
+ pass() {
+ log(">No votes")
+ next_imperial_election()
+ }
+}
+
+function end_imperial_election() {
+ if (game.count >= 5) {
+ log("Francis Stephen of Lorraine is Emperor.")
+ game.flags |= F_EMPEROR_AUSTRIA
+ } else {
+ log("Charles Albert of Bavaria is Emperor.")
+ game.flags |= F_EMPEROR_FRANCE
+ }
+ game.flags &= ~F_IMPERIAL_ELECTION
+ goto_start_turn()
+}
+
/* SETUP */
const POWER_FROM_SETUP_STAGE = [