Commit 23a02541 authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

GameHandler → ScoreValues

parent b57d2540
......@@ -59,7 +59,7 @@ class diviner_game
$this->user = user::getInstance();
$this->diviner = $this->user->id;
//récupération des points de sanction (not handled by gameHandler et tant pis)
//récupération des points de sanction (not handled by ScoreValues et tant pis)
$this->pointsSanction = loosePointsDevin;
......@@ -143,8 +143,8 @@ class diviner_game
//récupération du contenu de la carte
$this->card = new Card($this->raisin->carteID);
//Gestion du temps
$gh = new GameHandler();
$this->time = $gh->get_augur_time($this->user->userlvl, $this->raisin->duration);
$sv = new ScoreValues();
$this->time = $sv->get_augur_time($this->user->userlvl, $this->raisin->duration);
// récupération du pseudo de l'oracle pour savoir qui on écoute
$db = db::getInstance();
......
......@@ -50,9 +50,9 @@ class oracle_alea_exist
$this->card=$card;
//Gestion des règles
$gh = new GameHandler();
$this->time = $gh->get_oracle_time($this->user->userlvl);
$this->card->set_forbidden_count($gh->get_forbidden_count($this->user->userlvl));
$sv = new ScoreValues();
$this->time = $sv->get_oracle_time($this->user->userlvl);
$this->card->set_forbidden_count($sv->get_forbidden_count($this->user->userlvl));
$res = true;
}
......
......@@ -243,9 +243,9 @@ class oracle_card_alea
$carte->store();
$this->card = $carte ;
//Gestion des règles
$gh = new GameHandler();
$this->time = $gh->get_oracle_time($this->user->userlvl);
$this->card->set_forbidden_count($gh->get_forbidden_count($this->user->userlvl));
$sv = new ScoreValues();
$this->time = $sv->get_oracle_time($this->user->userlvl);
$this->card->set_forbidden_count($sv->get_forbidden_count($this->user->userlvl));
unset($this->res);
// affichage de la carte
include('./views/oracle.card.display.html');
......
......@@ -61,9 +61,9 @@ class oracle_card_byid
else{
// Sélection "dans ce cas là on laisse les gens jouer avec n'importe quelle carte (pour le moment) à terme on pourrait utiliser la item factory pour vérifier que le joueur a droit…"
$this->card = new Card((int) $this->carteId);
$gh = new GameHandler();
$this->time = $gh->get_oracle_time($this->user->userlvl);
$this->card->set_forbidden_count($gh->get_forbidden_count($this->user->userlvl));
$sv = new ScoreValues();
$this->time = $sv->get_oracle_time($this->user->userlvl);
$this->card->set_forbidden_count($sv->get_forbidden_count($this->user->userlvl));
}
return $res;
}
......
......@@ -13,7 +13,7 @@ class ScoreHandler{
private $recording;
private $lang;
private $lang_iso;
private $gh;//game handler
private $sv;//game handler
const ORACLE = 1;
const DRUID = 2;
const AUGUR = 3;
......@@ -25,7 +25,7 @@ class ScoreHandler{
public function __construct($user1_or_id = true, $user1_role_or_lang = self::AUGUR, $recording_or_id = false){
$this->db = db::getInstance();
$this->lang_iso = new IsoLang();
$this->gh = new GameHandler();
$this->gh = new ScoreValues();
if($user1_or_id === true){
$user = user::getInstance();
}
......
<?php
//A class to handle the main rules
class GameHandler{
class ScoreValues{
const LVL_EASY = 0;
const LVL_MEDIUM = 1;
const LVL_HARD = 2;
......@@ -38,6 +38,20 @@ class GameHandler{
const DRUID_VERIF = 25;
const DRUID_VERIF_ERROR = 100;
const DRUID_CREATE_CARD = 40;
const RECORDING_SCORE_FORMULA =
"IF(`validation`='given up',
-ROUND(`mise`/3),
IF(`validation`='invalid',
-ROUND(1.5*`mise`),
IF(`validation`='valid',
ROUND(`mise`*(0.5+`nbSucces`/`nbTentatives`)),
0
)
)
)";
private static $DRUID_STRINGS = array(0 => 'invalid',
1 => 'valid');
//utilities
//To unify the way levels are defined throughout the game
......@@ -125,6 +139,14 @@ class GameHandler{
return self::DRUID_CREATE_CARD;
}
public function get_druid_string($valid){
return self::$MULTIPLIERS_WIN[$valid];
}
public function get_recording_score_sql_formula(){
return self::RECORDING_SCORE_FORMULA;
}
public function get_stake($game_lvl, $card_lvl, $user_lvl, $won=true){
if(!is_int($game_lvl)){
$game_lvl = $this->unify_Lvl($game_lvl);
......@@ -161,6 +183,8 @@ class GameHandler{
return round($res);
}
//quick and dirty rules consistance
public function forbid_count_to_string($lang){
return self::const_table_to_string($lang, self::$FORBID_COUNT);
......
......@@ -9,8 +9,8 @@ include('./views/page.header.html');
<?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));
$sv = new ScoreValues();
$this->carte->set_forbidden_count($sv->get_forbidden_count($this->rec_level));
echo $this->carte;
$_SESSION["idCard"] = $this->carte->get_id();
$_SESSION["idEnregistrement"] = $this->record_id;
......
......@@ -9,8 +9,8 @@ include('./views/page.header.html');
<?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()));
$sv = new ScoreValues();
$this->carte->set_forbidden_count($sv->get_forbidden_count($this->rec->get_level()));
echo $this->carte;
$_SESSION["idCard"] = $this->carte->get_id();
$_SESSION["idEnregistrement"] = $this->rec->get_id();
......
......@@ -20,7 +20,7 @@
<h3><strong>Random Card Description</strong></h3>
<h4>Read well through the signs, and spread the good news!</h4>
<p class="text-center">A card will appear to you, randomly selected. Careful, you cannot describe a card you have created as a Druid. Check if your microphone is correctly working, follow the instructions and let’s go!</p>
<p class="text-center">Depending on the difficulty you choose, you will have maximum <?php $gh = new GameHandler();echo $gh->oracle_time_to_string("en") ;?> seconds to produce a description of the word given in the card without using the word, the (<?php $gh = new GameHandler();echo $gh->forbid_count_to_string("en") ;?>) forbidden words associated (depending on the level) or apparented words. Keep in mind that your description will be subject to a validation, so there is no interest in cheating (except losing points ;) ). Additional time is given to you so you can listen to your description and delete it.</p>
<p class="text-center">Depending on the difficulty you choose, you will have maximum <?php $sv = new ScoreValues();echo $sv->oracle_time_to_string("en") ;?> seconds to produce a description of the word given in the card without using the word, the (<?php $sv = new ScoreValues();echo $sv->forbid_count_to_string("en") ;?>) forbidden words associated (depending on the level) or apparented words. Keep in mind that your description will be subject to a validation, so there is no interest in cheating (except losing points ;) ). Additional time is given to you so you can listen to your description and delete it.</p>
<p class="text-center">If you want to start over the recording (but not the timer), you can press <img src="style/default.css/imgs/restart.png"/></p>
<p class="text-center">You will receive points if your recording is considered valid by a druid, but you will lose some if the druid does not think it follows the rules, so think well! If the Augur cannot guess your word, you will also lose points. But if the augur finds it you will win points.</p>
......
......@@ -20,7 +20,7 @@
<h3>Description d'une carte au hasard</h3>
<h4>Lis les signes dans le ciel, et prêche la bonne nouvelle!</h4>
<p class="text-justify">Une carte comme celle citée précédemment t'apparaîtra. Attention, tu ne peux pas jouer une carte que tu as créée comme druide. Vérifie que ton micro fonctionne, suis les instructions et c'est parti !</p>
<p class="text-justify">Tu auras un maximum de <?php $gh = new GameHandler();echo $gh->oracle_time_to_string("fr") ;?> secondes (selon le niveau de jeu choisi) pour faire deviner ton mot sans utiliser les mots interdits (<?php $gh = new GameHandler();echo $gh->forbid_count_to_string("fr") ;?> selon la difficulté), le mot à deviner ou les mots de la même famille que ces deux derniers. Garde en tête que ta description sera soumise à validation donc il est inutile de tricher! (Sauf si tu veux perdre des points ;) ).</p>
<p class="text-justify">Tu auras un maximum de <?php $sv = new ScoreValues();echo $sv->oracle_time_to_string("fr") ;?> secondes (selon le niveau de jeu choisi) pour faire deviner ton mot sans utiliser les mots interdits (<?php $sv = new ScoreValues();echo $sv->forbid_count_to_string("fr") ;?> selon la difficulté), le mot à deviner ou les mots de la même famille que ces deux derniers. Garde en tête que ta description sera soumise à validation donc il est inutile de tricher! (Sauf si tu veux perdre des points ;) ).</p>
<p class="text-justify">Si tu veux réinitialiser ton enregistrement (mais pas le chronomètre) tu peux appuyer sur <img src="style/default.css/imgs/restart.png"/></p>
<p class="text-justify">Tu recevras des points si ton enregistrement est validé par le Druide, tu recevras des points, dans le cas contraire, tu en perdras. Si le Devin ne trouve pas le mot décrit, tu perdras des points, mais tu en gagneras s'il interprète correctement ta prophétie.</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