Add StatusController, improve local game logic, and enable Swagger in API
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user