경기방식중에 "리그방식" 로직

· 16년 전 · 1872
소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~

자주 쓰이는 경기방식중에는
1. 리그방식
2. 링크방식
3. 토너먼트방식
이렇게 존재하는데요~

아래 소스는 리그방식 생성소스입니다.
1개의 라운드 안에 중복된 팀이 경기가 잡히지 않게
기본 로직만 있는거라서 도움이 될지 모르겠네요..

<?
////////////////////////////////////////////
$jocnt = 4; // 조 갯수
$roundloopfcnt = 1; // 같은 라운드 반복 횟수:기본값1(국내프로축구에서 자주 쓰임)
$teamcnt = 12; // 조당 팀갯수
////////////////////////////////////////////
for($j=0; $j<$jocnt; $j++){
 // 1개 조내의 경기수(라운드 반복 제외)
 $if_jogamecnt = 0;
 for($i=1; $i<$teamcnt; $i++){
  $if_jogamecnt = $if_jogamecnt + $i;
 }
 // 팀별코드 부여
 for($i=0; $i<$teamcnt; $i++){
  $if_teamcode[$i] = $i+1;
 }
 // 1개 조내의 1개 라운내의 경기수
 $if_roundincnt = floor($teamcnt/2);
 // 라운드 수
 $if_roundcnt = ($if_jogamecnt / $if_roundincnt) * $roundloopfcnt;
 if(!($teamcnt%2)){ // 짝수
  $if_teamcode_0 = array_shift($if_teamcode);
  sort($if_teamcode);
 }else{
  $if_teamcode_temp = $if_teamcode;
  $temp1 = array_pop($if_teamcode);
  for($ti=1; $ti<=count($if_teamcode); $ti++){
   $if_teamcode_temp[$ti] = $if_teamcode[$ti-1];
  }
  $if_teamcode_temp[0] = $temp1;
  ksort($if_teamcode_temp);
  $if_teamcode = $if_teamcode_temp;
 }
 $if_teamcode2 = $if_teamcode;
 for($c=0; $c<$if_roundcnt; $c++){
  for($i=0; $i<$if_roundincnt; $i++){
   $if_gamecnt++;
   if(!($teamcnt%2)){
    if($i==0){
     $team1 = $if_teamcode_0;
     $team2 = $if_teamcode2[0];
    }else{
     $team1 = $if_teamcode2[$i];
     $team2 = $if_teamcode2[count($if_teamcode2)-($i)];
    }
   }else{
    $team1 = $if_teamcode2[$i+1];
    $team2 = $if_teamcode2[count($if_teamcode2)-($i+1)];
   }
   echo "No. ".$if_gamecnt." || ".($j+1)." 조 | ".($c+1)." 라운드 | ".$team1."팀 vs ".$team2."팀<br>";
  }
  $temp1 = array_pop($if_teamcode2);
  for($ti=1; $ti<=count($if_teamcode2); $ti++){
   $if_teamcode3[$ti] = $if_teamcode2[$ti-1];
  }
  $if_teamcode3[0] = $temp1;
  ksort($if_teamcode3);
  $if_teamcode2 = $if_teamcode3;
 }
}
?>
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
15년 전 조회 872
15년 전 조회 1,335
15년 전 조회 1,322
15년 전 조회 3,090
15년 전 조회 3,475
15년 전 조회 2,152
15년 전 조회 1,604
15년 전 조회 2,220
15년 전 조회 1,714
15년 전 조회 1,338
15년 전 조회 4,027
15년 전 조회 1,679
15년 전 조회 1,763
15년 전 조회 3,042
15년 전 조회 1,733
15년 전 조회 4,418
15년 전 조회 2,623
15년 전 조회 3,399
15년 전 조회 2,037
15년 전 조회 2,266
15년 전 조회 1,549
15년 전 조회 4,609
15년 전 조회 4,262
15년 전 조회 4,064
15년 전 조회 5,448
15년 전 조회 3,688
15년 전 조회 2,047
15년 전 조회 1,996
15년 전 조회 2,140
16년 전 조회 1,848
16년 전 조회 4,283
16년 전 조회 3,172
16년 전 조회 2,333
16년 전 조회 1,923
16년 전 조회 2,128
16년 전 조회 2,634
16년 전 조회 1,714
16년 전 조회 2,635
16년 전 조회 1,960
16년 전 조회 2,096
16년 전 조회 1,740
16년 전 조회 2,435
16년 전 조회 1,756
16년 전 조회 2,179
16년 전 조회 2,346
16년 전 조회 1,434
16년 전 조회 1,498
16년 전 조회 2,148
16년 전 조회 5,571
16년 전 조회 1,873
16년 전 조회 2,392
16년 전 조회 2,591
16년 전 조회 1,744
16년 전 조회 1,536
16년 전 조회 2,454
16년 전 조회 5,164
16년 전 조회 2,439
16년 전 조회 3,099
16년 전 조회 1,966
16년 전 조회 3,841
16년 전 조회 4,678
16년 전 조회 3,324
16년 전 조회 2,562
16년 전 조회 2,658
16년 전 조회 2,898
16년 전 조회 2,405
16년 전 조회 5,783
16년 전 조회 3,596
16년 전 조회 1,585
16년 전 조회 1,930
16년 전 조회 5,294
16년 전 조회 2,548
16년 전 조회 3,628
16년 전 조회 2,902
16년 전 조회 1,771
16년 전 조회 5,612
16년 전 조회 2,726
16년 전 조회 6,193
16년 전 조회 2,154
16년 전 조회 4,226
16년 전 조회 3,255
16년 전 조회 2,438
16년 전 조회 2,449
16년 전 조회 4,614
16년 전 조회 3,512
16년 전 조회 3,050
16년 전 조회 3,181
16년 전 조회 2,307
16년 전 조회 1,981
16년 전 조회 1,900
16년 전 조회 1,603
16년 전 조회 1,904
16년 전 조회 2,119
16년 전 조회 1,812
16년 전 조회 5,054
16년 전 조회 4,075
16년 전 조회 2,001
16년 전 조회 1,763
16년 전 조회 2,483
16년 전 조회 4,766