Model refactoring, reducing number of static methods
This commit is contained in:
parent
92a07b1684
commit
bc5ec5edce
7 changed files with 145 additions and 48 deletions
|
|
@ -15,7 +15,7 @@ class Tipp extends Model
|
|||
|
||||
// get tendency Color
|
||||
public static function getCol($user_id,$game_id) {
|
||||
$tipp=Tipp::getTipp($user_id,$game_id);
|
||||
$tipp = Tipp::getTipp($user_id,$game_id);
|
||||
$game = Game::where('id',$tipp->game_id)->first();
|
||||
|
||||
$tippTendenz = $tipp->score1 - $tipp->score2;
|
||||
|
|
@ -62,12 +62,9 @@ class Tipp extends Model
|
|||
|
||||
if ($tippTendenz==$gameTendenz) { $score=1; }
|
||||
|
||||
|
||||
if ( ($tipp1 == $goals1) && ($tipp2 == $goals2) ) {
|
||||
$bonus = max(0,$goals1 + $goals2 - 3);
|
||||
$score= 2 + $bonus;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if ($joker==true) {
|
||||
|
|
@ -79,6 +76,18 @@ class Tipp extends Model
|
|||
return $score;
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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;
|
||||
|
||||
$jokerValue=0;
|
||||
if ($joker) {
|
||||
$jokerValue = max(0, $goals1 + $goals2 - 3) + 1;
|
||||
}
|
||||
return 100 + $jokerValue;
|
||||
}
|
||||
|
||||
|
||||
public static function getTippScore($user_id,$game_id, $team=0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue