summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-25 18:29:06 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-30 21:59:25 +0200
commitfd156e7326312a98689fb462f86c3b8dd0f4e9af (patch)
tree46b77a20541587250cd0d4d94b4be960ffad1a17 /rules.js
parentda247e3d238af2c8f45e3e6be191152beb821795 (diff)
downloadfriedrich-fd156e7326312a98689fb462f86c3b8dd0f4e9af.tar.gz
fix test scenario
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js31
1 files changed, 24 insertions, 7 deletions
diff --git a/rules.js b/rules.js
index 9eb514a..63f5ad5 100644
--- a/rules.js
+++ b/rules.js
@@ -1304,7 +1304,7 @@ function can_train_move_anywhere(p) {
function can_general_move_anywhere(p) {
let from = game.pos[p]
for (let to of data.cities.adjacent[from])
- if (can_move_general_in_theory(to))
+ if (can_move_general_in_theory(p, to))
return true
return false
}
@@ -1315,9 +1315,9 @@ states.movement = {
let done_trains = true
for (let p of all_power_generals[game.power]) {
- if (!set_has(game.moved, p) && is_supreme_commander(p) && game.pos[p] < ELIMINATED) {
+ if (!set_has(game.moved, p) && game.pos[p] < ELIMINATED) {
if (can_general_move_anywhere(p)) {
- gen_action_piece(p)
+ gen_action_supreme_commander(game.pos[p])
done_generals = false
}
}
@@ -1424,6 +1424,20 @@ function forbid_capture(s) {
return false
}
+function forbid_capture_by(p, s) {
+ switch (game.fx) {
+ case NEXT_TURN_CUMBERLAND_MAY_NOT_MOVE_INTO_ATTACK_POSITION:
+ return p === GEN_CUMBERLAND
+ case NEXT_TURN_SOUBISE_MAY_NOT_MOVE_INTO_ATTACK_POSITION:
+ return p === GEN_SOUBISE
+ case NEXT_TURN_FRIEDRICH_MAY_NOT_MOVE_INTO_ATTACK_POSITION:
+ return p === GEN_FRIEDRICH
+ case NEXT_TURN_NO_GENERAL_MAY_BE_ATTACKED_IN_THE_CITY_OF_HALLE:
+ return s === HALLE
+ }
+ return false
+}
+
function can_move_train_to(to) {
return !has_any_piece(to)
}
@@ -1432,12 +1446,12 @@ function can_continue_train_from(_) {
return true
}
-function can_move_general_in_theory(to) {
+function can_move_general_in_theory(p, to) {
if (has_friendly_supply_train(to))
return false
if (has_any_other_general(to))
return false
- if (has_enemy_supply_train(to) && forbid_capture(to))
+ if (has_enemy_supply_train(to) && forbid_capture_by(p, to))
return false
if (count_pieces(to) >= 3)
return false
@@ -3735,8 +3749,11 @@ exports.setup = function (seed, scenario, options) {
shuffle_bigint(game.deck)
- if (scenario === "TEST")
- game.clock = [ 1,2,3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18 ]
+ if (scenario === "TEST") {
+ game.turn = 3
+ game.clock = [ 18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1 ]
+ }
+
if (game.scenario === 1)
log("# The War in the West")