summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js62
1 files changed, 51 insertions, 11 deletions
diff --git a/rules.js b/rules.js
index 57ec240..bbc9550 100644
--- a/rules.js
+++ b/rules.js
@@ -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)