Commit 52467e2d authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

iso in dB + duration of recording

parent 5fe2930b
......@@ -48,3 +48,4 @@ enregistrements/*
sys/db.config.php
sys/config.php
/add_cards.php
/debug.txt
......@@ -120,6 +120,7 @@ CREATE TABLE IF NOT EXISTS `enregistrement` (
`carteID` int(11) NOT NULL,
`nivcarte` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`validation` enum('valid','invalid','limbo') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'limbo',
`duration` TINYINT UNSIGNED NOT NULL COMMENT 'the length in seconds of the recording (max 255 sec)',
PRIMARY KEY (`enregistrementID`),
UNIQUE KEY `cheminEnregistrement` (`cheminEnregistrement`),
KEY `idOracle` (`idOracle`),
......@@ -299,6 +300,210 @@ INSERT INTO `user_niveau` (`id`, `userid`, `spoken_lang`, `niveau`) VALUES
INSERT INTO `score` (`scoreID`, `userid`, `scoreGlobal`, `scoreOracle`, `scoreDruide`, `scoreDevin`, `langue`, `first_game_time`) VALUES
(1, 1, 0, 0, 0, 0, 'Français', '');
-- --------------------------------------------------------
--
-- Structure de la table `langues`
--
CREATE TABLE IF NOT EXISTS `langues` (
`iso_code` varchar(3) CHARACTER SET utf8 NOT NULL COMMENT 'iso language code',
`french` varchar(16) CHARACTER SET utf8 NOT NULL COMMENT 'nom de la langue en FR',
`english` varchar(16) CHARACTER SET utf8 DEFAULT NULL COMMENT 'language name in English',
PRIMARY KEY (`iso_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Contenu de la table `langues`
--
INSERT INTO `langues` (`iso_code`, `french`, `english`) VALUES
('aa', 'Afar', NULL),
('ab', 'Abkhaze', NULL),
('ae', 'Avestique', NULL),
('af', 'Afrikaans', NULL),
('ak', 'Akan', NULL),
('am', 'Amharique', NULL),
('an', 'Aragonais', NULL),
('ar', 'Arabe', NULL),
('as', 'Assamais', NULL),
('av', 'Avar', NULL),
('ay', 'Aymara', NULL),
('az', 'Azéri', NULL),
('ba', 'Bachkir', NULL),
('be', 'Biélorusse', NULL),
('bg', 'Bulgare', NULL),
('bh', 'Bihari', NULL),
('bi', 'Bichelamar', NULL),
('bm', 'Bambara', NULL),
('bn', 'Bengali', NULL),
('bo', 'Tibétain', NULL),
('br', 'Breton', NULL),
('bs', 'Bosnien', NULL),
('ca', 'Catalan', NULL),
('ce', 'Tchétchène', NULL),
('ch', 'Chamorro', NULL),
('co', 'Corse', NULL),
('cr', 'Cri', NULL),
('cs', 'Tchèque', NULL),
('cu', 'Vieux-slave', NULL),
('cv', 'Tchouvache', NULL),
('cy', 'Gallois', NULL),
('da', 'Danois', NULL),
('de', 'Allemand', NULL),
('dv', 'Maldivien', NULL),
('dz', 'Dzongkha', NULL),
('ee', 'Ewe', NULL),
('el', 'Grec moderne', NULL),
('en', 'Anglais', 'English'),
('eo', 'Espéranto', NULL),
('es', 'Espagnol', NULL),
('et', 'Estonien', NULL),
('eu', 'Basque', NULL),
('fa', 'Persan', NULL),
('ff', 'Peul', NULL),
('fi', 'Finnois', NULL),
('fj', 'Fidjien', NULL),
('fo', 'Féroïen', NULL),
('fr', 'Français', NULL),
('fy', 'Frison', NULL),
('ga', 'Irlandais', NULL),
('gd', 'Écossais', NULL),
('gl', 'Galicien', NULL),
('gn', 'Guarani', NULL),
('gu', 'Gujarati', NULL),
('gv', 'Mannois', NULL),
('ha', 'Haoussa', NULL),
('he', 'Hébreu', NULL),
('hi', 'Hindi', NULL),
('ho', 'Hiri motu', NULL),
('hr', 'Croate', NULL),
('ht', 'Créole haïtien', NULL),
('hu', 'Hongrois', NULL),
('hy', 'Arménien', NULL),
('hz', 'Héréro', NULL),
('ia', 'Interlingua', NULL),
('id', 'Indonésien', NULL),
('ie', 'Occidental', NULL),
('ig', 'Igbo', NULL),
('ii', 'Yi', NULL),
('ik', 'Inupiak', NULL),
('io', 'Ido', NULL),
('is', 'Islandais', NULL),
('it', 'Italien', NULL),
('iu', 'Inuktitut', NULL),
('ja', 'Japonais', NULL),
('jv', 'Javanais', NULL),
('ka', 'Géorgien', NULL),
('kg', 'Kikongo', NULL),
('ki', 'Kikuyu', NULL),
('kj', 'Kuanyama', NULL),
('kk', 'Kazakh', NULL),
('kl', 'Groenlandais', NULL),
('km', 'Khmer', NULL),
('kn', 'Kannada', NULL),
('ko', 'Coréen', NULL),
('kr', 'Kanouri', NULL),
('ks', 'Cachemiri', NULL),
('ku', 'Kurde', NULL),
('kv', 'Komi', NULL),
('kw', 'Cornique', NULL),
('ky', 'Kirghiz', NULL),
('la', 'Latin', NULL),
('lb', 'Luxembourgeois', NULL),
('lg', 'Ganda', NULL),
('li', 'Limbourgeois', NULL),
('ln', 'Lingala', NULL),
('lo', 'Lao', NULL),
('lt', 'Lituanien', NULL),
('lu', 'Luba-katanga', NULL),
('lv', 'Letton', NULL),
('mg', 'Malgache', NULL),
('mh', 'Marshallais', NULL),
('mi', 'Maori de Nouvell', NULL),
('mk', 'Macédonien', NULL),
('ml', 'Malayalam', NULL),
('mn', 'Mongol', NULL),
('mo', 'Moldave', NULL),
('mr', 'Marathi', NULL),
('ms', 'Malais', NULL),
('mt', 'Maltais', NULL),
('my', 'Birman', NULL),
('na', 'Nauruan', NULL),
('nb', 'Norvégien Bokmål', NULL),
('nd', 'Sindebele', NULL),
('ne', 'Népalais', NULL),
('ng', 'Ndonga', NULL),
('nl', 'Néerlandais', NULL),
('nn', 'Norvégien Nynors', NULL),
('no', 'Norvégien', NULL),
('nr', 'Nrebele', NULL),
('nv', 'Navajo', NULL),
('ny', 'Chichewa', NULL),
('oc', 'Occitan', NULL),
('oj', 'Ojibwé', NULL),
('om', 'Oromo', NULL),
('or', 'Oriya', NULL),
('os', 'Ossète', NULL),
('pa', 'Pendjabi', NULL),
('pi', 'Pali', NULL),
('pl', 'Polonais', NULL),
('ps', 'Pachto', NULL),
('pt', 'Portugais', NULL),
('qu', 'Quechua', NULL),
('rm', 'Romanche', NULL),
('rn', 'Kirundi', NULL),
('ro', 'Roumain', NULL),
('ru', 'Russe', NULL),
('rw', 'Kinyarwanda', NULL),
('sa', 'Sanskrit', NULL),
('sc', 'Sarde', NULL),
('sd', 'Sindhi', NULL),
('se', 'Same du Nord', NULL),
('sg', 'Sango', NULL),
('si', 'Cingalais', NULL),
('sk', 'Slovaque', NULL),
('sl', 'Slovène', NULL),
('sm', 'Samoan', NULL),
('sn', 'Shona', NULL),
('so', 'Somali', NULL),
('sq', 'Albanais', NULL),
('sr', 'Serbe', NULL),
('ss', 'Swati', NULL),
('st', 'Sotho du Sud', NULL),
('su', 'Soundanais', NULL),
('sv', 'Suédois', NULL),
('sw', 'Swahili', NULL),
('ta', 'Tamoul', NULL),
('te', 'Télougou', NULL),
('tg', 'Tadjik', NULL),
('th', 'Thaï', NULL),
('ti', 'Tigrigna', NULL),
('tk', 'Turkmène', NULL),
('tl', 'Tagalog', NULL),
('tn', 'Tswana', NULL),
('to', 'Tongien', NULL),
('tr', 'Turc', NULL),
('ts', 'Tsonga', NULL),
('tt', 'Tatar', NULL),
('tw', 'Twi', NULL),
('ty', 'Tahitien', NULL),
('ug', 'Ouïghour', NULL),
('uk', 'Ukrainien', NULL),
('ur', 'Ourdou', NULL),
('uz', 'Ouzbek', NULL),
('ve', 'Venda', NULL),
('vi', 'Vietnamien', NULL),
('vo', 'Volapük', NULL),
('wa', 'Wallon', NULL),
('wo', 'Wolof', NULL),
('xh', 'Xhosa', NULL),
('yi', 'Yiddish', NULL),
('yo', 'Yoruba', NULL),
('za', 'Zhuang', NULL),
('zh', 'Chinois', NULL),
('zu', 'Zoulou', NULL);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<?php
session_start();
error_reporting(E_ALL);//error_reporting(0); dsactiver
error_reporting(E_ALL);//error_reporting(0); désactiver
ini_set('display_errors', '1');
header('Content-Type: text/html; charset=UTF-8');
require('./sys/utils.func.php');
......@@ -14,13 +14,12 @@ require('./languages/language.php');
$user = user::getInstance();
$userlogged = $user->logged_in();
if ( !$userlogged ){
header('Location: index.php');
header('Location: index.php');
}
else{
$title = 'Game of Words / Administration';
include('./views/page.header.html');
include('./controllersJS/menu_lang.js');
include('./sys/load_iso.php');
echo "<h1>".$lang['admin']."</h1>";
require_once('./models/item.factory.class.php');
$cardFactory = new ItemFactory($user->id,$user->langGame);
......@@ -32,4 +31,4 @@ else{
echo $card;
}
}
?>
\ No newline at end of file
?>
......@@ -7,16 +7,16 @@ class diviner_game
private $mode = '';
private $errors = array();
private $lang = array();
private $lang = array();
private $motadeviner='';
private $nivcarte = '';
private $userlang = '';
private $user= '';
private $diviner= '';
private $pointsSanction ='';
private $raisin ='';
private $res2 = '';
private $card = '';
......@@ -24,10 +24,10 @@ class diviner_game
private $result= '';
private $sanction ='';
private $score='';
private $carteValide = false;
private $adresse = '';
private $reussie = 'en cours';
private $temps='';
......@@ -43,9 +43,9 @@ class diviner_game
{
if ( $this->init() )
{
$this->sanctionLastPartie();
$this->sanctionLastPartie();
if($this->selectpartie()){
$this->update();
$this->update();
}
return $this->display();
}
......@@ -81,16 +81,17 @@ class diviner_game
private function sanctionLastPartie()
{ // fonction qui permet de vérifier l'état de la dernière partie et de sanctionner le joueur de 5 pts s'il a quitté la partitatut = "en cours")
include_once('./sys/load_iso.php');
$lang_iso = new IsoLang();
$db = db::getInstance();
$sql = "SELECT *
FROM parties WHERE idDevin = \"".$this->diviner."\"
FROM parties WHERE idDevin = \"".$this->diviner."\"
ORDER BY parties.tpsDevin DESC
LIMIT 1";
$res=$db->query($sql);
$this->sanction = mysqli_fetch_assoc($res);
if($this->sanction['reussie'] == "en cours"){
$sql = "SELECT *
FROM sanctionCarte
WHERE idDevin ='".$this->diviner."' AND enregistrementID='".$this->sanction['enregistrementID']."'";
......@@ -101,23 +102,23 @@ class diviner_game
$sql = "INSERT INTO sanctionCarte
(idDevin,enregistrementID)
VALUES (".$this->diviner.",".$this->sanction['enregistrementID'].")";
if( $res = $db->query($sql)){
$sql = "SELECT scoreDevin, scoreGlobal
FROM score
WHERE userid ='".$this->diviner."' AND langue='" . $iso[$this->userlang] . "'";
WHERE userid ='".$this->diviner."' AND langue='" . $lang_iso->french_for($this->userlang) . "'";
$res = $db->query($sql);
$this->score = mysqli_fetch_assoc($res);
$this->score = mysqli_fetch_assoc($res);
if ($this->score['scoreDevin'] >= $this->pointsSanction) { #à modifier avec un fichier config
$this->score['scoreDevin']-=$this->pointsSanction;
$this->score['scoreGlobal']-=$this->pointsSanction;
$sql='UPDATE score
$sql='UPDATE score
SET scoreDevin="'.$this->score['scoreDevin'].'", scoreGlobal ="'.$this->score['scoreGlobal'].'"
WHERE userid="'.$this->diviner.'" AND langue="' . $iso[$this->userlang] . '"';
WHERE userid="'.$this->diviner.'" AND langue="' . $lang_iso->french_for($this->userlang) . '"';
$res=$db->query($sql);
array_push($this->lang,"sanction");
}
......@@ -174,18 +175,18 @@ class diviner_game
}
}
catch(Exception $e){
array_push($this->errors,'NoGame');
array_push($this->errors,'NoGame');
}
$this->setcarteValide($res);
return $res;
}
private function update()
{
//Insertion des informations dans la table parties
//connexion à  la bd
//connexion à  la bd
$db = db::getInstance();
$sql = 'INSERT INTO parties
(enregistrementID,idDevin,tpsDevin,reussie)
VALUES(' .
......@@ -200,7 +201,7 @@ class diviner_game
private function display()
{
include('./views/diviner.game.html');
return true;
}
......@@ -210,4 +211,3 @@ class diviner_game
}
?>
......@@ -9,13 +9,13 @@ class diviner_result
private $userlvl = '';
private $lang = '';
private $devinName ='';
private $previousSGDev = 0;
private $previousSDev = 0;
private $previousSGOracle = 0;
private $previousSOracle = 0;
private $pointsDev = 10;
private $reussie = 'oui';
public function set_mode($mode)
......@@ -33,10 +33,14 @@ class diviner_result
return false;
}
public function __construct(){
require_once('./sys/load_iso.php');
}
private function init()
{
include('./sys/load_iso.php');
{
$lang_iso = new IsoLang();
$db = db::getInstance();
//Récupération des informaions de base: userid
$this->user = user::getInstance();
......@@ -51,14 +55,14 @@ class diviner_result
$i=0;
while ($i<count($spoken_lang)) {
if(strcmp($iso[$this->lang],$spoken_lang[$i]) == 0){
if(strcmp($lang_iso->french_for($this->lang),$spoken_lang[$i]) == 0){
break;
}
$i++;
}
if($i!=count($spoken_lang)){
$lang_lvl = explode(';',$res['niveau'])[$i];
$sql = 'SELECT * FROM coeff_niveau_langue WHERE niveau_langue="' . $lang_lvl . '"';
$result = $db->query($sql);
$this->lang_lvl_pts = mysqli_fetch_assoc($result)['coeff'];
......@@ -79,36 +83,39 @@ class diviner_result
{
if(!isset($_SESSION["motDeviner"]))
{
include('./sys/load_iso.php');
$lang_iso = new IsoLang();
require_once('./controllers/update_score_coeff.php');
//connexion à la BD
$db = db::getInstance();
updateScoreDevinSucces($this->devin,$iso[$_SESSION["langDevin"]],$this->points);
updateScoreDevinSucces($this->devin,$lang_iso->french_for($_SESSION["langDevin"]),$this->points);
$pointsCoef = $this->points*$this->lang_lvl_pts;
$_SESSION["pointsCoef"] = $pointsCoef;
$db = db::getInstance();
$sql = 'UPDATE parties
$sql = 'UPDATE parties
SET reussie='.$db->escape((string) $this->reussie).'
WHERE idDevin='.$this->devin.' ORDER BY tpsDevin DESC LIMIT 1 ';
WHERE idDevin='.$this->devin.' ORDER BY tpsDevin DESC LIMIT 1 ';
$db->query($sql);
//Récupération de enregistrementID
$sql = 'SELECT enregistrementID FROM parties WHERE idDevin="'.$this->devin.'" ORDER BY tpsDevin DESC LIMIT 1 ';
$res1=$db->query($sql);
$res1=$db->query($sql);
$this->res2= mysqli_fetch_assoc($res1);
// récupération de l'id de l'oracle et de la carte grâce à enregistrementID
$sql = 'SELECT idOracle,carteID,OracleLang
FROM enregistrement WHERE enregistrementID='.$this->res2['enregistrementID'].'';
$res1=$db->query($sql);
FROM enregistrement WHERE enregistrementID='.$this->res2['enregistrementID'].'';
$res1=$db->query($sql);
$res3= mysqli_fetch_assoc($res1);
updateScoreOracleDevinSucces($res3["idOracle"],$iso[$res3["OracleLang"]],$this->res2['enregistrementID']);
updateScoreOracleDevinSucces($res3["idOracle"],$lang_iso->french_for($res3["OracleLang"]),$this->res2['enregistrementID']);
echo "updateScoreOracleDevinSucces(".$res3["idOracle"].",".$lang_iso->french_for($res3["OracleLang"]).",".$this->res2['enregistrementID'].");";/**/
$this->oracle=$res3["idOracle"];
// récupération du contenu de la carte avec carteID
require_once("./models/card.class.php");
$carte = new Card($res3['carteID']);
......@@ -120,14 +127,14 @@ class diviner_result
}
else{
header('Location: index.php?page.home.html');
header('Location: index.php?page.home.html');
return false;
}
}
private function display()
{
$_SESSION["notif"]["notification_done"]["Devin"] = 'points';
$_SESSION["notif"]["notification_done"]["Devin"] = 'points';
include('./views/diviner.result.html');
return true;
}
......
......@@ -4,7 +4,7 @@ require_once("./models/card.class.php");
class diviner_timeout
{
private $mode = '';
private $user = '';
private $diviner = '';
private $devinName='';
......@@ -13,7 +13,7 @@ class diviner_timeout
private $previousSGO = 0;
private $previousSO = 0;
private $res = '';
private $reussie ='non';
......@@ -38,7 +38,7 @@ class diviner_timeout
{
//récupération des informations de base : userid
$this->user = user::getInstance();
$this->diviner = $this->user->id;
$this->diviner = $this->user->id;
$this->devinName = $this->user->username;
$this->userlvl = userlvl::getInstance();
$this->points= $this->userlvl->get_points();
......@@ -49,67 +49,41 @@ class diviner_timeout
private function carte_et_scoreOracle()
{
include('./sys/load_iso.php');
require_once('./sys/load_iso.php');
require_once('./controllers/update_score_coeff.php');
if(!isset($_SESSION["timeOutOracle"])){
// récupération d'enregistrementID pour récupérer l'id de l'Oracle et l'id de la carte
//connexion à la BD
$db = db::getInstance();
//Récupération de enregistrementID
$sql = 'SELECT enregistrementID FROM parties WHERE idDevin="'.$this->diviner.'" ORDER BY tpsDevin DESC LIMIT 1 ';
$res1=$db->query($sql);
$res1=$db->query($sql);
$this->res2= mysqli_fetch_assoc($res1);
// récupération de l'id de l'oracle et de la carte grâce à enregistrementID
$sql = 'SELECT idOracle,carteID,OracleLang
FROM enregistrement WHERE enregistrementID='.$this->res2['enregistrementID'].'';
$res1=$db->query($sql);
FROM enregistrement WHERE enregistrementID='.$this->res2['enregistrementID'].'';
$res1=$db->query($sql);
$res3= mysqli_fetch_assoc($res1);
$this->oracle = $res3['idOracle'];
$this->oracle = $res3['idOracle'];
// récupération du contenu de la carte avec carteID
$carte = new Card($res3['carteID']);
$this->res= $carte->dirtify();
// Requête de modification des scores de l'Oracle qui a fait une description non trouvée par le devin
updateScoreOracleDevinEchec($this->oracle,$iso[$res3["OracleLang"]],$this->res2['enregistrementID']);
//~ //récupération du score précédent;
//~ $sql = 'SELECT `scoreGlobal`,`scoreOracle` FROM `score` WHERE `userid`="'.$this->oracle.'" AND langue="'.$iso[$res3["OracleLang"]].'"';
//~ $result=$db->query($sql);
//~ $res5= mysqli_fetch_assoc($result);
//~ $this->previousSGO= $res5['scoreGlobal'];
//~ $this->previousSO= $res5['scoreOracle'];
//~
//~ //maj des variables de scores: le score ne doit jamais être négatif.
//~ $points = $this->points*0.5;
//~ $_SESSION["pointsCoef"] = $points;
//~
//~ if($this->previousSO >= $points)
//~ {
//~ $this->previousSGO = $this->previousSGO - $points;
//~ $this->previousSO = $this->previousSO - $points;
//~ }
//~ //maj du score dans la BD
//~ $sql = 'UPDATE score
//~ SET scoreGlobal='.$db->escape((string) $this->previousSGO) . ', ' .
//~ 'scoreOracle='.$db->escape((string) $this->previousSO) . '
//~ WHERE userid='.$this->oracle.' AND langue="'.$iso[$res3["OracleLang"]].'"';
//~
//~ $db->query($sql);
$lang_iso = new IsoLang();
updateScoreOracleDevinEchec($this->oracle,$lang_iso->french_for($res3["OracleLang"]),$this->res2['enregistrementID']);
$_SESSION["timeOutOracle"]=true;
return false;
}
else{
header('Location: index.php?page.home.html');
return false;
header('Location: index.php?page.home.html');
return false;
}
}
......@@ -117,12 +91,12 @@ class diviner_timeout
{
// Requête de mise à jour de la table partie
$db = db::getInstance();
$sql = 'UPDATE parties
$sql = 'UPDATE parties
SET reussie='.$db->escape((string) $this->reussie).'
WHERE idDevin='.$this->diviner.' ORDER BY tpsDevin DESC LIMIT 1 ';