ilmala/tourney

一个简单的随机锦标赛生成器

0.1.1 2022-10-28 08:48 UTC

This package is auto-updated.

Last update: 2024-09-28 13:51:20 UTC


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