summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--events.txt22
-rw-r--r--rules.js103
2 files changed, 96 insertions, 29 deletions
diff --git a/events.txt b/events.txt
index 7f587f6..911fc0d 100644
--- a/events.txt
+++ b/events.txt
@@ -263,10 +263,28 @@ SHADED 23
steal (game.current) VE 2
EVENT 24
- log "NOT IMPLEMENTED"
+ current VE
+ prompt "Free Migrate in up to 2 Provinces."
+ space_opt 2 can_migrate_in_space(s)
+ free_migrate
+ mark_space
+ endspace
+ prompt "Replace a Unit with a Raja."
+ clean_p
+ piece_opt 1 (can_place_piece(0, VE, ELITE) && set_has(game.vm.m, piece_space(p)) && is_enemy_unit(p))
+ set_piece_space
+ remove
+ auto_place (game.current) ELITE
+ set_space -1
+ endpiece
+
SHADED 24
- log "NOT IMPLEMENTED"
+ current [DS BK]
+ prompt "Place up to 2 Units in each Province with a Temple."
+ space_opt all has_temple(s)
+ place_opt 2 (game.current) UNITS
+ endspace
EVENT 25
log "NOT IMPLEMENTED"
diff --git a/rules.js b/rules.js
index 1b3a69e..1ba60fe 100644
--- a/rules.js
+++ b/rules.js
@@ -258,7 +258,7 @@ exports.setup = function (seed, scenario, _options) {
}
function setup_deck() {
- game.deck = [ 35, 29, 28, 27, 32, 23, 8, 7, 6, 5, 3, 36, 10, 37, 11, 2, 10, 1, 12, 13, 14 ]
+ game.deck = [ 35, 29, 28, 24, 32, 23, 8, 7, 6, 5, 3, 36, 10, 37, 11, 2, 10, 1, 12, 13, 14 ]
}
function setup_standard() {
@@ -1488,12 +1488,6 @@ function goto_migrate() {
game.state = "migrate"
}
-function goto_migrate_space() {
- push_summary()
- game.state = "migrate_space"
- game.cmd.count = 0
-}
-
states.migrate = {
prompt() {
view.prompt = "Migrate: Select a Province as the Migrate destination."
@@ -1514,6 +1508,12 @@ states.migrate = {
end_migrate: end_command
}
+function goto_migrate_space() {
+ push_summary()
+ game.state = "migrate_space"
+ game.cmd.count = 0
+}
+
states.migrate_space = {
prompt() {
view.prompt = `Migrate: Move in up to three ${PIECE_FACTION_TYPE_NAME[game.current][ELITE]}s.`
@@ -1544,8 +1544,16 @@ states.migrate_space = {
log_space(game.cmd.where, "Migrate")
pop_summary()
let f = (game.current === BK) ? VE : BK
+ if (game.vm) {
+ for (let p of game.cmd.pieces) {
+ set_add(game.vm.pp, p);
+ }
+ }
+
if (!game.cmd.shift && has_piece_faction(game.cmd.where, f)) {
game.state = "migrate_shift_influence"
+ } else if (game.vm) {
+ vm_next()
} else {
game.state = "migrate"
}
@@ -1572,6 +1580,14 @@ states.migrate_shift_influence = {
},
skip() {
game.cmd.shift = true
+ end_migrate_shift_influence()
+ }
+}
+
+function end_migrate_shift_influence() {
+ if (game.vm) {
+ vm_next()
+ } else {
game.state = "migrate"
}
}
@@ -2495,7 +2511,7 @@ function piece_faction(p) {
return BK
if (p >= first_piece[VE][DISC] && p <= last_piece[VE][DISC])
return VE
- throw "IMPOSSIBLE"
+ throw "IMPOSSIBLE - piece_faction"
}
function piece_name(p) {
@@ -2519,7 +2535,7 @@ function piece_type(p) {
return DISC
if (p >= first_piece[VE][DISC] && p <= last_piece[VE][DISC])
return DISC
- throw "IMPOSSIBLE"
+ throw "IMPOSSIBLE - piece_type"
}
function has_governor(s) {
@@ -2664,13 +2680,13 @@ function add_influence(faction) {
move_all_faction_piece_from(BK, ELITE, S_BK_INF_4, AVAILABLE)
else if (faction === VE)
move_all_faction_piece_from(VE, ELITE, S_VE_INF_1 + game.inf[faction] - 1, AVAILABLE)
- else if (game.vm)
- vm_next()
}
function remove_influence(faction) {
- if (game.inf[faction] === 0)
+ if (game.inf[faction] === 0) {
+ end_influence()
return
+ }
game.inf[faction]--
log(faction_name[faction] + " loses influence.")
@@ -2682,8 +2698,15 @@ function remove_influence(faction) {
troops_to_inf_track(BK, S_BK_INF_2)
else if (faction === VE)
troops_to_inf_track(VE, S_VE_INF_1 + game.inf[faction])
- else if (game.vm)
+ else
+ end_influence()
+}
+
+function end_influence() {
+ if (game.vm)
vm_next()
+ else
+ game.state = game.inf_shift.next
}
function troops_to_inf_track(faction, s) {
@@ -2699,10 +2722,8 @@ function troops_to_inf_track(faction, s) {
if (moved < 2) {
goto_return_troops(faction, 2-moved, s)
- } else if (game.vm) {
- vm_next()
- } else{
- game.state = game.inf_shift.next
+ } else {
+ end_influence()
}
}
@@ -2738,12 +2759,8 @@ states.return_troops = {
},
end_return() {
pop_summary()
- if (game.vm)
- vm_next()
- else {
- game.current = game.inf_shift.save_current
- game.state = game.inf_shift.next
- }
+ game.current = game.inf_shift.save_current
+ end_influence()
}
}
@@ -3423,6 +3440,12 @@ function vm_asm() {
vm_next()
}
+function vm_clean_p() {
+ game.vm.pp = []
+ game.vm.pl = []
+ vm_next()
+}
+
function vm_current() {
if (vm_operand(1) !== game.current)
game.state = "vm_current"
@@ -3850,8 +3873,7 @@ states.vm_place = {
function vm_add_influence() {
if (game.inf[vm_operand(1)] !== 4)
add_influence(vm_operand(1))
- else
- vm_next()
+ vm_next()
}
function vm_remove_influence() {
@@ -3956,6 +3978,16 @@ function vm_free_govern() {
goto_govern_space()
}
+// VM: MIGRATE
+
+function vm_free_migrate() {
+ let shift = (game.cmd && game.cmd.shift) ? true : false
+ init_free_command("Migrate", game.vm.s)
+ game.cmd.pieces = game.vm.pp
+ game.cmd.shift = shift
+ goto_migrate_space()
+}
+
// VM: RALLY
function vm_free_rally() {
@@ -4410,13 +4442,30 @@ CODE[23 * 2 + 1] = [
// EVENT 24
CODE[24 * 2 + 0] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, VE ],
+ [ vm_prompt, "Free Migrate in up to 2 Provinces." ],
+ [ vm_space, true, 0, 2, (s)=>can_migrate_in_space(s) ],
+ [ vm_free_migrate ],
+ [ vm_mark_space ],
+ [ vm_endspace ],
+ [ vm_prompt, "Replace a Unit with a Raja." ],
+ [ vm_clean_p ],
+ [ vm_piece, false, 0, 1, (p,s)=>(can_place_piece(0, VE, ELITE) && set_has(game.vm.m, piece_space(p)) && is_enemy_unit(p)) ],
+ [ vm_set_piece_space ],
+ [ vm_remove ],
+ [ vm_auto_place, false, 0, false, ()=>(game.current), ELITE ],
+ [ vm_set_space, -1 ],
+ [ vm_endpiece ],
[ vm_return ],
]
// SHADED 24
CODE[24 * 2 + 1] = [
- [ vm_log, "NOT IMPLEMENTED" ],
+ [ vm_current, [DS, BK] ],
+ [ vm_prompt, "Place up to 2 Units in each Province with a Temple." ],
+ [ vm_space, true, 0, 999, (s)=>has_temple(s) ],
+ [ vm_place, false, 1, 2, ()=>(game.current), UNITS ],
+ [ vm_endspace ],
[ vm_return ],
]