Skip to content

Commit

Permalink
chore: apply biome unsafe checks
Browse files Browse the repository at this point in the history
  • Loading branch information
kacperwyczawski committed Aug 18, 2024
1 parent 5c37ded commit 9f2fa50
Show file tree
Hide file tree
Showing 19 changed files with 469 additions and 406 deletions.
71 changes: 35 additions & 36 deletions src/game/board.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
import { Pawn } from "../pieces/pawn";
import { Cell } from "./cell";
import { Player } from "./player";
import { Point } from "./point";
const maps: Record<string, { default: string }> = import.meta.glob("../maps/*.txt", {
query: "?raw",
eager: true,
})
import type { Cell } from "./cell";
import type { Player } from "./player";
import type { Point } from "./point";
const maps: Record<string, { default: string }> = import.meta.glob(
"../maps/*.txt",
{
query: "?raw",
eager: true,
},
);

export default class Board {
#cells: Cell[][] = []
#cells: Cell[][] = [];

get rows() {
return this.#cells
}
get rows() {
return this.#cells;
}

get allCells() {
return this.#cells.flat()
}
get allCells() {
return this.#cells.flat();
}

get size() {
return this.#cells.length
}
get size() {
return this.#cells.length;
}

constructor(
mapName: string,
players: Player[]
) {
const map = maps[`../maps/${mapName}.txt`].default
.split("\n");
map.pop()
constructor(mapName: string, players: Player[]) {
const map = maps[`../maps/${mapName}.txt`].default.split("\n");
map.pop();
map.forEach((row, y) => {
this.#cells[y] = [];
row.split("").forEach((symbol, x) => {
const cell: Cell = {
owner: null,
building: null,
piece: null,
point: {x, y}
}
owner: null,
building: null,
piece: null,
point: { x, y },
};
if (symbol === ".") {
} else if (symbol === "1") {
cell.piece = new Pawn("white")
cell.building = "castle"
cell.owner = players[0]
cell.piece = new Pawn("white");
cell.building = "castle";
cell.owner = players[0];
} else if (symbol === "2") {
cell.piece = new Pawn("black")
cell.building = "castle"
cell.owner = players[1]
cell.piece = new Pawn("black");
cell.building = "castle";
cell.owner = players[1];
} else if (symbol === "w") {
cell.building = "wall";
} else if (symbol === "c") {
Expand All @@ -60,6 +59,6 @@ export default class Board {
}

cellAt(point: Point) {
return this.#cells[point.y][point.x]
return this.#cells[point.y][point.x];
}
}
16 changes: 8 additions & 8 deletions src/game/cell.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Piece } from "../pieces/piece"
import { Player } from "./player"
import { Point } from "./point"
import type { Piece } from "../pieces/piece";
import type { Player } from "./player";
import type { Point } from "./point";

export type Cell = {
owner: Player | null,
building: Building | null,
piece: Piece | null,
point: Point
}
owner: Player | null;
building: Building | null;
piece: Piece | null;
point: Point;
};
Loading

0 comments on commit 9f2fa50

Please sign in to comment.