traces.handler.class.php 16.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
require_once('./sys/db.class.php');
require_once('./models/user.class.php');
require_once('./models/recording.class.php');
require_once('./models/card.class.php');
require_once('./sys/load_iso.php');
require_once('./models/userlvl.class.php');
require_once("./controllers/notificationMessage.php");

class TracesHandler{
	private $db;
	private $oracle = false;
	private $druid = false;
	private $augur = false;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
15
	private $queries;
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
	private $user;
	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(){
		$this->db = db::getInstance();
		$this->lang_iso = new IsoLang();
		$this->sv = new ScoreValues();
		$this->user = user::getInstance();
		$this->notif = new Notification(false);
		require_once('./languages/language.fn.php');
		$this->messages = get_messages($this->user->get_lang(), $this->db);
Mathieu Loiseau's avatar
Mathieu Loiseau committed
35
		$this->reset_queries();
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
36
37
	}

Mathieu Loiseau's avatar
Mathieu Loiseau committed
38
	public function reset_queries(){
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
39
40
41
42
43
		$this->queries = array();
	}

	public function add_query($query){
		array_push($this->queries, $query);
44
45
	}

Mathieu Loiseau's avatar
Mathieu Loiseau committed
46
	public function oracle_see_card($card){
47
48
49
50
51
52
53
		try{
			$lang = $this->lang_iso->any_to_iso($card->get_lang());
			$user_level = $this->user->get_lang_lvl($lang);
		}catch(Exception $E){
			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
Mathieu Loiseau's avatar
Mathieu Loiseau committed
54
		$this->reset_queries();
Mathieu Loiseau's avatar
Mathieu Loiseau committed
55
56
		$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));
57
			//create recording
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
58
		$this->add_query("INSERT INTO `enregistrement` (`idOracle`, `OracleLang`, `carteID`, `nivcarte`, `nivpartie`, `validation`, `miseD`, `miseV`)
59
60
61
62
					 VALUES ('".$this->user->id."','".
									$lang."', '".
									$card->get_id()."', '".
									$card->get_level()."', '".
Mathieu Loiseau's avatar
Mathieu Loiseau committed
63
									$this->user->userlvl."','given up', '".$stakes['D']."', '".$stakes['V']."');");
64
		//score
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
65
66
		$this->add_query("SET @recording_id = LAST_INSERT_ID();");
		$this->add_query("UPDATE `stats` SET `score_oracle`=`score_oracle`+(SELECT ".$this->sv->get_recording_score_sql_formula()." FROM `enregistrement` WHERE `enregistrementID`=@recording_id), `nbAbandons_oracle`=`nbAbandons_oracle`+1, `nbJeux_oracle`=`nbJeux_oracle`+1 WHERE `userid`='".$this->user->id."' AND `langue`='$lang';");
67
		//notification
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
68
		$this->add_query($this->notif->addNotifGAME(
Mathieu Loiseau's avatar
Mathieu Loiseau committed
69
				$this->user->id,$this->messages['Oracle_started'].$stakes["V"]." pts.",
70
71
72
				$this->messages['img_oracle'],
				$this->messages['notif']['Oracle_started']
			));
Mathieu Loiseau's avatar
Mathieu Loiseau committed
73
		if(!$this->db->transaction($this->queries, false)){
74
			$res = false;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
75
			throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
76
77
78
79
80
81
82
83
		}
		else{
			$res = true;
		}
		return $res;
	}

	public function post_record($cardId, $rec_path, $rec_length){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
84
		$this->reset_queries();
85
		//update recording
Mathieu Loiseau's avatar
Mathieu Loiseau committed
86
			//prepare score
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
87
		$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';");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
88
			//actual recording update
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
89
		$this->add_query("UPDATE `enregistrement` SET `cheminEnregistrement` = '$rec_path', `duration`='$rec_length', `tpsEnregistrement`=CURRENT_TIMESTAMP, `validation` = 'limbo' WHERE  `enregistrementID`=@recording_id;");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
90
		//score update
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
91
		$this->add_query("UPDATE `stats` SET `score_oracle`=`score_oracle`+(SELECT ".$this->sv->get_recording_score_sql_formula()." FROM `enregistrement` WHERE `enregistrementID`=@recording_id)-(@previous_recording_score), `nbAbandons_oracle`=`nbAbandons_oracle`-1, `nbEnregistrements_oracle`=`nbEnregistrements_oracle`+1 WHERE `userid`='".$this->user->id."' AND `langue`=@lang;");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
92
		//notifications
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
93
		$this->add_query($this->notif->cancelLastNotifOfType(
94
95
			$this->user->id,
			$this->messages['notif']['Oracle_started']));
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
96
		$this->add_query($this->notif->addNotifGAME(
97
98
99
100
101
			$this->user->id,
			$this->messages['Oracle_posted'],
			$this->messages['img_oracle'],
			$this->messages['notif']['Oracle_posted']
		));
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
102
		if(!$this->db->transaction($this->queries)){
103
			$res = false;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
104
			throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
105
106
107
108
109
110
111
112
		}
		else{
			$res = true;
		}
		return $res;
	}

