Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 1cedcdac authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

new scoring!!! (maybe buggy)

parent a71397d4
TRUNCATE `arbitrage` ;
TRUNCATE `cartes` ;
TRUNCATE `enregistrement` ;
TRUNCATE `mots_interdits`;
TRUNCATE `notif` ;
TRUNCATE `parties` ;
UPDATE `stats` SET `nbJeux_oracle` = '0', `nbAbandons_oracle` = '0', `nbEnregistrements_oracle` = '0', `nbErreurs_oracle` = '0', `nbLectures_oracle` = '0', `nbSucces_oracle` = '0', `score_oracle` = '0', `nbCartes_druide` = '0', `nbArbitrages_druide` = '0', `nbErrArbitrage_druide` = '0', `score_druide` = '0', `nbEnregistrements_devin` = '0', `nbMotsTrouves_devin` = '0', `score_devin` = '0' WHERE *;
UPDATE `stats` SET `nbJeux_oracle` = '0', `nbAbandons_oracle` = '0', `nbEnregistrements_oracle` = '0', `nbErreurs_oracle` = '0', `nbLectures_oracle` = '0', `nbSucces_oracle` = '0', `score_oracle` = '0', `nbCartes_druide` = '0', `nbArbitrages_druide` = '0', `nbErrArbitrage_druide` = '0', `sommeMises_devin`=0, `score_druide` = '0', `nbEnregistrements_devin` = '0', `nbMotsTrouves_devin` = '0', `score_devin` = '0' ;
-- games
TRUNCATE `themes` ;
TRUNCATE `themes_cartes` ;
TRUNCATE `mots_interdits`;
TRUNCATE `cartes` ;
--
-- TRUNCATE `langues` ;
-- TRUNCATE `user` ;
......
......@@ -3,7 +3,6 @@ require_once("./models/item.factory.class.php");
require_once("./models/card.class.php");
require_once("./models/userlvl.class.php");
require_once("./controllers/traces.handler.class.php");
/**/include_once("debug.php");
class diviner_game
{
......@@ -11,7 +10,6 @@ class diviner_game
private $errors = array();
private $lang = array();
private $motadeviner='';
private $nivcarte = '';
private $th ;
......
......@@ -38,40 +38,31 @@ class diviner_result
$this->devin = $this->user->id;
$this->devinName = $this->user->username;
$this->lang = $_SESSION["langDevin"];
return true;
if(isset($_GET['recording_id'])){
$this->recording_id=$_GET['recording_id'];
if(isset($_GET['duration'])){
$this->duration=$_GET['duration'];
return true;
}
}
return false;
}
private function score()
{
if(!isset($_SESSION["motDeviner"]))
{
$lang_iso = new IsoLang();
//Récupération des infos nécessaires
$db = db::getInstance();
$query = "SET @id_enr = NULL;
UPDATE `parties` SET `reussie`=".$db->escape((string) $this->reussie).", `enregistrementID` = (SELECT @id_enr := `enregistrementID`) WHERE idDevin='".$this->devin."' ORDER BY tpsDevin DESC LIMIT 1;
SELECT @id_enr;";
$db->multi_query_last_result($query);
$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');
$sh = new ScoreHandler($this->devin, ScoreHandler::AUGUR, $tmpRecording);
$sh->update_scores(true); //because they won…
private function score(){
require_once("./controllers/traces.handler.class.php");
$th = new TracesHandler();
$th->augur_win($this->recording_id, $this->duration);
//for dynamic notification don't want to take the time to understand them…
$_SESSION["notif"]["notification_error"]["Devin"] = 'diviner_timeout';
//used in view
$tmpRecording = new Recording($this->recording_id);
$this->oracle = $tmpRecording->get_oracle_id();
$this->rec_level = $tmpRecording->get_level();
// récupération du contenu de la carte avec carteID
require_once("./models/card.class.php");
$this->carte = new Card($tmpRecording->get_card_id());
$_SESSION["motDeviner"] = true;//pour éviter de s'ajouter des points à l'infini avec des refresh
return true;
}
else{
header('Location: index.php?page.home.html');
return false;
}
// récupération du contenu de la carte avec carteID
require_once("./models/card.class.php");
$this->carte = new Card($tmpRecording->get_card_id());
return true;
}
private function display()
......
......@@ -5,6 +5,8 @@ class diviner_timeout
{
private $mode = '';
private $partieID;
private $user = '';
private $diviner = '';
private $devinName='';
......@@ -19,13 +21,16 @@ class diviner_timeout
$this->mode = $mode;
}
public function process()
{
if ( $this->init() )
{
$this->carte_et_scoreOracle();
$this->updateparties();
return $this->display();
public function process(){
try{
if ( $this->init() ){
$this->init_card_and_recording();
$this->update_score();
return $this->display();
}
}
catch(Exception $e){
header('Location: index.php');
}
return false;
}
......@@ -39,49 +44,43 @@ class diviner_timeout
return true;
}
private function carte_et_scoreOracle()
{
private function init_card_and_recording(){
$res = false;
require_once('./sys/load_iso.php');
$lang_iso = new IsoLang();
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 ';
$db->query($sql);
// 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`, `partieID` FROM `parties` WHERE `idDevin`='$this->diviner' AND `reussite`='en cours' ORDER BY `tpsDevin` DESC LIMIT 1 ";
if($db->query($sql)){
require_once("./models/recording.class.php");
$this->rec= new Recording($db->fetch_assoc()['enregistrementID']);
//mise à jour des scores
require_once('./controllers/update_score_coeff.php');
$sh = new ScoreHandler($this->diviner, ScoreHandler::AUGUR, $this->rec);
$sh->update_scores(false); //because they lost…
$tmpTable = $db->fetch_assoc();
$this->partieID = $tmpTable['partieID'];
$this->rec= new Recording($tmpTable['enregistrementID']);
// récupération du contenu de la carte avec carteID
$this->carte = new Card($this->rec->get_card_id());
$_SESSION["timeOutOracle"]=true;
return false;
$res = true;
}
else{
header('Location: index.php?page.home.html');
return false;
throw new Exception($query."yielded no result, there's a problem in the consistance of the db, maybe the user toyed with the url…");
}
return $res;
}
private function updateparties()
{
// Requête de mise à jour de la table partie
$db = db::getInstance();
$sql = 'UPDATE parties
SET reussie='.$db->escape((string) $this->reussie).'
WHERE idDevin='.$this->diviner.' ORDER BY tpsDevin DESC LIMIT 1 ';
$db->query($sql);
//for dynamic notification don't want to take the time to understand them…
$_SESSION["notif"]["notification_error"]["Devin"] = 'diviner_timeout';
private function update_score(){
require_once("./controllers/traces.handler.class.php");
$th = new TracesHandler();
if(isset($_GET['duration'])){
$duration = $_GET['duration'];
}
else{
$duration = false;
}
$th->augur_loss($this->partieID, $this->rec->get_id(), $duration);
//for dynamic notification don't want to take the time to understand them…
$_SESSION["notif"]["notification_error"]["Devin"] = 'diviner_timeout';
return false;
}
......
......@@ -132,11 +132,11 @@ class druid_card
{
require_once('./sys/load_iso.php');
$lang_iso = new IsoLang();
require_once('./controllers/update_score_coeff.php');
//Requête de modification du score du Druide l'accomplissement de son fastidieux travail de création de carte
$sh = new ScoreHandler($this->createur, $this->userlang);
$sh->update_scores();
require_once("./controllers/traces.handler.class.php");
$th = new TracesHandler();
$th->druid_create_card($this->userlang);
$_SESSION["CreateCard"]=true;
//affichage de l'aperçu de la carte avec son identifiant
......
......@@ -6,7 +6,6 @@ require_once('./models/card.class.php');
require_once('./sys/load_iso.php');
require_once('./models/userlvl.class.php');
require_once("./controllers/notificationMessage.php");
/**/require_once("./controllers/update_score_coeff.php");/**///transition to new scoreHandler
class TracesHandler{
private $db;
......@@ -33,10 +32,10 @@ class TracesHandler{
$this->notif = new Notification(false);
require_once('./languages/language.fn.php');
$this->messages = get_messages($this->user->get_lang(), $this->db);
$this->reinit_queries();
$this->reset_queries();
}
public function reinit_queries(){
public function reset_queries(){
$this->queries = array();
}
......@@ -52,7 +51,7 @@ class TracesHandler{
throw new Exception("$lang ne semble pas être une langue…");
}
//once a card is seen it is stored in db for score and next play
$this->reinit_queries();
$this->reset_queries();
$stakes = array("V" => $this->sv->get_stake($this->user->userlvl, $card->get_level(), $user_level, true),
"D" => $this->sv->get_stake($this->user->userlvl, $card->get_level(), $user_level, false));
//create recording
......@@ -71,7 +70,7 @@ class TracesHandler{
$this->messages['img_oracle'],
$this->messages['notif']['Oracle_started']
));
if(!$this->db->transaction($this->queries)){
if(!$this->db->transaction($this->queries, false)){
$res = false;
throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
}
......@@ -82,7 +81,7 @@ class TracesHandler{
}
public function post_record($cardId, $rec_path, $rec_length){
$this->reinit_queries();
$this->reset_queries();
//update recording
//prepare score
$this->add_query("SELECT @previous_recording_score := ".$this->sv->get_recording_score_sql_formula().", @recording_id := `enregistrementID`, @lang := `OracleLang` FROM `enregistrement` WHERE `enregistrement`.`idOracle` = ".$this->user->id." AND `enregistrement`.`carteID`='$cardId';");
......@@ -111,7 +110,7 @@ class TracesHandler{
}
public function abort_record($recording_path){
$this->reinit_queries();
$this->reset_queries();
//update recording
//prepare score
$this->add_query("SELECT @previous_recording_score := ".$this->sv->get_recording_score_sql_formula().", @recording_id := `enregistrementID`, @lang := `OracleLang` FROM `enregistrement` WHERE `enregistrement`.`cheminEnregistrement` = '$recording_path';");
......@@ -139,8 +138,27 @@ class TracesHandler{
return $res;
}
public function druid_create_card($lang){
$this->reset_queries();
$this->add_query("UPDATE `stats` SET `nbCartes_druide`=`nbCartes_druide`+1, `score_druide`=`score_druide`+".$this->sv->get_druid_create_card_score()." WHERE `userid`='".$this->user->id."' AND `langue`='$lang';");
$this->add_query(
$this->notif->addNotifGAME(
$this->user->id,
$this->messages['Card_created'].$this->sv->get_druid_create_card_score()." pts",
$this->messages['img_druid'],
$this->messages['notif']['Card_created']));
if(!$this->db->transaction($this->queries, false)){
$res = false;
throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
}
else{
$res = true;
}
return $res;
}
public function druid_validate($recordingID, $validate=true, $revoke=false){
$this->reinit_queries();
$this->reset_queries();
//insert new arbitrage
$this->add_query("INSERT INTO `arbitrage` (`enregistrementID`, `idDruide` , `validation`) VALUES(
'$recordingID',
......@@ -177,9 +195,9 @@ class TracesHandler{
$this->add_query("UPDATE `stats` SET `nbArbitrages_druide` = `nbArbitrages_druide`+1, `score_druide` = `score_druide`+".$this->sv->get_druid_verification_score()." WHERE `stats`.`userid` = '".$this->user->id."' AND `stats`.`langue` = @lang;");
//update former druids score
if($revoke){
$this->add_query("UPDATE `stats` SET `nbErrArbitrage_druide` = `nbErrArbitrage_druide`+1, `score_druide` = IF(`score_druide`-".$this->sv->get_druid_verification_error_score()." WHERE `stats`.`langue` = @lang AND `stats`.`userid` IN (SELECT `idDruide` FROM `arbitrage` WHERE `enregistrementID`='$recordingID' AND `arbitrageID` < @arbitrage_id AND 'validation'!='".
$this->sv->get_druid_string($validate).");");
$this->add_query("UPDATE `stats` SET `nbErrArbitrage_druide` = `nbErrArbitrage_druide`+1, `score_druide` = IF(`score_druide`+".$this->sv->get_druid_verification_error_score()." WHERE `stats`.`langue` = @lang AND `stats`.`userid` IN (SELECT `idDruide` FROM `arbitrage` WHERE `enregistrementID`='$recordingID' AND `arbitrageID` < @arbitrage_id AND 'validation'='".
$this->add_query("UPDATE `stats` SET `nbErrArbitrage_druide` = `nbErrArbitrage_druide`+1, `score_druide` = `score_druide`-".$this->sv->get_druid_verification_error_score()." WHERE `stats`.`langue` = @lang AND `stats`.`userid` IN (SELECT `idDruide` FROM `arbitrage` WHERE `enregistrementID`='$recordingID' AND `arbitrageID` < @arbitrage_id AND 'validation'!='".
$this->sv->get_druid_string($validate)."');");
$this->add_query("UPDATE `stats` SET `nbErrArbitrage_druide` = `nbErrArbitrage_druide`+1, `score_druide` = `score_druide`+".$this->sv->get_druid_verification_error_score()." WHERE `stats`.`langue` = @lang AND `stats`.`userid` IN (SELECT `idDruide` FROM `arbitrage` WHERE `enregistrementID`='$recordingID' AND `arbitrageID` < @arbitrage_id AND 'validation'='".
$this->sv->get_druid_string($validate)."');");
}
//the notifications
......@@ -199,7 +217,7 @@ class TracesHandler{
false
));
//TODO, il faudrait des notifications de réhabilitation / révocation, mais de toute façon il y a pas vraiment la fonctionnalité…
if(!$this->db->transaction($this->queries)){
if(!$this->db->transaction($this->queries, false)){
$res = false;
throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
}
......@@ -212,19 +230,21 @@ class TracesHandler{
//so that if the augur reloads to give up without loss there's a penalty
//and not for oracle
public function augur_start_play($rec_id, $rec_lang, $rec_level){
$this->reinit_queries();
$this->reset_queries();
$user_level = $this->user->get_lang_lvl($this->lang_iso->any_to_iso($rec_lang));
$stake = $this->sv->get_augur_divination_stake($this->user->userlvl, $rec_level, $user_level);
//create game
$this->add_query("INSERT INTO `parties` (`enregistrementID`, `idDevin`, `mise`, `nivPartie`, `nivCarte`) VALUES ('$rec_id', '".$this->user->id."', '$stake', '".$this->user->userlvl."', '$rec_level');");
//update stats
$this->add_query("UPDATE `stats` SET `nbEnregistrements_devin` = `nbEnregistrements_devin`+1, `sommeMises_devin`=`sommeMises_devin`+$stake WHERE `userid`='".$this->user->id."';");
$this->add_query("UPDATE `stats` SET `score_devin`='".$this->sv->get_augur_score_formula()."' WHERE `userid`='".$this->user->id."';");
//two queries (update score needs up to date stats)
$this->add_query("UPDATE `stats` SET `nbEnregistrements_devin` = `nbEnregistrements_devin`+1 WHERE `langue`='$rec_lang' AND `userid`='".$this->user->id."';");
$this->add_query("UPDATE `stats` SET `score_devin`='".$this->sv->get_augur_score_formula()."' WHERE `langue`='$rec_lang' AND `userid`='".$this->user->id."';");
$this->add_query($this->notif->addNotifGAME($this->user->id,
$this->messages['Augur_playing'],
$this->messages['img_oracle'],
$this->messages['notif']['Augur_playing']));
if(!$this->db->transaction($this->queries)){
if(!$this->db->transaction($this->queries, false)){
//false because of update while score is 0
$res = false;
throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
}
......@@ -236,22 +256,104 @@ class TracesHandler{
//don't find (end timer, either by giving up or not)
//augur & oracle
public function augur_loss(){
//update partie + durée (NULL = vidé le chrono) réussite non
//stats devin cf. start play (→ on ne change pas)
//enr + 1 tentative
//stats oracle +1 lecture → update score
public function augur_loss($game_id, $recording_id, $duration){
$this->reset_queries();
//augur, just needs to update game (partie) stats are already up to date (see start_play)
if(!$duration){
$duration = "NULL";
}
else{
$duration = "'$duration'";
}
$this->add_query("UPDATE `parties` SET `duree_Partie`=$duration, `reussite`='non' WHERE `partieID`='$game_id' AND `reussite`='en cours';");
//update Oracle
//former score
$this->add_query("SELECT @previous_recording_score := ".$this->sv->get_recording_score_sql_formula().", @lang:=`OracleLang`, @oracle_id:= `idOracle` FROM `enregistrement` WHERE `enregistrementID`='$recording_id';");
//recording
$this->add_query("UPDATE `enregistrement` SET `nbTentatives`=`nbTentatives`+1 WHERE `enregistrementID`='$recording_id';");
//score diff
$this->add_query("SELECT @recording_score_diff := ".$this->sv->get_recording_score_sql_formula()."-(@previous_recording_score) FROM `enregistrement` WHERE `enregistrementID`='$recording_id';");
//update score
$this->add_query("UPDATE `stats` SET `nbLectures_oracle`=`nbLectures_oracle`+1, `score_oracle`=`score_oracle`+@recording_score_diff WHERE `userid`=@oracle_id AND `langue`=@lang;");
//notifications
//augur
$this->add_query($this->notif->cancelLastNotifOfType(
$this->user->id,
$this->messages['notif']['Augur_playing']));
$this->add_query($this->notif->addNotif(
$this->user->id,
"'".$this->messages['Devin_played'].$this->messages['Devin_oracle'][false]."'",
"@oracle_id",
$this->messages['notif']['Devin_oracle'][false],
false
));
//oracle
$this->add_query($this->notif->addNotif(
"@oracle_id",
"'".$this->user->username." ".$this->messages['Oracle_devin'][false]."'",
$this->user->id,
$this->messages['notif']['Oracle_devin'][false],
false
));
if(!$this->db->transaction($this->queries)){
$res = false;
throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
}
else{
$res = true;
}
return $res;
}
//augur (and oracle) win
public function augur_win(){
//update partie + durée réussite oui
public function augur_win($recording_id, $duration){
//stats devin : +1 nbMotsTrouves_devin + mise / update score
//enr +1 tentative + 1 succès
//oracle +1 lecture +1 succès → update score.
$this->reset_queries();
//begin update Augur
//update partie : durée / réussite → oui
$this->add_query("UPDATE `parties` SET `duree_Partie`=$duration, `reussite`='oui' WHERE `enregistrementID`='$recording_id' AND `reussite`='en cours' AND `mise`=(@mise := `mise`) AND `idDevin`=".$this->user->id.";");
//update Oracle
//former score
$this->add_query("SELECT @previous_recording_score := ".$this->sv->get_recording_score_sql_formula().", @lang:=`OracleLang`, @oracle_id:= `idOracle` FROM `enregistrement` WHERE `enregistrementID`='$recording_id';");
//recording
$this->add_query("UPDATE `enregistrement` SET `nbTentatives`=`nbTentatives`+1, `nbSucces`=`nbSucces`+1 WHERE `enregistrementID`='$recording_id';");
//score diff
$this->add_query("SELECT @recording_score_diff := ".$this->sv->get_recording_score_sql_formula()."-(@previous_recording_score) FROM `enregistrement` WHERE `enregistrementID`='$recording_id';");
//update score
$this->add_query("UPDATE `stats` SET `nbLectures_oracle` = `nbLectures_oracle` + 1 , `nbSucces_oracle` = `nbSucces_oracle` + 1 , `score_oracle` = `score_oracle` + @recording_score_diff WHERE `userid`=@oracle_id AND `langue`=@lang;");
//end update Augur
//update stats :
$this->add_query("UPDATE `stats` SET `nbMotsTrouves_devin`=`nbMotsTrouves_devin`+1, `sommeMises_devin`=`sommeMises_devin`+@mise WHERE `userid`=".$this->user->id." AND `langue`=@lang;");
//notifications
//augur
$this->add_query($this->notif->cancelLastNotifOfType(
$this->user->id,
$this->messages['notif']['Augur_playing']));
$this->add_query($this->notif->addNotif(
$this->user->id,
"'".$this->messages['Devin_played'].$this->messages['Devin_oracle'][true]."'",
"@oracle_id",
$this->messages['notif']['Devin_oracle'][true],
false
));
//oracle
$this->add_query($this->notif->addNotif(
"@oracle_id",
"'".$this->user->username." ".$this->messages['Oracle_devin'][true]."'",
$this->user->id,
$this->messages['notif']['Oracle_devin'][true],
false
));
if(!$this->db->transaction($this->queries)){
$res = false;
throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
}
else{
$res = true;
}
return $res;
}
}?>
<?php
require_once('./sys/db.class.php');
require_once('./models/user.class.php');
require_once('./models/recording.class.php');
require_once('./sys/load_iso.php');
require_once('./models/userlvl.class.php');
class ScoreHandler{
private $db;
private $oracle = false;
private $druid = false;
private $augur = false;
private $recording;
private $lang;
private $lang_iso;
private $sv;//game handler
const ORACLE = 1;
const DRUID = 2;
const AUGUR = 3;
/*Except for the druid card creation, the score handler basically requires two users and a recording, to be able to process the scores, the constructor allows to set the appropriate variables*/
//if $user1 is true we are considering the logged in user
//otherwise we expect a user id.
//For druid card creation we only need the language concerned (otherwise we get it through the recording)
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 ScoreValues();
if($user1_or_id === true){
$user = user::getInstance();
}
else{
$user = new user($user1_or_id);
}
if($recording_or_id === false){//we have ourselves a card creator druid
$this->druid = $user;
try{
$this->lang = $this->lang_iso->any_to_iso($user1_role_or_lang);
}catch(Exception $E){
throw new Exception("$user1_role_or_lang ne semble pas être une langue…");
}
}
else{
if(is_int($recording_or_id)){
$this->recording = new Recording($recording_or_id);
}
else{//if it is not an id it is a recording (or so we decide :S)
$this->recording = $recording_or_id;
}
$this->oracle = new user($this->recording->get_oracle_id());
$this->lang = $this->lang_iso->any_to_iso($this->recording->get_lang());
if($user1_role_or_lang === self::DRUID){
$this->druid = $user;
}
else if($user1_role_or_lang === self::AUGUR){
$this->augur = $user;
}
else{
throw new Exception("On aurait dû avoir un devin (".self::AUGUR.") ou un druide (".self::DRUID."), au lieu de ça on a eu : '$user1_role_or_lang'.");
}
}
}
private function store_in_db($user_id, $lang_code, $role, $diff){
switch($role){
case self::ORACLE :
$role = "scoreOracle";
break;
case self::DRUID :
$role = "scoreDruide";
break;
case self::AUGUR :
$role = "scoreDevin";
break;
}
$sql = "UPDATE `score` SET `$role` = `$role` + ($diff), `scoreGlobal`=`scoreGlobal`+ ($diff) WHERE `score`.`userid` = '$user_id' AND `langue`='".$this->lang_iso->french_for($lang_code)."'";
$this->db->query($sql);
if($this->db->affected_rows() != 1){
throw new Exception("store score in db : mais que se passe-t-il ? ($sql)");
}
}
//The context allows to pick the appropriate score computation, we only need to know if it was a success (=the druid found the recording appropriate or the augur found the word.)
public function update_scores($success=true,$notify=true){
if($notify===true){
require_once("./controllers/notificationMessage.php");
$notif = new Notification();
if(!isset($lang)){
include("./languages/language.php");
}
}
else{
$notify = false;
}
//druid
$score=0;//useless initialization
if($this->druid !== false){
if($this->oracle === false){//card creator
$score = $this->gh->get_druid_create_card_score();
$this->store_in_db(
$this->druid->id,
$this->lang,
self::DRUID,
$score
);
if($notify){
$notif->addNotifGAME($this->druid->id, $lang['Card_created'].$score." pts",$lang['img_druid']);
}
}
else{//recording verification
$score = $this->gh->get_druid_verification_score();
$this->store_in_db(
$this->druid->id,
$this->lang,
self::DRUID,
$score
);
if($notify){
$notif->addNotifGAME($this->druid->id, $lang['Rec_verified'].$this->oracle->username." ($score pts)",$lang['img_druid']);
}
$score = $this->gh->get_oracle_verification_score(
$this->recording->get_level(),
$this->recording->get_card_level(),
$this->oracle->get_lang_lvl($this->lang),
$success
);
$this->store_in_db(