map, player, game, gamemode data now database driven
This commit is contained in:
53
Sources/App/Models/Game.swift
Normal file
53
Sources/App/Models/Game.swift
Normal file
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// Game.swift
|
||||
// App
|
||||
//
|
||||
// Created by Michael Simard on 10/29/21.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
import Fluent
|
||||
import Vapor
|
||||
|
||||
final class Game: Model, Content {
|
||||
// Name of the table or collection.
|
||||
static let schema = "game"
|
||||
|
||||
@ID(key: .id)
|
||||
var id: UUID?
|
||||
|
||||
@Field(key: "game_id")
|
||||
var gameId: String
|
||||
|
||||
@Field(key: "name")
|
||||
var name: String
|
||||
|
||||
@Field(key: "maps")
|
||||
var maps: String
|
||||
|
||||
|
||||
@Field(key: "enabled")
|
||||
var enabled: Bool
|
||||
|
||||
|
||||
|
||||
|
||||
// Creates a new, empty .
|
||||
init() { }
|
||||
|
||||
// Creates a new with all properties set.
|
||||
init(id: UUID? = nil, gameId: String, name: String, maps:String, enabled:Bool) {
|
||||
self.id = id
|
||||
self.gameId = gameId
|
||||
self.name = name
|
||||
self.maps = maps
|
||||
self.enabled = enabled
|
||||
}
|
||||
|
||||
|
||||
var mapIds:[Int] {
|
||||
maps.components(separatedBy: ",").map{Int($0)!}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user