summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--play.js2
-rw-r--r--rules.js57
2 files changed, 57 insertions, 2 deletions
diff --git a/play.js b/play.js
index 213b304..6923502 100644
--- a/play.js
+++ b/play.js
@@ -995,6 +995,8 @@ function on_update() {
// Decree buttons
action_button("build", "Build")
+ action_button("demand", "Demand Obedience")
+ action_button("end_demand", "End Demand Obedience")
action_button("collect", "Collect")
action_button("tax", "Tax")
action_button("trade", "Trade")
diff --git a/rules.js b/rules.js
index 001a6f7..a083f47 100644
--- a/rules.js
+++ b/rules.js
@@ -403,6 +403,11 @@ function end_conscript_space() {
game.state = "conscript"
}
+function goto_demand() {
+ init_command("Demand Obedience")
+ game.state = "demand"
+}
+
function goto_govern() {
init_command("Govern")
game.state = "govern"
@@ -539,6 +544,7 @@ states.command_decree = {
build: goto_build,
collect: goto_collect,
conscript: goto_conscript,
+ demand: goto_demand,
govern: goto_govern,
march: goto_march,
rally: goto_rally,
@@ -657,6 +663,31 @@ states.conscript_space = {
}
}
+states.demand = {
+ prompt() {
+ view.prompt = "Demand Obedience: Select a Controlled province with a Governor"
+
+ if (can_select_cmd_space(0) && can_demand())
+ for (let s = first_space; s <= last_space; ++s)
+ if (!is_selected_cmd_space(s) && can_demand_in_space(s))
+ gen_action_space(s)
+
+ view.actions.end_demand = prompt_end_cmd(1)
+ },
+ space(s) {
+ push_undo()
+ select_cmd_space(s, 0)
+ add_resources(DS, SPACES[s].pop)
+ add_tributary(s)
+ to_obedient_space(s)
+ log_space(s, "Demand Obedience")
+ },
+ end_demand() {
+ game.decree = 0
+ game.state = "command_decree"
+ }
+}
+
states.govern = {
prompt() {
view.prompt = "Govern: Select a Tributary, Controlled, Mongol Invader region or Dehli."
@@ -1033,7 +1064,7 @@ function gen_any_decree() {
if (game.current === DS) {
view.actions.collect = can_collect() ? 1 : 0
// view.actions.campaign = can_campaign() ? 1 : 0
- // view.actions.demand = can_demand() ? 1 : 0
+ view.actions.demand = can_demand() ? 1 : 0
} else if (game.current === BK) {
view.actions.trade = can_trade() ? 1 : 0
view.actions.build = can_build() ? 1 : 0
@@ -1053,6 +1084,17 @@ function can_build_in_space(s) {
return has_piece(s, game.current, ELITE) && !has_piece(s, game.current, DISC)
}
+function can_demand() {
+ for (let s = first_space; s <= last_province; ++s)
+ if (can_demand_in_space(s))
+ return true
+ return false
+}
+
+function can_demand_in_space(s) {
+ return is_faction_control(s, DS) && has_piece(s, DS, ELITE)
+}
+
function can_tax() {
return tax_count() > 0
}
@@ -1101,7 +1143,13 @@ function is_rebel(p) {
function to_obedient(p) {
let faction = piece_faction(p)
let piece_index = p - first_piece[faction][ELITE]
- game.rebel[faction] |= ~(1 << piece_index)
+ game.rebel[faction] &= ~(1 << piece_index)
+}
+
+function to_obedient_space(s) {
+ for (let p of iter_rebel_elite())
+ if (piece_space(p) === s)
+ to_obedient(p)
}
function to_rebel(p) {
@@ -1784,6 +1832,11 @@ function* iter_faction_movable(faction) {
}
}
+function* iter_rebel_elite() {
+ yield* iter_faction_pieces(BK, ELITE)
+ yield* iter_faction_pieces(VE, ELITE)
+}
+
// === CONST ===