map, player, game, gamemode data now database driven

This commit is contained in:
Michael Simard
2021-10-31 00:01:27 -05:00
parent b0b0b7bc60
commit 64a66e28b8
22 changed files with 711 additions and 143 deletions

View File

@@ -0,0 +1,31 @@
//
// Configuration.swift
// App
//
// Created by Michael Simard on 10/29/21.
//
import Foundation
import Fluent
import Vapor
struct Configuration : Content {
var games:[GameConfig]
var gameModes:[GameModeConfig]
var gameModeGroups:[GameModeGroupConfig]
var players:[PlayerConfig]
var lossReasons:[LossReasonConfig]
init (games:[GameConfig], gameModes:[GameModeConfig], gameModeGroups:[GameModeGroupConfig], players:[PlayerConfig], lossReasons:[LossReasonConfig]){
self.games = games
self.gameModes = gameModes
self.gameModeGroups = gameModeGroups
self.players = players
self.lossReasons = lossReasons
}
}

View File

@@ -0,0 +1,22 @@
//
// GameConfig.swift
// App
//
// Created by Michael Simard on 10/29/21.
//
import Foundation
import Fluent
import Vapor
struct GameConfig: Content {
var gameId: String
var name: String
var maps: [MapConfig]
var enabled:Bool
}

View File

@@ -0,0 +1,18 @@
//
// GameModeConfig.swift
// App
//
// Created by Michael Simard on 10/29/21.
//
import Foundation
import Fluent
import Vapor
struct GameModeConfig:Content {
var gameModeId:Int
var name:String
var competitive:Bool
}

View File

@@ -0,0 +1,19 @@
//
// GameModeGroupConfig.swift
// App
//
// Created by Michael Simard on 10/29/21.
//
import Foundation
import Fluent
import Vapor
struct GameModeGroupConfig: Content {
var gameModeIds: String
var gameModeGroupId: String
var name: String
}

View File

@@ -0,0 +1,15 @@
//
// LossReasonsConfig.swift
// App
//
// Created by Michael Simard on 10/30/21.
//
import Foundation
import Fluent
import Vapor
struct LossReasonConfig: Content {
var reasonId: Int
var name: String
}

View File

@@ -0,0 +1,19 @@
//
// MapConfig.swift
// App
//
// Created by Michael Simard on 10/29/21.
//
import Foundation
import Fluent
import Vapor
struct MapConfig:Content, Hashable{
var mapId:Int
var name:String
var imageName:String
var gameModeGroupIds:[String]
}

View File

@@ -0,0 +1,15 @@
//
// PlayerConfig.swift
// App
//
// Created by Michael Simard on 10/30/21.
//
import Foundation
import Fluent
import Vapor
struct PlayerConfig: Content {
var playerId: Int
var name: String
}

View File

@@ -10,7 +10,7 @@ import Vapor
import Fluent
struct MapRecord: Content {
var map:Map
var map:MapConfig
var stats:Stats
var ratio:String
}

View File

@@ -7,7 +7,7 @@
import Foundation
struct Map: Hashable, Codable {
struct OldMap: Hashable, Codable {
var id: Int
var name:String
var imageName:String