diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-08-02 15:40:23 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-10-27 12:00:41 +0100 |
commit | ba532d98fd0f2f848f9cf4d804b3a5a29daba7ab (patch) | |
tree | e5712a83e64a27ecb41b5e0bef6baf0dacb50963 /rules.js | |
parent | ab72f6d38ccea89fef2ab0ce2863c6da60255917 (diff) | |
download | time-of-crisis-ba532d98fd0f2f848f9cf4d804b3a5a29daba7ab.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 @@ -3290,7 +3294,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) @@ -3303,6 +3307,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" } @@ -3313,12 +3338,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) { @@ -3342,8 +3378,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) @@ -3367,8 +3405,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) |