T201704101427
This commit is contained in:
@@ -51,7 +51,7 @@ if($uid == '') {
|
||||
$new_time = $old_time + $time;
|
||||
$db->query('UPDATE "Games" SET "total_time" = $1 WHERE "ID" = $2', array($new_time, $uid));
|
||||
|
||||
//set highscore
|
||||
//set category highscore
|
||||
$cid = $db->query('SELECT "current_category" FROM "Games" WHERE "ID" = $1', array($uid))
|
||||
['data'][0]['current_category'];
|
||||
if($db->query('SELECT EXISTS (SELECT 1 FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2)',
|
||||
@@ -64,7 +64,7 @@ if($uid == '') {
|
||||
$db->query('UPDATE "Highscores" SET "score" = $1 WHERE "Users_ID" = $2 AND "Categories_ID" = $3',
|
||||
array($new_high, $uid, $cid));
|
||||
|
||||
//create next question if existing, end object otherwise
|
||||
//create next question if existing, end object otherwise - then set user highscore
|
||||
if($db->query('SELECT EXISTS (SELECT 1 FROM "GamesQuestions" WHERE "Games_ID" = $1)',array($uid))
|
||||
['data'][0]['exists'] == 't') {
|
||||
$next_question = Question::get_next_question($db, $uid);
|
||||
@@ -77,6 +77,9 @@ if($uid == '') {
|
||||
'SELECT "highscore" FROM "Users" WHERE "ID" = $1',
|
||||
array($uid)
|
||||
)['data'][0]['highscore'];
|
||||
$answered_questions = $db->query('SELECT "answered_questions" FROM "Games" WHERE "ID" = $1',
|
||||
array($uid))['data'][0]['answered_questions'];
|
||||
$new_points = round($new_points / $answered_questions);
|
||||
$new_user_high = $old_user_high == 0 ? $new_points : round($old_user_high * 0.95 + $new_points * 0.05);
|
||||
$db->query('UPDATE "Users" SET "highscore" = $1 WHERE "ID" = $2', array($new_user_high, $uid));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user