This commit is contained in:
Leander
2017-04-06 13:01:23 +02:00
parent 305fcbeb2c
commit b6a1bdce96
2 changed files with 24 additions and 12 deletions

View File

@@ -69,7 +69,10 @@ if($uid == '') {
$end = array('score' => $new_points, 'time' => $new_time);
$data = array('results' => $results, 'end' => $end);
$db->query('DELETE FROM "Games" WHERE "ID" = $1', array($uid));
$old_user_high = $db->query('SELECT "highscore" FROM "Users" WHERE "ID" = $1', array($uid));
$old_user_high = $db->query(
'SELECT "highscore" FROM "Users" WHERE "ID" = $1',
array($uid)
)['data'][0]['highscore'];
$new_user_high = $old_user_high == 0 ? $new_points : intval($old_user_high * 0.95 + $new_points * 0.05);
$db->query('UPDATE "Users" SET "highscore" = $1 WHERE "ID" = $1', array($uid));
}