summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js67
1 files changed, 67 insertions, 0 deletions
diff --git a/rules.js b/rules.js
index d179869..7f9b3e7 100644
--- a/rules.js
+++ b/rules.js
@@ -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