Add StatusController, improve local game logic, and enable Swagger in API

This commit is contained in:
2026-02-22 19:01:43 +01:00
committed by Jonas
parent 7395b6d3bf
commit f98d9e79b2
8 changed files with 218 additions and 7 deletions
+6 -2
View File
@@ -8,17 +8,21 @@ class LocalGame {
this.field = Array.from({ length: fieldSize.y }, () => Array(fieldSize.x).fill(0))
}
place(locationX: number): void {
place(locationX: number | null): void {
if(locationX === null) return;
console.log(
`Player ${this.currentPlayer} placed a field at x: ${locationX}`
)
for (let y = this.field.length - 1; y >= 0; y--) {
const row = this.field[y]
if (row && row[locationX] === 0) {
row[locationX] = this.currentPlayer
this.currentPlayer = this.currentPlayer === 1 ? 2 : 1
break
}
}
this.currentPlayer = this.currentPlayer === 1 ? 2 : 1
}
}