feedback7: the battle sim uses engine-independent math — Chrome, Firefox, Safari and the server agree bit for bit (PR #373 by @Cloudnyco)
- server/sim/detmath.js: hypot (sqrt of the squares, rescaled outside 2^±500), powi (integer powers in double-double, one rounding), sin / cos (fdlibm 5.3) and atan2 (fdlibm / FreeBSD msun) built only from correctly rounded IEEE operations; the sim's Math.hypot / sin / cos / atan2 / pow calls go through it (65 files); eslint.config.js forbids the approximated Math functions under server/sim and test/sim/detmath.test.js scans for them. - sin / cos / atan2 are the algorithms V8 runs in Node, so the server's results stay; only hypot differs from V8's. Golden: 2 moved — diy-027 (a hypot distance, damage +80) and coop3-ABYSS-5 (a later card pick from round 9, same end). - Applied unchanged after review (Grok static review: MERGE; the diff read in full: no network, no new dependency). - Tests: broad node --test 5155 / 5155 with the new file tracked (detmath 7 / 7, package 10 / 10); lint 0 errors, typecheck, check:imports.
This commit is contained in:
1 parent
2580152a3a
commit
ae22335cfe
65 files changed
+616
-141
No files matched your search
@@ -57,6 +57,7 @@ import { canTargetEnemy } from '../../../targeting.js';
|
||||
import { bodyInRadius } from '../../../body.js';
|
||||
import { hasHp } from '../../../damage.js';
|
||||
import { COLS } from '../../../constants.js';
|
||||
import { sin, cos, atan2 } from '../../../detmath.js';
|
||||
|
||||
const S1 = 'skchr_hsgma2_1';
|
||||
const S2 = 'skchr_hsgma2_2';
|
||||
@@ -98,7 +99,7 @@ export default {
|
||||
/** S2: the shield's centre after `turned` degrees (row 0 is the bottom row: counter-clockwise = a growing angle). */
|
||||
const shieldAt = (unit, sh) => {
|
||||
const a = sh.a0 + (sh.turned * Math.PI) / 180;
|
||||
return { x: unit.x + SHIELD_START * Math.cos(a), y: unit.y + SHIELD_START * Math.sin(a) };
|
||||
return { x: unit.x + SHIELD_START * cos(a), y: unit.y + SHIELD_START * sin(a) };
|
||||
};
|
||||
const touching = (battle, unit, p) => battle.enemies.filter((e) => canTargetEnemy(unit, e, GROUND) && bodyInRadius(e, p.x, p.y, SHIELD_RADIUS));
|
||||
/** S2: one shield pulse — 停顿, the arts hit, and her heal of heal_ratio × the HP it removed (ignoring her 禁疗). */
|
||||
@@ -128,7 +129,7 @@ export default {
|
||||
if (!('hits' in s2Attack)) return;
|
||||
plainS2(); // the throw was this attack: the shield flies from now on
|
||||
const [fr, fc] = unit.fwd;
|
||||
unit.mem.hsShield = { a0: Math.atan2(fr, fc), turned: 0, acc: 0 };
|
||||
unit.mem.hsShield = { a0: atan2(fr, fc), turned: 0, acc: 0 };
|
||||
battle.fx('zone', { x: unit.x, y: unit.y, radius: SHIELD_START + SHIELD_RADIUS, dur: SHIELD_TURN / SHIELD_SPEED, id: unit.id, skill: 'hsgma2:shield' });
|
||||
shieldPulse(battle, unit, shieldAt(unit, unit.mem.hsShield));
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user