ilmala / tourney
一个简单的随机锦标赛生成器
0.1.1
2022-10-28 08:48 UTC
Requires
- php: ^8.1
- illuminate/collections: ^9.36
- illuminate/support: ^9.36
Requires (Dev)
- pestphp/pest: ^1.22
README
一个简单的随机锦标赛生成器
特性
- 从3到30支队伍的锦标赛
- 偶数和奇数队伍数量,多余队伍轮换
如何使用
use Tourney\Tourney; $teamNames = [ 'Bayern Monaco', 'Olimpia Milano', 'Partizan', 'Virtus Bologna' ]; $tournament = (new Tourney())->generate( participants: $teams, );
打印结果
// Basic Loop foreach ($tournament->turns() as $turn) { echo "Turn {$turn->number()}<br>"; foreach ($turn->games() as $game) { echo "{$game->description()}<br>"; } echo "<br>"; }
队伍可以是Tourney\Models\Team
类的实例
$team = new \Tourney\Models\Team( name: 'Olimpia Milano', key: 'OM-01', ); $team->name(); // The name of the Team $team->key(); // Maybe a reference key of your application team model