Skip to content
Snippets Groups Projects
Commit 836e99f9 authored by yanis's avatar yanis
Browse files

Création WordToGuess()

parent 61888b70
No related branches found
No related tags found
No related merge requests found
......@@ -24,9 +24,54 @@ class GameEngine: NSObject {
private var wordToGuess : String = ""
private var attemptsRemaining : Int = 0
private var guessedLetters : [Character] = []
private
override init() {
//code
//
}
func WordToGuess(theme: String, difficulty: String) -> String{
var word = ""
if theme == "Animals"{
if difficulty == "Easy"{
let randomInt = Int.random(in: 0..<listThemeAnimalsEasy.count)
word = listThemeAnimalsEasy[randomInt]
} else {
let randomInt = Int.random(in: 0..<listThemeAnimalsHard.count)
word = listThemeAnimalsHard[randomInt]
}
} else if theme == "Sports"{
if difficulty == "Easy"{
let randomInt = Int.random(in: 0..<listThemeSportsEasy.count)
word = listThemeAnimalsEasy[randomInt]
} else {
let randomInt = Int.random(in: 0..<listThemeSportsHard.count)
word = listThemeSportsHard[randomInt]
}
} else if theme == "Food"{
if difficulty == "Easy"{
let randomInt = Int.random(in: 0..<listThemeFoodEasy.count)
word = listThemeFoodEasy[randomInt]
} else {
let randomInt = Int.random(in: 0..<listThemeFoodHard.count)
word = listThemeFoodHard[randomInt]
}
} else if theme == "Cities"{
if difficulty == "Easy"{
let randomInt = Int.random(in: 0..<listThemeCitiesEasy.count)
word = listThemeCitiesEasy[randomInt]
} else {
let randomInt = Int.random(in: 0..<listThemeCitiesHard.count)
word = listThemeCitiesHard[randomInt]
}
} else if theme == "Colors"{
if difficulty == "Easy"{
let randomInt = Int.random(in: 0..<listThemeColorsEasy.count)
word = listThemeColorsEasy[randomInt]
} else {
let randomInt = Int.random(in: 0..<listThemeColorsHard.count)
word = listThemeColorsHard[randomInt]
}
}
return word
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment