Hit tiles: positions round half to even (PRTS 作战机制); enemies held just inside the field edge

This commit is contained in:
Cloudnyco committed 2026-10-11 21:33:44 +08:00
1 parent bc50cac01f
commit 119a04888a
13 files changed
+113 -24

No files matched your search

+11
View File
@@ -46,6 +46,17 @@ export function hypot(x, y) {
return Math.sqrt(x * x + y * y);
}
/**
* x rounded to an integer, ties to even (2.5 → 2, 3.5 → 4, −2.5 → −2): the rule PRTS 作战机制 gives for the tile of a
* target — 受击方坐标经round函数取整(四舍六入五成双)得到其所属格坐标. Math.round rounds ties up (2.5 → 3). Exact; never −0.
* @param {number} x
*/
export function roundHalfEven(x) {
const f = Math.floor(x);
if (x - f !== 0.5) return Math.round(x) + 0;
return (f % 2 === 0 ? f : f + 1) + 0;
}
// ---- integer powers ----------------------------------------------------------------------------------------------
const SPLIT = 134217729; // 2^27 + 1 (Dekker)