summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2025-01-22 15:30:31 -0500
committerJoël Simoneau <simoneaujoel@gmail.com>2025-01-22 15:30:31 -0500
commitd175614dee7eeb82060e2cfd5d32efa8a6a9182b (patch)
tree00bfebffb64eb5793bee397a00b1f33444062a92
parent8b3cba4c8faaa5e603a1c9cba5d994258d9069a4 (diff)
downloadvijayanagara-d175614dee7eeb82060e2cfd5d32efa8a6a9182b.tar.gz
Event 5.
-rw-r--r--events.txt28
-rw-r--r--rules.js54
2 files changed, 74 insertions, 8 deletions
diff --git a/events.txt b/events.txt
index 1d18102..e0be988 100644
--- a/events.txt
+++ b/events.txt
@@ -39,10 +39,32 @@ SHADED 4
log "NOT IMPLEMENTED"
EVENT 5
- log "NOT IMPLEMENTED"
+ current REBEL_FACTIONS
+ prompt `Replace up to three Delhi Sultanate Units with Rebelling ${PIECE_FACTION_TYPE_NAME[game.current][ELITE]}.`
+ piece_undo_opt 3 (is_adjacent_to_city(C_CHITTOR, piece_space(p)) && can_place_piece(piece_space(p), game.current, ELITE) && is_ds_unit(p))
+ set_piece_space
+ remove
+ auto_place (game.current) ELITE
+ set_space -1
+ endpiece
+ prompt `Place a ${PIECE_FACTION_TYPE_NAME[game.current][DISC]} in Rajput Kingdoms.`
+ space_opt 1 (s === S_RAJPUT_KINGDOMS && can_place_piece(s, game.current, DISC))
+ auto_place (game.current) DISC
+ endspace
SHADED 5
- log "NOT IMPLEMENTED"
+ current DS
+ prompt "Replace up to 3 opposing Units adjacent to Chittor."
+ piece_undo_opt 3 (is_adjacent_to_city(C_CHITTOR, piece_space(p)) && can_place_piece(piece_space(p), DS, TROOPS) && is_enemy_piece(p))
+ set_piece_space
+ remove
+ auto_place DS TROOPS
+ set_space -1
+ endpiece
+ prompt "Place a Qasbah in Rajput Kingdoms."
+ space_opt 1 (s === S_RAJPUT_KINGDOMS && can_place_piece(s, DS, DISC))
+ auto_place DS DISC
+ endspace
EVENT 6
log "NOT IMPLEMENTED"
@@ -232,7 +254,7 @@ SHADED 32
EVENT 33
current (has_majority_goa())
prompt "Remove up to 3 Opposing Units adjacent to Goa."
- piece_opt 3 (is_adjacent_to_city(C_GOA, piece_space(p)))
+ piece_opt 3 (is_adjacent_to_city(C_GOA, piece_space(p)) && is_enemy_piece(p))
remove
endpiece
resources (game.current) 2
diff --git a/rules.js b/rules.js
index f4594ab..a4984a1 100644
--- a/rules.js
+++ b/rules.js
@@ -258,7 +258,7 @@ exports.setup = function (seed, scenario, _options) {
}
function setup_deck() {
- game.deck = [ 3, 36, 10, 37, 11, 2, 41, 4, 5, 6, 7, 8, 9, 10, 1, 12, 13, 14 ]
+ game.deck = [ 5, 3, 36, 10, 37, 11, 2, 41, 4, 6, 7, 8, 9, 10, 1, 12, 13, 14 ]
}
function setup_standard() {
@@ -2486,6 +2486,10 @@ function is_adjacent(a, b) {
return set_has(SPACES[a].adjacent, b)
}
+function is_enemy_piece(p) {
+ return piece_faction(p) !== game.current
+}
+
function is_piece(p, faction, type) {
return p >= first_piece[faction][type] && p <= last_piece[faction][type]
}
@@ -3430,6 +3434,14 @@ function vm_log() {
vm_next()
}
+function vm_mark_space() {
+ if (game.vm.m)
+ set_add(game.vm.m, game.vm.s)
+ else
+ game.vm.m = [ game.vm.s ]
+ vm_next()
+}
+
function vm_move() {
log("Moved " + piece_name(game.vm.p) + " to S" + game.vm.s + " from S" + piece_space(game.vm.p) + ".")
place_piece(game.vm.p, game.vm.s)
@@ -3556,6 +3568,16 @@ function vm_save_space() {
vm_next()
}
+function vm_set_piece_space() {
+ game.vm.s = piece_space(game.vm.p)
+ vm_next()
+}
+
+function vm_set_space() {
+ game.vm.s = vm_operand(1)
+ vm_next()
+}
+
// VM: PIECE ITERATOR
function vm_piece() {
@@ -3853,7 +3875,7 @@ CODE[3 * 2 + 1] = [
[ vm_steal, DS, BK, 2 ],
[ vm_endif ],
[ vm_if, ()=>has_piece_faction(game.vm.s, VE) ],
- [ vm_steal, DS, VE, -2 ],
+ [ vm_steal, DS, VE, 2 ],
[ vm_endif ],
[ vm_endspace ],
[ vm_return ],
@@ -3873,13 +3895,35 @@ CODE[4 * 2 + 1] = [
// EVENT 5
CODE[5 * 2 + 0] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, REBEL_FACTIONS ],
+ [ vm_prompt, ()=>`Replace up to three Delhi Sultanate Units with Rebelling ${PIECE_FACTION_TYPE_NAME[game.current][ELITE]}.` ],
+ [ vm_piece, true, 0, 3, (p,s)=>(is_adjacent_to_city(C_CHITTOR, piece_space(p)) && can_place_piece(piece_space(p), game.current, ELITE) && is_ds_unit(p)) ],
+ [ vm_set_piece_space ],
+ [ vm_remove ],
+ [ vm_auto_place, false, 0, ()=>(game.current), ELITE ],
+ [ vm_set_space, -1 ],
+ [ vm_endpiece ],
+ [ vm_prompt, ()=>`Place a ${PIECE_FACTION_TYPE_NAME[game.current][DISC]} in Rajput Kingdoms.` ],
+ [ vm_space, true, 0, 1, (s)=>(s === S_RAJPUT_KINGDOMS && can_place_piece(s, game.current, DISC)) ],
+ [ vm_auto_place, false, 0, ()=>(game.current), DISC ],
+ [ vm_endspace ],
[ vm_return ],
]
// SHADED 5
CODE[5 * 2 + 1] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, DS ],
+ [ vm_prompt, "Replace up to 3 opposing Units adjacent to Chittor." ],
+ [ vm_piece, true, 0, 3, (p,s)=>(is_adjacent_to_city(C_CHITTOR, piece_space(p)) && can_place_piece(piece_space(p), DS, TROOPS) && is_enemy_piece(p)) ],
+ [ vm_set_piece_space ],
+ [ vm_remove ],
+ [ vm_auto_place, false, 0, DS, TROOPS ],
+ [ vm_set_space, -1 ],
+ [ vm_endpiece ],
+ [ vm_prompt, "Place a Qasbah in Rajput Kingdoms." ],
+ [ vm_space, true, 0, 1, (s)=>(s === S_RAJPUT_KINGDOMS && can_place_piece(s, DS, DISC)) ],
+ [ vm_auto_place, false, 0, DS, DISC ],
+ [ vm_endspace ],
[ vm_return ],
]
@@ -4231,7 +4275,7 @@ CODE[32 * 2 + 1] = [
CODE[33 * 2 + 0] = [
[ vm_current, ()=>(has_majority_goa()) ],
[ vm_prompt, "Remove up to 3 Opposing Units adjacent to Goa." ],
- [ vm_piece, false, 0, 3, (p,s)=>(is_adjacent_to_city(C_GOA, piece_space(p))) ],
+ [ vm_piece, false, 0, 3, (p,s)=>(is_adjacent_to_city(C_GOA, piece_space(p)) && is_enemy_piece(p)) ],
[ vm_remove ],
[ vm_endpiece ],
[ vm_resources, false, ()=>(game.current), 2 ],