summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-16 19:39:52 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:48 +0100
commitda8e47dee845d1c513fec3f21a0015c48ea1632e (patch)
tree1ab34aad46ff17947badcae1ce45181271f29edc
parent24fe632fe7c3a95b32ac9c75f2c7322f21de4a62 (diff)
downloadtable-battles-da8e47dee845d1c513fec3f21a0015c48ea1632e.tar.gz
WIP CHECK ATTACKS
-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"