From 33497bb6e8b030021cfb737a782a4fa22cb8ca97 Mon Sep 17 00:00:00 2001 From: ychaili <yanis10154158vsdcsw@gmail.com> Date: Tue, 16 May 2023 15:46:49 +0200 Subject: [PATCH] guessLetter() --- Pendu/GameEngine.swift | 18 +++++++++++------- PenduTests/PenduTests.swift | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Pendu/GameEngine.swift b/Pendu/GameEngine.swift index 8c43086..a11054f 100644 --- a/Pendu/GameEngine.swift +++ b/Pendu/GameEngine.swift @@ -23,7 +23,6 @@ class GameEngine: NSObject { private var wordToGuess : String = "" private var attemptsRemaining : Int = 0 - private var guessedLetters : [Character] = [] override init() { // @@ -75,13 +74,18 @@ class GameEngine: NSObject { return word } - public func startNewGame(difficulty: String) -> Void { - print(WordToGuess(theme: "Animals", difficulty: "Easy")) - } + //public func startNewGame(difficulty: String) -> Void { + //wordToGuess = WordToGuess(theme: "Animals", difficulty: "Easy") + //} - public func guessLetter(letter: Character) -> Void { - // Vérification de la lettre proposée par le joueur - // Mise à jour de l'état de la lettre + public func guessLetter(letter: Character) -> Bool { + + if wordToGuess.contains(letter) { + return true + } else { + return false + } + } public func isGameOver() -> Bool { diff --git a/PenduTests/PenduTests.swift b/PenduTests/PenduTests.swift index d659345..b960a74 100644 --- a/PenduTests/PenduTests.swift +++ b/PenduTests/PenduTests.swift @@ -32,5 +32,5 @@ class PenduTests: XCTestCase { // Put the code you want to measure the time of here. } } - + } -- GitLab