summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js139
1 files changed, 110 insertions, 29 deletions
diff --git a/rules.js b/rules.js
index 6dec54a..f880362 100644
--- a/rules.js
+++ b/rules.js
@@ -146,34 +146,34 @@ const all_power_generals_rev = all_power_generals.map(list => list.slice().rever
const all_pieces = [ ...all_power_generals.flat(), ...all_power_trains.flat() ]
const all_generals = [ ...all_power_generals.flat() ]
-const all_france_generals = [
+const all_france_bavaria_generals = [
...all_power_generals[P_FRANCE],
...all_power_generals[P_BAVARIA],
]
-const all_prussia_generals = [
+const all_prussia_saxony_generals = [
...all_power_generals[P_PRUSSIA],
...all_power_generals[P_SAXONY],
- ...all_power_generals[P_PRAGMATIC],
]
-const all_austria_generals = [
+const all_austria_pragmatic_generals = [
...all_power_generals[P_AUSTRIA],
+ ...all_power_generals[P_PRAGMATIC],
]
-const all_france_trains = [
+const all_france_bavaria_trains = [
...all_power_trains[P_FRANCE],
...all_power_trains[P_BAVARIA],
]
-const all_prussia_trains = [
+const all_prussia_saxony_trains = [
...all_power_trains[P_PRUSSIA],
...all_power_trains[P_SAXONY],
- ...all_power_trains[P_PRAGMATIC],
]
-const all_austria_trains = [
+const all_austria_pragmatic_trains = [
...all_power_trains[P_AUSTRIA],
+ ...all_power_trains[P_PRAGMATIC],
]
const all_france_allied_trains = [
@@ -200,6 +200,54 @@ const all_france_allied_generals = [
...all_power_generals[P_SAXONY],
]
+const all_powers_prussia_saxony_pragmatic_austria = [ P_PRUSSIA, P_SAXONY, P_PRAGMATIC, P_AUSTRIA ]
+const all_powers_france_bavaria_pragmatic_austria = [ P_FRANCE, P_BAVARIA, P_PRAGMATIC, P_AUSTRIA ]
+const all_powers_france_bavaria_prussia_saxony = [ P_FRANCE, P_BAVARIA, P_PRUSSIA, P_SAXONY ]
+
+function all_non_coop_powers(pow) {
+ switch (pow) {
+ case P_FRANCE:
+ case P_BAVARIA:
+ return all_powers_prussia_saxony_pragmatic_austria
+ case P_PRUSSIA:
+ case P_SAXONY:
+ return all_powers_france_bavaria_pragmatic_austria
+ case P_PRAGMATIC:
+ case P_AUSTRIA:
+ return all_powers_france_bavaria_prussia_saxony
+ }
+}
+
+function all_controlled_generals(pow) {
+ switch (pow) {
+ case P_FRANCE:
+ case P_BAVARIA:
+ return all_france_bavaria_generals
+ case P_PRUSSIA:
+ case P_SAXONY:
+ return all_prussia_saxony_generals
+ case P_PRAGMATIC:
+ return all_power_generals[P_PRAGMATIC]
+ case P_AUSTRIA:
+ return all_power_generals[P_AUSTRIA]
+ }
+}
+
+function all_controlled_trains(pow) {
+ switch (pow) {
+ case P_FRANCE:
+ case P_BAVARIA:
+ return all_france_bavaria_trains
+ case P_PRUSSIA:
+ case P_SAXONY:
+ return all_prussia_saxony_trains
+ case P_PRAGMATIC:
+ return all_power_trains[P_PRAGMATIC]
+ case P_AUSTRIA:
+ return all_power_trains[P_AUSTRIA]
+ }
+}
+
function all_allied_trains(pow) {
switch (pow) {
case P_FRANCE:
@@ -498,12 +546,11 @@ function has_enemy_piece(to) {
return false
}
-function has_any_other_general(to) {
- for (let other of all_powers)
- if (other !== game.power)
- for (let p of all_power_generals[other])
- if (game.pos[p] === to)
- return true
+function has_non_cooperative_general(to) {
+ for (let other of all_non_coop_powers(game.power))
+ for (let p of all_controlled_generals(other))
+ if (game.pos[p] === to)
+ return true
return false
}
@@ -590,18 +637,25 @@ function eliminate_general(p, indent) {
const POWER_FROM_ACTION_STEP = [
P_FRANCE, // and bavaria
P_PRUSSIA, // and saxony
- P_AUSTRIA, // and pragmatic army
- P_PRAGMATIC, // moves interleaved with austria, but attacks after austria
+ P_AUSTRIA, // and pragmatic army -- interleave with pragmatic moves on flanders map
+ P_PRAGMATIC, // interleave with austria moves on flanders map
]
function set_active_to_current_action_step() {
set_active_to_power(POWER_FROM_ACTION_STEP[game.step])
}
+function goto_end_turn() {
+ // TODO: winter
+ goto_start_turn()
+}
+
function goto_start_turn() {
game.turn += 1
game.step = 0
+ log("# Turn " + game.turn)
+
game.selected = null
delete game.ia_lost
@@ -617,14 +671,17 @@ function goto_action_stage() {
clear_undo()
log("=" + game.power)
+
+ // TODO: minor powers controlled at the same time
+
goto_tactical_cards()
}
function end_action_stage() {
clear_undo()
- if (++game.step === 7)
- goto_clock_of_fate()
+ if (++game.step === 4)
+ goto_end_turn()
else
goto_action_stage()
}
@@ -713,7 +770,7 @@ function draw_tc(n) {
while (n > 0) {
if (game.deck.length === 0) {
if (k > 0)
- log("Drew " + k + " TC.")
+ log(POWER_NAME[game.power] + " " + k + " TC.")
k = 0
next_tactics_deck()
if (game.deck.length === 0) {
@@ -727,7 +784,7 @@ function draw_tc(n) {
}
if (k > 0)
- log("Drew " + k + " TC.")
+ log(POWER_NAME[game.power] + " " + k + " TC.")
}
function goto_tactical_cards() {
@@ -758,6 +815,26 @@ function end_tactical_cards() {
// MARIA: supply is before movement
+ if (game.power === P_FRANCE) {
+ set_active_to_power(P_BAVARIA)
+ 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)
+
+ // TODO: draw pragmatic cards before austria moves
+
+ // MARIA TODO: supply!
+
goto_movement()
}
@@ -873,7 +950,7 @@ states.movement = {
let done_generals = true
let done_trains = true
- for (let p of all_power_generals[game.power]) {
+ for (let p of all_controlled_generals(game.power)) {
if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) {
if (can_general_move_anywhere(p)) {
gen_action_piece(p)
@@ -882,7 +959,7 @@ states.movement = {
}
}
- for (let p of all_power_trains[game.power]) {
+ for (let p of all_controlled_trains(game.power)) {
if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) {
if (can_train_move_anywhere(p)) {
gen_action_piece(p)
@@ -910,6 +987,8 @@ states.movement = {
let here = game.pos[p]
+ set_active_to_power(piece_power[p])
+
// Note: Can only move one piece at a time in Maria!
game.selected = [ p ]
@@ -960,7 +1039,7 @@ function can_move_train_to(to) {
function can_move_general_in_theory(_p, to) {
if (has_friendly_supply_train(to))
return false
- if (has_any_other_general(to))
+ if (has_non_cooperative_general(to))
return false
if (has_enemy_supply_train(to))
return false
@@ -972,7 +1051,7 @@ function can_move_general_in_theory(_p, to) {
function can_move_general_to(to) {
if (has_friendly_supply_train(to))
return false
- if (has_any_other_general(to))
+ if (has_non_cooperative_general(to))
return false
if (has_enemy_supply_train(to))
return false
@@ -994,11 +1073,11 @@ function move_general_to(to) {
// uniting stacks (turn all oos if one is oos)
let oos = false
- for (let p of all_power_generals[game.power])
+ for (let p of all_controlled_generals(game.power))
if (game.pos[p] === to && is_out_of_supply(p))
oos = true
if (oos)
- for (let p of all_power_generals[game.power])
+ for (let p of all_controlled_generals(game.power))
if (game.pos[p] === to)
set_out_of_supply(p)
@@ -1034,7 +1113,7 @@ function move_general_to(to) {
}
// uniting stacks: flag all as moved and stop moving
- for (let p of all_power_generals[pow]) {
+ for (let p of all_controlled_generals(pow)) {
if (game.pos[p] === to && !set_has(game.selected, p)) {
set_add(game.moved, p)
stop = true
@@ -1229,6 +1308,8 @@ function end_move_piece() {
delete game.move_path
game.selected = null
game.state = "movement"
+
+ set_active_to_current_action_step()
}
/* RECRUITMENT */
@@ -1291,7 +1372,7 @@ function has_available_depot() {
function can_re_enter_general(to) {
if (has_friendly_supply_train(to))
return false
- if (has_any_other_general(to))
+ if (has_non_cooperative_general(to))
return false
if (1 + count_generals(to) > 3)
return false
@@ -1525,7 +1606,7 @@ function goto_combat() {
let from = []
let to = []
- for (let p of all_power_generals[game.power])
+ for (let p of all_controlled_generals(game.power))
if (game.pos[p] < ELIMINATED)
set_add(from, game.pos[p])