summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoël Simoneau <simoneaujoel@gmail.com>2025-03-20 13:55:24 -0400
committerJoël Simoneau <simoneaujoel@gmail.com>2025-03-20 13:55:24 -0400
commit363832b218dc87c1ef1dadf1c1b5c1dbf5bd239d (patch)
tree954ee35c6c909f05d8560ec43c6b5e52f19d2d55
parent1b8fa58e831c7db6e5f9d46ce3548d7ffe03bcf5 (diff)
downloadvijayanagara-363832b218dc87c1ef1dadf1c1b5c1dbf5bd239d.tar.gz
Better support in attacks
-rw-r--r--rules.js27
1 files changed, 21 insertions, 6 deletions
diff --git a/rules.js b/rules.js
index 70aba8d..7cc6955 100644
--- a/rules.js
+++ b/rules.js
@@ -1272,6 +1272,8 @@ states.attack_adjacent_support = {
set_add(game.cmd.pieces, p)
game.cmd.n_adj -= 1
game.cmd.n_units[0] += 1
+ if (game.cmd.target === DS)
+ to_rebel(p)
},
next() {
game.state = "attack_space"
@@ -1279,6 +1281,7 @@ states.attack_adjacent_support = {
}
states.attack_space = {
+ inactive: "Attack",
prompt() {
view.prompt = "Attack: Roll the die to attack."
view.who = game.cmd.selected
@@ -1307,8 +1310,8 @@ function next_attack_cavalry_step() {
game.cmd.d_hit = game.dice.slice(4).filter(d => d > 0 && d <= game.cmd.n_units[1] && d < 6).length
game.cmd.victor = get_attack_victor()
log_br()
- log(`${faction_name[game.cmd.attacker]} scores ${game.cmd.a_hit} hits.`)
- log(`${faction_name[game.cmd.target]} scores ${game.cmd.d_hit} hits.`)
+ log(`${faction_acronyms[game.cmd.attacker]} scores ${game.cmd.a_hit} hits.`)
+ log(`${faction_acronyms[game.cmd.target]} scores ${game.cmd.d_hit} hits.`)
goto_attack_casualties()
}
}
@@ -1350,7 +1353,7 @@ states.attack_cavalry = {
view.prompt = "Attack: Use cavalry to Charge your dice or Screen your opponent's dice."
if (has_cavalry(game.current))
for (let d of curr_die)
- if (game.dice[d] > 1 && (game.current === game.cmd.attacker || game.dice[d] < 6))
+ if (can_use_cavalry_on_d(d))
gen_action_die(d)
view.actions.next = 1
@@ -1370,6 +1373,16 @@ states.attack_cavalry = {
}
}
+function can_use_cavalry_on_d(d) {
+ if (game.dice[d] < 1)
+ return false
+
+ if (game.current === game.cmd.target && game.dice[d] === 6 && d < 4)
+ return false
+
+ return true
+}
+
function get_attack_victor() {
if (game.cmd.a_hit > game.cmd.d_hit)
return game.cmd.attacker
@@ -1440,6 +1453,7 @@ states.attack_casualties = {
}
function end_attack_casualties() {
+ clear_undo()
if (game.cmd.step === 2) {
game.cmd.step += 1
goto_attack_casualties()
@@ -2147,6 +2161,7 @@ states.campaign_moves = {
},
space(s) {
+ push_undo()
log_space(s, "Campaign")
push_summary()
@@ -2886,7 +2901,7 @@ function has_unmoved_piece(space, faction) {
function has_valid_attackers(s, faction) {
let valid_attacker = false
for_each_movable(faction, p => {
- if (piece_space(p) === s)
+ if (piece_space(p) === s && !set_has(game.cmd.pieces, p))
valid_attacker = true
if (piece_space(p) === s || (has_piece(piece_space(p), faction, DISC) && SPACES[s].adjacent.includes(piece_space(p))))
if (!game.cmd.pieces || game.cmd.pieces.length === 0)
@@ -3173,7 +3188,7 @@ function add_influence(faction) {
return
game.inf[faction]++
- log(faction_name[faction] + " gains Influence.")
+ log(faction_acronyms[faction] + " gains Influence.")
update_vp()
if (faction === BK && game.inf[faction] === 2)
@@ -3189,7 +3204,7 @@ function remove_influence(faction) {
end_influence()
} else {
game.inf[faction]--
- log(faction_name[faction] + " loses Influence.")
+ log(faction_acronyms[faction] + " loses Influence.")
update_vp()
if (faction === BK && game.inf[faction] === 3)