Move the test-only toolDig helper into the test harness (t84)
Written by the local model (qwen3-coder-30b) in a sandboxed worktree via local-run; reviewed by Claude. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,38 +28,3 @@ function forBrush(cx, cy, r, fn) {
|
||||
// how far the drill reaches: set by the bit, and stretched or shortened by the pulse width
|
||||
function drillReach(w = drillWidth) { return Math.round(BIT_TIERS[player.bitTier].reach * (PULSE_W[w] || PULSE_W[1]).reach); }
|
||||
function inDrillReach(x, y, w) { const dx = x - (bot.x + bot.w / 2), dy = y - (bot.y + bot.h / 2), R2 = drillReach(w); return dx * dx + dy * dy <= R2 * R2; }
|
||||
// Plain digging in a circle. The game itself uses the resonance drill (drill.js); the tests use
|
||||
// this to clear rock quickly.
|
||||
function toolDig(cx, cy, r) {
|
||||
const tier = BIT_TIERS[player.bitTier];
|
||||
let dug = 0, tooHard = 0, far = 0;
|
||||
forBrush(cx, cy, r, (x, y, i) => {
|
||||
if (!inDrillReach(x, y)) { far++; return; }
|
||||
const m = mat[i];
|
||||
if (bgm[i] && (m === EMPTY || PH[m] === PH_GAS || PH[m] === PH_LIQUID)) { if (cutTree(i, x, y, tier)) dug++; return; }
|
||||
if (PH[m] !== PH_SOLID) return;
|
||||
if (PARTMAT[m] || part[i] || mach[i]) return;
|
||||
const h = HARD[m];
|
||||
if (h > tier.hard) { tooHard = m; return; }
|
||||
const p = digp[i] + tier.speed * 60 / (1 + h * h * 0.6);
|
||||
if (p >= 255) {
|
||||
const to = YLD[m];
|
||||
const b = blockP[((y / BS) | 0) * BW + ((x / BS) | 0)];
|
||||
setCell(i, to, temp[i], 0);
|
||||
discover(to, x, y, m, 'dig');
|
||||
if (isWall(b) && !blockIntegrity(((y / BS) | 0) * BW + ((x / BS) | 0))) removeBlock((x / BS) | 0, (y / BS) | 0);
|
||||
dug++;
|
||||
if ((dug & 3) === 0) emit({ t: 'debris', x, y, m });
|
||||
} else { digp[i] = p; renderDirtyIdx(i); }
|
||||
});
|
||||
stats.dug += dug;
|
||||
let status = '';
|
||||
void 0;
|
||||
if (far && !dug && !tooHard) status = `Out of reach; your bit reaches ${drillReach()} grains.`;
|
||||
if (tooHard && !dug) {
|
||||
const need = BIT_TIERS.find(b => b.hard >= HARD[tooHard]);
|
||||
const nb = need ? need.name.toLowerCase() : 'better bit';
|
||||
status = HARD[tooHard] > 6 ? `${MD[tooHard].name} cannot be drilled.` : `${MD[tooHard].name} is too hard; needs ${/^[aeiou]/.test(nb) ? 'an' : 'a'} ${nb}.`;
|
||||
}
|
||||
return { dug, status, tooHard };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user