summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2025-03-08 19:30:27 -0500
committerJoël Simoneau <simoneaujoel@gmail.com>2025-03-08 19:30:27 -0500
commit3c6cb57b15420b0d56af26e2e8b52ad70c2b8508 (patch)
treef360ec9887b78ad56dba5368fdd448789823f2d1 /rules.js
parent473b61c1dd1b0f79b13ef1aae506b496100a5e45 (diff)
downloadvijayanagara-3c6cb57b15420b0d56af26e2e8b52ad70c2b8508.tar.gz
Event 6.
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js121
1 files changed, 103 insertions, 18 deletions
diff --git a/rules.js b/rules.js
index f114e8d..135b2df 100644
--- a/rules.js
+++ b/rules.js
@@ -703,7 +703,7 @@ states.march = {
view.actions.end_march = prompt_end_cmd(1)
},
space(s) {
- push_undo
+ push_undo()
select_cmd_space(s, 1)
goto_march_space()
},
@@ -1885,28 +1885,68 @@ function goto_campaign() {
game.state = "campaign"
}
+function is_n_from_warangal(n, s) {
+ let queue = [[s, []]]
+
+ while (queue.length) {
+ let [node, path] = queue.shift();
+
+ if (path.length === n) {
+ if (is_adjacent_to_city(C_WARANGAL, node))
+ return true
+ } else if (path.length < n) {
+ for (let neighbor of SPACES[node].adjacent) {
+ if (!set_has(path, neighbor) && !set_has(game.decree.campaign, neighbor)) {
+ queue.push([neighbor, [...path, neighbor]]);
+ }
+ }
+ }
+ }
+ return false;
+}
+
states.campaign = {
prompt() {
- view.prompt = "Campaign: Select four contiguous spaces, from start to finish."
view.actions.campaign_spaces = [...game.decree.campaign].sort((a, b) => a - b)
- if (game.decree.campaign.length === 0) {
- for (let s = first_space; s <= last_space; ++s) {
- if (can_start_campaign_in_space(s))
- gen_action_space(s)
+ if (game.vm && game.vm.fp === 13) {
+ view.prompt = "Campaign: Select four contiguous spaces, finishing adjacent to Warangal"
+ if (game.decree.campaign.length === 0) {
+ for (let s = first_space; s <= last_space; ++s) {
+ console.log("TEST! ", SPACE_NAME[s], is_n_from_warangal(3, s))
+ if (can_start_campaign_in_space(s) && is_n_from_warangal(3, 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) && is_n_from_warangal(3-game.decree.campaign.length, 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))
- gen_action_space(s)
+ } else {
+ 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))
+ 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))
+ gen_action_space(s)
+ }
}
}
},
space(s) {
+ push_undo()
game.decree.campaign.push(s)
- if (game.decree.campaign.length === 4)
+ if (game.decree.campaign.length === 4) {
+ if (game.vm)
+ game.vm.m = s
game.state = "campaign_moves"
+ }
}
}
@@ -3030,12 +3070,14 @@ function update_control() {
if (is_tributary(s))
game.prosperity[DS] += SPACES[s].pop
else {
- let c = has_majority(s)
- if (c <= VE)
- game.control[c] |= (1 << s)
+ let f = has_majority(s)
+ if (f <= VE)
+ game.control[f] |= (1 << s)
- if (c === BK || c === VE)
- game.prosperity[c] += SPACES[s].pop
+ if (f === BK || f === VE) {
+ game.prosperity[f] += SPACES[s].pop
+ to_rebel_space(s, f)
+ }
}
}
update_vp()
@@ -4377,6 +4419,40 @@ states.event_4 = {
}
}
+// VM: SHADED_6
+
+function vm_shaded_6() {
+ init_free_decree("Campaign")
+ game.decree = {
+ campaign: [],
+ pieces: [],
+ selected: []
+ }
+ game.state = "campaign"
+}
+
+function vm_shaded_6_2() {
+ console.log(game)
+ game.state = "shaded_6_2"
+}
+
+states.shaded_6_2 = {
+ prompt() {
+ event_prompt("Steal 3 Resources from a Faction where the Campaign ended.")
+ if (has_piece_faction(game.vm.m, BK))
+ gen_action_resources(BK)
+ if (has_piece_faction(game.vm.m, VE))
+ gen_action_resources(VE)
+ },
+ resources(f) {
+ let n = Math.min(game.resources[f], 3)
+ add_resources(f, -n)
+ add_resources(DS, n)
+ log(`${faction_name[game.current]} steals ${n} Resources from ${faction_name[f]}.`)
+ vm_next()
+ }
+}
+
// VM: EVENT_25
function vm_event_25() {
@@ -4598,13 +4674,22 @@ CODE[5 * 2 + 1] = [
// EVENT 6
CODE[6 * 2 + 0] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, REBEL_FACTIONS ],
+ [ vm_prompt, "Select a Province adjacent to Warangal to remove a Tributary marker." ],
+ [ vm_space, true, 0, 1, (s)=>(is_adjacent_to_city(C_WARANGAL, s)) ],
+ [ vm_remove_tributary ],
+ [ vm_prompt, ()=>`Place up to 2 ${PIECE_FACTION_TYPE_NAME[game.current][ELITE]}.` ],
+ [ vm_place, false, 1, 2, ()=>(game.current), ELITE ],
+ [ vm_endspace ],
[ vm_return ],
]
// SHADED 6
CODE[6 * 2 + 1] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, DS ],
+ [ vm_prompt, "Campaign: Select four contiguous spaces, finishing adjacent to Warangal" ],
+ [ vm_shaded_6 ],
+ [ vm_shaded_6_2 ],
[ vm_return ],
]