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

front

parent d7cc07a9
......@@ -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"));
}
......
......@@ -13,4 +13,6 @@ Online::addSqlQuery('ONLINE_IDMIN',
"SELECT USER_ID FROM (SELECT MIN(ONLINE_ID) AS MINID FROM ONLINE) AS MIN, ONLINE WHERE ONLINE.ONLINE_ID=MIN.MINID");
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");
\ No newline at end of file
"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'
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,
......
<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: {
......
<template>
<div>
<span class="scoreboard">You: {{myScore}} - Oponent: {{oponentScore}}</span>
<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;
......
<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")
......
<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('/')
}
},
......
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