game_id)->first(); $tippTendenz = $tipp->score1 - $tipp->score2; if ($tippTendenz > 0) {$tippTendenz=1;} if ($tippTendenz < 0) {$tippTendenz=-1;} $gameTendenz = $game->score1 - $game->score2; if ($gameTendenz<0) {$gameTendenz=-1;} if ($gameTendenz>0) {$gameTendenz=1;} if ($tippTendenz!=$gameTendenz || $game->score1 ==-1 || $game->score2==-1 || $tipp->score1 == -1 || $tipp->score2==-1) { return ""; } $styling='background-color:grey;'; if ( ($tipp->score1 == $game->score1) && ($tipp->score2 == $game->score2) ) { $styling='background-color:orange;'; if ($tipp->joker==true) { $styling='background-color:red'; } } return $styling; } public static function getTipp( $user_id,$game_id) { //Log::info("getTipp for game_id, user_id = ".$game_id.",".$user_id); return DB::table('tipps')->where([ ['user_id','=',$user_id], ['game_id','=',$game_id] ])->first(); } public static function getScoreLocal($goals1, $goals2, $tipp1, $tipp2, $joker) { $score=0; $tippTendenz = $tipp1 - $tipp2; if ($tippTendenz > 0) {$tippTendenz=1;} if ($tippTendenz < 0) {$tippTendenz=-1;} $gameTendenz = $goals1 - $goals2; if ($gameTendenz<0) {$gameTendenz=-1;} if ($gameTendenz>0) {$gameTendenz=1;} if ($tippTendenz==$gameTendenz) { $score=1; } if ( ($tipp1 == $goals1) && ($tipp2 == $goals2) ) { $bonus = max(0,$goals1 + $goals2 - 3); $score= 2 + $bonus; } if ($joker==true) { $score = $score * 2; } if ($tipp1==-1||$tipp2==-1||$goals1==-1||$goals2==-1) { $score=0; } return $score; } public static function getTippScore($user_id,$game_id, $team=0) { //Log::info("Getting tippstring for game_id=". $game_id .", user_id=" . $user_id.", $team=".$team); $tipp=Tipp::getTipp($user_id,$game_id); if (!$tipp) { //Log::info("not found !"); return "x"; } $tippScore=""; if ($team==0) { $tippScore= $tipp->score1;} else { $tippScore=$tipp->score2; } if ($tippScore==-1) { /*Log::info("untipped!");*/$tippScore="x";} //Log::info("Returning: ". $tippScore); return $tippScore; } public static function getScore($tipp_id) { $tipp = Tipp::where('id',$tipp_id)->first(); $game = Game::where('id',$tipp->game_id)->first(); $bonus = max(0,$game->score1 + $game->score2 - 3); $tippTendenz = $tipp->score1 - $tipp->score2; if ($tippTendenz > 0) {$tippTendenz=1;} if ($tippTendenz < 0) {$tippTendenz=-1;} $gameTendenz = $game->score1 - $game->score2; if ($gameTendenz<0) {$gameTendenz=-1;} if ($gameTendenz>0) {$gameTendenz=1;} $score=0; if ($tippTendenz == $gameTendenz) { $score=1; } if ( ($tipp->score1 == $game->score1) && ($tipp->score2 == $game->score2) ) { $score=2 + $bonus; } if ($tipp->joker==true) { $score = $score *2; } if ($game->score1 == -1) { $score=0; } if ($tipp->score1==-1 || $tipp->score2==-1) {$score=0;} return $score; } public static function resultString($tipp_id) { $tipp = Tipp::where('id',$tipp_id)->first(); $rStr="Ungetippt"; if ($tipp->score1 > -1) $rStr= $tipp->score1 . " : " . $tipp->score2; return $rStr; } }