Switch to SQLite database over text files

This commit is contained in:
Christoph Hagen
2021-12-22 22:13:09 +01:00
parent 86456b2441
commit 5eafcfdf4d
10 changed files with 148 additions and 564 deletions

View File

@ -1,24 +1,30 @@
import Foundation
import WebSocketKit
typealias PlayerName = String
class Player {
let name: PlayerName
let totalPoints: Int
var socket: WebSocket?
var isNextActor: Bool
init(name: PlayerName, socket: WebSocket? = nil) {
init(name: PlayerName, points: Int, socket: WebSocket? = nil) {
self.name = name
self.socket = socket
self.isNextActor = false
self.totalPoints = points
}
init(player: Player) {
self.name = player.name
self.socket = player.socket
self.isNextActor = false
self.totalPoints = player.totalPoints
}
var actions: [PlayerAction] {
@ -31,6 +37,7 @@ class Player {
var info: PlayerInfo {
var result = PlayerInfo(name: name)
result.points = totalPoints
result.isConnected = isConnected
result.isNextActor = isNextActor
result.state = states.map { $0.rawValue }