diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 107 |
1 files changed, 83 insertions, 24 deletions
@@ -176,6 +176,69 @@ const all_austria_trains = [ ...all_power_trains[P_AUSTRIA], ] +const all_france_allied_trains = [ + ...all_power_trains[P_FRANCE], + ...all_power_trains[P_BAVARIA], + ...all_power_trains[P_PRUSSIA], + ...all_power_trains[P_SAXONY], +] + +const all_austria_allied_trains = [ + ...all_power_trains[P_AUSTRIA], + ...all_power_trains[P_PRAGMATIC], +] + +const all_austria_allied_generals = [ + ...all_power_generals[P_AUSTRIA], + ...all_power_generals[P_PRAGMATIC], +] + +const all_france_allied_generals = [ + ...all_power_generals[P_FRANCE], + ...all_power_generals[P_BAVARIA], + ...all_power_generals[P_PRUSSIA], + ...all_power_generals[P_SAXONY], +] + +function all_allied_trains(pow) { + switch (pow) { + case P_FRANCE: + case P_BAVARIA: + case P_PRUSSIA: + case P_SAXONY: + return all_france_allied_trains + case P_AUSTRIA: + case P_PRAGMATIC: + return all_austria_allied_trains + } +} + +function all_enemy_trains(pow) { + switch (pow) { + case P_FRANCE: + case P_BAVARIA: + case P_PRUSSIA: + case P_SAXONY: + return all_austria_allied_trains + case P_AUSTRIA: + case P_PRAGMATIC: + return all_france_allied_trains + } +} + +function all_enemy_generals(pow) { + switch (pow) { + case P_FRANCE: + case P_BAVARIA: + case P_PRUSSIA: + case P_SAXONY: + return all_austria_allied_generals + case P_AUSTRIA: + case P_PRAGMATIC: + return all_france_allied_generals + } +} + function is_general(p) { return p < 20 } @@ -334,7 +397,7 @@ function get_top_piece(s) { } function get_supreme_commander(s) { - // TODO: promoted minor power + // TODO: promoted minor power (check who is actually on top!) for (let p of all_generals) if (game.pos[p] === s) return p @@ -405,31 +468,31 @@ function has_any_piece(to) { } function has_friendly_supply_train(to) { - for (let p of all_friendly_trains[game.power]) + for (let p of all_allied_trains(game.power)) if (game.pos[p] === to) return true return false } function has_enemy_supply_train(to) { - for (let p of all_enemy_trains[game.power]) + for (let p of all_enemy_trains(game.power)) if (game.pos[p] === to) return true return false } function has_enemy_general(to) { - for (let p of all_enemy_generals[game.power]) + for (let p of all_enemy_generals(game.power)) if (game.pos[p] === to) return true return false } function has_enemy_piece(to) { - for (let p of all_enemy_generals[game.power]) + for (let p of all_enemy_generals(game.power)) if (game.pos[p] === to) return true - for (let p of all_enemy_trains[game.power]) + for (let p of all_enemy_trains(game.power)) if (game.pos[p] === to) return true return false @@ -813,7 +876,7 @@ states.movement = { for (let p of all_power_generals[game.power]) { if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) { if (can_general_move_anywhere(p)) { - gen_action_supreme_commander(game.pos[p]) + gen_action_piece(p) done_generals = false } } @@ -847,14 +910,8 @@ states.movement = { let here = game.pos[p] - if (is_general(p)) { - game.selected = [] - for (let other of all_power_generals[game.power]) - if (other >= p && game.pos[other] === here && !set_has(game.moved, other)) - game.selected.push(other) - } else { - game.selected = [ p ] - } + // Note: Can only move one piece at a time in Maria! + game.selected = [ p ] game.count = 0 @@ -884,7 +941,8 @@ states.movement = { delete game.move_conq delete game.move_reconq - goto_recruit() + // MARIA: recruit during winter goto_recruit() + goto_combat() }, } @@ -965,7 +1023,7 @@ function move_general_to(to) { } // eliminate supply train - for (let p of all_enemy_trains[pow]) { + for (let p of all_enemy_trains(pow)) { if (game.pos[p] === to) { if (!game.move_elim) game.move_elim = [] @@ -1293,7 +1351,7 @@ function has_re_entry_space(p) { } function is_attack_position(s) { - for (let p of all_enemy_generals[game.power]) + for (let p of all_enemy_generals(game.power)) if (set_has(data.cities.adjacent[s], game.pos[p])) return true return false @@ -1363,7 +1421,7 @@ states.recruit = { for (let p of all_power_generals[game.power]) { if (game.troops[p] > 0 && game.troops[p] < 8) { let s = game.pos[p] - gen_action_supreme_commander(s) + gen_action_piece(s) } else if (game.pos[p] === ELIMINATED && has_re_entry_space(p)) gen_action_piece(p) @@ -1426,7 +1484,8 @@ function end_recruit() { delete game.recruit } - goto_combat() + // MARIA: NOT goto_combat() + // goto_combat() } states.re_enter = { @@ -1470,7 +1529,7 @@ function goto_combat() { if (game.pos[p] < ELIMINATED) set_add(from, game.pos[p]) - for (let p of all_enemy_generals[game.power]) + for (let p of all_enemy_generals(game.power)) if (game.pos[p] < ELIMINATED) set_add(to, game.pos[p]) @@ -2215,7 +2274,7 @@ states.supply_restore = { if (game.pos[p] >= ELIMINATED) continue if (is_out_of_supply(p) && has_supply_line(p)) - gen_action_supreme_commander(game.pos[p]) + gen_action_piece(game.pos[p]) } }, piece(x) { @@ -2239,7 +2298,7 @@ states.supply_eliminate = { if (game.pos[p] >= ELIMINATED) continue if (is_out_of_supply(p) && !has_supply_line(p)) - gen_action_supreme_commander(game.pos[p]) + gen_action_piece(game.pos[p]) } }, piece(x) { @@ -2260,7 +2319,7 @@ states.supply_flip = { if (game.pos[p] >= ELIMINATED) continue if (!is_out_of_supply(p) && !has_supply_line(p)) - gen_action_supreme_commander(game.pos[p]) + gen_action_piece(game.pos[p]) } }, piece(x) { |