summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js54
1 files changed, 36 insertions, 18 deletions
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 ],
]