T201704101533

This commit is contained in:
Leander
2017-04-10 15:33:59 +02:00
parent c83fcaed65
commit e913f593df

View File

@@ -72,7 +72,6 @@ if($uid == '') {
} else { } else {
$end = array('score' => $new_points, 'time' => $new_time); $end = array('score' => $new_points, 'time' => $new_time);
$data = array('results' => $results, 'end' => $end); $data = array('results' => $results, 'end' => $end);
$db->query('DELETE FROM "Games" WHERE "ID" = $1', array($uid));
$old_user_high = $db->query( $old_user_high = $db->query(
'SELECT "highscore" FROM "Users" WHERE "ID" = $1', 'SELECT "highscore" FROM "Users" WHERE "ID" = $1',
array($uid) array($uid)
@@ -80,9 +79,9 @@ if($uid == '') {
$answered_questions = $db->query('SELECT "answered_questions" FROM "Games" WHERE "ID" = $1', $answered_questions = $db->query('SELECT "answered_questions" FROM "Games" WHERE "ID" = $1',
array($uid))['data'][0]['answered_questions']; array($uid))['data'][0]['answered_questions'];
$new_points = round($new_points / $answered_questions); $new_points = round($new_points / $answered_questions);
print $new_points;
$new_user_high = $old_user_high == 0 ? $new_points : round($old_user_high * 0.95 + $new_points * 0.05); $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)); $db->query('UPDATE "Users" SET "highscore" = $1 WHERE "ID" = $2', array($new_user_high, $uid));
$db->query('DELETE FROM "Games" WHERE "ID" = $1', array($uid));
} }
} }