summaryrefslogtreecommitdiff
path: root/rules.js
diff options
context:
space:
mode:
Diffstat (limited to 'rules.js')
-rw-r--r--rules.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/rules.js b/rules.js
index c92b2ba..bca5b72 100644
--- a/rules.js
+++ b/rules.js
@@ -22,7 +22,38 @@ function find_card(s, n) {
// for (let c of data.cards) for (let a of c.actions) console.log(a.type, a.effect)
// for (let c of data.cards) console.log(c.dice)
-for (let c of data.cards) for (let a of c.actions) { if (a.type === "Counterattack") console.log(c.number, a.type, a.sequence, a.target) }
+//for (let c of data.cards) for (let a of c.actions) { if (a.type === "Counterattack") console.log(c.number, a.type, a.sequence, a.target) }
+
+function check_attack_res(c, a) {
+ if (a.choice)
+ return
+ if (c.rules && c.rules["attack_reserve"])
+ return
+ if (c.rules && c.rules["ignore_reserve"])
+ return
+ let pc = null
+ let dead = []
+ let last = a.target_list[a.target_list.length-1]
+ for (let tid of a.target_list) {
+ let t = data.cards[tid]
+ if (!t.reserve) {
+ // all good, targetable out of reserve
+ dead.push(tid)
+ } else if (Array.isArray(t.reserve)) {
+ // in reserve
+ for (let rid of t.reserve)
+ if (!dead.includes(rid) && tid !== last)
+ console.log("BLOCK (RES)", c.scenario, c.number, a.target, "(" + t.name + ")", "\n\t" + c.rule_text_1)
+ dead.push(tid)
+ } else {
+ // commanded?
+ if (tid !== last)
+ console.log("BLOCK (CMD)", c.scenario, c.number, a.target, "(" + t.name + ")", "\n\t" + c.rule_text_1)
+ }
+ }
+}
+
+for (let c of data.cards) for (let a of c.actions) { if (a.type === "Attack") check_attack_res(c, a) }
const P1 = "First"
const P2 = "Second"