0) { $tippTendenz = 1; } if ($tippTendenz < 0) { $tippTendenz = -1; } $gameTendenz = $goals1 - $goals2; if ($gameTendenz < 0) { $gameTendenz = -1; } if ($gameTendenz > 0) { $gameTendenz = 1; } // Tendenz richtig if ($tippTendenz == $gameTendenz) { $score = 1; } // Genaues Ergebnis richtig (gibt 2 Grundpunkte + Bonus) if (($tipp1 == $goals1) && ($tipp2 == $goals2)) { $bonus = max(0, $goals1 + $goals2 - 3); $score = 2 + $bonus; } // Joker verdoppelt die Punktzahl if ($joker == true) { $score = $score * 2; } return $score; } /** * Gibt das Styling/die Farbe für die Tendenz zurück (fürs Frontend) */ public static function getCol($goals1, $goals2, $tipp1, $tipp2, $joker) { if ($tipp1 == -1 || $tipp2 == -1 || $goals1 == -1 || $goals2 == -1) { return ""; } $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) { return ""; } $styling = 'background-color:grey;'; if (($tipp1 == $goals1) && ($tipp2 == $goals2)) { $styling = 'background-color:orange;'; if ($joker) { $styling = 'background-color:red'; } } return $styling; } }