Pint applied for formatting

This commit is contained in:
Alex Wulf
2022-07-05 15:55:47 +02:00
parent bfc558d1f2
commit 7d4547df6a
68 changed files with 670 additions and 402 deletions

View File

@ -1,4 +1,6 @@
<?php namespace DNW\Skills;
<?php
namespace DNW\Skills;
use Exception;
@ -8,7 +10,9 @@ use Exception;
abstract class SkillCalculator
{
private $_supportedOptions;
private $_playersPerTeamAllowed;
private $_totalTeamsAllowed;
protected function __construct($supportedOptions, TeamsRange $totalTeamsAllowed, PlayersRange $playerPerTeamAllowed)
@ -20,24 +24,24 @@ abstract class SkillCalculator
/**
* Calculates new ratings based on the prior ratings and team ranks.
* @param GameInfo $gameInfo Parameters for the game.
* @param array $teamsOfPlayerToRatings A mapping of team players and their ratings.
* @param array $teamRanks The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
*
* @param GameInfo $gameInfo Parameters for the game.
* @param array $teamsOfPlayerToRatings A mapping of team players and their ratings.
* @param array $teamRanks The ranks of the teams where 1 is first place. For a tie, repeat the number (e.g. 1, 2, 2).
* @return All the players and their new ratings.
*/
public abstract function calculateNewRatings(GameInfo $gameInfo,
abstract public function calculateNewRatings(GameInfo $gameInfo,
array $teamsOfPlayerToRatings,
array $teamRanks);
/**
* Calculates the match quality as the likelihood of all teams drawing.
*
* @param GameInfo $gameInfo Parameters for the game.
* @param array $teamsOfPlayerToRatings A mapping of team players and their ratings.
* @param GameInfo $gameInfo Parameters for the game.
* @param array $teamsOfPlayerToRatings A mapping of team players and their ratings.
* @return The quality of the match between the teams as a percentage (0% = bad, 100% = well matched).
*/
public abstract function calculateMatchQuality(GameInfo $gameInfo, array $teamsOfPlayerToRatings);
abstract public function calculateMatchQuality(GameInfo $gameInfo, array $teamsOfPlayerToRatings);
public function isSupported($option)
{
@ -49,21 +53,19 @@ abstract class SkillCalculator
self::validateTeamCountAndPlayersCountPerTeamWithRanges($teamsOfPlayerToRatings, $this->_totalTeamsAllowed, $this->_playersPerTeamAllowed);
}
private static function validateTeamCountAndPlayersCountPerTeamWithRanges(array $teams,
TeamsRange $totalTeams,
PlayersRange $playersPerTeam)
private static function validateTeamCountAndPlayersCountPerTeamWithRanges(array $teams, TeamsRange $totalTeams, PlayersRange $playersPerTeam)
{
$countOfTeams = 0;
foreach ($teams as $currentTeam) {
if (!$playersPerTeam->isInRange(count($currentTeam))) {
throw new Exception("Player count is not in range");
if (! $playersPerTeam->isInRange(count($currentTeam))) {
throw new Exception('Player count is not in range');
}
$countOfTeams++;
}
if (!$totalTeams->isInRange($countOfTeams)) {
throw new Exception("Team range is not in range");
if (! $totalTeams->isInRange($countOfTeams)) {
throw new Exception('Team range is not in range');
}
}
}
@ -71,6 +73,8 @@ abstract class SkillCalculator
class SkillCalculatorSupportedOptions
{
const NONE = 0x00;
const PARTIAL_PLAY = 0x01;
const PARTIAL_UPDATE = 0x02;
}
}