diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-12-14 22:40:36 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2023-02-18 13:02:38 +0100 |
commit | 06cc8ab749f4784d431e068d691b66d8f95d8c63 (patch) | |
tree | 3390c1e865601a45ab5ffabde9dac8a54ca41c74 | |
parent | fd82619388044a7177b95dacc19efe2e401ba75a (diff) | |
download | nevsky-06cc8ab749f4784d431e068d691b66d8f95d8c63.tar.gz |
Some +1 Command capabilities and extra seats.
-rw-r--r-- | rules.js | 144 | ||||
-rw-r--r-- | tools/gendata.js | 6 |
2 files changed, 128 insertions, 22 deletions
@@ -182,19 +182,25 @@ const LOC_TESOVO = find_locale("Tesovo") const LOC_SABLIA = find_locale("Sablia") // Capability usage tracking flags -const FLAG_TEUTONIC_RAIDERS = 1 << 0 -const FLAG_TEUTONIC_CONVERTS = 1 << 1 -const FLAG_TEUTONIC_WARRIOR_MONKS = 1 << 2 -const FLAG_TEUTONIC_HILLFORTS = 1 << 3 -const FLAG_RUSSIAN_LODYA_BOATS = 1 << 4 -const FLAG_RUSSIAN_LODYA_SHIPS = 1 << 5 +const FLAG_LEGATE = 1 << 0 +const FLAG_TEUTONIC_RAIDERS = 1 << 1 +const FLAG_TEUTONIC_CONVERTS = 1 << 2 +const FLAG_TEUTONIC_ORDENSBURGEN = 1 << 3 +const FLAG_TEUTONIC_WARRIOR_MONKS = 1 << 4 +const FLAG_TEUTONIC_HILLFORTS = 1 << 5 +const FLAG_RUSSIAN_LODYA_BOATS = 1 << 6 +const FLAG_RUSSIAN_LODYA_SHIPS = 1 << 7 const AOW_TEUTONIC_RAIDERS = AOW_T2 const AOW_TEUTONIC_COGS = AOW_T18 const AOW_TEUTONIC_CONVERTS = AOW_T3 +const AOW_TEUTONIC_ORDENSBURGEN = AOW_T12 const AOW_TEUTONIC_BALISTARII = [ AOW_T4, AOW_T5, AOW_T6 ] const AOW_RUSSIAN_RAIDERS = [ AOW_R12, AOW_R14 ] +const AOW_RUSSIAN_LUCHNIKI = [ AOW_R1, AOW_R2 ] +const AOW_RUSSIAN_DRUZHINA = [ AOW_R5, AOW_R6 ] +const AOW_RUSSIAN_HOUSE_OF_SUZDAL = AOW_R11 // TODO: advanced service const VASSAL_UNAVAILABLE = 0 @@ -261,6 +267,22 @@ const USABLE_TRANSPORT = [ [ BOAT, SHIP ] ] +const COMMANDERIES = [ + LOC_ADSEL, + LOC_FELLIN, + LOC_LEAL, + LOC_WENDEN +] + +function is_commandery(loc) { + return ( + loc === LOC_ADSEL || + loc === LOC_FELLIN || + loc === LOC_LEAL || + loc === LOC_WENDEN + ) +} + function current_turn() { return game.turn >> 1 } @@ -609,6 +631,14 @@ function is_vassal_mustered(vassal) { return game.lords.vassals[vassal] === VASSAL_MUSTERED } +function is_teutonic_lord(lord) { + return lord >= first_p1_lord && lord <= last_p1_lord +} + +function is_russian_lord(lord) { + return lord >= first_p2_lord && lord <= last_p2_lord +} + function is_friendly_lord(lord) { return lord >= first_friendly_lord && lord <= last_friendly_lord } @@ -622,22 +652,50 @@ function is_lord_at_friendly_locale(lord) { return is_friendly_locale(loc) } +function for_each_seat(lord, fn) { + let list = data.lords[lord].seats + + for (let seat of list) + fn(seat) + + if (is_teutonic_lord(lord)) { + if (has_global_capability("Ordensburgen")) { + for (let commandery of COMMANDERIES) + if (!set_has(list, commandery)) + fn(seat) + } + } + + if (is_russian_lord(lord)) { + if (has_global_capability("Archbishopric")) + if (!set_has(list, LOC_NOVGOROD)) + fn(LOC_NOVGOROD) + } + + if (lord === LORD_YAROSLAV) { + if (has_conquered_marker(LOC_PSKOV)) + if (!set_has(list, LOC_PSKOV)) + fn(LOC_PSKOV) + } +} + function is_lord_at_seat(lord) { - // TODO: extra seats from capabilities - // TODO: Yaroslav and Pskov if conquered let here = get_lord_locale(lord) - for (let seat of data.lords[lord].seats) - if (here === seat) - return true - return false + let result = false + for_each_seat(lord, seat => { + if (seat === here) + result = true + }) + return result } function has_free_seat(lord) { - // TODO: extra seats from capabilities - for (let loc of data.lords[lord].seats) - if (is_friendly_locale(loc)) - return true - return false + let result = false + for_each_seat(lord, seat => { + if (!result && is_friendly_locale(seat)) + result = true + }) + return result } function has_friendly_lord(loc) { @@ -1677,9 +1735,10 @@ states.levy_muster_lord = { states.muster_lord_at_seat = { prompt() { view.prompt = `Muster: Select seat for ${lord_name[game.who]}.` - for (let loc of data.lords[game.who].seats) + for_each_seat(game.who, seat => { if (is_friendly_locale(loc)) gen_action_locale(loc) + }) }, locale(loc) { push_undo() @@ -2053,6 +2112,13 @@ function goto_actions() { game.state = "actions" game.who = game.command game.count = 0 + + if (game.active === TEUTONS) { + if (has_global_capability("Ordensburgen")) { + if (is_commandery(get_lord_locale(game.who))) + set_flag(FLAG_TEUTONIC_ORDENSBURGEN) + } + } } function end_actions() { @@ -2063,14 +2129,49 @@ function end_actions() { game.who = NOBODY game.group = 0 + clear_flag(FLAG_LEGATE) clear_flag(FLAG_TEUTONIC_RAIDERS) clear_flag(FLAG_TEUTONIC_CONVERTS) + clear_flag(FLAG_TEUTONIC_ORDENSBURGEN) goto_feed() } +function this_lord_has_russian_druzhina() { + if (game.active === RUSSIANS) + if (lord_has_capability(game.who, AOW_RUSSIAN_DRUZHINA)) + return count_lord_forces(game.who, KNIGHTS) > 0 + return false +} + +function this_lord_has_house_of_suzdal() { + if (game.active === RUSSIANS) + if (lord_has_capability(game.who, AOW_RUSSIAN_DRUZHINA)) + return is_lord_on_map(LORD_ALEKSANDR) || is_lord_on_map(LORD_ANDREY) + return false +} + function get_available_actions() { - return data.lords[game.command].command - game.count + let n = data.lords[game.command].command + + if (game.active === TEUTONS) { + if (has_flag(FLAG_LEGATE)) + ++n + if (has_flag(FLAG_TEUTONIC_ORDENSBURGEN)) + ++n + if (game.who === LORD_HEINRICH || game.who === LORD_KNUD_ABEL) + if (has_global_capability("Treaty of Stensby")) + ++n + } + + if (game.active === RUSSIANS) { + if (this_lord_has_russian_druzhina()) + ++n + if (this_lord_has_house_of_suzdal()) + ++n + } + + return n - game.count } function use_all_actions() { @@ -2083,6 +2184,11 @@ states.actions = { view.prompt = `${lord_name[game.who]} has ${avail}x actions.` + if (game.active === TEUTONS) { + if (game.count === 0 && is_located_with_legate()) + view.actions.legate = 1 + } + if (avail > 0) { if (is_lord_besieged(game.who)) { if (can_action_sally()) diff --git a/tools/gendata.js b/tools/gendata.js index 11623b0..ba32d49 100644 --- a/tools/gendata.js +++ b/tools/gendata.js @@ -138,7 +138,7 @@ function defloc(region, stronghold, type, name) { function defway(type, list) { let ix = ways.length - list = list.map(name=>locmap[name]).sort((a,b)=>a-b) + list = list.map(name=>locmap[name]).sort(cmpnum) ways.push({type, locales: list}) for (let from of list) { for (let to of list) { @@ -294,7 +294,7 @@ trackway("Velikaya River, Velikiye Luki") let seaports = [ "Riga", "Pernau", "Leal", "Reval", "Narwia", "Luga", "Koporye", "Neva" -].map(name => locmap[name]).sort((a,b)=>a-b) +].map(name => locmap[name]).sort(cmpnum) function dumplist(name, list) { print(name + ":[") @@ -318,7 +318,7 @@ locales.forEach(loc => { }) function seats(list) { - return list.split(", ").map(name => locmap[name]).sort((a,b)=>a-b) + return list.split(", ").map(name => locmap[name]).sort(cmpnum) } let lords = [ |