	public function abort_record($recording_path){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
113
		$this->reset_queries();
Mathieu Loiseau's avatar
Mathieu Loiseau committed
114
115
		//update recording
			//prepare score
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
116
		$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';");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
117
			//actual recording update
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
118
		$this->add_query("UPDATE `enregistrement` SET `validation` = 'given up', `tpsEnregistrement`=CURRENT_TIMESTAMP WHERE `enregistrement`.`cheminEnregistrement` = '$recording_path'; ");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
119
		//score update
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
120
		$this->add_query("UPDATE `stats` SET `score_oracle`=`score_oracle`+(SELECT ".$this->sv->get_recording_score_sql_formula()." FROM `enregistrement` WHERE `enregistrementID`=@recording_id)-(@previous_recording_score), `nbAbandons_oracle`=`nbAbandons_oracle`+1, `nbEnregistrements_oracle`=`nbEnregistrements_oracle`-1 WHERE `userid`='".$this->user->id."' AND `langue`=@lang;");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
121
		//notifications
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
122
		$this->add_query($this->notif->cancelLastNotifOfType(
Mathieu Loiseau's avatar
Mathieu Loiseau committed
123
124
			$this->user->id,
			$this->messages['notif']['Oracle_posted']));
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
125
		$this->add_query($this->notif->addNotifGAME(
Mathieu Loiseau's avatar
Mathieu Loiseau committed
126
127
128
129
130
			$this->user->id,
			$this->messages['Oracle_abort'],
			$this->messages['img_oracle'],
			$this->messages['notif']['Oracle_abort']
		));
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
131
		if(!$this->db->transaction($this->queries)){
132
			$res = false;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
133
			throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
134
135
136
137
138
139
140
		}
		else{
			$res = true;
		}
		return $res;
	}

Mathieu Loiseau's avatar
Mathieu Loiseau committed
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
	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;
	}

160
	public function druid_validate($recordingID, $validate=true, $revoke=false){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
161
		$this->reset_queries();
162
		//insert new arbitrage
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
163
		$this->add_query("INSERT INTO `arbitrage` (`enregistrementID`, `idDruide` , `validation`) VALUES(
Mathieu Loiseau's avatar
Mathieu Loiseau committed
164
165
166
			'$recordingID',
			'".$this->user->id."',
			'".$this->sv->get_druid_string($validate)."');");
167
		if($revoke){
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
168
			$this->add_query("SET @arbitrage_id = LAST_INSERT_ID();");
169
170
171
172
		}

		//update recording
			//previous score and variables
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
173
		$this->add_query("SELECT @previous_recording_score := ".$this->sv->get_recording_score_sql_formula().", @lang:=`OracleLang`, @oracle_id:= `idOracle` FROM `enregistrement` WHERE `enregistrementID`='$recordingID';");
174
			//new recording validation
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
175
		$this->add_query("UPDATE `enregistrement` SET `validation` =  '".
176
			$this->sv->get_druid_string($validate)."' WHERE `enregistrementID`='$recordingID';");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
177
178
		//update oracle score
			//the score itself
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
179
		$this->add_query("SELECT @recording_score_diff :=  ".$this->sv->get_recording_score_sql_formula()."-(@previous_recording_score) FROM `enregistrement` WHERE `enregistrementID`='$recordingID';");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
180
181
182
		$nb_err = "";
		if($revoke){
			if($validate){
183
184
				$nb_err = ", `nbErreurs_oracle` = `nbErreurs_oracle` - 1";
			}
Mathieu Loiseau's avatar
Mathieu Loiseau committed
185
			else{
186
187
188
				$nb_err = ", `nbErreurs_oracle` = `nbErreurs_oracle` + 1";
			}
		}
Mathieu Loiseau's avatar
Mathieu Loiseau committed
189
190
191
		elseif (!$validate) {
			$nb_err = ", `nbErreurs_oracle` = `nbErreurs_oracle` + 1";
		}
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
192
		$this->add_query("UPDATE `stats` SET `score_oracle`=`score_oracle`+@recording_score_diff$nb_err WHERE `userid`=@oracle_id AND `langue`=@lang;");
193
194

		//update druid score
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
195
		$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;");
196
197
		//update former druids score
		if($revoke){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
198
199
200
			$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'='".
201
202
				$this->sv->get_druid_string($validate)."');");
		}
