Fix trainer mobile map and entrance hazard limits

This commit is contained in:
nyan404 committed 2026-11-22 17:34:19 +03:00
1 parent eb04ce3e48
commit ba25b64190
10 files changed
+208 -39

No files matched your search

+14 -2
View File
@@ -52,7 +52,19 @@ export function generateField(input = DEFAULTS, random = Math.random) {
[candidates[i], candidates[j]] = [candidates[j], candidates[i]];
}
const count = Math.min(Math.max(5, options.growth + options.season + 2 * (options.height - 1)), candidates.length);
const hazards = new Set(candidates.slice(0, count));
// The safe entrance and x2 y1 already cap x1 y1 at 2 and x1 y2 at 3.
// Cap x1 y3 at 4 during placement, skipping only a fifth hazard in its neighborhood.
const leftThirdNeighbors = neighbors(2 * COLS);
const hazards = new Set();
let leftThirdHazards = 0;
for (const id of candidates) {
if (hazards.size === count) break;
if (leftThirdNeighbors.includes(id)) {
if (leftThirdHazards === 4) continue;
leftThirdHazards++;
}
hazards.add(id);
}
const values = Array.from({length: ROWS * COLS}, (_,id)=>neighbors(id).filter(n => hazards.has(n)).length);
return { start: START, exit, base, reserved, hazards, values };
}
@@ -143,7 +155,7 @@ export class Training {
id, entrance: id === START, exit: id === this.#field.exit, transition: this.#transition(id), base: this.#field.base.includes(id),
opened: this.#opened.has(id), marked: this.#marks.has(id), rating: this.#ratings.get(id) ?? null,
available: !ended && this.#available(id),
value: this.#opened.has(id) || ended ? this.#field.values[id] : null,
value: id === START || this.#opened.has(id) || ended ? this.#field.values[id] : null,
...(ended ? {hazard: this.#field.hazards.has(id), wrong: this.#marks.has(id) && !this.#field.hazards.has(id)} : {}),
})),
};