From 5145d0a79551acad5197bfd63581c5218665b46e Mon Sep 17 00:00:00 2001 From: Joël Simoneau Date: Sun, 9 Mar 2025 18:36:48 -0400 Subject: Event 30 --- events.txt | 11 +++++++++-- rules.js | 54 ++++++++++++++++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 20 deletions(-) diff --git a/events.txt b/events.txt index b5f62c0..6594ce5 100644 --- a/events.txt +++ b/events.txt @@ -616,10 +616,17 @@ SHADED 29 endspace EVENT 30 - log "NOT IMPLEMENTED" + current BK + prompt "Free Attack in each Province with a fort, without defenders." + space_opt 5 (has_fort(s) && can_attack_in_space(s)) + free_attack + endspace SHADED 30 - log "NOT IMPLEMENTED" + prompt "Free limited Attak, without defenders." + space 1 (can_attack_in_space(s)) + free_attack + endspace EVENT 31 current REBEL_FACTIONS diff --git a/rules.js b/rules.js index edfddfc..869fd36 100644 --- a/rules.js +++ b/rules.js @@ -965,7 +965,6 @@ function goto_attack() { } function goto_attack_select() { - game.cmd.selected = [] game.cmd.target = [0, 0, 0, 0] if (game.current === DS) { game.cmd.target[BK] += can_attack_rebel_in_space(game.cmd.where, BK) @@ -995,11 +994,14 @@ function roll_attack() { if (game.cmd.target === DS && game.cmd.attacker === MI && game.cmd.where === S_DELHI) game.dice[3] = 0 - if (game.cmd.target === BK && has_piece(game.cmd.where, BK, DISC)) + let is_shaded_28 = (game.vm && game.vm.fp === 57) + let is_event_30 = (game.vm && game.vm.fp === 60) + let is_shaded_30 = (game.vm && game.vm.fp === 61) + + if (game.cmd.target === BK && has_piece(game.cmd.where, BK, DISC) && !is_shaded_30) game.dice[3] = 0 - let is_shaded_28 = (game.vm && game.vm.fp === 57) - if (is_shaded_28) { + if (is_shaded_28 || is_event_30 || is_shaded_30) { game.dice[4] = 0 game.dice[5] = 0 } @@ -1336,11 +1338,15 @@ function goto_attack_resolution() { game.dice = [0, 0, 0, 0, 0, 0] if (is_rebel_faction(game.cmd.target) && is_rebel_faction(game.cmd.attacker)) attack_influence_shift() + if (game.cmd.attacker === MI) { game.current = game.cmd.sa_faction game.state = "plunder" - } else + } else if (game.vm) { + vm_next() + } else { game.state = "attack" + } } function attack_influence_shift() { @@ -2721,7 +2727,7 @@ function has_valid_attackers(s, faction) { function can_support_from(s, faction) { let valid_attacker = false for_each_movable(faction, p => { - if (piece_space(p) === s && has_piece(s, faction, DISC)) + if (piece_space(p) === s && has_piece(s, faction, DISC) && s !== game.cmd.where && !set_has(game.cmd.pieces, p)) valid_attacker = true }) return valid_attacker @@ -2825,13 +2831,9 @@ function has_governor(s) { return has_piece(s, DS, ELITE) } -function has_qasbah(s) { - return has_piece(s, DS, DISC) -} - -function has_temple(s) { - return has_piece(s, VE, DISC) -} +function has_fort(s) { return has_piece(s, BK, DISC) } +function has_qasbah(s) { return has_piece(s, DS, DISC) } +function has_temple(s) { return has_piece(s, VE, DISC) } function has_ds_unit(s) { return has_piece(s, DS, ELITE) || has_piece(s, DS, TROOPS) @@ -4442,15 +4444,24 @@ function vm_remove_tributary() { // VM: ATTACK function vm_free_attack() { - if (!can_attack_in_space(game.vm.s)) + if (!can_attack_in_space(game.vm.s) && !(game.cmd && game.cmd.pieces)) vm_next() else { - init_free_command("Attack", game.vm.s) + log_space(game.vm.s, "Attack") + let pieces = (game.cmd && game.cmd.pieces) ? game.cmd.pieces : [] + game.cmd = { + type: "Attack", + limited: 1, + free: 1, + spaces: [], + selected: [], + pieces: pieces, + where: game.vm.s, + } game.cmd.attacker = game.current game.cmd.support_space = null if (typeof vm_inst(1) !== "undefined") { - game.cmd.selected = [] game.cmd.target = vm_inst(1) goto_attack_space() } else { @@ -5503,13 +5514,20 @@ CODE[29 * 2 + 1] = [ // EVENT 30 CODE[30 * 2 + 0] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_current, BK ], + [ vm_prompt, "Free Attack in each Province with a fort, without defenders." ], + [ vm_space, true, 0, 5, (s)=>(has_fort(s) && can_attack_in_space(s)) ], + [ vm_free_attack ], + [ vm_endspace ], [ vm_return ], ] // SHADED 30 CODE[30 * 2 + 1] = [ - [ vm_log, "NOT IMPLEMENTED" ], + [ vm_prompt, "Free limited Attak, without defenders." ], + [ vm_space, true, 1, 1, (s)=>(can_attack_in_space(s)) ], + [ vm_free_attack ], + [ vm_endspace ], [ vm_return ], ] -- cgit v1.2.3