hrbattle 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/battle/targeting.js +21 -0
- package/package.json +1 -1
package/dist/battle/targeting.js
CHANGED
|
@@ -34,5 +34,26 @@ export function selectTargets(rule, caster, allUnits, rng) {
|
|
|
34
34
|
const anchor = enemies[0];
|
|
35
35
|
return enemies.filter((u) => Math.abs(u.position - anchor.position) <= 1);
|
|
36
36
|
}
|
|
37
|
+
if (rule === "lastRowEnemy") {
|
|
38
|
+
if (enemies.length === 0) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const maxPos = Math.max(...enemies.map((u) => u.position));
|
|
42
|
+
return enemies.filter((u) => u.position === maxPos);
|
|
43
|
+
}
|
|
44
|
+
if (rule === "firstAndLastEnemy") {
|
|
45
|
+
if (enemies.length === 0) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const minPos = Math.min(...enemies.map((u) => u.position));
|
|
49
|
+
const maxPos = Math.max(...enemies.map((u) => u.position));
|
|
50
|
+
if (minPos === maxPos) {
|
|
51
|
+
return enemies.filter((u) => u.position === minPos);
|
|
52
|
+
}
|
|
53
|
+
return enemies.filter((u) => u.position === minPos || u.position === maxPos);
|
|
54
|
+
}
|
|
55
|
+
if (rule === "selfWithAdjacent") {
|
|
56
|
+
return allies.filter((u) => Math.abs(u.position - caster.position) <= 1);
|
|
57
|
+
}
|
|
37
58
|
return enemies.length > 0 ? [enemies[0]] : [];
|
|
38
59
|
}
|