diff --git a/Sources/App/Content/Config/ColorSchemeConfig.swift b/Sources/App/Content/Config/ColorSchemeConfig.swift index 151b95d..6263a4f 100644 --- a/Sources/App/Content/Config/ColorSchemeConfig.swift +++ b/Sources/App/Content/Config/ColorSchemeConfig.swift @@ -13,7 +13,7 @@ import Fluent import Vapor struct ColorSchemeConfig: Content { - var gameId: Int + var gameId: String var tileColour: String? var winColour: String? var lossColour: String? diff --git a/Sources/App/Content/Config/Configuration.swift b/Sources/App/Content/Config/Configuration.swift index ba80d51..4c4070a 100644 --- a/Sources/App/Content/Config/Configuration.swift +++ b/Sources/App/Content/Config/Configuration.swift @@ -17,7 +17,7 @@ struct Configuration : Content { var gameModes:[GameModeConfig] var gameModeGroups:[GameModeGroupConfig] var players:[PlayerConfig] - var lossReasons:[LossReasonConfig] + var lossReasons:[LossReasonConfig] init (games:[GameConfig], gameModes:[GameModeConfig], gameModeGroups:[GameModeGroupConfig], players:[PlayerConfig], lossReasons:[LossReasonConfig]){ diff --git a/Sources/App/Content/Config/GameConfig.swift b/Sources/App/Content/Config/GameConfig.swift index baa2f79..96c5370 100644 --- a/Sources/App/Content/Config/GameConfig.swift +++ b/Sources/App/Content/Config/GameConfig.swift @@ -18,6 +18,8 @@ struct GameConfig: Content { var maps: [MapConfig] var enabled:Bool var colours:ColorSchemeConfig? + var shortName:String + var imageName:String } diff --git a/Sources/App/Controllers/AppDataController.swift b/Sources/App/Controllers/AppDataController.swift index 6e04ec4..c60ede9 100644 --- a/Sources/App/Controllers/AppDataController.swift +++ b/Sources/App/Controllers/AppDataController.swift @@ -70,7 +70,7 @@ struct AppDataController: RouteCollection { - return GameConfig(gameId: game.gameId, name: game.name, maps: mapConfigs, enabled: game.enabled, colours: colourSchemeConfigs.first{game.gameId == "\($0.gameId)"}) + return GameConfig(gameId: game.gameId, name: game.name, maps: mapConfigs, enabled: game.enabled, colours: colourSchemeConfigs.first{game.gameId == "\($0.gameId)"}, shortName: game.shortName, imageName: game.imageName) }) return Configuration(games:gameConfigs, gameModes: gameModeConfigs, gameModeGroups: gameModeGroupConfigs, players: playerConfigs, lossReasons: lossReasonConfigs) } diff --git a/Sources/App/Models/ColourScheme.swift b/Sources/App/Models/ColourScheme.swift index 2a01e4f..d72d6b2 100644 --- a/Sources/App/Models/ColourScheme.swift +++ b/Sources/App/Models/ColourScheme.swift @@ -19,7 +19,7 @@ final class ColourScheme: Model, Content { var id: UUID? @Field(key: "game_id") - var gameId: Int + var gameId: String @Field(key: "tile_colour") var tileColour: String? @@ -35,7 +35,7 @@ final class ColourScheme: Model, Content { init() { } // Creates a new with all properties set. - init(id: UUID? = nil, gameId: Int, tileColour: String?,winColour: String?,lossColour: String? ) { + init(id: UUID? = nil, gameId: String, tileColour: String?,winColour: String?,lossColour: String? ) { self.id = id self.gameId = gameId self.tileColour = tileColour diff --git a/Sources/App/Models/Game.swift b/Sources/App/Models/Game.swift index 5f2bace..fe81cd1 100644 --- a/Sources/App/Models/Game.swift +++ b/Sources/App/Models/Game.swift @@ -31,19 +31,26 @@ final class Game: Model, Content { @Field(key: "enabled") var enabled: Bool - + @Field(key: "short_name") + var shortName: String + + @Field(key: "image_name") + var imageName: String + // Creates a new, empty . init() { } // Creates a new with all properties set. - init(id: UUID? = nil, gameId: String, name: String, maps:String, enabled:Bool) { + init(id: UUID? = nil, gameId: String, name: String, maps:String, enabled:Bool, shortName:String, imageName:String) { self.id = id self.gameId = gameId self.name = name self.maps = maps self.enabled = enabled + self.shortName = shortName + self.imageName = imageName }