mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-02 08:28:12 +00:00
fa7b7fceb3
## Description: ### ✅ Summary of Changes This PR enables the ESLint rule **`@typescript-eslint/no-unused-vars`** as requested in the issue and applies the necessary code adjustments across the project. #### 🔧 What was done: - Activated the rule `@typescript-eslint/no-unused-vars` in the ESLint config. - Updated ~70 files to comply with the rule: - Replaced unused variables with a `_` prefix where appropriate. - Added inline ESLint disable comments (`eslint-disable-next-line`) for specific cases where the variable or code block seemed important for context, readability, or future use. - Ensured no linting errors remain related to this rule. --- ### ❓ Clarification Some cases were handled with inline disable comments instead of removing the variable entirely, to avoid accidental breaking changes or loss of intent. If a different approach is preferred (e.g., stricter removal or alternative handling), I’m happy to adjust the implementation accordingly — just let me know! --- ### 🙌 Next Steps Please review and let me know if: - Any file should be handled differently. - You prefer removal instead of disabling in certain areas. - Additional rules should be enforced or reverted. I’m available to make any follow-up improvements needed. --- ### 🎃 Hacktoberfest Note I'm participating in **Hacktoberfest**, so if this PR is accepted, please add the label: `hacktoberfest-accepted` Thank you! #1784 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: DISCORD_USERNAME
66 lines
1.4 KiB
TypeScript
66 lines
1.4 KiB
TypeScript
export enum SearchMapTileType {
|
|
Land,
|
|
Shore,
|
|
Water,
|
|
}
|
|
|
|
export class TerrainSearchMap {
|
|
private width: number;
|
|
private height: number;
|
|
private mapData: Uint8Array;
|
|
|
|
constructor(buffer: SharedArrayBuffer) {
|
|
this.mapData = new Uint8Array(buffer);
|
|
this.width = (this.mapData[1] << 8) | this.mapData[0];
|
|
this.height = (this.mapData[3] << 8) | this.mapData[2];
|
|
}
|
|
|
|
node(x: number, y: number): SearchMapTileType {
|
|
const packedByte = this.mapData[4 + y * this.width + x];
|
|
const isLand = packedByte & 0b10000000;
|
|
const magnitude = packedByte & 0b00011111;
|
|
if (isLand) {
|
|
return SearchMapTileType.Land;
|
|
}
|
|
if (magnitude < 10) {
|
|
return SearchMapTileType.Shore;
|
|
}
|
|
return SearchMapTileType.Water;
|
|
}
|
|
|
|
neighbors(x: number, y: number): Array<{ x: number; y: number }> {
|
|
const result: Array<{ x: number; y: number }> = [];
|
|
|
|
// Check all 8 adjacent tiles
|
|
const dirs = [
|
|
[-1, -1],
|
|
[0, -1],
|
|
[1, -1],
|
|
[-1, 0],
|
|
[1, 0],
|
|
[-1, 1],
|
|
[0, 1],
|
|
[1, 1],
|
|
];
|
|
|
|
for (const [dx, dy] of dirs) {
|
|
const newX = x + dx;
|
|
const newY = y + dy;
|
|
|
|
// Check bounds
|
|
if (newX >= 0 && newX < this.width && newY >= 0 && newY < this.height) {
|
|
result.push({ x: newX, y: newY });
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
getWidth(): number {
|
|
return this.width;
|
|
}
|
|
|
|
getHeight(): number {
|
|
return this.height;
|
|
}
|
|
}
|