Fix error creating a table

This commit is contained in:
Christoph Hagen 2022-10-12 22:02:01 +02:00
parent 30abe56325
commit 454bd204b8
2 changed files with 3 additions and 4 deletions

View File

@ -43,7 +43,7 @@ final class TableManagement {
try await table.create(on: database) try await table.create(on: database)
player.$table.id = table.id player.$table.id = table.id
try await player.update(on: database) try await player.update(on: database)
let waitingTable = WaitingTable(newTable: table) let waitingTable = WaitingTable(newTable: table, user: player)
self.tables[waitingTable.id] = waitingTable self.tables[waitingTable.id] = waitingTable
return waitingTable.tableInfo(forPlayer: player.name) return waitingTable.tableInfo(forPlayer: player.name)
} }

View File

@ -23,10 +23,9 @@ final class WaitingTable: AbstractTable<WaitingPlayer> {
/** /**
Create a new table. Create a new table.
- Parameter name: The name of the table - Parameter name: The name of the table
- Parameter isPublic: The table is visible and joinable by everyone - Parameter player: The user who created the table
*/ */
init(newTable object: Table) { init(newTable object: Table, user: User) {
let user = object.players[0]
let player = WaitingPlayer(name: user.name, points: user.points) let player = WaitingPlayer(name: user.name, points: user.points)
player.isNextActor = true player.isNextActor = true
super.init(id: object.id!, name: object.name, isPublic: object.isPublic, players: [player]) super.init(id: object.id!, name: object.name, isPublic: object.isPublic, players: [player])