diff options
-rw-r--r-- | play.js | 7 | ||||
-rw-r--r-- | rules.js | 67 |
2 files changed, 74 insertions, 0 deletions
@@ -1609,6 +1609,13 @@ function on_update() { action_button("enter", "Enter Capital") action_button("leave", "Leave Capital") + action_button("mip_to_sip", "M > S") + action_button("mip_to_pip", "M > P") + action_button("sip_to_mip", "S > M") + action_button("sip_to_pip", "S > P") + action_button("pip_to_mip", "P > M") + action_button("pip_to_sip", "P > S") + action_button("automatic", "Automatic") action_button("spend_military", "Spend Military") action_button("spend_senate", "Spend Senate") @@ -608,6 +608,9 @@ function has_militia_force_marched(province) { return game.mbattled & (4096 << p function set_militia_force_marched(province) { game.mbattled |= (4096 << province) } function clear_militia_force_marched(province) { game.mbattled &= ~(4096 << province) } +function has_used_market(province) { return game.umarket & (1 << province) } +function set_used_market(province) { game.umarket |= (1 << province) } + function has_used_port(province) { return game.uport & (1 << province) } function set_used_port(province) { game.uport |= (1 << province) } @@ -1349,6 +1352,7 @@ function goto_start_turn() { game.combat_legacy = 0 if (is_deluxe()) { + game.umarket = 0 game.uport = 0 } @@ -1934,6 +1938,10 @@ function can_select_governor(id) { if (game.pip >= get_improvement_cost()) return true + // Goto Market + if (has_market(where) && !has_used_market(where) && game.mip + game.sip + game.pip > 0) + return true + return false } @@ -2116,6 +2124,14 @@ states.take_actions = { if (can_build_improvement(where)) if (game.pip >= get_improvement_cost()) view.actions.build_improvement = 1 + + // Goto Market + if (is_deluxe() && has_market(where)) { + if (!has_used_market(where) && game.mip + game.sip + game.pip > 0) + view.actions.market = 1 + else + view.actions.market = 0 + } } // General Actions @@ -2375,6 +2391,57 @@ states.take_actions = { else enter_capital() }, + + market() { + push_undo() + game.state = "use_market" + }, +} + +// IMPROVEMENT: MARKET + +function use_market_effect(mip, sip, pip) { + let where = get_governor_location(game.selected_governor) + log("Used Market in %" + where + ".") + game.mip += mip + game.sip += sip + game.pip += pip + game.state = "take_actions" + set_used_market(where) +} + +states.use_market = { + inactive: "Market", + prompt() { + prompt(`Market: ${game.mip} military, ${game.sip} senate, ${game.pip} populace.`) + if (game.mip > 0) { + view.actions.mip_to_sip = 1 + view.actions.mip_to_pip = 1 + } else { + view.actions.mip_to_sip = 0 + view.actions.mip_to_pip = 0 + } + if (game.sip > 0) { + view.actions.sip_to_mip = 1 + view.actions.sip_to_pip = 1 + } else { + view.actions.sip_to_mip = 0 + view.actions.sip_to_pip = 0 + } + if (game.pip > 0) { + view.actions.pip_to_mip = 1 + view.actions.pip_to_sip = 1 + } else { + view.actions.pip_to_mip = 0 + view.actions.pip_to_sip = 0 + } + }, + mip_to_sip() { use_market_effect(-1, 1, 0) }, + mip_to_pip() { use_market_effect(-1, 0, 1) }, + sip_to_mip() { use_market_effect(1, -1, 0) }, + sip_to_pip() { use_market_effect(0, -1, 1) }, + pip_to_mip() { use_market_effect(1, 0, -1) }, + pip_to_sip() { use_market_effect(0, 1, -1) }, } // ACTION: BUILD IMPROVEMENT |