summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js39
1 files changed, 28 insertions, 11 deletions
diff --git a/rules.js b/rules.js
index ce16773..1905b3d 100644
--- a/rules.js
+++ b/rules.js
@@ -127,6 +127,14 @@ exports.view = function (state, role) {
dice: game.dice,
}
+ if (game.cmd && game.cmd.attacker) {
+ view.attack = {
+ where: game.cmd.where,
+ attacker: game.cmd.attacker,
+ target: game.cmd.target
+ }
+ }
+
if (game.result) {
view.prompt = game.victory
} else if (!is_current_role(role)) {
@@ -1036,7 +1044,7 @@ function attack_use_cavalry(d) {
} else if (is_a_die && !is_attacker) {
screen_die(d)
} else if (!is_a_die && !is_attacker) {
- charge_die[d]
+ charge_die(d)
}
}
@@ -1214,7 +1222,7 @@ function goto_attack_cavalry() {
states.attack_cavalry = {
prompt() {
- view.prompt = "Attack: Use cavalry to..."
+ view.prompt = "Attack: Use cavalry to Charge your dice or Screen your opponent's dice."
view.who = game.cmd.selected
let curr_die = [0, 1, 2, 3, 4, 5]
@@ -1232,7 +1240,6 @@ states.attack_cavalry = {
log(`${faction_acronyms[game.current]} is using Cavalry.`)
game.cmd.cavalry = true
}
-
attack_use_cavalry(d)
},
next() {
@@ -1251,25 +1258,30 @@ function get_attack_victor() {
}
function goto_attack_casualties(step) {
+ let next_state
if (step === "target") {
game.current = game.cmd.target
game.cmd.count = game.cmd.a_hit
- game.state = "attack_casualties"
+ next_state = "attack_casualties"
} else if (step === "attacker") {
game.current = game.cmd.attacker
game.cmd.count = game.cmd.d_hit
- game.state = "attack_casualties"
+ next_state = "attack_casualties"
}
+
+ if (game.cmd.count > 0)
+ game.state = next_state
+ else
+ end_attack_casualties()
}
states.attack_casualties = {
prompt() {
-
if (
game.cmd.count > 0 &&
game.cmd.selected.filter(p => piece_faction(p) === game.current).length > 0
) {
- view.prompt = `Attack: ${faction_acronyms[game.current]} must remove ${game.cmd.count} pieces as casualties.`
+ view.prompt = `Attack: Must remove ${game.cmd.count} pieces as casualties.`
for (let p of game.cmd.selected)
if (piece_faction(p) === game.current)
@@ -1286,16 +1298,21 @@ states.attack_casualties = {
game.cmd.count -= 1
},
next() {
- if (game.current === game.cmd.target)
- goto_attack_casualties("attacker")
- else
- goto_attack_resolution()
+ end_attack_casualties()
}
}
+function end_attack_casualties() {
+ if (game.current === game.cmd.target)
+ goto_attack_casualties("attacker")
+ else
+ goto_attack_resolution()
+}
+
function goto_attack_resolution() {
if (is_rebel_faction(game.cmd.target) && is_rebel_faction(game.cmd.attacker))
console.log("Implement shift")
+ game.dice = [0, 0, 0, 0, 0, 0]
game.state = "attack"
}