summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events.txt22
-rw-r--r--play.js10
-rw-r--r--rules.js206
-rw-r--r--tools/gencode.js1
4 files changed, 199 insertions, 40 deletions
diff --git a/events.txt b/events.txt
index e44cdf9..c260271 100644
--- a/events.txt
+++ b/events.txt
@@ -730,7 +730,8 @@ SHADED 36
endpiece
SUCC 1
- current DS
+ force_current DS
+ loge "Power struggle in Delhi."
campaign
force_current BK
prompt "Gain Cavalry token equal to Influence and Forts."
@@ -742,7 +743,22 @@ SUCC 1
resources VE (game.inf[VE] + count_pieces_on_map(VE, DISC))
SUCC 2
- log "NOT IMPLEMENTED"
+ force_current DS
+ campaign
+ force_current BK
+ any_limited_command
+ cav_resources (Math.min(game.prosperity[BK],3))
+ force_current VE
+ any_limited_command
+ cav_resources (Math.min(game.prosperity[VE],3))
SUCC 3
- log "NOT IMPLEMENTED"
+ force_current DS
+ loge "Renewed focus on infrastructure."
+ influence_succession
+ force_current BK
+ loge "Trade network covers the Deccan."
+ influence_succession
+ force_current VE
+ loge "Vast, unifying medieval metropolis."
+ influence_succession
diff --git a/play.js b/play.js
index 0b42493..15ab76c 100644
--- a/play.js
+++ b/play.js
@@ -520,8 +520,8 @@ function init_ui() {
register_action(ui.resources[DS], "resources", DS)
register_action(ui.resources[BK], "resources", BK)
register_action(ui.resources[VE], "resources", VE)
- register_action(ui.tokens.token_bk_influence, "inf", BK)
- register_action(ui.tokens.token_ve_influence, "inf", VE)
+ register_action(ui.tokens.token_bk_influence, "influence", BK)
+ register_action(ui.tokens.token_ve_influence, "influence", VE)
register_action(ui.tokens.token_mongol_cavalry, "token", 10)
ui.this_card.onmouseenter = on_focus_this_event
@@ -960,8 +960,8 @@ function on_update() {
ui.header.classList.toggle("bk", view.current === BK)
ui.header.classList.toggle("ve", view.current === VE)
- ui.tokens.token_bk_influence.classList.toggle("action", is_action("inf", BK))
- ui.tokens.token_ve_influence.classList.toggle("action", is_action("inf", VE))
+ ui.tokens.token_bk_influence.classList.toggle("action", is_action("influence", BK))
+ ui.tokens.token_ve_influence.classList.toggle("action", is_action("influence", VE))
ui.resources[DS].classList.toggle("action", is_action("resources", DS))
ui.resources[BK].classList.toggle("action", is_action("resources", BK))
@@ -1183,6 +1183,8 @@ function on_update() {
// Event buttons
action_button("obedient", "Obedient")
action_button("rebelling", "Rebelling")
+ action_button("remove_influence", "Remove Influence")
+ action_button("add_influence", "Add Influence")
// Other buttons
action_button("roll", "Roll")
diff --git a/rules.js b/rules.js
index 3d2e092..459edc4 100644
--- a/rules.js
+++ b/rules.js
@@ -352,11 +352,13 @@ function goto_card() {
goto_mongol_invaders(VE)
} else if (this_card() === 45) {
log_h1("C" + this_card()) // Zenith of the Delhi Sultanate
- succession_1()
+ succession()
} else if (this_card() === 46) {
log_h1("C" + this_card()) // Rise of the Rebel Sultans
+ succession()
} else if (this_card() === 47) {
log_h1("C" + this_card()) // Lords of the Deccan
+ succession()
} else if (this_card() === 43 || this_card() === 44) {
log_h1("C" + this_card()) // Timurid Empire
} else {
@@ -391,14 +393,18 @@ function goto_eligible() {
} else {
game.state = "eligible"
game.decree = {}
- game.cmd = {
- limited: 0,
- free: 0,
- spaces: [],
- pieces: [],
- where: -1,
- pass: 1
- }
+ reset_cmd()
+ }
+}
+
+function reset_cmd() {
+ game.cmd = {
+ limited: 0,
+ free: 0,
+ spaces: [],
+ pieces: [],
+ where: -1,
+ pass: 1
}
}
@@ -477,7 +483,10 @@ function goto_cavalry(n, next) {
game.state = "cavalry"
else {
if (game.vm) {
- upop_summary()
+ if (is_succession())
+ pop_summary()
+ else
+ upop_summary()
vm_next()
} else {
pop_summary()
@@ -560,12 +569,16 @@ function goto_tax() {
/* SUCCESSION */
-function succession_1() {
+function succession() {
game.current = DS
game.succ += 1
goto_vm(game.succ * 2 + 72)
}
+function is_succession() {
+ return (game.vm && game.vm.fp > 72)
+}
+
/* STATES */
states.eligible = {
@@ -690,10 +703,10 @@ states.compromising_gifts = {
view.actions.end_gifts = 1
},
- inf() {
- log_h2(faction_acronyms[game.current] + "Compromising Gifts")
- logi_resources(game.current, 2)
- add_resources(game.current, 2)
+ influence(f) {
+ log_h2(faction_acronyms[f] + "Compromising Gifts")
+ logi_resources(f, 2)
+ add_resources(f, 2)
game.inf_shift = {
"next": "cavalry",
}
@@ -701,7 +714,7 @@ states.compromising_gifts = {
"n": 2,
"next": null
}
- remove_influence(game.current)
+ remove_influence(f)
},
end_gifts() {
end_card()
@@ -846,7 +859,25 @@ function init_command(type) {
game.cmd.type = type
}
-function init_free_command(type, s) {
+function init_vm_command(type, free, limited) {
+ push_undo()
+ if (limited)
+ log_h2(faction_name[game.current] + " - Limited " + type)
+ else
+ log_h2(faction_name[game.current] + " - " + type)
+
+ game.cmd = {
+ type: type,
+ limited: limited,
+ free: free,
+ spaces: [],
+ selected: [],
+ pieces: [],
+ where: -1,
+ }
+}
+
+function init_free_command_in_space(type, s) {
log_space(s, type)
game.cmd = {
type: type,
@@ -1713,6 +1744,7 @@ states.migrate_shift_influence = {
},
resources() {
let f = (game.current === BK) ? VE : BK
+ log_br()
add_resources(game.current, -1)
add_influence(game.current)
game.cmd.shift = true
@@ -1839,7 +1871,7 @@ function prompt_end_decree() {
}
function init_decree(type) {
- if (!(game.vm && game.vm.fp > 72))
+ if (!is_succession())
push_undo()
log_h2(faction_name[game.current] + " - " + type)
game.decree = {}
@@ -3178,7 +3210,7 @@ function gen_action_die(d) {
}
function gen_action_influence(faction) {
- gen_action("inf", faction)
+ gen_action("influence", faction)
}
function gen_action_piece(p) {
@@ -4038,7 +4070,7 @@ function vm_endrepeat() {
}
function vm_return() {
- if (game.vm.fp <= 72)
+ if (!is_succession())
game.state = "vm_return"
else
end_event()
@@ -4364,8 +4396,10 @@ function vm_remove_influence() {
function vm_resources() {
if (vm_operand(3) !== 0)
game.state = "vm_resources"
- else
+ else {
+ logi("Nothing")
vm_next()
+ }
}
states.vm_resources = {
@@ -4425,9 +4459,12 @@ states.vm_steal = {
// VM : CAVALRY OR RESOURCES
function vm_cav_resources() {
- push_summary()
- game.vm.count = vm_inst(1)
- game.state = "vm_cav_resources"
+ game.vm.count = vm_operand(1)
+ if (game.vm.count > 0) {
+ push_summary()
+ game.state = "vm_cav_resources"
+ } else
+ vm_next()
}
states.vm_cav_resources = {
@@ -4574,12 +4611,12 @@ function vm_demand_obedience() {
// VM: GOVERN
function vm_free_govern() {
- init_free_command("Govern", game.vm.s)
+ init_free_command_in_space("Govern", game.vm.s)
goto_govern_space()
}
function vm_govern_in_space() {
- init_free_command("Govern", game.vm.s)
+ init_free_command_in_space("Govern", game.vm.s)
game.cmd.free = 0
goto_govern_space()
}
@@ -4599,7 +4636,7 @@ function vm_govern() {
// VM: MARCH
function vm_free_march() {
- init_free_command("March", game.vm.s)
+ init_free_command_in_space("March", game.vm.s)
game.cmd.pieces = []
goto_march_space()
}
@@ -4625,10 +4662,57 @@ function vm_free_migrate() {
// VM: RALLY
function vm_free_rally() {
- init_free_command("Rally", game.vm.s)
+ init_free_command_in_space("Rally", game.vm.s)
goto_rally_space()
}
+// VM: INFLUENCE SUCCESSION
+
+function vm_influence_succession() {
+ game.cmd = {}
+ game.cmd.who = null
+ game.cmd.count = 3
+ game.state = "influence_succession"
+}
+
+states.influence_succession = {
+ prompt() {
+ if (game.resources[game.current] < 3) {
+ event_prompt("Not enough resources.")
+ } else if (game.cmd.count === 0) {
+ event_prompt("Done.")
+ } else if (!game.cmd.who) {
+ event_prompt(`Select the Influence marker to shift (${game.cmd.count} remaining).`)
+ gen_action_influence(BK)
+ gen_action_influence(VE)
+ } else {
+ let f2 = other_rebel_faction(game.cmd.who)
+ event_prompt(`Spend 3 resources to shift ${faction_name[game.cmd.who]}'s Influence (${game.cmd.count} remaining).`)
+ gen_action_influence(f2)
+ if (game.inf[game.cmd.who] < 4)
+ view.actions.add_influence = 1
+ if (game.inf[game.cmd.who] > 0)
+ view.actions.remove_influence = 1
+ }
+ view.actions.next = 1
+ },
+ influence(f) {
+ game.cmd.who = f
+ },
+ add_influence() {
+ add_resources(game.current, -3)
+ add_influence(game.cmd.who)
+ game.cmd.count -= 1
+ },
+ remove_influence() {
+ add_resources(game.current, -3)
+ remove_influence(game.cmd.who)
+ game.cmd.count -= 1
+ },
+ next: vm_next
+}
+
+
// VM: MIX
function vm_conspire_trade() { game.state = "vm_conspire_trade" }
@@ -4671,6 +4755,46 @@ states.vm_govern_attack_demand = {
}
}
+function vm_any_limited_command() {
+ game.state = "vm_any_limited_command"
+}
+
+states.vm_any_limited_command = {
+ prompt() {
+ event_prompt("Execute a free limited Command.")
+ reset_cmd()
+ view.actions.rally = can_rally() ? 1 : 0
+ view.actions.migrate = can_migrate() ? 1 : 0
+ view.actions.rebel = can_rebel() ? 1 : 0
+ view.actions.attack = can_attack() ? 1 : 0
+ },
+ rally() {
+ push_undo()
+ init_vm_command("Rally", true, true)
+ game.state = "rally"
+
+ },
+ migrate() {
+ push_undo()
+ init_vm_command("Migrate", true, true)
+ game.state = "migrate"
+
+ },
+ rebel() {
+ push_undo()
+ init_vm_command("Rebel", true, true)
+ game.state = "rebel"
+
+ },
+ attack() {
+ push_undo()
+ init_vm_command("Attack", true, true)
+ game.cmd.attacker = game.current
+ game.cmd.support_space = null
+ game.state = "attack"
+ }
+}
+
// VM: EVENT_4
@@ -5777,27 +5901,43 @@ CODE[36 * 2 + 1] = [
// SUCC 1
CODE[1 * 2 + 72] = [
- [ vm_current, DS ],
+ [ vm_force_current, DS ],
+ [ vm_loge, "Power struggle in Delhi." ],
[ vm_campaign ],
[ vm_force_current, BK ],
[ vm_prompt, "Gain Cavalry token equal to Influence and Forts." ],
- [ vm_loge, "Military, labor, market, thrives" ],
+ [ 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_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_force_current, DS ],
+ [ vm_campaign ],
+ [ vm_force_current, BK ],
+ [ vm_any_limited_command ],
+ [ vm_cav_resources, ()=>(Math.min(game.prosperity[BK],3)) ],
+ [ vm_force_current, VE ],
+ [ vm_any_limited_command ],
+ [ vm_cav_resources, ()=>(Math.min(game.prosperity[VE],3)) ],
[ vm_return ],
]
// SUCC 3
CODE[3 * 2 + 72] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_force_current, DS ],
+ [ vm_loge, "Renewed focus on infrastructure." ],
+ [ vm_influence_succession ],
+ [ vm_force_current, BK ],
+ [ vm_loge, "Trade network covers the Deccan." ],
+ [ vm_influence_succession ],
+ [ vm_force_current, VE ],
+ [ vm_loge, "Vast, unifying medieval metropolis." ],
+ [ vm_influence_succession ],
[ vm_return ],
]
diff --git a/tools/gencode.js b/tools/gencode.js
index 1cf119c..e60a2cb 100644
--- a/tools/gencode.js
+++ b/tools/gencode.js
@@ -130,6 +130,7 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) {
break
case "log":
+ case "loge":
case "prompt":
emit([ line[0], line.slice(1).join(" ") ])
break