Commit 56c2a8f3 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

re-trial (bad recording - no score associated)

parent 37ccb36b
......@@ -55,6 +55,7 @@ class diviner_result
$this->record_id = $db->fetch_assoc()["@id_enr"];
$tmpRecording = new Recording($this->record_id);
$this->oracle = $tmpRecording->get_oracle_id();
$this->rec_level = $tmpRecording->get_level();
//mise à jour des scores
require_once('./controllers/update_score_coeff.php');
......
......@@ -21,6 +21,7 @@ class druid_arbitrage
private $adresse = '';
private $oracle = '';
private $enregistrement='';
private $revoke=false;
private $valid = 'valid';
private $invalid = 'invalid';
......@@ -30,11 +31,26 @@ class druid_arbitrage
$this->mode = $mode;
}
private function readyToApplyDecision(){
return isset($this->invalidate);
}
private function invalidate(){
$res = "not set";
if(isset($this->invalidate)){
$res = $this->invalidate;
}
return $res;
}
public function process()
{
if ( $this->init() )
{
$this->selectpartie();
if(!$this->readyToApplyDecision()){
//to be able to use it even without using the druid interface
$this->selectpartie();
}
return $this->display_et_scores();
}
return false;
......@@ -42,12 +58,33 @@ class druid_arbitrage
private function init()
{
$res = true;
//récupération des informations de bases : userid, langue et la date
$this->user = user::getInstance();
$this->druid = $this->user->id;
$this->userlang = $this->user->langGame;
return true;
//cas où on effectue un traitement
if(isset($_POST["enregistrement1"])){
$this->enregistrement = $_POST["enregistrement1"];
}
if(isset($_POST["oracle"])){
$this->oracle = $_POST['oracle'];
}
if(isset($_POST['invalidate'])){
$this->invalidate = true;
}
if(isset($_POST['validate'])){
$this->invalidate = false;
}
if(isset($_POST['revoke'])){
$this->revoke = true;//revoking a decision by another druid
}
if( (($this->enregistrement!='') && ($this->oracle!='') && isset($this->invalidate))
!=(($this->enregistrement!='') || ($this->oracle!='') || isset($this->invalidate)) ){
$res = false;
array_push($this->errors, 'druidNotReady');
}
return $res;
}
//Revoir dans le cas où toutes les cartes ont été supprimés du serveur.
private function selectpartie(){
......@@ -131,17 +168,11 @@ class druid_arbitrage
require_once('./controllers/update_score_coeff.php');
//connexion à la BD
$db = db::getInstance();
if(isset($_POST["enregistrement1"]) && isset($_POST["oracle"])){
$this->enregistrement = $_POST["enregistrement1"];
$this->oracle = $_POST['oracle'];
}
if(isset($this->enregistrement) && ($this->enregistrement!="") ){
$sh = new ScoreHandler($this->druid, ScoreHandler::DRUID,(int) $this->enregistrement);
}
// après avoir cliqué sur "au bûcher" = description vide ou fautive
if(isset($_POST['invalidate']))
{
if($this->invalidate() === true){
// Requête d'insertion des info dans la table 'arbitrage'
$sql = 'INSERT INTO arbitrage
(enregistrementID,idDruide,validation)
......@@ -157,7 +188,7 @@ class druid_arbitrage
WHERE enregistrementID="'.$this->enregistrement .'" ' ;
$db->query($sql);
// Requête de modification du score de l'Oracle dont la description est jetée en pâture aux flammes du bûcher purificateur
//Requête de modification du score de l'Oracle dont la description est jetée en pâture aux flammes du bûcher purificateur
//Requête de modification du score du Druide après l'accomplissement de son fastidieux travail d'inquisition
$sh->update_scores(false);
......@@ -166,7 +197,7 @@ class druid_arbitrage
header('Location: index.php?page.home.html');
// après avoir cliqué sur "valider" = description correcte et jouable
}elseif (isset($_POST['validate'])){
}elseif ($this->invalidate() === false){
// insertion des informations dans la table arbitrage
$sql = 'INSERT INTO arbitrage
(enregistrementID,idDruide,validation)
......@@ -191,7 +222,6 @@ class druid_arbitrage
header('Location: index.php?page.home.html');
// sinon, c'est le premier passage dans la page, il n'y a pas encore eu d'arbitrage donc on affiche la page d'arbitrage
}
else{
include('./views/druid.arbitrage.html');
}
......
......@@ -107,7 +107,7 @@ class ScoreHandler{
$notif->addNotifGAME($this->druid->id, $lang['Card_created'].$score." pts",$lang['img_druid']);
}
}
else{//card verification
else{//recording verification
$score = $this->gh->get_druid_verification_score();
$this->store_in_db(
$this->druid->id,
......
......@@ -10,7 +10,6 @@ require('./models/user.class.php');
require('./models/userlvl.class.php');
require('./languages/language.php');
// Initialisation
if ( isset($_POST['cancel_form']) )
{
......
......@@ -132,7 +132,7 @@ $lang['card_level'] = 'Level of the card: ';
$lang['guess'] = 'Guess !';
$lang['which_word'] = 'What is the word described ?';
$lang["RecordCard"] ='If you want to record yourself click here: ';
$lang["RecordArbitre"] ='If you want to judge this record click here: ';
$lang["RecordArbitre"] ='If you think this recording should have been declared invalid, take matters into your own hands: ';
$lang["restart"] ='Play again ? ';
$lang["start"] ='It\'s time to play the game !';
$lang['start_playback']="Play recording";
......@@ -220,6 +220,9 @@ $lang['Devin_played'] = "You listened to a recording by ";
$lang['Devin_oracle'][true] = "And you found the word!";
$lang['Devin_oracle'][false] = "And you did not find the word…";
$lang['druidNotReady'] = "All the required variables for a Druid decision have not been set…";
$lang['page_errors'] = "Error in processing query";
$lang['img_augur'] = "./profil/diviner.jpg";
$lang['img_druid'] = "./profil/druide.jpg";
$lang['img_oracle'] = "./profil/oracle.jpg";
......
......@@ -127,7 +127,7 @@ $lang['guess'] = 'Devine !';
$lang['which_word'] = 'Quel est le mot décrit ?';
$lang['NoGame'] = 'Il n\'y a plus de carte à jouer. Peut-être pourriez vous en ajouter quelques unes <a href=\'index.php?mode=druid.card\'>ici</a>…';
$lang['RecordCard'] = 'Si vous voulez proposer un enregistrement pour cette carte cliquez ici&nbsp; ';
$lang['RecordArbitre'] = 'Si vous voulez arbitrer cet enregistrement cliquez ici : ';
$lang['RecordArbitre'] = 'Si vous pensez que cet enregistrement est invalide, vous pouvez prendre les choses en main&nbsp;:';
$lang['restart'] = 'Rejouer une partie ? ';
$lang['start'] = 'Il est temps de jouer !';
$lang['start_playback'] = "Commencer l'écoute";
......@@ -214,6 +214,9 @@ $lang['Devin_played'] = 'Vous avez écouté un enregistrement de ';
$lang['Devin_oracle'][true] = 'Et vous avez trouvé&nbsp;!';
$lang['Devin_oracle'][false] = "Mais vous n'avez pas trouvé…";
$lang['druidNotReady'] = "Tous les paramètres nécessaires à la gestion d'une décision n'ont pas été spécifiés…";
$lang['page_errors'] = "Erreur durant le traitement de la requête";
$lang['img_augur'] = './profil/diviner.jpg';
$lang['img_druid'] = './profil/druide.jpg';
$lang['img_oracle'] = './profil/oracle.jpg';
......
......@@ -36,6 +36,7 @@ class GameHandler{
self::LVL_HARD => 30/*,
self::LVL_HARDEST => 30*/);
const DRUID_VERIF = 25;
const DRUID_VERIF_ERROR = 100;
const DRUID_CREATE_CARD = 40;
//utilities
//To unify the way levels are defined throughout the game
......@@ -114,10 +115,12 @@ class GameHandler{
public function get_druid_verification_score(){
return self::DRUID_VERIF;
}
public function get_druid_verification_error_score(){
return self::DRUID_VERIF_ERROR;
}
public function get_druid_create_card_score(){
return self::DRUID_CREATE_CARD;
}
private function get_stake($game_lvl, $card_lvl, $user_lvl, $won=true){
if(!is_int($game_lvl)){
$game_lvl = $this->unify_Lvl($game_lvl);
......
......@@ -6,23 +6,25 @@ include('./views/page.header.html');
<div id="jrForm">
<form class="form-jr" role="form" id="diviner.timeout" method="post" action="./index.php">
<fieldset>
<?php
$this->carte->set_view("./views/card.inline.display.php");
echo $this->carte;
$_SESSION["idCard"] = $this->carte->get_id();
$_SESSION["idEnregistrement"] = $this->record_id;
?>
<p><?php echo $lang["RecordCard"]?><a id="ImgDivin" href="index.php?mode=oracle.byid"><img src="./style/default.css/imgs/recON.png" width='20px' height='20px'></a>
</p>
<p><?php echo $lang["RecordArbitre"];?><a id="ImgDivin" href="index.php?mode=druid.arbitrage"><img src="./style/default.css/imgs/arbitre.png" width='20px' height='20px'></a>
</p>
<p><?php echo $lang["restart"];?><a id="ImgDivin" href="index.php?mode=diviner.game"><img src="./style/default.css/imgs/restart.png" width='20px' height='20px'></a>
</p>
</br></br>
<?php
$this->carte->set_view("./views/card.inline.display.php");
require_once("./models/userlvl.class.php");
$gh = new GameHandler();
$this->carte->set_forbidden_count($gh->get_forbidden_count($this->rec_level));
echo $this->carte;
$_SESSION["idCard"] = $this->carte->get_id();
$_SESSION["idEnregistrement"] = $this->record_id;
?>
<input type="hidden" name="enregistrement1" value="<?php echo $this->record_id; ?>" />
<input type="hidden" name="invalidate" value="et oué, gros" />
<input type="hidden" name="mode" value="druid.arbitrage" />
<input type="hidden" name="oracle" value="<?php echo $this->oracle; ?>" />
<input type="hidden" name="revoke" value="true" /><!--To say we are revoking a prior decision-->
<p><?php echo $lang["RecordArbitre"];?> </p>
<div id="form-cmd">
<input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['return']; ?>" class="submit_buttons" />
<input class="btn btn-lg btn-primary btn-block submit_buttons" name="submit_form" value="<?php echo $lang['invalidate']; ?>" type="submit" />
<input class="btn btn-lg btn-primary btn-block submit_buttons" onclick="window.location.href='./index.php?mode=diviner.game'" value="<?php echo $lang['restart']; ?>" />
<input class="btn btn-lg btn-primary btn-block submit_buttons" value="<?php echo $lang['return']; ?>" onclick="window.location.href='./index.php'"/>
</div>
</fieldset>
</form>
......
<?php
$title = 'Diviner Timeout';
include('./views/page.header.html');
?>
<div id="main-container">
<div id="jrForm">
<form class="form-jr" role="form" id="diviner.timeout" method="post" action="./index.php">
<fieldset>
<?php
$this->carte->set_view("./views/card.inline.display.php");
echo $this->carte;
$_SESSION["idCard"] = $this->carte->get_id();
$_SESSION["idEnregistrement"] = $this->rec->get_id();
?>
<p><?php echo $lang["RecordCard"]?><a id="ImgDivin" href="index.php?mode=oracle.byid"><img src="./style/default.css/imgs/recON.png" width='20px' height='20px'></a>
</p>
<p><?php echo $lang["RecordArbitre"];?><a id="ImgDivin" href="index.php?mode=druid.arbitrage"><img src="./style/default.css/imgs/arbitre.png" width='20px' height='20px'></a>
</p>
<p><?php echo $lang["restart"];?><a id="ImgDivin" href="index.php?mode=diviner.game"><img src="./style/default.css/imgs/restart.png" width='20px' height='20px'></a>
</p>
</br></br>
<?php
$this->carte->set_view("./views/card.inline.display.php");
require_once("./models/userlvl.class.php");
$gh = new GameHandler();
$this->carte->set_forbidden_count($gh->get_forbidden_count($this->rec->get_level()));
echo $this->carte;
$_SESSION["idCard"] = $this->carte->get_id();
$_SESSION["idEnregistrement"] = $this->rec->get_id();
?>
<input type="hidden" name="enregistrement1" value="<?php echo $this->rec->get_id(); ?>" />
<input type="hidden" name="invalidate" value="et oué, gros" />
<input type="hidden" name="mode" value="druid.arbitrage" />
<input type="hidden" name="oracle" value="<?php echo $this->rec->get_oracle_id(); ?>" />
<input type="hidden" name="revoke" value="true" /><!--To say we are revoking a prior decision-->
<p><?php echo $lang["RecordArbitre"];?> </p>
<div id="form-cmd">
<input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['return']; ?>" class="submit_buttons" />
<input class="btn btn-lg btn-primary btn-block submit_buttons" name="submit_form" value="<?php echo $lang['invalidate']; ?>" type="submit" />
<input class="btn btn-lg btn-primary btn-block submit_buttons" onclick="window.location.href='./index.php?mode=diviner.game'" value="<?php echo $lang['restart']; ?>" />
<input class="btn btn-lg btn-primary btn-block submit_buttons" value="<?php echo $lang['return']; ?>" onclick="window.location.href='./index.php'"/>
</div>
</fieldset>
</form>
......
......@@ -26,7 +26,6 @@ include('./views/page.header.html');
</dl>
<div id="form-cmd">
<input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['return']; ?>" class="submit_buttons" />
<!--<input type="hidden" name="mode" value="<?php //echo $this->mode; ?>"/> -->
</div>
<?php }
......@@ -34,30 +33,28 @@ include('./views/page.header.html');
if(isset($pointsPerdus)){ ?>
<!--<fieldset>-->
<legend class="form-jr-heading"><?php echo $lang['result']; ?></legend>
<p class='messageUtil'><?php echo $lang['giveUp'].'</br>'; ?></p>
<div id="form-cmd">
<input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['return']; ?>" class="submit_buttons" />
<!--<input type="hidden" name="mode" value="<?php //echo $this->mode; ?>"/> -->
<?php }
else{?>
<!--<fieldset>-->
<legend class="form-jr-heading"><?php echo $lang['result']; ?></legend>
<p class='messageUtil'><?php echo $lang['giveUpWithoutPoints'].'</br>'; ?></p>
<div id="form-cmd">
<input class="btn btn-lg btn-primary btn-block" type="submit" id="submit_form" name="submit_form" value="<?php echo $lang['return']; ?>" class="submit_buttons" />
<!--<input type="hidden" name="mode" value="<?php //echo $this->mode; ?>"/> -->
</div>
<?php }
}?>
}?>
<!--</fieldset>-->
</form>
</div>
......
......@@ -17,7 +17,8 @@ $notif->readNotif();
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<!--Module de son : -->
<script src="http://cdn.webrtc-experiment.com/RecordRTC.min.js"></script>
<!-- Adaptation au Bootstrap -->
<link rel="stylesheet" type="text/css" href="style/default.css/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="style/default.css/css/bootstrap-theme.css">
......@@ -32,10 +33,6 @@ $notif->readNotif();
<link rel="stylesheet" type="text/css" href="style/default.css/css/ns-default.css" />
<link rel="stylesheet" type="text/css" href="style/default.css/css/ns-style-other.css" />
<!--Module de son : -->
<script src="http://cdn.webrtc-experiment.com/RecordRTC.min.js"></script>
<!-- For notifications-->
<script src="controllersJS/Notification/modernizr.custom.js"></script>
<script src="controllersJS/sendSQL.js"></script>
......
<?php include_once("./models/userlvl.class.php"); ?>
<h2 class="text-center">Greetings Wise One, welcome in Game of Words!</h2>
<h2 class="text-center">Greetings Wise One, welcome to Game of Words!</h2>
<h4 class="text-center">It’s time to show off your talents!</h4>
<p class="text-justify">Game of Word offers an asynchronous online avatar of guessing game, reusing game mechanics from ‘Taboo’, created in 1990 by Brian Hersch and Bernard Bougrèle, and published by Hasbro. The purpose of the game is to make other players guess words in a limited time. Be careful, on each card are written forbidden words. Words of the same ‘family’ are also forbidden.</p>
......
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