Skip to content
Snippets Groups Projects
Commit 1304c6a3 authored by Chaili Yanis's avatar Chaili Yanis
Browse files

Merge branch 'feature/creation_moteur_du_jeu' into 'main'

Feature/creation moteur du jeu

See merge request prism-ios-equipe-3/pendu!1
parents 2a8df8a1 33497bb6
Branches
No related tags found
No related merge requests found
......@@ -17,6 +17,10 @@
BF3C48282A0A1FCD00CE128F /* PenduTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3C48272A0A1FCD00CE128F /* PenduTests.swift */; };
BF3C48322A0A1FCD00CE128F /* PenduUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3C48312A0A1FCD00CE128F /* PenduUITests.swift */; };
BF3C48342A0A1FCD00CE128F /* PenduUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3C48332A0A1FCD00CE128F /* PenduUITestsLaunchTests.swift */; };
BF3C48432A0A3CFF00CE128F /* GameEngineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3C48422A0A3CFF00CE128F /* GameEngineTests.swift */; };
D082CCC92A0A33D600D97981 /* GameEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D082CCC82A0A33D600D97981 /* GameEngine.swift */; };
D082CCCA2A0A33D600D97981 /* GameEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D082CCC82A0A33D600D97981 /* GameEngine.swift */; };
D082CCCB2A0A33D600D97981 /* GameEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = D082CCC82A0A33D600D97981 /* GameEngine.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
......@@ -51,6 +55,8 @@
BF3C482D2A0A1FCD00CE128F /* PenduUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PenduUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
BF3C48312A0A1FCD00CE128F /* PenduUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PenduUITests.swift; sourceTree = "<group>"; };
BF3C48332A0A1FCD00CE128F /* PenduUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PenduUITestsLaunchTests.swift; sourceTree = "<group>"; };
BF3C48422A0A3CFF00CE128F /* GameEngineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GameEngineTests.swift; sourceTree = "<group>"; };
D082CCC82A0A33D600D97981 /* GameEngine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GameEngine.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -109,6 +115,8 @@
BF3C481B2A0A1FCD00CE128F /* LaunchScreen.storyboard */,
BF3C481E2A0A1FCD00CE128F /* Info.plist */,
BF3C48162A0A1FCA00CE128F /* Pendu.xcdatamodeld */,
D082CCC82A0A33D600D97981 /* GameEngine.swift */,
BF3C48422A0A3CFF00CE128F /* GameEngineTests.swift */,
);
path = Pendu;
sourceTree = "<group>";
......@@ -261,6 +269,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D082CCC92A0A33D600D97981 /* GameEngine.swift in Sources */,
BF3C48122A0A1FCA00CE128F /* ViewController.swift in Sources */,
BF3C480E2A0A1FCA00CE128F /* AppDelegate.swift in Sources */,
BF3C48182A0A1FCA00CE128F /* Pendu.xcdatamodeld in Sources */,
......@@ -273,6 +282,8 @@
buildActionMask = 2147483647;
files = (
BF3C48282A0A1FCD00CE128F /* PenduTests.swift in Sources */,
D082CCCA2A0A33D600D97981 /* GameEngine.swift in Sources */,
BF3C48432A0A3CFF00CE128F /* GameEngineTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -281,6 +292,7 @@
buildActionMask = 2147483647;
files = (
BF3C48322A0A1FCD00CE128F /* PenduUITests.swift in Sources */,
D082CCCB2A0A33D600D97981 /* GameEngine.swift in Sources */,
BF3C48342A0A1FCD00CE128F /* PenduUITestsLaunchTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
//
// GameEngine.swift
// Pendu
//
// Created by Sofiane Lasri-Trienpont on 09/05/2023.
//
import UIKit
class GameEngine: NSObject {
private var listThemeAnimalsEasy : [String] = ["Chien", "Chat", "Lion", "Girafe", "Éléphant", "Serpent", "Oiseau", "Tigre", "Papillon", "Singe"]
private var listThemeSportsEasy : [String] = ["Football", "Basket-ball", "Tennis", "Natation", "Rugby", "Golf", "Volley-ball", "Baseball", "Athlétisme", "Boxe"]
private var listThemeFoodEasy : [String] = ["Pomme", "Banane", "Carotte", "Poisson", "Riz", "Fromage", "Pain", "Chocolat", "Fraise", "Poulet"]
private var listThemeCitiesEasy : [String] = ["Paris", "Londres", "New York", "Rome", "Tokyo", "Sydney", "Barcelone", "Berlin", "Istanbul", "Mumbai"]
private var listThemeColorsEasy : [String] = ["Rouge", "Bleu", "Vert", "Jaune", "Rose", "Violet", "Orange", "Gris", "Marron", "Noir"]
private var listThemeAnimalsHard : [String] = ["Chimpanzé", "Lynx", "Hippopotame", "Pélican", "Kangourou", "Anaconda", "Chimère", "Panda roux", "Calmar géant", "Ouistiti"]
private var listThemeSportsHard : [String] = ["Escrime", "Squash", "Haltérophilie", "Badminton", "Ski de fond", "Pentathlon moderne", "Canoë-kayak", "Aviron", "Patinage artistique", "Triathlon"]
private var listThemeFoodHard : [String] = ["Artichaut", "Quinoa", "Courge", "Wasabi", "Chou-fleur", "Sarrasin", "Salsifis", "Morue", "Canneberge", "Pistache"]
private var listThemeCitiesHard : [String] = ["Copenhague", "Budapest", "Dubrovnik", "Séoul", "Marrakech", "Reykjavik", "La Nouvelle-Orléans", "Bratislava", "Wellington", "Accra"]
private var listThemeColorsHard : [String] = ["Écarlate", "Azur", "Émeraude", "Safran", "Pourpre", "Indigo", "Sienne", "Cyan", "Vermillon", "Lavande"]
private var wordToGuess : String = ""
private var attemptsRemaining : Int = 0
override init() {
//
}
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
}
//public func startNewGame(difficulty: String) -> Void {
//wordToGuess = WordToGuess(theme: "Animals", difficulty: "Easy")
//}
public func guessLetter(letter: Character) -> Bool {
if wordToGuess.contains(letter) {
return true
} else {
return false
}
}
public func isGameOver() -> Bool {
// Vérification si le jeu est terminé
return false;
}
public func isLetterGuesses(letter: Character) -> Bool {
return false;
}
public func saveScore() -> Void {
// Enregistrement du score dans la base Core Data
}
static func getOnlineScoreboard() -> Void {
// Récupération du classement depuis le serveur
}
}
//
// GameEngineTests.swift
// PenduTests
//
// Created by Sofiane Lasri-Trienpont on 09/05/2023.
//
import XCTest
class GameEngineTests: XCTestCase {
override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDownWithError() throws {
// Put teardown code here. This method is called after the invocation of each test method in the class.
}
func testIsGameOver() throws {
let game:GameEngine = GameEngine();
XCTAssertEqual(false, game.isGameOver());
}
func testStartNewGame() throws {
let game:GameEngine = GameEngine();
let mot1 = game.WordToGuess(theme: "Sports", difficulty: "Hard")
let mot2 = game.WordToGuess(theme: "Sports", difficulty: "Hard")
XCTAssertNotEqual(mot1, mot2)
}
}
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
<elements/>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="20086" systemVersion="21E258" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Scoreboard" representedClassName="Scoreboard" syncable="YES" codeGenerationType="class">
<attribute name="categoryName" optional="YES" attributeType="String"/>
<attribute name="difficulty" optional="YES" attributeType="String"/>
<attribute name="playerName" optional="YES" attributeType="String"/>
<attribute name="score" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
</entity>
<elements>
<element name="Scoreboard" positionX="-63" positionY="-18" width="128" height="89"/>
</elements>
</model>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment