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

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

자주 쓰이는 경기방식중에는
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년 전 조회 681
15년 전 조회 1,170
15년 전 조회 1,141
15년 전 조회 2,925
15년 전 조회 3,248
15년 전 조회 1,921
15년 전 조회 1,430
15년 전 조회 2,041
15년 전 조회 1,558
15년 전 조회 1,153
15년 전 조회 3,847
15년 전 조회 1,489
15년 전 조회 1,589
15년 전 조회 2,812
15년 전 조회 1,505
15년 전 조회 4,240
15년 전 조회 2,452
15년 전 조회 3,228
15년 전 조회 1,843
15년 전 조회 2,076
15년 전 조회 1,374
15년 전 조회 4,449
15년 전 조회 4,035
15년 전 조회 3,855
15년 전 조회 5,274
15년 전 조회 3,504
15년 전 조회 1,881
15년 전 조회 1,822
15년 전 조회 1,964
15년 전 조회 1,670
15년 전 조회 4,068
15년 전 조회 2,994
15년 전 조회 2,158
16년 전 조회 1,748
16년 전 조회 1,979
16년 전 조회 2,467
16년 전 조회 1,540
16년 전 조회 2,478
16년 전 조회 1,805
16년 전 조회 1,915
16년 전 조회 1,550
16년 전 조회 2,259
16년 전 조회 1,586
16년 전 조회 2,001
16년 전 조회 2,186
16년 전 조회 1,254
16년 전 조회 1,328
16년 전 조회 1,972
16년 전 조회 5,409
16년 전 조회 1,715
16년 전 조회 2,236
16년 전 조회 2,431
16년 전 조회 1,575
16년 전 조회 1,373
16년 전 조회 2,297
16년 전 조회 5,010
16년 전 조회 2,285
16년 전 조회 2,936
16년 전 조회 1,825
16년 전 조회 3,668
16년 전 조회 4,512
16년 전 조회 3,165
16년 전 조회 2,419
16년 전 조회 2,512
16년 전 조회 2,751
16년 전 조회 2,248
16년 전 조회 5,586
16년 전 조회 3,440
16년 전 조회 1,432
16년 전 조회 1,775
16년 전 조회 5,147
16년 전 조회 2,389
16년 전 조회 3,484
16년 전 조회 2,723
16년 전 조회 1,633
16년 전 조회 5,434
16년 전 조회 2,542
16년 전 조회 6,041
16년 전 조회 2,019
16년 전 조회 4,092
16년 전 조회 3,103
16년 전 조회 2,296
16년 전 조회 2,309
16년 전 조회 4,452
16년 전 조회 3,372
16년 전 조회 2,900
16년 전 조회 3,046
16년 전 조회 2,162
16년 전 조회 1,847
16년 전 조회 1,760
16년 전 조회 1,479
16년 전 조회 1,747
16년 전 조회 1,980
16년 전 조회 1,672
16년 전 조회 4,914
16년 전 조회 3,899
16년 전 조회 1,869
16년 전 조회 1,610
16년 전 조회 2,354
16년 전 조회 4,589