diff --git a/src/Models/Tipp.php b/src/Models/Tipp.php index 265a163..10737ea 100644 --- a/src/Models/Tipp.php +++ b/src/Models/Tipp.php @@ -80,38 +80,26 @@ class Tipp { } /** - * Gibt die CSS-Klasse für die Farbe des Tipps zurück (fürs Frontend) + * Gibt die CSS-Klasse für die Farbe des Tipps zurück (portiert aus Legacy Tipp::trendCol). + * + * - "col_tendenz" = richtige Tendenz (grau) + * - "col_exact" = richtiges Ergebnis (orange) + * - "col_joker_exact" = richtiges Ergebnis mit Joker (rot) + * - "" = kein Treffer, nicht getippt oder noch kein Ergebnis */ 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"; + if (self::isExact($goals1, $goals2, $tipp1, $tipp2)) { + return $joker ? "col_joker_exact" : "col_exact"; } - // Tendenzen berechnen - $tippTendenz = $tipp1 - $tipp2; - $gameTendenz = $goals1 - $goals2; + $tippSign = $tipp1 <=> $tipp2; + $gameSign = $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 ""; + return $tippSign === $gameSign ? "col_tendenz" : ""; } /** diff --git a/src/Views/ranking.php b/src/Views/ranking.php index 732569d..2f84c18 100644 --- a/src/Views/ranking.php +++ b/src/Views/ranking.php @@ -66,11 +66,10 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR