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 die CSS-Klasse für die Farbe des Tipps zurück (fürs Frontend) */ public static function getCol($goals1, $goals2, $tipp1, $tipp2, $joker) { if ($tipp1 == -1 || $tipp2 == -1 || $goals1 == -1 || $goals2 == -1) { return ""; } // 1. Exaktes Ergebnis if ($tipp1 == $goals1 && $tipp2 == $goals2) { return "col_exact"; } // Tendenzen berechnen $tippTendenz = $tipp1 - $tipp2; $gameTendenz = $goals1 - $goals2; // 2. Richtige Tordifferenz (impliziert richtige Tendenz, außer bei Unentschieden) if ($tippTendenz == $gameTendenz) { return "col_diff"; } // 3. Richtige Tendenz (Sieg, Niederlage, Unentschieden) // Normalisiere Tendenz auf -1, 0, 1 $tippSign = ($tippTendenz > 0) ? 1 : (($tippTendenz < 0) ? -1 : 0); $gameSign = ($gameTendenz > 0) ? 1 : (($gameTendenz < 0) ? -1 : 0); if ($tippSign == $gameSign) { return "col_tendenz"; } // Kein Treffer return ""; } }