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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sofiane Lasri
Hagraah Pendu
Commits
61f9db64
Commit
61f9db64
authored
Jun 13, 2023
by
Nathan
Browse files
Options
Downloads
Patches
Plain Diff
add POST Data
parent
88d165c8
No related branches found
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
+2
-2
2 additions, 2 deletions
Pendu/GameEngine.swift
Pendu/GameViewController.swift
+15
-11
15 additions, 11 deletions
Pendu/GameViewController.swift
with
17 additions
and
13 deletions
Pendu/GameEngine.swift
+
2
−
2
View file @
61f9db64
...
...
@@ -27,8 +27,8 @@ class GameEngine: NSObject {
private
var
guessedLetters
:
[
Character
]
=
[];
private
var
lastGuessedLetterTime
:
Date
?
=
nil
;
private
var
theme
:
String
=
""
;
private
var
difficulty
:
String
=
""
;
private
var
playerName
:
String
=
""
;
private
var
difficulty
:
String
=
"
Easy
"
;
private
var
playerName
:
String
=
"
PlayerName
"
;
private
var
score
:
Int
=
0
;
private
var
combo
:
Int
=
0
;
private
var
remainingLives
:
Int
=
8
;
...
...
This diff is collapsed.
Click to expand it.
Pendu/GameViewController.swift
+
15
−
11
View file @
61f9db64
...
...
@@ -208,24 +208,28 @@ class GameViewController: UIViewController {
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
)
!
)
var
components
=
URLComponents
()
components
.
queryItems
=
[
URLQueryItem
(
name
:
"score"
,
value
:
String
(
gameEngine
.
getScore
())),
URLQueryItem
(
name
:
"categoryName"
,
value
:
String
(
gameEngine
.
getCategoryName
())),
URLQueryItem
(
name
:
"difficulty"
,
value
:
String
(
gameEngine
.
getDifficulty
())),
URLQueryItem
(
name
:
"playerName"
,
value
:
String
(
gameEngine
.
getPlayerName
())),
]
let
formString
=
components
.
percentEncodedQuery
var
request
=
URLRequest
(
url
:
url
!
)
request
.
httpMethod
=
"POST"
request
.
httpBody
=
jsonData
request
.
httpBody
=
formString
?
.
data
(
using
:
.
utf8
)
// 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
...
...
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
sign in
to comment