Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
projet-cdaw
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thibaut Felten
projet-cdaw
Commits
a9b1f5fb
Commit
a9b1f5fb
authored
Dec 03, 2020
by
thibaut-felten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stats
parent
1bf70669
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
20 deletions
+48
-20
UserController.class.php
backend/MVC/controller/UserController.class.php
+21
-7
Game.vue
frontend/src/views/Game.vue
+27
-13
No files found.
backend/MVC/controller/UserController.class.php
View file @
a9b1f5fb
...
@@ -39,6 +39,8 @@ class UserController extends Controller {
...
@@ -39,6 +39,8 @@ class UserController extends Controller {
$id
=
$this
->
request
->
getURIParams
()[
0
];
$id
=
$this
->
request
->
getURIParams
()[
0
];
return
$this
->
deleteUser
(
$id
);
return
$this
->
deleteUser
(
$id
);
break
;
break
;
case
'OPTIONS'
:
return
Response
::
okresponse
(
json_encode
(
"OPTIONS"
));
}
}
return
Response
::
errorResponse
(
"unsupported parameters or method in user"
);
return
Response
::
errorResponse
(
"unsupported parameters or method in user"
);
...
@@ -106,24 +108,36 @@ class UserController extends Controller {
...
@@ -106,24 +108,36 @@ class UserController extends Controller {
}
}
if
(
array_key_exists
(
'USER_ROCK'
,
$data
)){
if
(
array_key_exists
(
'USER_ROCK'
,
$data
)){
$rock
=
$data
[
'USER_ROCK'
];
}
else
{
$rock
=
$userValues
->
USER_ROCK
+
$data
[
'USER_ROCK'
];
$rock
=
$userValues
->
USER_ROCK
+
$data
[
'USER_ROCK'
];
}
else
{
$rock
=
$userValues
->
USER_ROCK
;
}
}
if
(
array_key_exists
(
'USER_PAPER'
,
$data
)){
if
(
array_key_exists
(
'USER_PAPER'
,
$data
)){
$paper
=
$data
[
'USER_PAPER'
]
;
}
else
{
$paper
=
$userValues
->
USER_PAPER
+
$data
[
'USER_PAPER'
];
$paper
=
$userValues
->
USER_PAPER
+
$data
[
'USER_PAPER'
];
}
else
{
$paper
=
$userValues
->
USER_PAPER
;
}
}
if
(
array_key_exists
(
'USER_SCISSORS'
,
$data
)){
if
(
array_key_exists
(
'USER_SCISSORS'
,
$data
)){
$scissors
=
$data
[
'USER_SCISSORS'
]
;
$scissors
=
$userValues
->
USER_SCISSORS
+
$data
[
'USER_SCISSORS'
]
;
}
else
{
$scissors
=
$userValues
->
USER_SCISSORS
;
}
if
(
array_key_exists
(
'USER_WIN'
,
$data
)){
$win
=
$userValues
->
USER_WIN
+
$data
[
'USER_WIN'
]
;
}
else
{
$win
=
$userValues
->
USER_WIN
;
}
if
(
array_key_exists
(
'USER_LOST'
,
$data
)){
$lost
=
$userValues
->
USER_LOST
+
$data
[
'USER_LOST'
]
;
}
else
{
}
else
{
$
scissors
=
$userValues
->
USER_SCISSORS
+
$data
[
'USER_SCISSORS'
]
;
$
lost
=
$userValues
->
USER_LOST
;
}
}
$user
=
User
::
updateUser
(
array
(
"id"
=>
$id
,
"login"
=>
$login
,
"email"
=>
$email
,
"lastname"
=>
$lastname
,
"firstname"
=>
$firstname
,
"paper"
=>
$paper
,
"scissors"
=>
$scissors
,
"rock"
=>
$rock
));
$user
=
User
::
updateUser
(
array
(
"id"
=>
$id
,
"login"
=>
$login
,
"email"
=>
$email
,
"lastname"
=>
$lastname
,
"firstname"
=>
$firstname
,
"paper"
=>
$paper
,
"scissors"
=>
$scissors
,
"rock"
=>
$rock
,
"win"
=>
$win
,
"win"
=>
$win
));
$response
=
new
Response
(
200
,
json_encode
(
$user
));
$response
=
new
Response
(
200
,
json_encode
(
$user
));
return
$response
;
return
$response
;
}
}
...
...
frontend/src/views/Game.vue
View file @
a9b1f5fb
...
@@ -118,27 +118,41 @@ export default {
...
@@ -118,27 +118,41 @@ export default {
}
}
if
(
this
.
myScore
>=
3
){
if
(
this
.
myScore
>=
3
){
alert
(
"Vous avez gagné !"
)
alert
(
"Vous avez gagné !"
)
this
.
updateUser
()
console
.
log
(
user
.
token
)
let
win
=
1
let
lost
=
0
this
.
updateUser
(
win
,
lost
)
this
.
$router
.
push
(
"/"
)
this
.
$router
.
push
(
"/"
)
}
}
else
if
(
this
.
oponentScore
>=
3
){
else
if
(
this
.
oponentScore
>=
3
){
alert
(
"Vous avez perdu ..."
)
alert
(
"Vous avez perdu ..."
)
this
.
updateUser
()
let
win
=
0
let
lost
=
1
this
.
updateUser
(
win
,
lost
)
this
.
$router
.
push
(
"/"
)
this
.
$router
.
push
(
"/"
)
}
}
},
},
updateUser
:
async
function
(){
updateUser
:
async
function
(
win
,
lost
){
let
rock
=
this
.
rock
if
(
user
.
id
<
1000000
){
let
paper
=
this
.
paper
let
rock
=
this
.
rock
let
scissors
=
this
.
scissors
let
paper
=
this
.
paper
let
scissors
=
this
.
scissors
await
fetch
(
console
.
log
(
"ID : "
+
user
.
id
)
sessionStorage
.
getItem
(
'APIURL'
)
+
`/user/
${
user
.
id
}
`
,
console
.
log
(
"TOKEN : "
+
user
.
token
)
{
await
fetch
(
method
:
"PUT"
,
sessionStorage
.
getItem
(
'APIURL'
)
+
`/user/
${
user
.
id
}
`
,
body
:
JSON
.
stringify
({
USER_PAPER
:
paper
,
USER_ROCK
:
rock
,
USER_SCISSORS
:
scissors
}),
{
}
method
:
"PUT"
,
)
headers
:
{
'Authorization'
:
'Bearer '
+
user
.
token
,
'Content-Type'
:
'application/json'
},
body
:
JSON
.
stringify
({
USER_PAPER
:
paper
,
USER_ROCK
:
rock
,
USER_SCISSORS
:
scissors
,
USER_LOST
:
lost
,
USER_WIN
:
win
}),
}
)
}
}
}
,
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment