-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* digedag/cfc_league#99 Add judo as sports
- Loading branch information
Showing
10 changed files
with
509 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Table\Judo; | ||
|
||
use System25\T3sports\Table\IComparator; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2011-2024 Rene Nitzsche (rene@system25.de) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
/** | ||
* Comperator methods for volleyball league tables. | ||
*/ | ||
class Comparator implements IComparator | ||
{ | ||
private $_teamData; | ||
|
||
public function setTeamData(array &$teamdata) | ||
{ | ||
$this->_teamData = $teamdata; | ||
} | ||
|
||
/** | ||
* Funktion zur Sortierung der Tabellenzeilen. | ||
*/ | ||
public function compare($t1, $t2) | ||
{ | ||
// Zwangsabstieg prüfen | ||
if (-1 == ($t1['static_position'] ?? 0)) { | ||
return 1; | ||
} | ||
if (-1 == ($t2['static_position'] ?? 0)) { | ||
return -1; | ||
} | ||
|
||
if ($t1['points'] == $t2['points']) { | ||
// Punkte sind gleich, also Differenzen der Siege prüfen | ||
$t1diff = $t1['goals1'] - $t1['goals2']; | ||
$t2diff = $t2['goals1'] - $t2['goals2']; | ||
if ($t1diff == $t2diff) { | ||
// Jetzt zählt die Differenz der Unterbewertung | ||
$t1scorediff = $t1['score1'] - $t1['score2']; | ||
$t2scorediff = $t2['score1'] - $t2['score2']; | ||
if ($t1scorediff == $t2scorediff) { | ||
return 0; // Punkt und Torgleich | ||
} | ||
|
||
return $t1scorediff > $t2scorediff ? -1 : 1; | ||
} | ||
|
||
return $t1diff > $t2diff ? -1 : 1; | ||
} | ||
|
||
return $t1['points'] > $t2['points'] ? -1 : 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Table\Judo; | ||
|
||
use Exception; | ||
use System25\T3sports\Table\Football\Configurator as FootballConfigurator; | ||
use System25\T3sports\Table\IComparator; | ||
use tx_rnbase; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2024 Rene Nitzsche (rene@system25.de) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
/** | ||
* Configurator for handball league tables. | ||
*/ | ||
class Configurator extends FootballConfigurator | ||
{ | ||
/** | ||
* Whether or not loose points are count. | ||
* | ||
* @return bool | ||
*/ | ||
public function isCountLoosePoints() | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* 0- 2-Punktsystem. | ||
*/ | ||
public function getPointSystem() | ||
{ | ||
return $this->cfgPointSystem; | ||
} | ||
|
||
/** | ||
* @return IComparator | ||
*/ | ||
public function getComparator(): IComparator | ||
{ | ||
$compareClass = $this->cfgComparatorClass ? $this->cfgComparatorClass : Comparator::class; | ||
$comparator = tx_rnbase::makeInstance($compareClass); | ||
if (!is_object($comparator)) { | ||
throw new Exception('Could not instanciate comparator: '.$compareClass); | ||
} | ||
if (!($comparator instanceof IComparator)) { | ||
throw new Exception('Comparator is no instance of System25\T3sports\Table\IComparator: '.get_class($comparator)); | ||
} | ||
|
||
return $comparator; | ||
} | ||
|
||
protected function init() | ||
{ | ||
// Der TableScope wirkt sich auf die betrachteten Spiele (Hin-Rückrunde) aus | ||
$parameters = $this->configurations->getParameters(); | ||
$this->cfgTableScope = $this->getConfValue('tablescope'); | ||
// Wir bleiben mit den alten falschen TS-Einstellungen kompatibel und fragen | ||
// beide Einstellungen ab | ||
if ($this->configurations->get('tabletypeSelectionInput') || $this->getConfValue('tablescopeSelectionInput')) { | ||
$this->cfgTableScope = $parameters->offsetGet('tablescope') ? $parameters->offsetGet('tablescope') : $this->cfgTableScope; | ||
} | ||
|
||
// tabletype means home or away matches only | ||
$this->cfgTableType = $this->getConfValue('tabletype'); | ||
if ($this->configurations->get('tabletypeSelectionInput') || $this->getConfValue('tabletypeSelectionInput')) { | ||
$this->cfgTableType = $parameters->offsetGet('tabletype') ? $parameters->offsetGet('tabletype') : $this->cfgTableType; | ||
} | ||
|
||
$this->cfgPointSystem = $this->getCompetition()->getProperty('point_system'); | ||
if ($this->configurations->get('pointSystemSelectionInput') || $this->getConfValue('pointSystemSelectionInput')) { | ||
$this->cfgPointSystem = is_string($parameters->offsetGet('pointsystem')) ? intval($parameters->offsetGet('pointsystem')) : $this->cfgPointSystem; | ||
} | ||
$this->cfgLiveTable = (int) $this->getConfValue('showLiveTable'); | ||
$this->cfgComparatorClass = $this->getStrategyValue('comparator'); | ||
} | ||
} |
Oops, something went wrong.