-
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
6 changed files
with
424 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Table\Judo; | ||
|
||
use Exception; | ||
use System25\T3sports\Table\Football\Comparator; | ||
use System25\T3sports\Table\Football\Configurator as FootballConfigurator; | ||
use System25\T3sports\Table\IComparator; | ||
use tx_rnbase; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2024 Rene Nitzsche ([email protected]) | ||
* 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 tx_cfcleaguefe_table_football_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'); | ||
} | ||
} |
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,246 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Table\Judo; | ||
|
||
use System25\T3sports\Model\Fixture; | ||
use System25\T3sports\Table\Football\Table as FootballTable; | ||
use System25\T3sports\Table\IConfigurator; | ||
use System25\T3sports\Table\ITeam; | ||
use System25\T3sports\Utility\MatchSets; | ||
use tx_rnbase; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2011-2024 Rene Nitzsche ([email protected]) | ||
* 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! | ||
***************************************************************/ | ||
|
||
/** | ||
* Computes league tables for judo. | ||
* TODO: implement | ||
* Rules: | ||
* We will count points, sets and balls | ||
* team 1: 2:0, 2:1, 43:41 | ||
* 2 point for winner. | ||
*/ | ||
class Table extends FootballTable | ||
{ | ||
public const TABLE_TYPE = 'judo'; | ||
|
||
/** | ||
* @return Configurator | ||
*/ | ||
public function getConfigurator($forceNew = false): IConfigurator | ||
{ | ||
if ($forceNew || !is_object($this->configurator)) { | ||
$configuratorClass = $this->getConfValue('configuratorClass'); | ||
$configuratorClass = $configuratorClass ? $configuratorClass : Configurator::class; | ||
$this->configurator = tx_rnbase::makeInstance($configuratorClass, $this->getMatchProvider()->getBaseCompetition(), $this->configuration, $this->confId); | ||
} | ||
|
||
return $this->configurator; | ||
} | ||
|
||
/** | ||
* Zählt die Punkte für eine normale Tabelle. | ||
* | ||
* @param Fixture $match | ||
* @param int $toto | ||
* @param IConfigurator $configurator | ||
*/ | ||
protected function countStandard($match, $toto, IConfigurator $configurator) | ||
{ | ||
// Anzahl Spiele aktualisieren | ||
$home = $match->getHome(); | ||
$guest = $match->getGuest(); | ||
$this->addMatchCount($home); | ||
$this->addMatchCount($guest); | ||
|
||
// Für H2H modus das Spielergebnis merken | ||
$this->addResult($home, $guest, $match->getResult()); | ||
|
||
if (0 == $toto) { // Unentschieden | ||
$this->addPoints($home, $configurator->getPointsDraw()); | ||
$this->addPoints($guest, $configurator->getPointsDraw()); | ||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($home, $configurator->getPointsDraw()); | ||
$this->addPoints2($guest, $configurator->getPointsDraw()); | ||
} | ||
|
||
$this->addDrawCount($home); | ||
$this->addDrawCount($guest); | ||
} elseif (1 == $toto) { // Heimsieg | ||
// Für die | ||
$this->addPoints($home, $configurator->getPointsWin($match->getGoalsHome(), $match->getGoalsGuest())); | ||
$this->addPoints($guest, $configurator->getPointsLoose($match->getGoalsHome(), $match->getGoalsGuest())); | ||
|
||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($guest, $configurator->getPointsLoose($match->getGoalsHome(), $match->getGoalsGuest())); | ||
} | ||
|
||
$this->addWinCount($home); | ||
$this->addLoseCount($guest); | ||
} else { // Auswärtssieg | ||
$this->addPoints($home, $configurator->getPointsLoose($match->getGoalsHome(), $match->getGoalsGuest())); | ||
$this->addPoints($guest, $configurator->getPointsWin($match->getGoalsHome(), $match->getGoalsGuest())); | ||
|
||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($home, $configurator->getPointsWin($match->getGoalsHome(), $match->getGoalsGuest())); | ||
} | ||
$this->addLoseCount($home); | ||
$this->addWinCount($guest); | ||
} | ||
|
||
// $ballsHome = MatchSets::countSetPointsHome($match); | ||
// $ballsGuest = MatchSets::countSetPointsGuest($match); | ||
// $this->addBalls($home, $ballsHome, $ballsGuest); | ||
// $this->addBalls($guest, $ballsGuest, $ballsHome); | ||
|
||
// Jetzt die Tore summieren | ||
$this->addSets($home, $match->getGoalsHome(), $match->getGoalsGuest()); | ||
$this->addSets($guest, $match->getGoalsGuest(), $match->getGoalsHome()); | ||
} | ||
|
||
protected function initTeam(ITeam $team) | ||
{ | ||
$this->_teamData->setTeamData($team, 'balls1', 0); | ||
$this->_teamData->setTeamData($team, 'balls2', 0); | ||
$this->_teamData->setTeamData($team, 'balls_diff', 0); | ||
$this->_teamData->setTeamData($team, 'sets1', 0); | ||
$this->_teamData->setTeamData($team, 'sets2', 0); | ||
$this->_teamData->setTeamData($team, 'sets_diff', 0); | ||
} | ||
|
||
/** | ||
* Addiert Sätze zu einem Team. | ||
*/ | ||
protected function addSets(ITeam $team, $sets1, $sets2) | ||
{ | ||
$data = $this->_teamData->getTeamData($team->getTeamId()); | ||
$newSets1 = $data['sets1'] + $sets1; | ||
$newSets2 = $data['sets2'] + $sets2; | ||
$this->_teamData->setTeamData($team, 'sets1', $newSets1); | ||
$this->_teamData->setTeamData($team, 'sets2', $newSets2); | ||
$this->_teamData->setTeamData($team, 'sets_diff', $newSets1 - $newSets2); | ||
// TODO: Muss hier ggf. gerundet werden?? | ||
$this->_teamData->setTeamData($team, 'sets_quot', $newSets1 / ($newSets2 > 0 ? $newSets2 : 1)); | ||
} | ||
|
||
/** | ||
* Addiert Bälle zu einem Team. | ||
*/ | ||
protected function addBalls(ITeam $team, $balls1, $balls2) | ||
{ | ||
$data = $this->_teamData->getTeamData($team->getTeamId()); | ||
$newBalls1 = $data['balls1'] + $balls1; | ||
$newBalls2 = $data['balls2'] + $balls2; | ||
$this->_teamData->setTeamData($team, 'balls1', $newBalls1); | ||
$this->_teamData->setTeamData($team, 'balls2', $newBalls2); | ||
$this->_teamData->setTeamData($team, 'balls_diff', $newBalls1 - $newBalls2); | ||
$this->_teamData->setTeamData($team, 'balls_quot', $newBalls1 / ($newBalls2 > 0 ? $newBalls2 : 1)); | ||
} | ||
|
||
/** | ||
* Zählt die Punkte für eine Heimspieltabelle. Die Ergebnisse werden als nur für die | ||
* Heimmannschaft gewertet. | ||
* | ||
* @param Fixture $match | ||
* @param int $toto | ||
* @param IConfigurator $configurator | ||
*/ | ||
protected function countHome($match, $toto, IConfigurator $configurator) | ||
{ | ||
$home = $match->getHome(); | ||
$guest = $match->getGuest(); | ||
|
||
// Anzahl Spiele aktualisieren | ||
$this->addMatchCount($home); | ||
$this->addResult($home, $guest, $match->getGuest()); | ||
|
||
if (0 == $toto) { // Unentschieden | ||
$this->addPoints($home, $configurator->getPointsDraw()); | ||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($home, $configurator->getPointsDraw()); | ||
} | ||
$this->addDrawCount($home); | ||
} elseif (1 == $toto) { // Heimsieg | ||
$this->addPoints($home, $configurator->getPointsWin($match->isExtraTime(), $match->isPenalty())); | ||
$this->addWinCount($home); | ||
} else { // Auswärtssieg | ||
$this->addPoints($home, $configurator->getPointsLoose($match->isExtraTime(), $match->isPenalty())); | ||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($home, $configurator->getPointsWin($match->isExtraTime(), $match->isPenalty())); | ||
} | ||
$this->addLoseCount($home); | ||
} | ||
// $ballsHome = MatchSets::countSetPointsHome($match); | ||
// $ballsGuest = MatchSets::countSetPointsGuest($match); | ||
// $this->addBalls($home, $ballsHome, $ballsGuest); | ||
|
||
// Jetzt die Sätze summieren | ||
$this->addSets($home, $match->getGoalsHome(), $match->getGoalsGuest()); | ||
} | ||
|
||
/** | ||
* Zählt die Punkte für eine Auswärtstabelle. Die Ergebnisse werden als nur für die | ||
* Gastmannschaft gewertet. | ||
* | ||
* @param Fixture $match | ||
* @param int $toto | ||
* @param IConfigurator $configurator | ||
*/ | ||
protected function countGuest($match, $toto, IConfigurator $configurator) | ||
{ | ||
$home = $match->getHome(); | ||
$guest = $match->getGuest(); | ||
// Anzahl Spiele aktualisieren | ||
$this->addMatchCount($guest); | ||
$this->addResult($home, $guest, $match->getGuest()); | ||
|
||
if (0 == $toto) { // Unentschieden | ||
$this->addPoints($guest, $configurator->getPointsDraw()); | ||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($guest, $configurator->getPointsDraw()); | ||
} | ||
$this->addDrawCount($guest); | ||
} elseif (1 == $toto) { // Heimsieg | ||
$this->addPoints($guest, $configurator->getPointsLoose($match->isExtraTime(), $match->isPenalty())); | ||
if ($configurator->isCountLoosePoints()) { | ||
$this->addPoints2($guest, $configurator->getPointsWin($match->isExtraTime(), $match->isPenalty())); | ||
} | ||
$this->addLoseCount($guest); | ||
} else { // Auswärtssieg | ||
$this->addPoints($guest, $configurator->getPointsWin($match->isExtraTime(), $match->isPenalty())); | ||
$this->addWinCount($guest); | ||
} | ||
|
||
$ballsHome = MatchSets::countSetPointsHome($match); | ||
$ballsGuest = MatchSets::countSetPointsGuest($match); | ||
$this->addBalls($guest, $ballsGuest, $ballsHome); | ||
|
||
// Jetzt die Tore summieren | ||
$this->addSets($guest, $match->getGoalsGuest(), $match->getGoalsHome()); | ||
} | ||
|
||
public function getTypeID(): string | ||
{ | ||
return self::TABLE_TYPE; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -7,11 +7,7 @@ | |
/*************************************************************** | ||
* Copyright notice | ||
* | ||
<<<<<<< HEAD | ||
* (c) 2011-2024 Rene Nitzsche ([email protected]) | ||
======= | ||
* (c) 2011-2023 Rene Nitzsche ([email protected]) | ||
>>>>>>> master | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
|
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
Oops, something went wrong.