diff options
author | Joël Simoneau <simoneaujoel@gmail.com> | 2025-01-22 15:41:31 -0500 |
---|---|---|
committer | Joël Simoneau <simoneaujoel@gmail.com> | 2025-01-22 15:41:31 -0500 |
commit | a18976056bcceddf253263238ff6cef7ca6f9530 (patch) | |
tree | 18ca7812f2eae955126cdc503718ee7b40119ecc | |
parent | d175614dee7eeb82060e2cfd5d32efa8a6a9182b (diff) | |
download | vijayanagara-a18976056bcceddf253263238ff6cef7ca6f9530.tar.gz |
Event auto_place_rebel
-rw-r--r-- | events.txt | 2 | ||||
-rw-r--r-- | rules.js | 19 | ||||
-rw-r--r-- | tools/gencode.js | 5 |
3 files changed, 16 insertions, 10 deletions
@@ -44,7 +44,7 @@ EVENT 5 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 + auto_place_rebel (game.current) ELITE set_space -1 endpiece prompt `Place a ${PIECE_FACTION_TYPE_NAME[game.current][DISC]} in Rajput Kingdoms.` @@ -3196,11 +3196,13 @@ function object_group_by(items, callback) { // === ITERATORS AND ACTION GENERATORS === -function auto_place_piece(s, faction, type) { +function auto_place_piece(s, faction, type, is_rebel) { if (can_place_piece(s, faction, type)) { let p = find_piece(AVAILABLE, faction, type) if (p >= 0) { place_piece(p, s) + if (is_rebel) + to_rebel(p) return true } } @@ -3635,9 +3637,10 @@ states.vm_piece = { // VM: PLACE PIECE function vm_auto_place() { - let faction = vm_operand(3) - let type = vm_operand(4) - if (auto_place_piece(game.vm.s, faction, type)) { + let is_rebel = vm_operand(3) + let faction = vm_operand(4) + let type = vm_operand(5) + if (auto_place_piece(game.vm.s, faction, type, is_rebel)) { log("Placed " + PIECE_FACTION_TYPE_NAME[faction][type] + " in S" + game.vm.s + ".") vm_next() } else { @@ -3900,12 +3903,12 @@ CODE[5 * 2 + 0] = [ [ 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_auto_place, false, 0, true, ()=>(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_auto_place, false, 0, false, ()=>(game.current), DISC ], [ vm_endspace ], [ vm_return ], ] @@ -3917,12 +3920,12 @@ CODE[5 * 2 + 1] = [ [ 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_auto_place, false, 0, false, 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_auto_place, false, 0, false, DS, DISC ], [ vm_endspace ], [ vm_return ], ] diff --git a/tools/gencode.js b/tools/gencode.js index d155140..946464f 100644 --- a/tools/gencode.js +++ b/tools/gencode.js @@ -112,7 +112,10 @@ for (let line of fs.readFileSync("events.txt", "utf-8").split("\n")) { emit([ "place", false, 1, line[1], line[2] ]) break case "auto_place": - emit([ "auto_place", false, 0, line[1], line[2] ]) + emit([ "auto_place", false, 0, false, line[1], line[2] ]) + break + case "auto_place_rebel": + emit([ "auto_place", false, 0, true, line[1], line[2] ]) break case "log": |