16
|
1 //
|
|
2 // GameInfoProtocol+Structs.swift
|
|
3 // GeoQuiz
|
|
4 //
|
|
5 // Created by Dennis Concepción Martín on 20/10/22.
|
|
6 //
|
|
7
|
|
8 import Foundation
|
|
9 import SwiftUI
|
|
10
|
|
11 @objc
|
|
12 public enum GameType: Int16 {
|
|
13 case guessTheFlag, guessTheCapital, guessTheCountry, guessThePopulation
|
|
14 }
|
|
15
|
|
16 protocol GameInfo {
|
|
17 static var type: GameType { get }
|
|
18 static var level: String { get }
|
|
19 static var name: String { get }
|
|
20 static var symbol: String { get }
|
|
21 static var gradient: Gradient { get }
|
|
22 static var numberOfQuestions: Int { get }
|
|
23 }
|
|
24
|
|
25 class GuessTheFlagInfo: GameInfo {
|
|
26 static let type: GameType = .guessTheFlag
|
|
27 static let level = "Level 1"
|
|
28 static let name = "Guess the flag"
|
|
29 static let symbol = "flag.fill"
|
|
30 static let gradient: Gradient = .main
|
|
31
|
|
32 static var numberOfQuestions: Int {
|
|
33 let data: CountryData = load("countries.json")
|
|
34 return data.countries.count
|
|
35 }
|
|
36 }
|
|
37
|
|
38 class GuessTheCapitalInfo: GameInfo {
|
|
39 static let type: GameType = .guessTheFlag
|
|
40 static let level = "Level 2"
|
|
41 static let name = "Guess the capital"
|
|
42 static let symbol = "building.2.fill"
|
|
43 static let gradient: Gradient = .secondary
|
|
44
|
|
45 static var numberOfQuestions: Int {
|
|
46 let data: CountryData = load("countries.json")
|
|
47 return data.countries.count
|
|
48 }
|
|
49 }
|
|
50
|
|
51 class GuessTheCountryInfo: GameInfo {
|
|
52 static let type: GameType = .guessTheFlag
|
|
53 static let level = "Level 3"
|
|
54 static let name = "Guess the country"
|
|
55 static let symbol = "globe.americas.fill"
|
|
56 static let gradient: Gradient = .tertiary
|
|
57
|
|
58 static var numberOfQuestions: Int {
|
|
59 let data: CityData = load("cities.json")
|
|
60 return data.cities.count
|
|
61 }
|
|
62 }
|
|
63
|
|
64 class GuessThePopulationInfo: GameInfo {
|
|
65 static let type: GameType = .guessTheFlag
|
|
66 static let level = "Level 4"
|
|
67 static let name = "Guess the population"
|
|
68 static let symbol = "person.fill"
|
|
69 static let gradient: Gradient = .quaternary
|
|
70
|
|
71 static var numberOfQuestions: Int {
|
|
72 let data: CityData = load("cities.json")
|
|
73 return data.cities.count
|
|
74 }
|
|
75 }
|