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
895f4369
Commit
895f4369
authored
Dec 03, 2020
by
Robin Borgogno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
front
parent
d7cc07a9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
158 additions
and
17 deletions
+158
-17
OnlineController.class.php
backend/MVC/controller/OnlineController.class.php
+4
-2
Online.sql.php
backend/MVC/sql/Online.sql.php
+3
-1
panda.jpg
frontend/src/assets/img/panda.jpg
+0
-0
main.js
frontend/src/main.js
+1
-1
AdminPrivate.vue
frontend/src/views/AdminPrivate.vue
+36
-3
Game.vue
frontend/src/views/Game.vue
+15
-2
JoinPrivate.vue
frontend/src/views/JoinPrivate.vue
+46
-5
Online.vue
frontend/src/views/Online.vue
+53
-3
No files found.
backend/MVC/controller/OnlineController.class.php
View file @
895f4369
...
...
@@ -30,7 +30,8 @@ class OnlineController extends Controller {
case
'DELETE'
:
$id
=
$this
->
request
->
getURIParams
()[
0
];
return
$this
->
deleteUserOnline
(
$id
);
$data
=
json_decode
(
file_get_contents
(
"php://input"
),
TRUE
);
return
$this
->
deleteUserOnline
(
$id
,
$data
);
break
;
case
'OPTIONS'
:
...
...
@@ -53,9 +54,10 @@ class OnlineController extends Controller {
return
Response
::
okresponse
(
json_encode
(
"It's ok bro"
));
}
public
function
deleteUserOnline
(
$id
)
public
function
deleteUserOnline
(
$id
,
$data
)
{
Online
::
deleteUserOnline
(
array
(
":id"
=>
$id
));
Game
::
deleteUserGame
(
array
(
":GAME_ID"
=>
$data
[
'GAME_ID'
],
':USER_ID'
=>
$id
));
return
Response
::
okresponse
(
json_encode
(
"It's ok bro for delete"
));
}
...
...
backend/MVC/sql/Online.sql.php
View file @
895f4369
...
...
@@ -14,3 +14,5 @@ Online::addSqlQuery('ONLINE_IDMIN',
Online
::
addSqlQuery
(
'ONLINE_IDGAME'
,
"SELECT GAME_HISTO.* FROM (SELECT MAX(GAME_ID) AS MAXID FROM GAME WHERE GAME.GAME_PRIVATE = 0) AS MAXI, GAME_HISTO WHERE GAME_HISTO.GAME_ID=MAXI.MAXID"
);
frontend/src/assets/img/panda.jpg
0 → 100644
View file @
895f4369
9.15 KB
frontend/src/main.js
View file @
895f4369
...
...
@@ -4,7 +4,7 @@ import router from './router'
Vue
.
config
.
productionTip
=
false
sessionStorage
.
setItem
(
'APIURL'
,
'http://localhost/projet-cdaw/backend/MVC/api.php'
)
sessionStorage
.
setItem
(
'APIURL'
,
'http://localhost/
felten/
projet-cdaw/backend/MVC/api.php'
)
new
Vue
({
router
,
...
...
frontend/src/views/AdminPrivate.vue
View file @
895f4369
<
template
>
<
div
class=
"inscription"
>
<
center
class=
"inscription"
>
<LoginNavbar></LoginNavbar>
<div
class=
"
row _centered
"
>
<div
class=
"
espace
"
>
<div
class=
"column _600"
>
<div
class=
"codeGame"
>
<h1
class=
"titre"
>
Code de la partie :
</h1>
...
...
@@ -11,7 +11,8 @@
</div>
</div>
</div>
</div>
<button
class=
"btn"
@
click=
"retour()"
id=
"btn"
>
Retour
</button>
</center>
</
template
>
<
style
scoped
>
...
...
@@ -24,6 +25,23 @@
.titre
{
height
:
90%
;
}
.espace
{
padding
:
10%
;
}
.btn
{
background-color
:
transparent
;
border-radius
:
10px
;
border
:
4px
solid
#403d39
;
cursor
:
pointer
;
color
:
#403d39
;
font-size
:
28px
;
padding
:
16px
31px
;
font-weight
:
bold
;
white-space
:
nowrap
;
margin-left
:
1%
;
}
</
style
>
<
script
>
...
...
@@ -102,6 +120,21 @@ export default {
}
setTimeout
(()
=>
{
if
(
game
.
id
){
this
.
JoueurPresent
()}},
3000
)
// setInterval(() => {if(game.id){this.JoueurPresent()}}, 3000)
},
retour
:
async
function
()
{
let
data
=
{
"GAME_ID"
:
game
.
id
}
await
fetch
(
`http://localhost/felten/projet-cdaw/backend/MVC/api.php/online/
${
user
.
id
}
`
,
{
method
:
"DELETE"
,
body
:
JSON
.
stringify
(
data
)
}
)
this
.
$router
.
push
(
'/'
)
}
},
components
:
{
...
...
frontend/src/views/Game.vue
View file @
895f4369
<
template
>
<div>
<div
class=
"espace"
>
<div
class=
"separation"
>
<span
class=
"scoreboard"
>
You:
{{
myScore
}}
- Oponent:
{{
oponentScore
}}
</span>
</div>
<div>
<div
v-on:click=
"select('rock')"
>
<img
id=
"rock"
src=
"https://www.flaticon.com/svg/static/icons/svg/838/838023.svg"
alt=
"rock"
>
...
...
@@ -26,6 +28,17 @@
padding
:
15px
;
}
tr
{
height
:
20%
;}
.espace
{
padding
:
5%
;
}
.separation
{
padding
:
5%
;
}
.scoreboard
{
margin-bottom
:
20px
;
font-size
:
larger
;
...
...
frontend/src/views/JoinPrivate.vue
View file @
895f4369
<
template
>
<div
class=
"inscription"
>
<LoginNavbar></LoginNavbar>
<div
class=
"row _centered"
>
<div
class=
"column _600"
>
<center
class=
"column _600"
>
<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()"
id=
"btn"
>
Rejoindre
</button></tr>
</div>
</div>
<tr><button
class=
"btn"
@
click=
"rejoindre()"
id=
"btn"
>
Rejoindre
</button></tr>
<tr><button
class=
"btn"
>
<router-link
to=
"/choixPartie"
>
Retour
</router-link>
</button></tr>
</center>
</div>
</
template
>
<
style
scoped
>
.btn
{
background-color
:
transparent
;
border-radius
:
10px
;
border
:
4px
solid
#403d39
;
cursor
:
pointer
;
color
:
#403d39
;
font-family
:
Arial
;
font-size
:
28px
;
padding
:
16px
31px
;
font-weight
:
bold
;
margin
:
1%
;
}
center
{
padding-top
:
10%
;}
.codeGame
{
height
:
1.5em
;
width
:
35%
;
padding
:
16px
31px
;
font-size
:
28px
;
background-color
:
transparent
;
font-weight
:
bold
;
}
.label
{
height
:
1.5em
;
width
:
35%
;
padding
:
16px
31px
;
font-size
:
28px
;
background-color
:
transparent
;
font-weight
:
bold
;
}
tr
{
width
:
40%
}
</
style
>
<
script
>
const
user
=
require
(
"../model/user.js"
)
const
game
=
require
(
"../model/game.js"
)
...
...
frontend/src/views/Online.vue
View file @
895f4369
<
template
>
<
div
class=
"page"
onload=
"ajouterUser()"
>
<
center
class=
"page"
onload=
"ajouterUser()"
>
<div
class =
"titre"
>
Veuillez patienter ...
</div>
</div>
<tr></tr>
<button
class=
"btn"
@
click=
"retour()"
id=
"btn"
>
Retour
</button>
</center>
</
template
>
<
style
scoped
>
.titre
{
height
:
1.5em
;
width
:
35%
;
padding
:
16px
31px
;
font-size
:
28px
;
background-color
:
transparent
;
font-weight
:
bold
;
}
.btn
{
background-color
:
transparent
;
border-radius
:
10px
;
border
:
4px
solid
#403d39
;
cursor
:
pointer
;
color
:
#403d39
;
font-size
:
28px
;
padding
:
16px
31px
;
font-weight
:
bold
;
white-space
:
nowrap
;
margin-left
:
1%
;
}
tr
{
height
:
100px
;}
center
{
padding-top
:
10%
;}
</
style
>
<
script
>
const
user
=
require
(
"../model/user.js"
)
const
game
=
require
(
"../model/game.js"
)
...
...
@@ -12,6 +43,7 @@ const game = require("../model/game.js")
export
default
{
name
:
'ChoixPartie'
,
methods
:
{
ajouterUser
:
async
function
()
{
await
fetch
(
`http://localhost/felten/projet-cdaw/backend/MVC/api.php/online/
${
user
.
id
}
`
,
...
...
@@ -21,6 +53,7 @@ export default {
)
await
this
.
findGame
()
},
findGame
:
async
function
(){
console
.
log
(
user
.
id
)
const
res
=
await
fetch
(
...
...
@@ -33,6 +66,7 @@ export default {
const
result
=
await
res
.
json
()
console
.
log
(
result
)
if
(
result
.
length
>=
1
)
{
game
.
id
=
result
console
.
log
(
result
)
this
.
goGame
(
result
)
return
...
...
@@ -41,6 +75,7 @@ export default {
await
this
.
findGame
()
},
1000
)
},
goGame
:
async
function
(
gameID
)
{
let
url
=
"http://localhost/felten/projet-cdaw/backend/MVC/api.php/gameuser/game"
console
.
log
(
gameID
)
...
...
@@ -56,6 +91,21 @@ export default {
return
}
setTimeout
(()
=>
{
this
.
goGame
(
gameID
)},
2000
)
},
retour
:
async
function
()
{
let
data
=
{
"GAME_ID"
:
game
.
id
}
await
fetch
(
`http://localhost/felten/projet-cdaw/backend/MVC/api.php/online/
${
user
.
id
}
`
,
{
method
:
"DELETE"
,
body
:
JSON
.
stringify
(
data
)
}
)
this
.
$router
.
push
(
'/'
)
}
},
...
...
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