Mathieu Loiseau's avatar
Mathieu Loiseau committed
203
		//the notifications
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
204
		$this->add_query($this->notif->addNotif(
Mathieu Loiseau's avatar
Mathieu Loiseau committed
205
206
207
208
209
210
211
			"@oracle_id",
			"CONCAT('".$this->user->username.$this->messages['Oracle_verif'][$validate]."',
				' (', @recording_score_diff,' pts)')",
			$this->user->id,
			$this->messages['notif']['Oracle_verif'][$validate],
			false
		));
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
212
		$this->add_query($this->notif->addNotif(
Mathieu Loiseau's avatar
Mathieu Loiseau committed
213
214
215
216
217
218
			$this->user->id,
			"'".$this->messages['Rec_verified']."'",
			"@oracle_id",
			$this->messages['notif']['Rec_verified'],
			false
		));
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
219
		//TODO, il faudrait des notifications de réhabilitation / révocation, mais de toute façon il y a pas vraiment la fonctionnalité…
Mathieu Loiseau's avatar
Mathieu Loiseau committed
220
		if(!$this->db->transaction($this->queries, false)){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
221
			$res = false;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
222
			throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
Mathieu Loiseau's avatar
Mathieu Loiseau committed
223
224
225
226
227
		}
		else{
			$res = true;
		}
		return $res;
228
	}
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
229
230
231

	//so that if the augur reloads to give up without loss there's a penalty
	//and not for oracle
Mathieu Loiseau's avatar
Mathieu Loiseau committed
232
	public function augur_start_play($rec_id, $rec_lang, $rec_level){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
233
		$this->reset_queries();
Mathieu Loiseau's avatar
Mathieu Loiseau committed
234
235
236
237
238
		$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
Mathieu Loiseau's avatar
Mathieu Loiseau committed
239
240
			//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."';");
241
		$this->add_query("UPDATE `stats` SET `score_devin`=".$this->sv->get_augur_score_formula()." WHERE `langue`='$rec_lang' AND `userid`='".$this->user->id."';");
Mathieu Loiseau's avatar
Mathieu Loiseau committed
242
243
244
245
		$this->add_query($this->notif->addNotifGAME($this->user->id,
		$this->messages['Augur_playing'],
		$this->messages['img_oracle'],
		$this->messages['notif']['Augur_playing']));
Mathieu Loiseau's avatar
Mathieu Loiseau committed
246
247
		if(!$this->db->transaction($this->queries, false)){
			//false because of update while score is 0
Mathieu Loiseau's avatar
Mathieu Loiseau committed
248
249
250
251
252
253
254
			$res = false;
			throw new Exception("“".print_r($this->queries,true)."” could not be performed.\n".$this->db->get_error());
		}
		else{
			$res = true;
		}
		return $res;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
255
256
257
258
	}

	//don't find (end timer, either by giving up or not)
	//augur & oracle
Mathieu Loiseau's avatar
Mathieu Loiseau committed
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
	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;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
306
307
308
	}

	//augur (and oracle) win
Mathieu Loiseau's avatar
Mathieu Loiseau committed
309
	public function augur_win($recording_id, $duration){
Mathieu Loiseau's avatar
Mathieu Loiseau committed
310
311
312
		//stats devin : +1 nbMotsTrouves_devin + mise / update score
		//enr +1 tentative + 1 succès
		//oracle +1 lecture +1 succès → update score.
Mathieu Loiseau's avatar
Mathieu Loiseau committed
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
		$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 :
328
329
		$this->add_query("UPDATE `stats` SET `nbMotsTrouves_devin`=`nbMotsTrouves_devin`+1, `sommeMises_devin`=`sommeMises_devin`+@mise WHERE `userid`='".$this->user->id."' AND `langue`=@lang;");
		$this->add_query("UPDATE `stats` SET `score_devin`=".$this->sv->get_augur_score_formula()." WHERE `langue`=@lang AND `userid`='".$this->user->id."';");
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
330

Mathieu Loiseau's avatar
Mathieu Loiseau committed
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
		//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;
Mathieu Loiseau's avatar
ménage    
Mathieu Loiseau committed
359
	}
360
}?>