發新話題
打印

預算賽電腦抽籤代碼公告

[Close]

預算賽電腦抽籤代碼公告

未表公正先公開抽籤關鍵程式代碼
複製內容到剪貼板
代碼:
$count = 0;
srand((float) microtime() * 10000000);
while(count($team_list))
{
        $team_a = NULL;
        $team_b = NULL;

    $index = array_rand($team_list);
    $team_a = $team_list[$index];
    unset($team_list[$index]);
   
    if($team_a==3 || $team_a==20 || $team_a==27 || $team_a==24)  // 四隊種仔隊不用打預選直到16強
    {
        $team_b = 0;
        $query = sprintf('INSERT INTO game_nob5_team_pair (step,num_team,num_round,teams,regdate) VALUES (%d, 2, 3, "%s", "%s")',
            $step,
            $team_a.','.$team_b,
            date("y-m-d H:i:s")
        );
        mysql_query($query, $sql);
        $count++;
        continue;
    }
   
    if(count($team_list) == 0)
    {
        $team_b = 0; // 單數隊, 不戰勝
    }
    else
    {
        $index = array_rand($team_list);
        $team_b = $team_list[$index];
        unset($team_list[$index]);
    }
   
    $team_n = 0;
    if($team_a > $team_b)
    {
        $team_n = $team_a;
        $team_a = $team_b;
        $team_b = $team_n;
    }
   
    if($team_a==18 && $team_b==45)  //避開分隊
    {
        array_push($team_list, $team_a);
        array_push($team_list, $team_b);
        continue;
    }
   
    if($team_a==27 && $team_b==28) //避開分隊
    {
        array_push($team_list, $team_a);
        array_push($team_list, $team_b);
        continue;
    }   
   
    if($team_a==11 && $team_b==49) //避開分隊
    {
        array_push($team_list, $team_a);
        array_push($team_list, $team_b);
        continue;
    }
   
    if($team_a==16 && $team_b==26) //避開分隊
    {
        array_push($team_list, $team_a);
        array_push($team_list, $team_b);
        continue;
    }
   
    if($team_a==40 && $team_b==49) //避開分隊
    {
        array_push($team_list, $team_a);
        array_push($team_list, $team_b);
        continue;
    }
   
    $query = sprintf('INSERT INTO game_nob5_team_pair (step,num_team,num_round,teams,regdate) VALUES (%d, 2, 3, "%s", "%s")',
        $step,
        $team_a.','.$team_b,
        date("y-m-d H:i:s")
    );
    mysql_query($query, $sql);
   
    $count++;
}

TOP

發新話題