From 22702f705a817c29f1708aad4d5ae0cfb8f023dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nitzsche?= <rene@system25.de>
Date: Thu, 4 Apr 2024 21:55:56 +0200
Subject: [PATCH] Fix table generation for judo

---
 Classes/Table/Judo/Comparator.php              | 8 ++++----
 Resources/Private/Language/de.locallang_db.xlf | 4 ++++
 Resources/Private/Language/locallang_db.xlf    | 3 +++
 ext_localconf.php                              | 1 +
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Classes/Table/Judo/Comparator.php b/Classes/Table/Judo/Comparator.php
index fc14118..d0286c2 100644
--- a/Classes/Table/Judo/Comparator.php
+++ b/Classes/Table/Judo/Comparator.php
@@ -54,12 +54,12 @@ public function compare($t1, $t2)
 
         if ($t1['points'] == $t2['points']) {
             // Punkte sind gleich, also Differenzen der Siege prüfen
-            $t1diff = $t1['goals1'] - $t1['goals2'];
-            $t2diff = $t2['goals1'] - $t2['goals2'];
+            $t1diff = $t1['fights1'] - $t1['fights2'];
+            $t2diff = $t2['fights1'] - $t2['fights2'];
             if ($t1diff == $t2diff) {
                 // Jetzt zählt die Differenz der Unterbewertung
-                $t1scorediff = $t1['score1'] - $t1['score2'];
-                $t2scorediff = $t2['score1'] - $t2['score2'];
+                $t1scorediff = $t1['scores1'] - $t1['scores2'];
+                $t2scorediff = $t2['scores1'] - $t2['scores2'];
                 if ($t1scorediff == $t2scorediff) {
                     return 0; // Punkt und Torgleich
                 }
diff --git a/Resources/Private/Language/de.locallang_db.xlf b/Resources/Private/Language/de.locallang_db.xlf
index 6a5a1a4..a569721 100644
--- a/Resources/Private/Language/de.locallang_db.xlf
+++ b/Resources/Private/Language/de.locallang_db.xlf
@@ -551,6 +551,10 @@
 				<source>Volleyball 3 point system</source>
 				<target>Volleyball 3 Punktsystem</target>
 			</trans-unit>
+			<trans-unit id="tablestrategy_judo_2point" xml:space="preserve">
+				<source>Judo 2 point system</source>
+				<target>Judo 2 Punktsystem</target>
+			</trans-unit>
 		</body>
 	</file>
 </xliff>
diff --git a/Resources/Private/Language/locallang_db.xlf b/Resources/Private/Language/locallang_db.xlf
index a5f96fc..c41ded5 100644
--- a/Resources/Private/Language/locallang_db.xlf
+++ b/Resources/Private/Language/locallang_db.xlf
@@ -414,6 +414,9 @@
 			<trans-unit id="tablestrategy_volleyball_3point" xml:space="preserve">
 				<source>Volleyball 3 point system</source>
 			</trans-unit>
+			<trans-unit id="tablestrategy_judo_2point" xml:space="preserve">
+				<source>Judo 2 point system</source>
+			</trans-unit>
 		</body>
 	</file>
 </xliff>
diff --git a/ext_localconf.php b/ext_localconf.php
index a1179c0..6cf3d48 100644
--- a/ext_localconf.php
+++ b/ext_localconf.php
@@ -28,6 +28,7 @@
 System25\T3sports\Utility\Misc::registerTableStrategy('pointpermatch', 'LLL:EXT:cfc_league_fe/Resources/Private/Language/locallang_db.xlf:tablestrategy_pointpermatch', System25\T3sports\Table\ComparatorPPM::class);
 System25\T3sports\Utility\Misc::registerTableStrategy('volleyball3', 'LLL:EXT:cfc_league_fe/Resources/Private/Language/locallang_db.xlf:tablestrategy_volleyball_3point', System25\T3sports\Table\Volleyball\Comparator3Point::class);
 System25\T3sports\Utility\Misc::registerTableStrategy('volleyball2', 'LLL:EXT:cfc_league_fe/Resources/Private/Language/locallang_db.xlf:tablestrategy_volleyball_2point', System25\T3sports\Table\Volleyball\Comparator::class);
+System25\T3sports\Utility\Misc::registerTableStrategy('judo2', 'LLL:EXT:cfc_league_fe/Resources/Private/Language/locallang_db.xlf:tablestrategy_judo_2point', System25\T3sports\Table\Judo\Comparator::class);
 
 // FIXME: use DI for T3 10.x and higher
 // if (!\Sys25\RnBase\Utility\TYPO3::isTYPO104OrHigher()) {