diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-08-02 15:40:23 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-08-05 20:46:48 +0200 |
commit | e0a0d1a57d4ef0c45509f5241b0d1aebf312e4a1 (patch) | |
tree | 699651bd07d150f4d3fbeb07da694802021eeed9 /rules.js | |
parent | 084c4ed7f970d00af4349a01cba5093cef5e2ca2 (diff) | |
download | time-of-crisis-e0a0d1a57d4ef0c45509f5241b0d1aebf312e4a1.tar.gz |
v2: foederati
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 62 |
1 files changed, 51 insertions, 11 deletions
@@ -142,6 +142,10 @@ const PRETENDER_ADJACENT = [ /* HISPANIA */ [ GALLIA, AFRICA ], ] +function is_adjacent(a, b) { + return set_has(ADJACENT[a], b) +} + // BARBARIANS const ALAMANNI = 0 @@ -3288,7 +3292,7 @@ function gen_foederati(where) { } } -function can_play_foederati() { +function can_play_foederati_v1() { for (let i = 0; i < 6; ++i) { let id = game.current * 6 + i let where = get_general_location(id) @@ -3301,6 +3305,27 @@ function can_play_foederati() { return false } +function can_play_foederati_v2() { + // v2: only Roman provinces and not adjacent + for (let i = 0; i < 6; ++i) { + let id = game.current * 6 + i + let where = get_general_location(id) + if (is_province(where) && can_foederati_from_region(where)) + return true + where = get_governor_location(id) + if (is_province(where) && has_lone_militia(where) && can_foederati_from_region(where)) + return true + } + return false +} + +function can_play_foederati() { + if (is_classic()) + return can_play_foederati_v1() + else + return can_play_foederati_v2() +} + function play_foederati() { game.state = "foederati" } @@ -3311,12 +3336,23 @@ states.foederati = { prompt("Foederati: Choose an army you command...") for (let i = 0; i < 6; ++i) { let id = game.current * 6 + i - let where = get_general_location(id) - if (is_region(where) && can_foederati_from_region_or_adjacent(where)) - gen_action_general(id) - where = get_governor_location(id) - if (is_province(where) && has_lone_militia(where) && can_foederati_from_region_or_adjacent(where)) - gen_action_militia(where) + if (is_classic()) { + // v1: any region or from adjacent region + let where = get_general_location(id) + if (is_region(where) && can_foederati_from_region_or_adjacent(where)) + gen_action_general(id) + where = get_governor_location(id) + if (is_province(where) && has_lone_militia(where) && can_foederati_from_region_or_adjacent(where)) + gen_action_militia(where) + } else { + // v2: only Roman province and not adjacent + let where = get_general_location(id) + if (is_province(where) && can_foederati_from_region(where)) + gen_action_general(id) + where = get_governor_location(id) + if (is_province(where) && has_lone_militia(where) && can_foederati_from_region(where)) + gen_action_militia(where) + } } }, general(id) { @@ -3340,8 +3376,10 @@ states.foederati_general = { prompt("Foederati: Remove a barbarian.") view.selected_general = game.count gen_foederati(game.where) - for (let to of ADJACENT[game.where]) - gen_foederati(to) + if (is_classic()) { + for (let to of ADJACENT[game.where]) + gen_foederati(to) + } }, barbarian(id) { let tribe = get_barbarian_tribe(id) @@ -3365,8 +3403,10 @@ states.foederati_militia = { prompt("Foederati: Remove a barbarian.") view.selected_militia = game.where gen_foederati(game.where) - for (let to of ADJACENT[game.where]) - gen_foederati(to) + if (is_classic()) { + for (let to of ADJACENT[game.where]) + gen_foederati(to) + } }, barbarian(id) { let tribe = get_barbarian_tribe(id) |