Commit 895f4369 authored by Robin Borgogno's avatar Robin Borgogno

front

parent d7cc07a9
...@@ -30,7 +30,8 @@ class OnlineController extends Controller { ...@@ -30,7 +30,8 @@ class OnlineController extends Controller {
case 'DELETE': case 'DELETE':
$id = $this->request->getURIParams()[0]; $id = $this->request->getURIParams()[0];
return $this->deleteUserOnline($id); $data = json_decode(file_get_contents("php://input"),TRUE);
return $this->deleteUserOnline($id,$data);
break; break;
case 'OPTIONS': case 'OPTIONS':
...@@ -53,9 +54,10 @@ class OnlineController extends Controller { ...@@ -53,9 +54,10 @@ class OnlineController extends Controller {
return Response::okresponse(json_encode("It's ok bro")); return Response::okresponse(json_encode("It's ok bro"));
} }
public function deleteUserOnline($id) public function deleteUserOnline($id,$data)
{ {
Online::deleteUserOnline(array(":id" => $id)); 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")); return Response::okresponse(json_encode("It's ok bro for delete"));
} }
......
...@@ -14,3 +14,5 @@ Online::addSqlQuery('ONLINE_IDMIN', ...@@ -14,3 +14,5 @@ Online::addSqlQuery('ONLINE_IDMIN',
Online::addSqlQuery('ONLINE_IDGAME', 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"); "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");
...@@ -4,7 +4,7 @@ import router from './router' ...@@ -4,7 +4,7 @@ import router from './router'
Vue.config.productionTip = false 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({ new Vue({
router, router,
......
<template> <template>
<div class="inscription"> <center class="inscription">
<LoginNavbar></LoginNavbar> <LoginNavbar></LoginNavbar>
<div class="row _centered"> <div class="espace">
<div class="column _600"> <div class="column _600">
<div class="codeGame"> <div class="codeGame">
<h1 class="titre"> Code de la partie :</h1> <h1 class="titre"> Code de la partie :</h1>
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
</div> </div>
</div> </div>
</div> </div>
</div> <button class="btn" @click="retour()" id="btn">Retour</button>
</center>
</template> </template>
<style scoped> <style scoped>
...@@ -24,6 +25,23 @@ ...@@ -24,6 +25,23 @@
.titre{ .titre{
height: 90%; 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> </style>
<script> <script>
...@@ -102,6 +120,21 @@ export default { ...@@ -102,6 +120,21 @@ export default {
} }
setTimeout(() => {if(game.id){this.JoueurPresent()}}, 3000) setTimeout(() => {if(game.id){this.JoueurPresent()}}, 3000)
// setInterval(() => {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: { components: {
......
<template> <template>
<div> <div class="espace">
<div class="separation">
<span class="scoreboard">You: {{myScore}} - Oponent: {{oponentScore}}</span> <span class="scoreboard">You: {{myScore}} - Oponent: {{oponentScore}}</span>
</div>
<div> <div>
<div v-on:click="select('rock')"> <div v-on:click="select('rock')">
<img id="rock" src="https://www.flaticon.com/svg/static/icons/svg/838/838023.svg" alt="rock"> <img id="rock" src="https://www.flaticon.com/svg/static/icons/svg/838/838023.svg" alt="rock">
...@@ -26,6 +28,17 @@ ...@@ -26,6 +28,17 @@
padding: 15px; padding: 15px;
} }
tr {height: 20%;}
.espace {
padding: 5%;
}
.separation {
padding: 5%;
}
.scoreboard { .scoreboard {
margin-bottom: 20px; margin-bottom: 20px;
font-size: larger; font-size: larger;
......
<template> <template>
<div class="inscription"> <div class="inscription">
<LoginNavbar></LoginNavbar> <LoginNavbar></LoginNavbar>
<div class="row _centered"> <center class="column _600">
<div class="column _600">
<tr><label class="label">Code de la partie :</label></tr> <tr><label class="label">Code de la partie :</label></tr>
<tr><input v-model="idgame" class="codeGame" id="codeGame" required></tr> <tr><input v-model="idgame" class="codeGame" id="codeGame" required></tr>
<tr><button @click="rejoindre()" id="btn">Rejoindre</button></tr> <tr><button class="btn" @click="rejoindre()" id="btn">Rejoindre</button></tr>
</div> <tr><button class="btn">
</div> <router-link to="/choixPartie">Retour</router-link>
</button></tr>
</center>
</div> </div>
</template> </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> <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")
......
<template> <template>
<div class="page" onload="ajouterUser()"> <center class="page" onload="ajouterUser()">
<div class = "titre" >Veuillez patienter ...</div> <div class = "titre" >Veuillez patienter ...</div>
<tr></tr>
</div> <button class="btn" @click="retour()" id="btn">Retour</button>
</center>
</template> </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> <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")
...@@ -12,6 +43,7 @@ const game = require("../model/game.js") ...@@ -12,6 +43,7 @@ const game = require("../model/game.js")
export default { export default {
name: 'ChoixPartie', name: 'ChoixPartie',
methods: { methods: {
ajouterUser: async function() { ajouterUser: async function() {
await fetch( await fetch(
`http://localhost/felten/projet-cdaw/backend/MVC/api.php/online/${user.id}`, `http://localhost/felten/projet-cdaw/backend/MVC/api.php/online/${user.id}`,
...@@ -21,6 +53,7 @@ export default { ...@@ -21,6 +53,7 @@ export default {
) )
await this.findGame() await this.findGame()
}, },
findGame: async function(){ findGame: async function(){
console.log(user.id) console.log(user.id)
const res = await fetch( const res = await fetch(
...@@ -33,6 +66,7 @@ export default { ...@@ -33,6 +66,7 @@ export default {
const result = await res.json() const result = await res.json()
console.log(result) console.log(result)
if (result.length >= 1) { if (result.length >= 1) {
game.id = result
console.log(result) console.log(result)
this.goGame(result) this.goGame(result)
return return
...@@ -41,6 +75,7 @@ export default { ...@@ -41,6 +75,7 @@ export default {
await this.findGame() await this.findGame()
}, 1000) }, 1000)
}, },
goGame: async function(gameID) { goGame: async function(gameID) {
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(gameID) console.log(gameID)
...@@ -56,6 +91,21 @@ export default { ...@@ -56,6 +91,21 @@ export default {
return return
} }
setTimeout(() => {this.goGame(gameID)}, 2000) 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('/')
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment