Introduce LocalGame logic and integrate with LocalMode rendering.

This commit is contained in:
2026-02-19 21:05:33 +01:00
committed by Jonas
parent 13fdf97f5a
commit 7395b6d3bf
8 changed files with 63 additions and 20 deletions
@@ -0,0 +1,25 @@
import type { FieldSize } from '@/scripts/interfaces/FieldSize.ts'
class LocalGame {
public field: number[][]
private currentPlayer: number = 1;
constructor(fieldSize: FieldSize) {
this.field = Array.from({ length: fieldSize.y }, () => Array(fieldSize.x).fill(0))
}
place(locationX: number): void {
for (let y = this.field.length - 1; y >= 0; y--) {
const row = this.field[y]
if (row && row[locationX] === 0) {
row[locationX] = this.currentPlayer
break
}
}
this.currentPlayer = this.currentPlayer === 1 ? 2 : 1
}
}
export default LocalGame