summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.css12
-rw-r--r--play.js9
-rw-r--r--rules.js96
3 files changed, 87 insertions, 30 deletions
diff --git a/play.css b/play.css
index 5c17ea0..22c6d27 100644
--- a/play.css
+++ b/play.css
@@ -381,6 +381,18 @@ body.tint .militia.selected,
border-style: solid;
}
+.improvement.action {
+ box-shadow: 0 0 0px 1px #444, 0 0 0px 4px white;
+}
+
+.improvement.selected {
+ box-shadow: 0 0 0px 1px #444, 0 0 0px 4px yellow;
+}
+
+.improvement.spent {
+ filter: brightness(90%);
+}
+
.militia, .legion,
.alamanni, .franks, .goths, .nomads, .sassanids, .rival_emperor,
.general, .emperor_turns, .no_place_governor {
diff --git a/play.js b/play.js
index 42352b6..4da1841 100644
--- a/play.js
+++ b/play.js
@@ -974,6 +974,9 @@ function on_init() {
ui.imp_port[region] = create_building(region, "improvement port hide")
ui.imp_temple[region] = create_building(region, "improvement temple hide")
+ register_action(ui.imp_market[region], "use_market", region)
+ register_action(ui.imp_port[region], "use_port", region)
+
register_action(ui.capital[region], "capital", region)
register_action(ui.regions[region], "region", region)
@@ -1249,6 +1252,12 @@ function on_update() {
ui.militia[region].classList.toggle("selected", view.selected_militia === region)
+ ui.imp_market[region].classList.toggle("selected", view.selected_market === region)
+ ui.imp_market[region].classList.toggle("spent", view.umarket & (1 << region))
+
+ ui.imp_port[region].classList.toggle("selected", view.selected_port === region)
+ ui.imp_port[region].classList.toggle("spent", view.uport & (1 << region))
+
let imp_off = 0
if (has_amphitheater(region))
diff --git a/rules.js b/rules.js
index 61aed2a..4f339c4 100644
--- a/rules.js
+++ b/rules.js
@@ -1938,10 +1938,6 @@ 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
}
@@ -2021,6 +2017,13 @@ states.take_actions = {
for (let c of hand)
gen_action_card(c)
+ // Goto Market
+ if (is_deluxe() && game.mip + game.sip + game.pip > 0) {
+ for (let s = 0; s < 12; ++s)
+ if (has_market(s) && !has_used_market(s) && is_own_province(s))
+ gen_action_use_market(s)
+ }
+
// Use events on played cards
for (let c of game.played)
if (!set_has(game.used, c) && can_play_card_event(c))
@@ -2124,14 +2127,6 @@ 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
@@ -2392,28 +2387,61 @@ states.take_actions = {
enter_capital()
},
- market() {
+ use_port(s) {
+ push_undo()
+ game.state = "use_port"
+ },
+
+ use_market(s) {
push_undo()
game.state = "use_market"
+ game.where = s
+ },
+}
+
+// IMPROVEMENT: PORT
+
+states.use_port = {
+ inactive: "Port",
+ prompt() {
+ let from = get_general_location(game.selected_general)
+ view.prompt = "Use Port to sail to a distant province."
+ view.color = MILITARY
+ view.selected_general = game.selected_general
+ view.selected_port = from
+
+ for (let to = 0; to < 12; ++to) {
+ if (to !== from && !is_adjacent(from, to)) {
+ gen_action_region(to)
+ if (can_enter_capital(to))
+ gen_action_capital(to)
+ }
+ }
+ },
+ region(where) {
+ move_army_to(game.selected_general, where, false)
+ },
+ capital(where) {
+ move_army_to(game.selected_general, where, true)
},
}
// IMPROVEMENT: MARKET
function use_market_effect(mip, sip, pip) {
- let where = get_governor_location(game.selected_governor)
- log("Used Market in %" + where + ".")
+ log("Used Market in %" + game.where + ".")
game.mip += mip
game.sip += sip
game.pip += pip
game.state = "take_actions"
- set_used_market(where)
+ set_used_market(game.where)
}
states.use_market = {
inactive: "Market",
prompt() {
prompt(`Market: ${game.mip} military, ${game.sip} senate, ${game.pip} populace.`)
+ view.selected_market = game.where
if (game.mip > 0) {
view.actions.mip_to_sip = 1
view.actions.mip_to_pip = 1
@@ -3136,18 +3164,6 @@ function create_army(where, capital) {
// ACTION: MOVE ARMY
-function gen_sail_army(from) {
- if (is_own_province(from) && has_port(from) && !has_used_port(from)) {
- for (let to = 0; to < 12; ++to) {
- if (to !== from) {
- gen_action_region(to)
- if (can_enter_capital(to))
- gen_action_capital(to)
- }
- }
- }
-}
-
function gen_move_army() {
let from = get_general_location(game.selected_general)
if (game.mip >= 1) {
@@ -3160,7 +3176,8 @@ function gen_move_army() {
gen_action_region(to)
}
if (is_deluxe())
- gen_sail_army(from)
+ if (has_port(from) && !has_used_port(from) && is_own_province(from))
+ gen_action_use_port(from)
}
}
@@ -3882,7 +3899,8 @@ states.force_march = {
}
}
if (is_deluxe())
- gen_sail_army(where)
+ if (has_port(where) && !has_used_port(where) && is_own_province(where))
+ gen_action_use_port(where)
}
// Free Action: Enter/Leave Capital
@@ -3940,6 +3958,11 @@ states.force_march = {
remove_general_castra(game.selected_general)
resume_take_actions()
},
+
+ use_port(s) {
+ push_undo()
+ game.state = "use_port"
+ },
}
// CARD: Frumentarii
@@ -6027,6 +6050,11 @@ exports.view = function (state, player_name) {
emperor_turns: game.emperor_turns,
}
+ if (is_deluxe()) {
+ view.umarket = game.umarket
+ view.uport = game.uport
+ }
+
if (game.combat && states[game.state].show_battle) {
view.combat = game.combat
view.combat_region = game.where
@@ -6143,6 +6171,14 @@ function gen_action_support(where, level) {
gen_action("support", where << 3 | level)
}
+function gen_action_use_market(where) {
+ gen_action("use_market", where)
+}
+
+function gen_action_use_port(where) {
+ gen_action("use_port", where)
+}
+
function gen_action_card(c) {
gen_action("card", c)
}