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
ba60d466
Commit
ba60d466
authored
4 years ago
by
Robin Borgogno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shifumi
parent
f3958386
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
437 additions
and
48 deletions
+437
-48
ResultController.class.php
backend/MVC/controller/ResultController.class.php
+64
-0
Result.class.php
backend/MVC/model/Result.class.php
+27
-0
Game.sql.php
backend/MVC/sql/Game.sql.php
+1
-1
Result.sql.php
backend/MVC/sql/Result.sql.php
+10
-0
LoginNavbar.vue
frontend/src/components/LoginNavbar.vue
+2
-2
user.js
frontend/src/model/user.js
+2
-2
index.js
frontend/src/router/index.js
+15
-0
AdminPrivate.vue
frontend/src/views/AdminPrivate.vue
+39
-37
ChoixPartie.vue
frontend/src/views/ChoixPartie.vue
+2
-2
Game.vue
frontend/src/views/Game.vue
+147
-0
Inscription.vue
frontend/src/views/Inscription.vue
+5
-1
JoinPrivate.vue
frontend/src/views/JoinPrivate.vue
+52
-0
Login.vue
frontend/src/views/Login.vue
+4
-3
PlayerPrivate.vue
frontend/src/views/PlayerPrivate.vue
+67
-0
No files found.
backend/MVC/controller/ResultController.class.php
0 → 100644
View file @
ba60d466
<?php
include_once
__ROOT_DIR
.
'/libs/php-jwt/src/BeforeValidException.php'
;
include_once
__ROOT_DIR
.
'/libs/php-jwt/src/ExpiredException.php'
;
include_once
__ROOT_DIR
.
'/libs/php-jwt/src/SignatureInvalidException.php'
;
include_once
__ROOT_DIR
.
'/libs/php-jwt/src/JWT.php'
;
use
\Firebase\JWT\JWT
;
class
ResultController
extends
Controller
{
public
function
__construct
(
$name
,
$request
)
{
parent
::
__construct
(
$name
,
$request
);
}
// ==============
// Actions
// ==============
public
function
processRequest
()
{
switch
(
$this
->
request
->
getHttpMethod
())
{
case
'GET'
:
$id
=
$this
->
request
->
getURIParams
()[
0
];
return
$this
->
returnResultGameID
(
$id
);
case
'POST'
:
$id
=
$this
->
request
->
getURIParams
()[
0
];
$data
=
json_decode
(
file_get_contents
(
"php://input"
),
TRUE
);
return
$this
->
saveAwnser
(
$id
,
$data
);
break
;
case
'DELETE'
:
$data
=
json_decode
(
file_get_contents
(
"php://input"
),
TRUE
);
return
$this
->
deleteLine
(
$data
);
break
;
case
'OPTIONS'
:
return
Response
::
okresponse
(
json_encode
(
"OPTIONS"
));
// $data = json_decode(file_get_contents("php://input"),TRUE);
// return $this->deleteLine($data);
// break;
}
return
Response
::
errorResponse
(
"unsupported parameters or method in game"
);
}
public
function
saveAwnser
(
$id
,
$data
)
{
Result
::
saveAwnser
(
array
(
":id"
=>
$id
,
":user_id"
=>
$data
[
'USER_ID'
],
":awn"
=>
$data
[
'value'
]));
return
Response
::
okresponse
(
json_encode
(
"Tout va bien"
));
}
public
function
returnResultGameID
(
$id
)
{
$result
=
Result
::
returnResultGameID
(
array
(
":id"
=>
$id
));
return
Response
::
okresponse
(
json_encode
(
$result
));
}
public
function
deleteLine
(
$data
)
{
Result
::
deleteLigne
(
array
(
":id"
=>
$data
[
'USER_ID'
]));
return
Response
::
okresponse
(
json_encode
(
"Theo"
));
}
}
This diff is collapsed.
Click to expand it.
backend/MVC/model/Result.class.php
0 → 100644
View file @
ba60d466
<?php
class
Result
extends
Model
{
// ===========
// = Statics =
// ===========
protected
static
$table_name
=
'RESULT'
;
public
static
function
saveAwnser
(
$values
)
{
$stm
=
parent
::
exec
(
'RESULT_SAVE'
,
$values
);
}
public
static
function
returnResultGameID
(
$values
)
{
$stm
=
parent
::
exec
(
'RESULT_GET'
,
$values
);
return
$stm
->
fetchAll
();
}
public
static
function
deleteLigne
(
$values
)
{
$stm
=
parent
::
exec
(
'RESULT_DELETE'
,
$values
);
return
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
backend/MVC/sql/Game.sql.php
View file @
ba60d466
...
@@ -19,7 +19,7 @@ Game::addSqlQuery('GAME_DELETE',
...
@@ -19,7 +19,7 @@ Game::addSqlQuery('GAME_DELETE',
"DELETE FROM GAME WHERE GAME_ID=:GAME_ID"
);
"DELETE FROM GAME WHERE GAME_ID=:GAME_ID"
);
Game
::
addSqlQuery
(
'GAME_GET_USERS'
,
Game
::
addSqlQuery
(
'GAME_GET_USERS'
,
"SELECT
USER_ID
FROM GAME_HISTO WHERE GAME_ID=:GAME_ID"
);
"SELECT
*
FROM GAME_HISTO WHERE GAME_ID=:GAME_ID"
);
Game
::
addSqlQuery
(
'GAME_ADD_USER'
,
Game
::
addSqlQuery
(
'GAME_ADD_USER'
,
"INSERT INTO GAME_HISTO (GAME_HISTO_ID, GAME_ID, USER_ID) VALUES (NULL, :GAME_ID, :USER_ID)"
);
"INSERT INTO GAME_HISTO (GAME_HISTO_ID, GAME_ID, USER_ID) VALUES (NULL, :GAME_ID, :USER_ID)"
);
...
...
This diff is collapsed.
Click to expand it.
backend/MVC/sql/Result.sql.php
0 → 100644
View file @
ba60d466
<?php
Result
::
addSqlQuery
(
'RESULT_SAVE'
,
"INSERT INTO RESULT(USER_ID, RESULT_AWNSER, GAME_ID) VALUES (:user_id , :awn, :id)"
);
Result
::
addSqlQuery
(
'RESULT_GET'
,
"SELECT * FROM RESULT WHERE RESULT.GAME_ID = :id"
);
Result
::
addSqlQuery
(
'RESULT_DELETE'
,
"DELETE FROM RESULT WHERE RESULT.USER_ID = :id"
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/components/LoginNavbar.vue
View file @
ba60d466
...
@@ -3,10 +3,10 @@
...
@@ -3,10 +3,10 @@
<button
class=
"btn-login"
>
<button
class=
"btn-login"
>
<router-link
to=
"/"
>
Accueil
</router-link>
<router-link
to=
"/"
>
Accueil
</router-link>
</button>
</button>
<button
class=
"btn-login"
v-if=
"user.id
==
0"
>
<button
class=
"btn-login"
v-if=
"user.id
>= 100000
0"
>
<router-link
to=
"/inscription"
>
Inscription
</router-link>
<router-link
to=
"/inscription"
>
Inscription
</router-link>
</button>
</button>
<button
class=
"btn-login"
v-if=
"user.id
==
0"
>
<button
class=
"btn-login"
v-if=
"user.id
>= 100000
0"
>
<router-link
to=
"/login"
>
Connection
</router-link>
<router-link
to=
"/login"
>
Connection
</router-link>
</button>
</button>
<button
class=
"btn-user"
v-if=
"user.id!==0"
>
<button
class=
"btn-user"
v-if=
"user.id!==0"
>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/model/user.js
View file @
ba60d466
let
user
=
{
let
user
=
{
token
:
""
,
token
:
""
,
id
:
0
,
name
:
""
,
name
:
""
id
:
Math
.
floor
(
Math
.
random
()
*
1000000
+
1000000
)
}
}
module
.
exports
=
user
module
.
exports
=
user
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/router/index.js
View file @
ba60d466
...
@@ -44,6 +44,21 @@ const routes = [
...
@@ -44,6 +44,21 @@ const routes = [
path
:
"/updateUser"
,
path
:
"/updateUser"
,
name
:
"UpdateUser"
,
name
:
"UpdateUser"
,
component
:
()
=>
import
(
/* webpackChunkName: "login" */
'../views/UpdateUser.vue'
)
component
:
()
=>
import
(
/* webpackChunkName: "login" */
'../views/UpdateUser.vue'
)
},
{
path
:
"/joinPrivate"
,
name
:
"JoinPrivate"
,
component
:
()
=>
import
(
/* webpackChunkName: "login" */
'../views/JoinPrivate.vue'
)
},
{
path
:
"/playerPrivate"
,
name
:
"PlayerPrivate"
,
component
:
()
=>
import
(
/* webpackChunkName: "login" */
'../views/PlayerPrivate.vue'
)
},
{
path
:
"/game/:id"
,
name
:
"Game"
,
component
:
()
=>
import
(
/* webpackChunkName: "login" */
'../views/Game.vue'
)
}
}
]
]
...
...
This diff is collapsed.
Click to expand it.
frontend/src/views/AdminPrivate.vue
View file @
ba60d466
...
@@ -7,8 +7,7 @@
...
@@ -7,8 +7,7 @@
<h1
class=
"titre"
>
Code de la partie :
</h1>
<h1
class=
"titre"
>
Code de la partie :
</h1>
<h1
class=
"titre"
id=
"codeGame"
>
{{
gameID
()
}}
</h1>
<h1
class=
"titre"
id=
"codeGame"
>
{{
gameID
()
}}
</h1>
</div>
</div>
<div
class=
"joueurs"
>
<div
class=
"joueurs"
id=
"joueurs"
>
{{
JoueurPresent
()
}}
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -30,10 +29,11 @@
...
@@ -30,10 +29,11 @@
<
script
>
<
script
>
const
user
=
require
(
"../model/user.js"
)
const
user
=
require
(
"../model/user.js"
)
const
game
=
require
(
"../model/game.js"
)
const
game
=
require
(
"../model/game.js"
)
export
default
{
export
default
{
name
:
'AdminPrivate'
,
name
:
'AdminPrivate'
,
methods
:
{
methods
:
{
createIdGame
:
function
(){
createIdGame
:
async
function
(){
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/game"
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/game"
let
data
=
{
let
data
=
{
...
@@ -46,17 +46,17 @@ export default {
...
@@ -46,17 +46,17 @@ export default {
// console.log(user)
// console.log(user)
fetch
(
url
,
params
)
let
response
=
await
fetch
(
url
,
params
)
.
then
(
response
=>
response
.
json
())
let
result
=
await
response
.
json
()
.
then
(
data
=>
{
console
.
log
(
result
)
document
.
getElementById
(
"codeGame"
).
innerHTML
=
data
[
0
].
id
;
document
.
getElementById
(
"codeGame"
).
innerHTML
=
result
[
0
].
id
;
game
.
id
=
data
[
0
].
id
;
game
.
id
=
result
[
0
].
id
;
console
.
log
(
game
.
id
)
// console.log(game.id)
})
},
},
gameID
:
function
(){
gameID
:
async
function
(){
this
.
createIdGame
()
await
this
.
createIdGame
()
this
.
ajoutAdminGame
()
await
this
.
ajoutAdminGame
()
await
this
.
JoueurPresent
()
},
},
returnUserID
:
function
(){
returnUserID
:
function
(){
return
user
.
id
return
user
.
id
...
@@ -64,46 +64,48 @@ export default {
...
@@ -64,46 +64,48 @@ export default {
returnGameID
:
function
(){
returnGameID
:
function
(){
return
game
.
id
return
game
.
id
},
},
ajoutAdminGame
:
function
(){
JoueurPresentAppel
:
async
function
(){
await
this
.
JoueurPresent
()
},
ajoutAdminGame
:
async
function
(){
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser"
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser"
console
.
log
(
this
.
returnUserID
())
console
.
log
(
game
.
id
)
console
.
log
(
this
.
returnGameID
())
let
data
=
{
let
data
=
{
"GAME_ID"
:
this
.
returnGameID
()
,
"GAME_ID"
:
game
.
id
,
"USER_ID"
:
this
.
returnUserID
()
"USER_ID"
:
user
.
id
,
}
}
var
params
=
{
var
params
=
{
method
:
'POST'
,
method
:
'POST'
,
body
:
JSON
.
stringify
(
data
)
};
body
:
JSON
.
stringify
(
data
)
};
fetch
(
url
,
params
)
await
fetch
(
url
,
params
)
.
then
(
response
=>
response
.
json
())
},
},
JoueurPresent
:
function
(){
JoueurPresent
:
async
function
(){
let
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser/game"
let
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser/game"
console
.
log
(
game
.
id
)
url
+=
"/"
+
game
.
id
;
url
+=
"/"
+
game
.
id
;
var
params
=
{
var
params
=
{
method
:
"GET"
method
:
"GET"
}
}
fetch
(
url
,
params
)
let
response
=
await
fetch
(
url
,
params
)
.
then
(
response
=>
response
.
json
())
let
result
=
await
response
.
json
()
.
then
(
data
=>
{
let
text
=
""
;
console
.
log
(
data
)
result
.
forEach
(
user
=>
{
let
text
;
text
+=
`<tr><h2 class='joueur' id='joueur'>
${
user
.
USER_ID
}
</h2></tr>`
data
.
forEach
(
user
=>
{
});
text
+=
"<h2 class='joueur' id='joueur'>"
+
user
.
USER_ID
+
"</h2>"
document
.
getElementById
(
"joueurs"
).
innerHTML
=
text
});
if
(
result
.
length
>=
2
){
document
.
getElementById
(
"joueurs"
).
innerHTML
=
text
this
.
$router
.
push
(
`/game/
${
game
.
id
}
`
)
})
return
}
setTimeout
(()
=>
{
if
(
game
.
id
){
this
.
JoueurPresent
()}},
3000
)
// setInterval(() => {if(game.id){this.JoueurPresent()}}, 3000)
}
}
},
},
components
:{
components
:
{
LoginNavbar
LoginNavbar
}
}
,
}
}
import
LoginNavbar
from
'../components/LoginNavbar.vue'
import
LoginNavbar
from
'../components/LoginNavbar.vue'
</
script
>
</
script
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/views/ChoixPartie.vue
View file @
ba60d466
...
@@ -7,13 +7,13 @@
...
@@ -7,13 +7,13 @@
<div
class=
"row"
>
<div
class=
"row"
>
<div
class=
"column"
>
<div
class=
"column"
>
<tr
class =
"espaceBtn"
><button
class=
"partie"
>
<tr
class =
"espaceBtn"
><button
class=
"partie"
>
<router-link
to=
"/
choixParti
e"
>
Rejoindre une partie publique
</router-link>
<router-link
to=
"/
gam
e"
>
Rejoindre une partie publique
</router-link>
</button></tr>
</button></tr>
<tr
class =
"espaceBtn"
><button
class=
"partie"
>
<tr
class =
"espaceBtn"
><button
class=
"partie"
>
<router-link
to=
"/adminPrivate"
>
Créer une partie privée
</router-link>
<router-link
to=
"/adminPrivate"
>
Créer une partie privée
</router-link>
</button></tr>
</button></tr>
<tr
class =
"espaceBtn"
><button
class=
"partie"
>
<tr
class =
"espaceBtn"
><button
class=
"partie"
>
<router-link
to=
"/
choixParti
e"
>
Rejoindre une partie privée
</router-link>
<router-link
to=
"/
joinPrivat
e"
>
Rejoindre une partie privée
</router-link>
</button></tr>
</button></tr>
</div>
</div>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
frontend/src/views/Game.vue
0 → 100644
View file @
ba60d466
<
template
>
<div>
<span
class=
"scoreboard"
>
You:
{{
myScore
}}
- Oponent:
{{
oponentScore
}}
</span>
<div>
<div
v-on:click=
"select('rock')"
>
<img
id=
"rock"
src=
"https://www.flaticon.com/svg/static/icons/svg/838/838023.svg"
alt=
"rock"
>
</div>
<div
v-on:click=
"select('paper')"
>
<img
id=
"paper"
src=
"https://www.flaticon.com/svg/static/icons/svg/3039/3039835.svg"
alt=
"paper"
>
</div>
<div
v-on:click=
"select('scissors')"
>
<img
id=
"scissors"
src=
"https://www.flaticon.com/svg/static/icons/svg/760/760911.svg"
alt=
"scissors"
>
</div>
</div>
</div>
</
template
>
<
style
scoped
>
img
{
width
:
64px
;
height
:
64px
;
}
.selected
{
border
:
4px
solid
red
;
border-radius
:
10px
;
padding
:
15px
;
}
.scoreboard
{
margin-bottom
:
20px
;
font-size
:
larger
;
}
</
style
>
<
script
>
let
havePlayed
=
false
const
user
=
require
(
"../model/user.js"
)
export
default
{
name
:
"RockPaperScissors"
,
data
:
function
()
{
return
{
oponentScore
:
0
,
myScore
:
0
}
},
methods
:
{
select
:
async
function
(
value
)
{
const
gameID
=
window
.
location
.
href
.
split
(
"/"
).
slice
(
-
1
)[
0
]
if
(
havePlayed
)
return
this
.
resetStyle
()
havePlayed
=
true
document
.
getElementById
(
value
).
classList
.
add
(
"selected"
)
await
fetch
(
`http://localhost/felten/projet-cdaw/backend/MVC/api.php/result/
${
gameID
}
`
,
{
method
:
"POST"
,
body
:
JSON
.
stringify
({
value
,
USER_ID
:
user
.
id
})
})
await
this
.
getResult
(
gameID
,
value
)
},
getResult
:
async
function
(
gameID
,
value
)
{
const
res
=
await
fetch
(
`http://localhost/felten/projet-cdaw/backend/MVC/api.php/result/
${
gameID
}
`
,
{
method
:
"GET"
}
)
const
result
=
await
res
.
json
()
if
(
result
.
length
>=
2
)
{
this
.
updateScore
(
result
,
value
)
this
.
resetStyle
()
havePlayed
=
false
setTimeout
(
async
()
=>
{
this
.
resetGame
(
result
)},
2000
)
return
}
setTimeout
(
async
()
=>
{
await
this
.
getResult
(
gameID
,
value
)
},
1000
)
},
updateScore
:
function
(
result
,
value
)
{
console
.
log
(
result
)
console
.
log
(
user
.
id
)
let
i
=
0
;
if
(
result
[
0
][
'USER_ID'
]
==
user
.
id
){
i
=
1
}
const
valueAgainst
=
result
[
i
][
'RESULT_AWNSER'
]
if
(
value
===
"paper"
){
if
(
valueAgainst
===
"rock"
){
this
.
myScore
+=
1
}
else
if
(
valueAgainst
===
"scissors"
){
this
.
oponentScore
+=
1
}
}
else
if
(
value
===
"rock"
){
if
(
valueAgainst
===
"paper"
){
this
.
oponentScore
+=
1
}
else
if
(
valueAgainst
===
"scissors"
){
this
.
myScore
+=
1
}
}
else
{
if
(
valueAgainst
===
"paper"
){
this
.
myScore
+=
1
}
else
if
(
valueAgainst
===
"rock"
){
this
.
oponentScore
+=
1
}
}
if
(
this
.
myScore
>=
3
){
alert
(
"Vous avez gagné !"
)
this
.
$router
.
push
(
"/"
)
}
else
if
(
this
.
oponentScore
>=
3
){
alert
(
"Vous avez perdu ..."
)
this
.
$router
.
push
(
"/"
)
}
},
resetGame
:
async
function
(
result
)
{
let
i
=
0
;
if
(
result
[
0
][
'USER_ID'
]
==
user
.
id
){
i
=
1
}
await
fetch
(
'http://localhost/felten/projet-cdaw/backend/MVC/api.php/result'
,
{
method
:
"DELETE"
,
body
:
JSON
.
stringify
({
USER_ID
:
result
[
i
][
'USER_ID'
]})
}
)
},
resetStyle
:
function
()
{
document
.
getElementById
(
"rock"
).
classList
.
remove
(
"selected"
)
document
.
getElementById
(
"paper"
).
classList
.
remove
(
"selected"
)
document
.
getElementById
(
"scissors"
).
classList
.
remove
(
"selected"
)
}
}
}
</
script
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/views/Inscription.vue
View file @
ba60d466
...
@@ -138,7 +138,11 @@ export default {
...
@@ -138,7 +138,11 @@ export default {
},
},
call
:
function
(
data
){
call
:
function
(
data
){
const
url
=
"http://localhost/projet-cdaw/backend/MVC/api.php/user"
// Felten config
// const url = "http://localhost/projet-cdaw/backend/MVC/api.php/user"
// Robin config
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/user"
var
params
=
{
var
params
=
{
method
:
'POST'
,
method
:
'POST'
,
...
...
This diff is collapsed.
Click to expand it.
frontend/src/views/JoinPrivate.vue
0 → 100644
View file @
ba60d466
<
template
>
<div
class=
"inscription"
>
<LoginNavbar></LoginNavbar>
<div
class=
"row _centered"
>
<div
class=
"column _600"
>
<form>
<tr><label
class=
"label"
>
Code de la partie :
</label></tr>
<tr><input
v-model=
"idgame"
class=
"codeGame"
id=
"codeGame"
required
></tr>
<tr><button
@
click=
"rejoindre()"
type=
"submit"
id=
"btn"
>
Rejoindre
</button></tr>
</form>
</div>
</div>
</div>
</
template
>
<
script
>
const
user
=
require
(
"../model/user.js"
)
const
game
=
require
(
"../model/game.js"
)
export
default
{
name
:
'JoinPrivate'
,
data
(){
return
this
.
idgame
=
""
;
},
methods
:
{
rejoindre
:
async
function
(){
if
((
Number
(
this
.
idgame
)
!=
this
.
idgame
||
Number
(
this
.
idgame
)
<
0
)){
console
.
log
(
Number
(
this
.
idgame
)
!=
this
.
idgame
)
console
.
log
(
Number
(
this
.
idgame
)
<
0
)
return
}
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser"
let
data
=
{
"GAME_ID"
:
this
.
idgame
,
"USER_ID"
:
user
.
id
}
var
params
=
{
method
:
'POST'
,
body
:
JSON
.
stringify
(
data
)
};
game
.
id
=
this
.
idgame
;
let
response
=
await
fetch
(
url
,
params
)
console
.
log
(
response
)
this
.
$router
.
push
(
"/playerPrivate"
)
}
},
components
:
{
LoginNavbar
},
}
import
LoginNavbar
from
'../components/LoginNavbar.vue'
</
script
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
frontend/src/views/Login.vue
View file @
ba60d466
...
@@ -96,10 +96,11 @@ export default {
...
@@ -96,10 +96,11 @@ export default {
},
},
call
:
function
(
login
,
password
){
call
:
function
(
login
,
password
){
const
url
=
"http://localhost/projet-cdaw/backend/MVC/api.php/login"
// Felten config
// const url = "http://localhost/projet-cdaw/backend/MVC/api.php/login"
// Robin config
// Robin config
//
const url = "http://localhost/felten/projet-cdaw/backend/MVC/api.php/login"
const
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/login"
let
data
=
{
let
data
=
{
login
:
login
,
login
:
login
,
...
@@ -116,7 +117,7 @@ export default {
...
@@ -116,7 +117,7 @@ export default {
.
then
(
response
=>
{
.
then
(
response
=>
{
user
.
token
=
response
.
jwt_token
user
.
token
=
response
.
jwt_token
user
.
id
=
response
.
data
.
id
user
.
id
=
response
.
data
.
id
user
.
name
=
response
.
data
.
name
user
.
login
=
response
.
data
.
login
})
})
.
then
(
this
.
$router
.
push
(
"/"
))
.
then
(
this
.
$router
.
push
(
"/"
))
}
}
...
...
This diff is collapsed.
Click to expand it.
frontend/src/views/PlayerPrivate.vue
0 → 100644
View file @
ba60d466
<
template
>
<div
class=
"inscription"
>
<LoginNavbar></LoginNavbar>
<div
class=
"row _centered"
>
<div
class=
"column _600"
>
<div
class=
"codeGame"
>
<h1
class=
"titre"
>
Code de la partie :
</h1>
<h1
class=
"titre"
id=
"codeGame"
>
{{
gameID
()
}}
</h1>
</div>
<div
class=
"joueurs"
id=
"joueurs"
>
{{
JoueurPresent
()
}}
</div>
</div>
</div>
</div>
</
template
>
<
style
scoped
>
.inscription
{
height
:
100%
;
margin
:
0
auto
;
max-width
:
1200px
;
}
.titre
{
height
:
90%
;
}
</
style
>
<
script
>
// const user = require("../model/user.js")
const
game
=
require
(
"../model/game.js"
)
export
default
{
name
:
'PlayerPrivate'
,
methods
:
{
gameID
:
function
(){
return
game
.
id
},
JoueurPresent
:
async
function
(){
let
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser/game"
console
.
log
(
game
.
id
)
url
+=
"/"
+
game
.
id
;
var
params
=
{
method
:
"GET"
}
let
response
=
await
fetch
(
url
,
params
)
let
result
=
await
response
.
json
()
console
.
log
(
result
)
let
text
=
""
;
result
.
forEach
(
user
=>
{
text
+=
`<tr><h2 class='joueur' id='joueur'>
${
user
.
USER_ID
}
</h2></tr>`
});
console
.
log
(
text
)
document
.
getElementById
(
"joueurs"
).
innerHTML
=
text
if
(
result
.
length
>=
2
){
this
.
$router
.
push
(
`/game/
${
game
.
id
}
`
)
return
}
setTimeout
(()
=>
{
if
(
game
.
id
){
this
.
JoueurPresent
()}},
3000
)
}
},
components
:
{
LoginNavbar
},
}
import
LoginNavbar
from
'../components/LoginNavbar.vue'
</
script
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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