summaryrefslogtreecommitdiff
path: root/rules.ts
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-05-01 14:06:10 +0200
committerTor Andersson <tor@ccxvii.net>2024-05-01 17:28:58 +0200
commit687e35cda69c6db8454ad4860cdc9e1df7b39d75 (patch)
tree8c7bb7eae75eb6af28c605e1357acf42731d7982 /rules.ts
parent39354efa24e130116930e168850c018f7ed9650a (diff)
downloadplantagenet-687e35cda69c6db8454ad4860cdc9e1df7b39d75.tar.gz
calculate engagements with ravine
Diffstat (limited to 'rules.ts')
-rw-r--r--rules.ts32
1 files changed, 31 insertions, 1 deletions
diff --git a/rules.ts b/rules.ts
index 7bce062..23297fc 100644
--- a/rules.ts
+++ b/rules.ts
@@ -5601,6 +5601,11 @@ states.exile_spoils = {
*/
+// See tools/engage.js for generating this table
+const ENGAGEMENTS = [null,null,null,null,null,null,null,null,null,[[2,5]],[[2,4]],[[2,4,5]],[[2,3]],[[2,3,5]],[[2,3,4]],[[2,3,4,5]],null,[[5,1]],[[1,4]],[[1,4,5]],[[3,1]],[[3,1,5]],[[1,3,4]],[[1,3,4,5]],null,[[1,2,5]],[[1,2,4]],[[1,4],[2,5]],[[1,2,3]],[[2,5],[3,1]],[[1,2,3,4]],[[1,3,4],[2,5]],null,[[0,5]],[[0,4]],[[0,4,5]],[[0,3]],[[0,3,5]],[[0,3,4]],[[0,3,4,5]],null,[[0,2,5]],[[0,2,4]],[[2,5],[0,4]],[[0,2,3]],[[0,3],[2,5]],[[0,3],[2,4]],null,null,[[0,1,5]],[[0,1,4]],[[0,1,4,5]],[[0,1,3]],[[0,3],[5,1]],[[0,3],[1,4]],[[0,3],[1,4,5]],null,[[0,1,2,5]],[[0,1,2,4]],[[0,1,4],[2,5]],[[0,1,2,3]],null,[[0,3],[1,2,4]],[[0,3],[1,4],[2,5]]]
+const ENGAGEMENTS_47 = [[[0,3],[2,4,5]],[[0,3],[2,4,5]]]
+const ENGAGEMENTS_61 = [[[0,3],[1,2,5]],[[0,3],[1,2,5]]]
+
const battle_strike_positions = [ D1, D2, D3, A1, A2, A3 ]
const battle_steps = [
@@ -7001,7 +7006,9 @@ states.reposition_center = {
// === 4.4.2 BATTLE ROUNDS: ENGAGE / STRIKE ===
-function determine_engagements() {
+function determine_engagements_BAD() {
+ // does not handle Ravine
+
let center = [ A2, D2 ]
let engagements = [
[ A1, D1 ],
@@ -7020,9 +7027,32 @@ function determine_engagements() {
}
}
results.unshift(center)
+
+ console.log("ENG", results)
+
return results
}
+function pack_battle_array() {
+ let bits = 0
+ for (let p = 0; p < 6; ++p)
+ if (filled(p))
+ bits |= (1 << p)
+ return bits
+}
+
+function determine_engagements() {
+ let bits = pack_battle_array()
+ if (bits === 47)
+ throw "BIT47" // return ENGAGEMENTS_47[0].slice()
+ else if (bits === 61)
+ throw "BIT61" // return ENGAGEMENTS_61[0].slice()
+ else if (ENGAGEMENTS[bits])
+ return ENGAGEMENTS[bits].slice()
+ else
+ return []
+}
+
function goto_determine_engagements() {
game.battle.step = 0
game.battle.engagements = determine_engagements()