diff options
-rw-r--r-- | play.js | 5 | ||||
-rw-r--r-- | rules.js | 80 |
2 files changed, 74 insertions, 11 deletions
@@ -204,8 +204,8 @@ const BURGUNDIANS = 5 const MERCENARIES = 6 const force_type_count = 7 -const force_action_name = [ "retinue", "vassal", "men_at_arms", "longbowmen", "militia", "burgundians", "mercenary" ] -const routed_force_action_name = [ "routed_retinue", "routed_vassal", "routed_men_at_arms", "routed_longbowmen", "routed_militia", "routed_burgundians", "routed_mercenary" ] +const force_action_name = [ "retinue", "vassal", "men_at_arms", "longbowmen", "militia", "burgundians", "mercenaries" ] +const routed_force_action_name = [ "routed_retinue", "routed_vassal", "routed_men_at_arms", "routed_longbowmen", "routed_militia", "routed_burgundians", "routed_mercenaries" ] const COIN = 1 const asset_type_count = 4 @@ -1633,6 +1633,7 @@ function on_update() { action_button("levy_troops", "Levy Troops") action_button("levy_beloved_warwick", "Beloved Warwick") action_button("levy_irishmen", "Irishmen") + action_button("soldiers_of_fortune", "Soldiers of Fortune") action_button("capability", "Capability") @@ -1655,6 +1655,22 @@ function can_add_troops_irishmen(lordwho, locale) { return false } +function can_add_troops_sof(lordwho, locale) { + let number = 6 + for (let lord = first_friendly_lord; lord <= last_friendly_lord; ++lord) { + number -= get_lord_forces(lord, MERCENARIES) + } + if (!has_exhausted_marker(locale) && + !is_exile(locale) && + lord_has_capability(lordwho, AOW_YORK_SOLDIERS_OF_FORTUNE) && + (get_lord_assets(lordwho, COIN) > 0 || get_shared_assets(lordwho, COIN) > 0) && + number >= 1 + ) + return true + else + return false +} + function can_add_transport(who, what) { return get_lord_assets(who, what) < 100 } @@ -2939,8 +2955,11 @@ states.levy_muster_lord = { if (can_add_troops_irishmen(game.who, here)) view.actions.levy_irishmen = 1 - } + if (can_add_troops_sof(game.who, here)) + view.actions.soldiers_of_fortune = 1 + } + if (game.count === 0 && game.flags.free_levy === 1 && can_add_troops(game.who, here)) { view.actions.levy_troops = 1 } @@ -3026,23 +3045,21 @@ states.levy_muster_lord = { levy_beloved_warwick() { push_undo() add_lord_forces(game.who, MILITIA, 5) - if (game.flags.free_levy === 1) { - ++game.count - game.flags.free_levy = 0 - } resume_levy_muster_lord() }, levy_irishmen() { push_undo() add_lord_forces(game.who, MILITIA, 5) - if (game.flags.free_levy === 1) { - ++game.count - game.flags.free_levy = 0 - } resume_levy_muster_lord() }, + soldiers_of_fortune() { + push_undo() + push_state("soldier_of_fortune") + + }, + capability() { push_undo() push_state("muster_capability") @@ -3068,6 +3085,51 @@ function chamberlains_eligible_levy(locale) { } } + +states.soldier_of_fortune = { + inactive: "sof", + prompt() { + set_lord_unfed(game.who, 1) + view.prompt = `Pay 1 Coin for Mercenaries ${lord_name[game.who]}.` + let done = true + + + if (done) { + if (is_lord_unfed(game.who)) { + if (get_lord_assets(game.who, COIN) > 0) { + done = false + gen_action_coin(game.who) + } + } + } + // Sharing + if (done) { + for (let lord = first_friendly_lord; lord <= last_friendly_lord; ++lord) { + if (is_lord_unfed(lord) && can_pay_from_shared(lord)) { + gen_action_lord(lord) + } + } + } + + }, + + coin(lord) { + push_undo() + let number = get_lord_forces(game.who, MERCENARIES) + let merc = 0 + if (number === 5) + merc = 1 + else + merc = 2 + add_lord_assets(lord, COIN, -1) + add_lord_forces(game.who, MERCENARIES, merc) + }, + lord(lord) { + push_undo() + game.who = lord + game.state = "pay_lord_shared" + }, +} states.muster_lord_at_seat = { inactive: "Muster", prompt() { |