summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js122
1 files changed, 109 insertions, 13 deletions
diff --git a/rules.js b/rules.js
index 3b59486..3d2e092 100644
--- a/rules.js
+++ b/rules.js
@@ -112,6 +112,7 @@ exports.view = function (state, role) {
actions: null,
log: game.log,
current: game.current,
+ succ: game.succ,
vp: game.vp,
resources: game.resources,
inf: game.inf,
@@ -215,6 +216,7 @@ exports.setup = function (seed, scenario, _options) {
active: null,
current: 0,
state: null,
+ succ: 0,
cylinder: [ ELIGIBLE, ELIGIBLE, ELIGIBLE ],
resources: [ 12, 6, 7 ],
vp: [ 18, 0, 0 ],
@@ -265,8 +267,29 @@ exports.setup = function (seed, scenario, _options) {
return save_game()
}
+function suffle_all_events() {
+ let deck = []
+ for (let i = 1; i <= 36; ++i)
+ deck.push(i)
+ shuffle(deck)
+ return deck
+}
+
function setup_deck() {
- game.deck = [ 4, 12, 13, 6, 34, 7, 21, 28, 29, 30, 31 ]
+ let cards = suffle_all_events()
+ let deck = []
+ let pile
+ let i = 0
+
+ for (let p = 0; p < 4; ++p) {
+ pile = cards.slice(i, i + 6)
+ i += 6
+ shuffle(pile)
+ deck = deck.concat(pile)
+ deck = deck.concat([45+p])
+ }
+
+ game.deck = deck
}
function setup_standard() {
@@ -327,7 +350,16 @@ function goto_card() {
} else if (this_card() >= 40 && this_card() <= 42) {
log_h1("Mongol Invaders C" + this_card())
goto_mongol_invaders(VE)
- } else {
+ } else if (this_card() === 45) {
+ log_h1("C" + this_card()) // Zenith of the Delhi Sultanate
+ succession_1()
+ } else if (this_card() === 46) {
+ log_h1("C" + this_card()) // Rise of the Rebel Sultans
+ } else if (this_card() === 47) {
+ log_h1("C" + this_card()) // Lords of the Deccan
+ } else if (this_card() === 43 || this_card() === 44) {
+ log_h1("C" + this_card()) // Timurid Empire
+ } else {
log_h1("C" + this_card())
adjust_eligibility(DS)
adjust_eligibility(BK)
@@ -526,6 +558,14 @@ function goto_tax() {
game.state = "tax"
}
+/* SUCCESSION */
+
+function succession_1() {
+ game.current = DS
+ game.succ += 1
+ goto_vm(game.succ * 2 + 72)
+}
+
/* STATES */
states.eligible = {
@@ -1799,7 +1839,8 @@ function prompt_end_decree() {
}
function init_decree(type) {
- push_undo()
+ if (!(game.vm && game.vm.fp > 72))
+ push_undo()
log_h2(faction_name[game.current] + " - " + type)
game.decree = {}
game.decree.type = type
@@ -1950,12 +1991,12 @@ states.campaign = {
view.prompt = "Campaign: Select four contiguous spaces, from start to finish."
if (game.decree.campaign.length === 0) {
for (let s = first_space; s <= last_space; ++s) {
- if (can_start_campaign_in_space(s))
+ if (can_start_campaign_in_space(s) && is_campaign_succ(s))
gen_action_space(s)
}
} else if (game.decree.campaign.length < 4) {
for (let s of SPACES[game.decree.campaign.at(-1)].adjacent) {
- if (!game.decree.campaign.includes(s))
+ if (!game.decree.campaign.includes(s) && is_campaign_succ(s))
gen_action_space(s)
}
}
@@ -2022,6 +2063,13 @@ states.campaign_moves = {
end_campaign: end_decree
}
+function is_campaign_succ(s) {
+ if (game.vm && game.vm.fp > 73)
+ if ([S_MOUNTAIN_PASSES, S_PUNJAB].includes(s))
+ return false
+ return true
+}
+
/* REBELS DECREES */
function can_build() {
@@ -3183,6 +3231,11 @@ function log(msg) {
game.log.push(msg)
}
+function loge(msg) {
+ log_br()
+ game.log.push(".e " + msg)
+}
+
function logi(msg) {
log(">" + msg)
}
@@ -3853,6 +3906,11 @@ states.vm_current = {
}
}
+function vm_force_current() {
+ game.current = vm_operand(1)
+ clear_undo()
+ vm_next()
+}
function vm_exec() {
vm_inst(0)()
@@ -3914,6 +3972,11 @@ function vm_log() {
vm_next()
}
+function vm_loge() {
+ loge(vm_operand(1))
+ vm_next()
+}
+
function vm_mark_space() {
if (game.vm.m)
set_add(game.vm.m, game.vm.s)
@@ -3975,7 +4038,10 @@ function vm_endrepeat() {
}
function vm_return() {
- game.state = "vm_return"
+ if (game.vm.fp <= 72)
+ game.state = "vm_return"
+ else
+ end_event()
}
states.vm_return = {
@@ -4296,7 +4362,10 @@ function vm_remove_influence() {
// VM: RESOURCES
function vm_resources() {
- game.state = "vm_resources"
+ if (vm_operand(3) !== 0)
+ game.state = "vm_resources"
+ else
+ vm_next()
}
states.vm_resources = {
@@ -4304,7 +4373,7 @@ states.vm_resources = {
let skip = vm_operand(1)
let f = vm_operand(2)
let n = vm_operand(3)
- if (n >= 0)
+ if (n > 0)
event_prompt(`${faction_name[f]} +${n} Resources.`)
else
event_prompt(`${faction_name[f]} ${n} Resources.`)
@@ -5053,7 +5122,7 @@ CODE[11 * 2 + 1] = [
// EVENT 12
CODE[12 * 2 + 0] = [
[ vm_current, REBEL_FACTIONS ],
- [ vm_gain_cavalry, 2 ],
+ [ vm_gain_cavalry, ()=>2 ],
[ vm_prompt, "Remove 4 Delhi Sultantes pieces from Provinces adjacent to Warangal." ],
[ vm_piece, false, 4, 4, (p,s)=>(is_adjacent_to_city(C_WARANGAL, piece_space(p)) && piece_faction(p) === DS) ],
[ vm_remove ],
@@ -5064,7 +5133,7 @@ CODE[12 * 2 + 0] = [
// SHADED 12
CODE[12 * 2 + 1] = [
[ vm_current, DS ],
- [ vm_gain_cavalry, 2 ],
+ [ vm_gain_cavalry, ()=>2 ],
[ vm_prompt, "Place a Qasbah in a Province adjacent to Warangal." ],
[ vm_space, true, 0, 1, (s)=>is_adjacent_to_city(C_WARANGAL, s) && can_place_piece(s, DS, DISC) ],
[ vm_auto_place, false, 0, false, DS, DISC ],
@@ -5122,7 +5191,7 @@ CODE[13 * 2 + 1] = [
// EVENT 14
CODE[14 * 2 + 0] = [
[ vm_current, VE ],
- [ vm_gain_cavalry, 2 ],
+ [ 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.` ],
@@ -5141,7 +5210,7 @@ CODE[14 * 2 + 0] = [
// SHADED 14
CODE[14 * 2 + 1] = [
[ vm_current, DS ],
- [ vm_gain_cavalry, 3 ],
+ [ vm_gain_cavalry, ()=>3 ],
[ vm_prompt, "Place up to 4 Troops and a 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 ],
@@ -5537,7 +5606,7 @@ CODE[28 * 2 + 1] = [
// EVENT 29
CODE[29 * 2 + 0] = [
[ vm_current, BK ],
- [ vm_gain_cavalry, 3 ],
+ [ vm_gain_cavalry, ()=>3 ],
[ vm_prompt, "Execute a free Limited Attack." ],
[ vm_space, true, 1, 1, (s)=>(can_attack_in_space(s)) ],
[ vm_free_attack ],
@@ -5705,3 +5774,30 @@ CODE[36 * 2 + 1] = [
[ vm_endpiece ],
[ vm_return ],
]
+
+// SUCC 1
+CODE[1 * 2 + 72] = [
+ [ vm_current, DS ],
+ [ vm_campaign ],
+ [ vm_force_current, BK ],
+ [ vm_prompt, "Gain Cavalry token equal to Influence and Forts." ],
+ [ vm_loge, "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_resources, false, VE, ()=>(game.inf[VE] + count_pieces_on_map(VE, DISC)) ],
+ [ vm_return ],
+]
+
+// SUCC 2
+CODE[2 * 2 + 72] = [
+ [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_return ],
+]
+
+// SUCC 3
+CODE[3 * 2 + 72] = [
+ [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_return ],
+]