Completed Dayscore Ranking

This commit is contained in:
Torsten 2017-08-29 15:52:12 +02:00
parent 1f5e056b7f
commit 76947b1df9
7 changed files with 294 additions and 155 deletions

View file

@ -104,9 +104,9 @@ class Tipp extends Model
// Bei Tagessieg gilt nur wer am meisten genau richtig getippt hat,
// Bei Gleichstand wer den höchsten Jokersieg hat ( Jokersieg mit mehr Toren zählt mehr)
public static function getDayScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker) {
// Bei Gleichstand gilt die Summe aller Rankscores, deshalb wird sie auch im Ergebnis gespeichert
// Fürs Dayscore-Bewerten ist rankscore allerdings irrelevant. Mit Rank nur fürs Sortieren, um die Auswahl einzugrenzen.
public static function getDayScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker, $rankScore=0) {
if ($tipp1==-1||$tipp2==-1||$goals1==-1||$goals2==-1) { return 0; } // Ungetippt oder Spiel hat noch kein Ergebnis
if ( ($tipp1 != $goals1) || ($tipp2 != $goals2) ) return 0;
@ -114,7 +114,7 @@ class Tipp extends Model
if ($joker) {
$jokerValue = max(0, $goals1 + $goals2 - 3) + 1;
}
return 100 + $jokerValue;
return 1000 + $jokerValue * 100 + $rankScore;
}
@ -210,4 +210,34 @@ class Tipp extends Model
Tipp::createTipps($user->id);
}
}
// Struktur: gameval * 1000 + jokerValue * 100 + rankscore
public static function addDayScoreValues($val1, $val2) {
$gameVal1 = intdiv($val1 , 1000);
$gameVal2 = intdiv( $val2, 1000);
$jokerVal1 = intdiv(($val1 - $gameVal1*1000),100);
$jokerVal2 = intdiv(($val2 - $gameVal2*1000),100);
if ( $gameVal1 ==0 ) { $jokerVal1=0; $rankVal1=0; }
if ( $gameVal2 ==0 ) { $jokerVal2=0; $rankVal2=0; }
$rankVal1 = $val1 - $gameVal1*1000 - $jokerVal1*100;
$rankVal2 = $val2 - $gameVal2*1000 - $jokerVal2*100;
// Minimaler Brainfuck, da $rankVal1 und $rankVal2 immer gleich sein sollten
$result = ($gameVal1 + $gameVal2) * 1000 + max($jokerVal1, $jokerVal2) * 100 + max ($rankVal1, $rankVal2);
return $result;
}
public static function getDayScoreWithoutRankScore($val) {
$gameVal = intdiv($val , 1000);
$jokerVal = intdiv(($val - $gameVal*1000),100);
if ($gameVal==0) return 0;
return $gameVal * 1000 + $jokerVal * 100;
}
}