summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js212
1 files changed, 153 insertions, 59 deletions
diff --git a/rules.js b/rules.js
index eae4029..089031a 100644
--- a/rules.js
+++ b/rules.js
@@ -291,6 +291,7 @@ function setup_deck() {
}
game.of_gods_and_kings[0] = cards[cards.length-1]
game.deck = deck
+ game.deck = [1, 45, 2, 46, 3, 47, 4, 48, 5, 49]
}
function setup_standard() {
@@ -474,18 +475,20 @@ function goto_cavalry(n, next) {
}
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
- }
+ game.state = "cavalry"
+ // Removing automatic cavalry tokens attribution
+ // 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 {
- end_cavalry()
- }
+ // if (game.cav.n !== 0)
+ // game.state = "cavalry"
+ // else {
+ // end_cavalry()
+ // }
}
function end_cavalry() {
@@ -583,15 +586,10 @@ function goto_tax() {
function succession() {
game.current = DS
- game.succ += 1
+ if (game.succ > 0)
+ game.succ += 1
- if (game.succ <= 3)
- goto_vm(game.succ * 2 + 72)
- else if (game.succ === 4) {
- timurid_step1()
- } else if (game.succ === 5) {
- goto_vm(game.succ * 2 + 72)
- }
+ goto_vm(game.succ * 2 + 74)
}
function is_succession() {
@@ -602,20 +600,6 @@ function is_timurid() {
return (game.vm && game.vm.fp > 78)
}
-function timurid_step1() {
- let n = Math.floor(count_pieces(AVAILABLE, MI, TROOPS) / 2)
-
- loge("Succession Crisis in Delhi.")
- push_summary()
- for (let i = 0; i < n; ++i) {
- let p = find_piece(AVAILABLE, MI, TROOPS)
- log_summary_place(p)
- place_piece(p, S_MOUNTAIN_PASSES)
- }
- pop_summary()
- end_card()
-}
-
/* STATES */
states.eligible = {
@@ -733,7 +717,7 @@ states.compromising_gifts = {
view.actions.end_gifts = 1
},
influence(f) {
- log_h2(faction_acronyms[f] + "Compromising Gifts")
+ log_h2(faction_name[f] + "Compromising Gifts")
log_resources(f, 2)
add_resources(f, 2)
game.inf_shift = {
@@ -1915,9 +1899,10 @@ function prompt_end_decree() {
}
function init_decree(type) {
- if (!is_succession())
+ if (!is_succession()) {
push_undo()
- log_h2(faction_name[game.current] + " - " + type)
+ log_h2(faction_name[game.current] + " - " + type)
+ }
game.decree = {
spaces: [],
}
@@ -2082,6 +2067,9 @@ states.campaign = {
}
}
+ if (is_succession())
+ view.actions.skip = 1
+
},
space(s) {
push_undo()
@@ -2091,6 +2079,10 @@ states.campaign = {
game.vm.m = s
game.state = "campaign_moves"
}
+ },
+ skip() {
+ logi("Nothing")
+ vm_next()
}
}
@@ -3174,7 +3166,9 @@ function remove_influence(faction) {
}
function end_influence() {
- if (game.vm)
+ if (game.vm && game.vm.fp === 80)
+ game.state = "vm_influence_succession"
+ else if (game.vm)
vm_next()
else {
if (typeof game.inf_shift.next === "function")
@@ -4124,6 +4118,11 @@ function vm_log_br() {
vm_next()
}
+function vm_log_h2() {
+ log_h2(faction_acronyms[vm_operand(1)] + " " + vm_operand(2))
+ vm_next()
+}
+
function vm_mark_space() {
if (game.vm.m)
set_add(game.vm.m, game.vm.s)
@@ -4598,18 +4597,21 @@ states.vm_steal = {
function vm_cav_resources() {
game.vm.count = vm_operand(1)
- if (game.vm.count > 0) {
+ if (game.vm.count > 0)
push_summary()
- game.state = "vm_cav_resources"
- } else
- vm_next()
+ game.state = "vm_cav_resources"
}
states.vm_cav_resources = {
prompt() {
- event_prompt(`Gain ${game.vm.count} Resources or Cavalry tokens.`)
- gen_action_resources(game.current)
- gen_take_cavalry(game.current)
+ if (game.vm.count === 0) {
+ event_prompt("No Cavalry token nor Resource to gain.")
+ view.actions.skip = 1
+ } else {
+ event_prompt(`Gain ${game.vm.count} Resource${game.vm.count > 1 ? "s": ""} or Cavalry token${game.vm.count > 1 ? "s": ""}.`)
+ gen_action_resources(game.current)
+ gen_take_cavalry(game.current)
+ }
},
resources(f) {
log_summary_resources(game.current)
@@ -4620,6 +4622,10 @@ states.vm_cav_resources = {
log_summary_cavalry(c)
set_cavalry_faction(c, game.current)
tick_cav_resources()
+ },
+ skip() {
+ logi("Nothing")
+ vm_next()
}
}
@@ -4824,16 +4830,33 @@ function vm_free_rebel() {
game.state = "rebel"
}
+// VM: FLIP DYNASTY
+
+function vm_flip_dynasty() { game.state = "vm_flip_dynasty" }
+
+states.vm_flip_dynasty = {
+ prompt() {
+ event_prompt("End of the oppressive Khalji Dynasty.")
+
+ view.actions.dynasty_card = 1
+ },
+ dynasty_card() {
+ game.succ += 1
+ logi("Dawn of the Tughlaq Dynasty, Rebel Commands are now available.")
+ vm_next()
+ }
+}
+
// VM: INFLUENCE SUCCESSION
function vm_influence_succession() {
game.cmd = {}
game.cmd.who = null
game.cmd.count = 3
- game.state = "influence_succession"
+ game.state = "vm_influence_succession"
}
-states.influence_succession = {
+states.vm_influence_succession = {
prompt() {
if (game.resources[game.current] < 3) {
event_prompt("Not enough resources.")
@@ -4852,22 +4875,68 @@ states.influence_succession = {
if (game.inf[game.cmd.who] > 0)
view.actions.remove_influence = 1
}
- view.actions.skip = 1
+ if (game.cmd.count === 3)
+ view.actions.skip = 1
+ if (game.cmd.count < 3)
+ view.actions.next = 1
},
influence(f) {
game.cmd.who = f
},
add_influence() {
+ push_undo()
add_resources(game.current, -3)
add_influence(game.cmd.who)
game.cmd.count -= 1
},
remove_influence() {
+ push_undo()
add_resources(game.current, -3)
remove_influence(game.cmd.who)
game.cmd.count -= 1
},
- skip: vm_next
+ next: vm_next,
+ skip() {
+ log("Declined influence shift.")
+ vm_next()
+ },
+}
+
+// VM : TIMURID CRISIS
+
+function vm_timurid_crisis() { game.state = "vm_timurid_crisis" }
+
+states.vm_timurid_crisis = {
+ prompt() {
+ event_prompt("Mongols Invaders gather in the Mountain Passes.")
+ gen_action_space(S_MONGOL_INVADERS)
+ },
+ space(s) {
+ log_space(S_MOUNTAIN_PASSES, "Advance")
+ let n = Math.floor(count_pieces(AVAILABLE, MI, TROOPS) / 2)
+ push_summary()
+ for (let i = 0; i < n; ++i) {
+ let p = find_piece(AVAILABLE, MI, TROOPS)
+ log_summary_place(p)
+ place_piece(p, S_MOUNTAIN_PASSES)
+ }
+ pop_summary()
+ vm_next()
+ }
+}
+
+function timurid_step1() {
+ let n = Math.floor(count_pieces(AVAILABLE, MI, TROOPS) / 2)
+
+ loge("Succession Crisis in Delhi.")
+ push_summary()
+ for (let i = 0; i < n; ++i) {
+ let p = find_piece(AVAILABLE, MI, TROOPS)
+ log_summary_place(p)
+ place_piece(p, S_MOUNTAIN_PASSES)
+ }
+ pop_summary()
+ end_card()
}
// VM : TIMURID ADVANCE
@@ -4998,6 +5067,7 @@ states.vm_any_limited_command = {
view.actions.migrate = can_migrate() ? 1 : 0
view.actions.rebel = can_rebel() ? 1 : 0
view.actions.attack = can_attack() ? 1 : 0
+ view.actions.skip = 1
},
rally() {
push_undo()
@@ -5022,7 +5092,8 @@ states.vm_any_limited_command = {
game.cmd.attacker = game.current
game.cmd.support_space = null
game.state = "attack"
- }
+ },
+ skip: vm_next
}
@@ -6193,51 +6264,74 @@ CODE[36 * 2 + 1] = [
[ vm_return ],
]
-// SUCC 1
-CODE[1 * 2 + 72] = [
+// SUCC 0
+CODE[0 * 2 + 74] = [
[ vm_force_current, DS ],
[ vm_loge, "Power struggle in Delhi." ],
+ [ vm_flip_dynasty ],
+ [ vm_log_h2, DS, "The Sultanate reimposes its dominance." ],
[ vm_campaign ],
[ vm_force_current, BK ],
[ vm_prompt, "Gain Cavalry token equal to Influence and Forts." ],
- [ vm_loge, "Military labor market thrives" ],
+ [ vm_log_h2, BK, "Military labor market thrives" ],
[ vm_gain_cavalry, ()=>(game.inf[BK] + count_pieces_on_map(BK, DISC)) ],
[ vm_force_current, VE ],
[ vm_prompt, "Gain resources equal to Influence and Temples." ],
- [ vm_loge, "Temple towns emerge anew" ],
+ [ vm_log_h2, VE, "Temple towns emerge anew" ],
[ vm_resources, false, VE, ()=>(game.inf[VE] + count_pieces_on_map(VE, DISC)) ],
[ vm_return ],
]
// SUCC 2
-CODE[2 * 2 + 72] = [
+CODE[2 * 2 + 74] = [
[ vm_force_current, DS ],
+ [ vm_log_h2, DS, "Delhi monitors its interests." ],
[ vm_campaign ],
[ vm_force_current, BK ],
+ [ vm_log_h2, BK, "Ala-ud-Din Hasan Bahman Shah gathers allies and takes the Deccan throne." ],
[ vm_any_limited_command ],
+ [ vm_if, ()=>(game.prosperity[BK] === 0) ],
+ [ vm_log_br ],
+ [ vm_log, "Not enough prosperity." ],
+ [ vm_else ],
[ vm_cav_resources, ()=>(Math.min(game.prosperity[BK],3)) ],
+ [ vm_endif ],
[ vm_force_current, VE ],
+ [ vm_log_h2, VE, "Sangama brothers establish an empire." ],
[ vm_any_limited_command ],
+ [ vm_if, ()=>(game.prosperity[VE] === 0) ],
+ [ vm_log_br ],
+ [ vm_log, "Not enough prosperity." ],
+ [ vm_else ],
[ vm_cav_resources, ()=>(Math.min(game.prosperity[VE],3)) ],
+ [ vm_endif ],
[ vm_return ],
]
// SUCC 3
-CODE[3 * 2 + 72] = [
+CODE[3 * 2 + 74] = [
[ vm_force_current, DS ],
- [ vm_loge, "Renewed focus on infrastructure." ],
+ [ vm_log_h2, DS, "Renewed focus on infrastructure." ],
[ vm_influence_succession ],
[ vm_force_current, BK ],
- [ vm_loge, "Trade network covers the Deccan." ],
+ [ vm_log_h2, BK, "Trade network covers the Deccan." ],
[ vm_influence_succession ],
[ vm_force_current, VE ],
- [ vm_loge, "Vast, unifying medieval metropolis." ],
+ [ vm_log_h2, VE, "Vast, unifying medieval metropolis." ],
[ vm_influence_succession ],
[ vm_return ],
]
+// SUCC 4
+CODE[4 * 2 + 74] = [
+ [ vm_force_current, DS ],
+ [ vm_log_h2, DS, "Succession Crisis in Delhi." ],
+ [ vm_timurid_crisis ],
+ [ vm_return ],
+]
+
// SUCC 5
-CODE[5 * 2 + 72] = [
+CODE[5 * 2 + 74] = [
[ vm_force_current, DS ],
[ vm_prompt, "Invaders are attacking in the Mountain Passes!" ],
[ vm_space, true, 1, 1, (s)=>(s === S_MOUNTAIN_PASSES && has_ds_unit(s) && has_mi_unit(s)) ],