diff options
Diffstat (limited to 'rules.js')
-rw-r--r-- | rules.js | 96 |
1 files changed, 66 insertions, 30 deletions
@@ -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) } |