summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js93
1 files changed, 79 insertions, 14 deletions
diff --git a/rules.js b/rules.js
index 1f813d1..cb09395 100644
--- a/rules.js
+++ b/rules.js
@@ -422,7 +422,24 @@ function goto_cavalry(n, next) {
"n": n,
"next": next
}
- game.state = "cavalry"
+ push_summary()
+
+ while (game.cav.n > 0 && n_available_cavalry() > 0) {
+ let c = find_cavalry(AVAILABLE)
+ log_summary_cavalry(c)
+ set_cavalry_faction(c, game.current)
+ game.cav.n -= 1
+ }
+
+ if (game.cav.n !== 0)
+ game.state = "cavalry"
+ else {
+ pop_summary()
+ if (game.vm)
+ vm_next()
+ else
+ game.states = game.cav.next
+ }
}
function goto_compromising_gifts() {
@@ -642,11 +659,14 @@ states.cavalry = {
},
token(c) {
game.cav.n -= 1
+ log_summary_cavalry(c)
set_cavalry_faction(c, game.current)
- // TODO: cavalry log
},
end_cavalry() {
- if (game.cav.next)
+ pop_summary()
+ if (game.vm)
+ vm_next()
+ else if (game.cav.next)
game.state = game.cav.next
else
goto_eligible()
@@ -692,14 +712,18 @@ states.demand = {
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")
+ demand_obedience_in_space(s)
},
end_demand: end_decree,
}
+function demand_obedience_in_space(s) {
+ add_resources(DS, SPACES[s].pop)
+ add_tributary(s)
+ to_obedient_space(s)
+ log_space(s, "Demand Obedience")
+}
+
states.march = {
prompt() {
view.prompt = "March: Select a space to move into."
@@ -1317,7 +1341,7 @@ function goto_conscript_space() {
states.conscript = {
prompt() {
- view.prompt = "Conscript: Select Tributaries, Qasbah or Dehli to place troops."
+ view.prompt = "Conscript: Select Tributaries, Qasbah or Delhi to place troops."
if (can_select_cmd_space(1) && can_conscript()) {
for (let s = first_space; s <= last_space; ++s) {
@@ -1403,7 +1427,7 @@ function goto_govern_space() {
states.govern = {
prompt() {
- view.prompt = "Govern: Select a Tributary, Controlled, Mongol Invader region or Dehli."
+ view.prompt = "Govern: Select a Tributary, Controlled, Mongol Invader region or Delhi."
if (can_select_cmd_space(1) && can_govern())
for (let s = first_space; s <= last_space; ++s)
@@ -2629,7 +2653,7 @@ function n_province_with_both_rebels() {
/* CAVALRY */
-function available_cavalry() {
+function n_available_cavalry() {
let n = 0
for (let c = 0; c <= LAST_CAVALRY; ++c)
if (game.cavalry[c] === AVAILABLE)
@@ -2973,6 +2997,14 @@ function log_summary_remove(p) {
log_summary("Removed % " + piece_name(p))
}
+function log_summary_cavalry(c) {
+ let from = game.cavalry[c]
+ if (from !== AVAILABLE)
+ log_summary(faction_acronyms[game.current] + " Cavalry + % from " + faction_acronyms[from] + ".")
+ else
+ log_summary(faction_acronyms[game.current] + " Cavalry + % from supply.")
+}
+
function logi_resources(faction, n) {
if (n > 0)
logi(faction_acronyms[faction] + " Resources +" + n)
@@ -2997,7 +3029,6 @@ function set_piece_space(p, s) {
game.pieces[p] = s
}
-
/* COMMON LIBRARY */
function clear_undo() {
@@ -3810,7 +3841,7 @@ function vm_place() {
function can_vm_place_imp(s, faction, type) {
if (!can_stack_piece(s, faction, type))
return false
- if (game.current === faction)
+ if (game.current === faction) // TODO: PLACE ONLY IF AVAILABLE
return true
return has_piece(AVAILABLE, faction, type)
}
@@ -3884,6 +3915,12 @@ states.vm_place = {
},
}
+// VM: GAIN_CAVALRY
+
+function vm_gain_cavalry() {
+ goto_cavalry(vm_operand(1), "")
+}
+
// VM: INFLUENCE
function vm_add_influence() {
@@ -3987,6 +4024,14 @@ function vm_free_compel() {
goto_compel_space()
}
+// VM: DEMAND_OBEDIENCE
+
+function vm_demand_obedience() {
+ if (can_demand_in_space(game.vm.s))
+ demand_obedience_in_space(game.vm.s)
+ vm_next()
+}
+
// VM: GOVERN
function vm_free_govern() {
@@ -4310,13 +4355,33 @@ CODE[13 * 2 + 1] = [
// EVENT 14
CODE[14 * 2 + 0] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, VE ],
+ [ vm_gain_cavalry, 2 ],
+ [ vm_asm, ()=>game.vm.count = 0 ],
+ [ vm_repeat, 2 ],
+ [ vm_prompt, ()=>`Place up to ${2-game.vm.count} Rajas adjacent to Vijayanagara.` ],
+ [ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_VIJAYANAGARA, s) && can_place_piece(s, VE, ELITE) ],
+ [ vm_auto_place, false, 0, false, VE, ELITE ],
+ [ vm_asm, ()=>(game.vm.count += 1) ],
+ [ vm_endspace ],
+ [ vm_endrepeat ],
+ [ vm_prompt, "Remove a Tributary marker in a Province adjacent to Vijayanagara." ],
+ [ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_VIJAYANAGARA, s) && is_tributary(s) ],
+ [ vm_remove_tributary ],
+ [ vm_endspace ],
[ vm_return ],
]
// SHADED 14
CODE[14 * 2 + 1] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, DS ],
+ [ vm_gain_cavalry, 3 ],
+ [ vm_prompt, "Place up to 4 Troops and 1 Governor in a province adjacent to Vijayanagara and Demand Obedience there." ],
+ [ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_VIJAYANAGARA, s) ],
+ [ vm_place, false, 1, 4, DS, TROOPS ],
+ [ vm_place, false, 1, 1, DS, ELITE ],
+ [ vm_demand_obedience ],
+ [ vm_endspace ],
[ vm_return ],
]