summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2025-03-10 13:48:23 -0400
committerJoël Simoneau <simoneaujoel@gmail.com>2025-03-10 13:48:23 -0400
commit9436b56542c0c80549835be0dae3b5c4d3280f40 (patch)
treeda8c8b646969574182ec1120b69ea6e50fb607a2
parentd8b3ff3d5a616615c947252741d00cb0964b9a7a (diff)
downloadvijayanagara-9436b56542c0c80549835be0dae3b5c4d3280f40.tar.gz
Basic Succession.
-rw-r--r--events.txt18
-rw-r--r--play.css2
-rw-r--r--play.js8
-rw-r--r--rules.js122
-rw-r--r--tools/gencode.js21
5 files changed, 150 insertions, 21 deletions
diff --git a/events.txt b/events.txt
index 3fdb09e..e44cdf9 100644
--- a/events.txt
+++ b/events.txt
@@ -728,3 +728,21 @@ SHADED 36
piece_opt 3 is_raja(p) && is_piece_on_map(p)
remove
endpiece
+
+SUCC 1
+ current DS
+ campaign
+ force_current BK
+ prompt "Gain Cavalry token equal to Influence and Forts."
+ loge "Military labor market thrives"
+ gain_cavalry (game.inf[BK] + count_pieces_on_map(BK, DISC))
+ force_current VE
+ prompt "Gain resources equal to Influence and Temples."
+ loge "Temple towns emerge anew"
+ resources VE (game.inf[VE] + count_pieces_on_map(VE, DISC))
+
+SUCC 2
+ log "NOT IMPLEMENTED"
+
+SUCC 3
+ log "NOT IMPLEMENTED"
diff --git a/play.css b/play.css
index 0fdc4aa..0d99af1 100644
--- a/play.css
+++ b/play.css
@@ -593,7 +593,7 @@ path.campaign { stroke: black; stroke-dasharray: 4 4; }
.card.card_46{background-image:url(cards100/Succession2_front.jpg)}
.card.card_47{background-image:url(cards100/Succession3_front.jpg)}
.card.card_dynasty_khalji{background-image:url(cards100/Dynasty_front.jpg)}
-.card.card_dynasty_khalji{background-image:url(cards100/Dynasty_back.jpg)}
+.card.card_dynasty_tughlaq{background-image:url(cards100/Dynasty_back.jpg)}
@media (min-resolution: 97dpi) {
.card.card_back{background-image:url(cards200/event_back.jpg)}
diff --git a/play.js b/play.js
index 1128d67..0b42493 100644
--- a/play.js
+++ b/play.js
@@ -986,6 +986,10 @@ function on_update() {
ui.shaded_event.classList.toggle("action", !!(view.actions && view.actions.shaded === 1))
ui.unshaded_event.classList.toggle("action", !!(view.actions && view.actions.unshaded === 1))
+ // Dynasty card
+ if (view.succ > 0)
+ ui.dynasty_card.className = "card card_dynasty_tughlaq"
+
layout_score()
let items = [ ]
@@ -1521,6 +1525,10 @@ function on_log(text) {
text = text.substring(3)
p.className = "indent italic"
}
+ else if (text.match(/^\.e/)) {
+ text = text.substring(3)
+ p.className = "italic"
+ }
else if (text.match(/^\.ad/)) {
text = text.substring(4)
p.className += " adice"
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 ],
+]
diff --git a/tools/gencode.js b/tools/gencode.js
index fb111bc..1cf119c 100644
--- a/tools/gencode.js
+++ b/tools/gencode.js
@@ -53,6 +53,16 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) {
console.log("// SHADED " + line[1])
console.log("CODE[" + line[1] + " * 2 + 1] = [")
break
+ case "SUCC":
+ if (first++) {
+ emit(["return"])
+ console.log("]")
+ }
+ SCODE[line[1]] = pc
+ console.log("")
+ console.log("// SUCC " + line[1])
+ console.log("CODE[" + line[1] + " * 2 + 72] = [")
+ break
case "if_space":
emit([ "if", "()=>can_vm_space(1,(s)=>" + line.slice(1).join(" ") + ")" ])
@@ -92,17 +102,14 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) {
break
case "resources":
- emit(["resources", false, line[1], line[2]])
+ emit(["resources", false, line[1], line.slice(2).join(" ")])
break
case "resources_opt":
- emit(["resources", true, line[1], line[2]])
+ emit(["resources", true, line[1], line.slice(2).join(" ")])
break
- case "shipment":
- emit([ "shipment", false, line[1], line[1], "(p,s)=>" + line.slice(2).join(" ") ])
- break
- case "shipment_opt":
- emit([ "shipment", false, 0, line[1], "(p,s)=>" + line.slice(2).join(" ") ])
+ case "gain_cavalry":
+ emit(["gain_cavalry", "()=>" + line.slice(1).join(" ")])
break
case "move_to":