diff --git a/src/Models/Tipp.php b/src/Models/Tipp.php index c559404..99da725 100644 --- a/src/Models/Tipp.php +++ b/src/Models/Tipp.php @@ -51,33 +51,37 @@ class Tipp { } /** - * Gibt das Styling/die Farbe für die Tendenz zurück (fürs Frontend) + * 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; - 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 ""; + // 2. Richtige Tordifferenz (impliziert richtige Tendenz, außer bei Unentschieden) + if ($tippTendenz == $gameTendenz) { + return "col_diff"; } - $styling = 'background-color:grey;'; + // 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 (($tipp1 == $goals1) && ($tipp2 == $goals2)) { - $styling = 'background-color:orange;'; - if ($joker) { - $styling = 'background-color:red'; - } + if ($tippSign == $gameSign) { + return "col_tendenz"; } - return $styling; + + // Kein Treffer + return ""; } } diff --git a/src/Views/ranking.php b/src/Views/ranking.php index b56b0c3..3b5b98a 100644 --- a/src/Views/ranking.php +++ b/src/Views/ranking.php @@ -66,7 +66,7 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR $td_class = 'col_joker_exact'; } ?> - + 🃏 diff --git a/src/Views/round.php b/src/Views/round.php index 938241a..3812096 100644 --- a/src/Views/round.php +++ b/src/Views/round.php @@ -65,7 +65,7 @@ require __DIR__ . '/partials/header.php'; $td_class = 'col_joker_exact'; } ?> - + 🃏