Skip to content

Commit

Permalink
Feature/judo (#92)
Browse files Browse the repository at this point in the history
* digedag/cfc_league#99 Add judo as sports
  • Loading branch information
digedag authored Mar 29, 2024
1 parent be95562 commit aa0fea8
Show file tree
Hide file tree
Showing 10 changed files with 509 additions and 14 deletions.
14 changes: 7 additions & 7 deletions Classes/Chart/ChartBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public function buildJson($table, $clubIds, ConfigurationInterface $configuratio
$configurations->get($confId.'team.logo.')
);
$dataSets[$scoreArr['teamId']] = [
'info' => [
'teamid' => $team->getProperty('uid'),
'clubid' => $scoreArr['clubId'],
'name' => $team->getProperty('name'),
'short_name' => $team->getProperty('short_name'),
'logo' => $logo,
],
'info' => [
'teamid' => $team->getProperty('uid'),
'clubid' => $scoreArr['clubId'],
'name' => $team->getProperty('name'),
'short_name' => $team->getProperty('short_name'),
'logo' => $logo,
],
];
}
$dataSets[$scoreArr['teamId']]['data'][] = $point;
Expand Down
2 changes: 2 additions & 0 deletions Classes/Table/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use System25\T3sports\Table\Football\Table as FootballTable;
use System25\T3sports\Table\Handball\Table as HandballTable;
use System25\T3sports\Table\Icehockey\Table as IcehockeyTable;
use System25\T3sports\Table\Judo\Table as JudoTable;
use System25\T3sports\Table\Volleyball\Table as VolleyballTable;
use tx_rnbase;

Expand Down Expand Up @@ -64,6 +65,7 @@ public static function createTableType($type)
FootballTable::TABLE_TYPE => FootballTable::class,
HandballTable::TABLE_TYPE => HandballTable::class,
IcehockeyTable::TABLE_TYPE => IcehockeyTable::class,
JudoTable::TABLE_TYPE => JudoTable::class,
VolleyballTable::TABLE_TYPE => VolleyballTable::class,
];

Expand Down
75 changes: 75 additions & 0 deletions Classes/Table/Judo/Comparator.php
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;
}
}
97 changes: 97 additions & 0 deletions Classes/Table/Judo/Configurator.php
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');
}
}
Loading

0 comments on commit aa0fea8

Please sign in to comment.