Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Hagraah Pendu
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sofiane Lasri
Hagraah Pendu
Commits
88d165c8
Commit
88d165c8
authored
2 years ago
by
Nathan
Browse files
Options
Downloads
Patches
Plain Diff
remove word
parent
19823115
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Pendu/GameEngine.swift
+17
-5
17 additions, 5 deletions
Pendu/GameEngine.swift
Pendu/GameViewController.swift
+61
-37
61 additions, 37 deletions
Pendu/GameViewController.swift
with
78 additions
and
42 deletions
Pendu/GameEngine.swift
+
17
−
5
View file @
88d165c8
...
...
@@ -11,15 +11,15 @@ import CoreData
class
GameEngine
:
NSObject
{
private
var
listThemeAnimalsEasy
:
[
String
]
=
[
"Chien"
,
"Chat"
,
"Lion"
,
"Girafe"
,
"elephant"
,
"Serpent"
,
"Oiseau"
,
"Tigre"
,
"Papillon"
,
"Singe"
];
private
var
listThemeSportsEasy
:
[
String
]
=
[
"Football"
,
"Basket-ball"
,
"Tennis"
,
"Natation"
,
"Rugby"
,
"Golf"
,
"Volley-ball"
,
"Baseball"
,
"Athletisme"
,
"Boxe"
];
private
var
listThemeSportsEasy
:
[
String
]
=
[
"Football"
,
"Tennis"
,
"Natation"
,
"Rugby"
,
"Golf"
,
"Baseball"
,
"Athletisme"
,
"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
]
=
[
"Chimpanze"
,
"Lynx"
,
"Hippopotame"
,
"Pelican"
,
"Kangourou"
,
"Anaconda"
,
"Chimere"
,
"Panda roux"
,
"Calmar geant"
,
"Ouistiti"
];
private
var
listThemeSportsHard
:
[
String
]
=
[
"Escrime"
,
"Squash"
,
"Halterophilie"
,
"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"
,
"Seoul"
,
"Marrakech"
,
"Reykjavik"
,
"La Nouvelle-Orleans"
,
"Bratislava"
,
"Wellington"
,
"Accra"
];
private
var
listThemeAnimalsHard
:
[
String
]
=
[
"Chimpanze"
,
"Lynx"
,
"Hippopotame"
,
"Pelican"
,
"Kangourou"
,
"Anaconda"
,
"Chimere"
,
"Panda roux"
,
"Ouistiti"
];
private
var
listThemeSportsHard
:
[
String
]
=
[
"Escrime"
,
"Squash"
,
"Halterophilie"
,
"Badminton"
,
"
Aviron
"
,
"Triathlon"
];
private
var
listThemeFoodHard
:
[
String
]
=
[
"Artichaut"
,
"Quinoa"
,
"Courge"
,
"Wasabi"
,
"Sarrasin"
,
"Salsifis"
,
"Morue"
,
"Canneberge"
,
"Pistache"
];
private
var
listThemeCitiesHard
:
[
String
]
=
[
"Copenhague"
,
"Budapest"
,
"Dubrovnik"
,
"Seoul"
,
"Marrakech"
,
"Reykjavik"
,
"Bratislava"
,
"Wellington"
,
"Accra"
];
private
var
listThemeColorsHard
:
[
String
]
=
[
"ecarlate"
,
"Azur"
,
"emeraude"
,
"Safran"
,
"Pourpre"
,
"Indigo"
,
"Sienne"
,
"Cyan"
,
"Vermillon"
,
"Lavande"
];
private
var
wordToGuess
:
String
=
""
;
...
...
@@ -166,6 +166,18 @@ class GameEngine: NSObject {
return
self
.
score
;
}
public
func
getPlayerName
()
->
String
{
return
self
.
playerName
;
}
public
func
getDifficulty
()
->
String
{
return
self
.
difficulty
;
}
public
func
getCategoryName
()
->
String
{
return
self
.
theme
;
}
public
func
saveScore
()
->
Void
{
// Enregistrement du score dans la base Core Data
...
...
This diff is collapsed.
Click to expand it.
Pendu/GameViewController.swift
+
61
−
37
View file @
88d165c8
...
...
@@ -185,11 +185,16 @@ class GameViewController: UIViewController {
func
initializeWordState
()
{
let
words
=
wordToGuess
.
components
(
separatedBy
:
" "
)
print
(
words
)
for
word
in
words
{
var
wordState
=
""
for
_
in
word
{
for
char
in
word
{
if
char
==
" "
{
wordState
+=
" "
}
else
{
wordState
+=
"_"
}
}
currentWordState
.
append
(
wordState
)
}
}
...
...
@@ -201,6 +206,26 @@ class GameViewController: UIViewController {
func
checkIfWordFound
()
{
if
currentWordState
.
joined
()
==
wordToGuess
{
let
url
=
URL
(
string
:
"https://miscs.sl-projects.com/IUT-ORSAY/LP-PRISM/TP-iOS/"
)
let
parametre
=
[
"score"
:
gameEngine
.
getScore
(),
"categoryName"
:
gameEngine
.
getCategoryName
(),
"difficulty"
:
gameEngine
.
getDifficulty
(),
"playerName"
:
gameEngine
.
getPlayerName
()]
as
[
String
:
Any
]
let
jsonData
=
try
?
JSONSerialization
.
data
(
withJSONObject
:
parametre
)
// Créer une requête URLRequest
var
request
=
URLRequest
(
url
:
(
url
)
!
)
request
.
httpMethod
=
"POST"
request
.
httpBody
=
jsonData
// Créer une session URLSession
let
session
=
URLSession
.
shared
// Créer une tâche de données pour envoyer la requête
let
task
=
session
.
dataTask
(
with
:
request
)
// Démarrer la tâche de données
task
.
resume
()
isWordFound
=
true
wordLabel
.
textColor
=
UIColor
.
green
A_Button
.
isHidden
=
true
...
...
@@ -268,7 +293,7 @@ class GameViewController: UIViewController {
let
guessedCorrectly
=
gameEngine
.
guessLetter
(
letter
:
Character
(
letter
))
score
.
text
=
"Score : "
+
String
(
gameEngine
.
getScore
())
for
(
wordIndex
,
word
)
in
wordToGuess
.
components
(
separatedBy
:
" "
)
.
enumerated
()
{
for
(
wordIndex
,
word
)
in
wordToGuess
.
components
(
separatedBy
:
.
whitespacesAndNewlines
)
.
enumerated
()
{
var
updateWord
=
""
let
wordCharacters
=
Array
(
currentWordState
[
wordIndex
])
for
(
charIndex
,
char
)
in
word
.
enumerated
()
{
...
...
@@ -276,7 +301,6 @@ class GameViewController: UIViewController {
if
currentChar
.
uppercased
()
==
guessedLetter
{
updateWord
+=
currentChar
// guessedCorrectly = true
}
else
{
let
currentWordStateChar
=
String
(
wordCharacters
[
charIndex
])
updateWord
+=
currentWordStateChar
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment