philicevic/berger
最新稳定版本:0.3.0
Composer 安装命令:
composer require philicevic/berger
包简介
A tool to create round robin tournament matchups using the Berger tables
README 文档
README
This package allows you to generate round robin tournament matchups based on the Berger tables.
Usage
use Philicevic\Berger\Services\RoundRobin;
// this creates 6 rounds where teams play each other twice
$teams = ['A', 'B', 'C', 'D'];
$matchesAgainstEachOther = 2;
$rounds = RoundRobin::makeFromTeams($teams, $matchesAgainstEachOther);
// or use it step by step
$teams = ['A', 'B', 'C', 'D'];
$rr = RoundRobin::create();
$rr->setTeams($teams);
$rounds = $rr->make();
$rounds will be an array of Round objects.
Round
foreach ($rounds as $round) {
// get array of fixtures
$round->fixtures;
// get number of round
$round->number;
// add fixture to round
$round->addFixture($fixture);
// remove fixture from round by index
$round->removeFixture($index);
// format round as array
$round->toArray();
}
// $round->toArray() will return something like this
[
[
[
'home' => 'A',
'away' => 'C',
'round' => 1,
],
[
'home' => 'B',
'away' => 'D',
'round' => 1,
],
],
[
[
'home' => 'C',
'away' => 'B',
'round' => 2,
],
[
'home' => 'D',
'away' => 'A',
'round' => 2,
],
],
[
[
'home' => 'A',
'away' => 'B',
'round' => 3,
],
[
'home' => 'C',
'away' => 'D',
'round' => 3,
],
],
]
Fixture
Every fixture has two properties.
$fixture->home
$fixture->away
Both contain just the name of the team.
You could also access the teams via the getTeams method.
// returns ["Team A", "Team B"]
$fixture->getTeams()
If you want to swap the places of the teams for a fixture you can also do that.
$fixture->swapTeams()
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-21