feat(shopro): 优化比赛模块功能和流程
- 新增赛制说明接口和页面 - 实现比赛列表和对阵详情页面 - 添加比赛计分功能 - 优化比赛报名和参赛者分配逻辑 - 重构赛制配置和对阵安排方法
This commit is contained in:
@@ -15,15 +15,18 @@ class Game17 implements GameInterface
|
||||
由前几名按比例瓜分 (可调 Default:40%/30%/20%/10%)';
|
||||
}
|
||||
|
||||
// 对阵安排
|
||||
// 首轮对阵安排
|
||||
public function match($game, $users): array
|
||||
{
|
||||
$math = $team = [];
|
||||
$utotal = count($users);
|
||||
//队伍分配
|
||||
for ($i = 0; $i < $utotal; $i++) {
|
||||
for ($j = $i + 1; $j < $utotal; $j++) {
|
||||
$team[] = json_encode([
|
||||
'name' => 'team' . $i . $j,
|
||||
$teamName = 'team' . $i . $j;
|
||||
// $team[] = json_encode([
|
||||
$team[] = ([
|
||||
'name' => $teamName,
|
||||
'user' => [
|
||||
[
|
||||
'user_id' => $users[$i]['user_id'],
|
||||
@@ -39,28 +42,44 @@ class Game17 implements GameInterface
|
||||
]
|
||||
]
|
||||
]);
|
||||
$users[$i]['team'] = $users[$j]['team'] = $teamName;
|
||||
}
|
||||
}
|
||||
// dd($team);
|
||||
$ttotal = count($users);
|
||||
// 对阵分配
|
||||
$ttotal = count($team);
|
||||
df("共 $utotal 人:");
|
||||
$n = 1;
|
||||
for ($i = 0; $i < $ttotal; $i++) {
|
||||
for ($j = $i + 1; $j < $ttotal; $j++) {
|
||||
if (array_intersect(array_column($team[$i]['user'], 'user_id'), array_column($team[$j]['user'], 'user_id'))) {
|
||||
continue;//一个人不能同时在两边队伍
|
||||
}
|
||||
$math[] = [
|
||||
'gym_id' => $game['gym_id'],
|
||||
'club_id' => $game['club_id'],
|
||||
'act_id' => $game['act_id'],
|
||||
'game_id' => $game['id'],
|
||||
'level' => 1,
|
||||
'turn' => $n,
|
||||
'teamA' => $team[$i],
|
||||
'teamB' => $team[$j],
|
||||
'level' => 1, //轮次
|
||||
'turn' => $n, //场次
|
||||
'teamA' => json_encode($team[$i]), //队伍A
|
||||
'teamB' => json_encode($team[$j]), //队伍B
|
||||
];
|
||||
// $ta =array_column($team[$i]['user'],'user_id');
|
||||
// $tb =array_column($team[$j]['user'],'user_id');
|
||||
// df("第 $n 场:".$ta[0].'/'.$ta[1].' VS '.$tb[0].'/'.$tb[1]);
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
// dd($math);
|
||||
$this->next($game, $math);
|
||||
return $math;
|
||||
}
|
||||
|
||||
// 下一轮对阵安排
|
||||
public function next($game, $math): array
|
||||
{
|
||||
$math = [];
|
||||
return $math;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,20 @@ namespace format;
|
||||
2. 规则类型:1八人转,2超八转,3混双转,4固搭转,5固定擂,6活动擂,7转转,8分区转,9擂台赛,10守擂赛,11追分赛,12固搭追分赛,13大循环群内赛,14两队PK赛,15战队淘汰赛,16单项淘汰赛,17分区循环淘汰赛
|
||||
|
||||
3. 需要引入新赛制请创建新的类文件,类文件需要实现GameInterface接口,并且文件名为`Game + 团队类型代码 + 规则类型代码.php`。
|
||||
如:赛制为双打八人转,则文件为format/Game11.php。
|
||||
赛制为单打擂台赛,则文件为format/Game29.php。
|
||||
如:赛制为双打+转转,则文件为format/Game17.php。
|
||||
赛制为单打+擂台赛,则文件为format/Game29.php。
|
||||
*/
|
||||
|
||||
interface GameInterface
|
||||
{
|
||||
// 赛制说明
|
||||
public function describe(): string;
|
||||
|
||||
// 对阵安排
|
||||
public function match($game,$users): array;
|
||||
// 首轮对阵安排
|
||||
public function match($game, $users): array;
|
||||
|
||||
// 下一轮对阵安排
|
||||
public function next($game, $math): array;
|
||||
|
||||
// 奖金分配
|
||||
public function prize($rank): array;
|
||||
|
||||
Reference in New Issue
Block a user