summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2025-04-13 08:07:41 -0400
committerJoël Simoneau <simoneaujoel@gmail.com>2025-04-13 08:07:41 -0400
commit6e39409d94b2a9c26d73777ca8c49a373ee5c68c (patch)
tree884c9d141f3a343ef7bea062fbba8a093567de11
parent8b8e940e42b6e8088eecd8f9a3bb004143e8ac62 (diff)
downloadvijayanagara-6e39409d94b2a9c26d73777ca8c49a373ee5c68c.tar.gz
fix leaky event cmd
-rw-r--r--events.txt12
-rw-r--r--rules.js21
2 files changed, 24 insertions, 9 deletions
diff --git a/events.txt b/events.txt
index a462906..98765bc 100644
--- a/events.txt
+++ b/events.txt
@@ -26,7 +26,8 @@ SHADED 1
log `Opposing Units to Rebelling in ${SPACE_NAME[game.vm.s]}.`
endif
endspace
- prompt "Free Attack in selected space."
+ clean_cmd
+ prompt `Free Attack in ${SPACE_NAME[game.vm.m[0]]}.`
space 1 (s === game.vm.m[0] && can_attack_in_space(s))
free_attack
endspace
@@ -50,6 +51,7 @@ SHADED 2
space 1 ((s === S_MOUNTAIN_PASSES || s === S_PUNJAB) && has_ds_unit(s) && has_piece(s, MI, TROOPS))
free_attack
endspace
+ clean_cmd
prompt "Rearrange up to 6 Units among Mountain Passes and Punjab and one other space."
space 1 (s !== S_MOUNTAIN_PASSES && s !== S_PUNJAB)
mark_space
@@ -464,11 +466,11 @@ EVENT 20
free_migrate
endif
endspace
- prompt `Rally in ${SPACE_NAME[game.vm.s]} for free.`
+ prompt `Rally in ${SPACE_NAME[game.vm.m[0]]} for free.`
space_opt 1 (game.vm.m[0] === s && can_rally_in_space(s))
free_rally
endspace
- prompt `Build in ${SPACE_NAME[game.vm.s]}.`
+ prompt `Build in ${SPACE_NAME[game.vm.m[0]]}.`
space_opt 1 (game.vm.m[0] === s && can_build_in_space(s))
free_build
endspace
@@ -695,13 +697,14 @@ EVENT 31
space_opt 1 (is_adjacent_to_city(C_VIJAYANAGARA, s) && can_migrate_in_space(s))
mark_space
free_migrate
+ clean_cmd
clean_p
prompt `Remove an opposing Unit from ${SPACE_NAME[game.vm.s]}.`
piece 1 (is_piece_in_event_space(p) && is_enemy_unit(p))
remove
endpiece
endspace
- prompt `Free Attack in ${SPACE_NAME[game.vm.s]}.`
+ prompt `Free Attack in ${SPACE_NAME[game.vm.m[0]]}.`
space_opt 1 (s === game.vm.m[0] && can_attack_in_space(s))
free_attack
endspace
@@ -825,6 +828,7 @@ SUCC 2
else
cav_resources (Math.min(game.prosperity[BK],3))
endif
+ clean_cmd
force_current VE
log_succ VE "Sangama brothers establish an empire."
any_limited_command
diff --git a/rules.js b/rules.js
index 3d9fc37..78a9651 100644
--- a/rules.js
+++ b/rules.js
@@ -4569,6 +4569,11 @@ function vm_clean_p() {
vm_next()
}
+function vm_clean_cmd() {
+ reset_cmd()
+ vm_next()
+}
+
function vm_current() {
if (vm_operand(1) !== game.current)
game.state = "vm_current"
@@ -4782,6 +4787,8 @@ function vm_endrepeat() {
}
function vm_return() {
+ reset_cmd()
+ game.decree = {}
if (!is_succession())
game.state = "vm_return"
else
@@ -5984,7 +5991,8 @@ CODE[1 * 2 + 1] = [
[ vm_log, ()=>`Opposing Units to Rebelling in ${SPACE_NAME[game.vm.s]}.` ],
[ vm_endif ],
[ vm_endspace ],
- [ vm_prompt, "Free Attack in selected space." ],
+ [ vm_clean_cmd ],
+ [ vm_prompt, ()=>`Free Attack in ${SPACE_NAME[game.vm.m[0]]}.` ],
[ vm_space, true, 1, 1, (s)=>(s === game.vm.m[0] && can_attack_in_space(s)) ],
[ vm_free_attack ],
[ vm_endspace ],
@@ -6013,6 +6021,7 @@ CODE[2 * 2 + 1] = [
[ vm_space, true, 1, 1, (s)=>((s === S_MOUNTAIN_PASSES || s === S_PUNJAB) && has_ds_unit(s) && has_piece(s, MI, TROOPS)) ],
[ vm_free_attack ],
[ vm_endspace ],
+ [ vm_clean_cmd ],
[ vm_prompt, "Rearrange up to 6 Units among Mountain Passes and Punjab and one other space." ],
[ vm_space, true, 1, 1, (s)=>(s !== S_MOUNTAIN_PASSES && s !== S_PUNJAB) ],
[ vm_mark_space ],
@@ -6168,7 +6177,7 @@ CODE[8 * 2 + 0] = [
// SHADED 8
CODE[8 * 2 + 1] = [
[ vm_current, DS ],
- [ vm_prompt, ()=>`In each Province adjacent to Devagiri and/or Gulbarga, Govern for free ignoring location requirements and place a Troop.` ],
+ [ vm_prompt, ()=>`In each Province adjacent clean_cmto Devagiri and/or Gulbarga, Govern for free ignoring location requirements and place a Troop.` ],
[ vm_asm, ()=>game.vm.ignore_loc_req = true ],
[ vm_space, true, 0, 999, (s)=>(is_adjacent_to_city(C_DEVAGIRI, s) || is_adjacent_to_city(C_GULBARGA, s)) && can_govern_in_space(s) ],
[ vm_free_govern_in_space ],
@@ -6532,11 +6541,11 @@ CODE[20 * 2 + 0] = [
[ vm_free_migrate ],
[ vm_endif ],
[ vm_endspace ],
- [ vm_prompt, ()=>`Rally in ${SPACE_NAME[game.vm.s]} for free.` ],
+ [ vm_prompt, ()=>`Rally in ${SPACE_NAME[game.vm.m[0]]} for free.` ],
[ vm_space, true, 0, 1, (s)=>(game.vm.m[0] === s && can_rally_in_space(s)) ],
[ vm_free_rally ],
[ vm_endspace ],
- [ vm_prompt, ()=>`Build in ${SPACE_NAME[game.vm.s]}.` ],
+ [ vm_prompt, ()=>`Build in ${SPACE_NAME[game.vm.m[0]]}.` ],
[ vm_space, true, 0, 1, (s)=>(game.vm.m[0] === s && can_build_in_space(s)) ],
[ vm_free_build ],
[ vm_endspace ],
@@ -6826,13 +6835,14 @@ CODE[31 * 2 + 0] = [
[ vm_space, true, 0, 1, (s)=>(is_adjacent_to_city(C_VIJAYANAGARA, s) && can_migrate_in_space(s)) ],
[ vm_mark_space ],
[ vm_free_migrate ],
+ [ vm_clean_cmd ],
[ vm_clean_p ],
[ vm_prompt, ()=>`Remove an opposing Unit from ${SPACE_NAME[game.vm.s]}.` ],
[ vm_piece, false, 1, 1, (p,s)=>(is_piece_in_event_space(p) && is_enemy_unit(p)) ],
[ vm_remove ],
[ vm_endpiece ],
[ vm_endspace ],
- [ vm_prompt, ()=>`Free Attack in ${SPACE_NAME[game.vm.s]}.` ],
+ [ vm_prompt, ()=>`Free Attack in ${SPACE_NAME[game.vm.m[0]]}.` ],
[ vm_space, true, 0, 1, (s)=>(s === game.vm.m[0] && can_attack_in_space(s)) ],
[ vm_free_attack ],
[ vm_endspace ],
@@ -6995,6 +7005,7 @@ CODE[2 * 2 + 74] = [
[ vm_else ],
[ vm_cav_resources, ()=>(Math.min(game.prosperity[BK],3)) ],
[ vm_endif ],
+ [ vm_clean_cmd ],
[ vm_force_current, VE ],
[ vm_log_succ, VE, "Sangama brothers establish an empire." ],
[ vm_any_limited_command ],