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

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

자주 쓰이는 경기방식중에는
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년 전 조회 684
15년 전 조회 1,173
15년 전 조회 1,143
15년 전 조회 2,926
15년 전 조회 3,251
15년 전 조회 1,925
15년 전 조회 1,432
15년 전 조회 2,048
15년 전 조회 1,559
15년 전 조회 1,158
15년 전 조회 3,853
15년 전 조회 1,495
15년 전 조회 1,592
15년 전 조회 2,816
15년 전 조회 1,509
15년 전 조회 4,244
15년 전 조회 2,454
15년 전 조회 3,228
15년 전 조회 1,845
15년 전 조회 2,078
15년 전 조회 1,377
15년 전 조회 4,451
15년 전 조회 4,037
15년 전 조회 3,859
15년 전 조회 5,276
15년 전 조회 3,507
15년 전 조회 1,882
15년 전 조회 1,826
15년 전 조회 1,966
15년 전 조회 1,674
15년 전 조회 4,070
15년 전 조회 2,998
15년 전 조회 2,159
16년 전 조회 1,751
16년 전 조회 1,979
16년 전 조회 2,468
16년 전 조회 1,542
16년 전 조회 2,481
16년 전 조회 1,807
16년 전 조회 1,918
16년 전 조회 1,555
16년 전 조회 2,263
16년 전 조회 1,589
16년 전 조회 2,004
16년 전 조회 2,190
16년 전 조회 1,257
16년 전 조회 1,330
16년 전 조회 1,976
16년 전 조회 5,411
16년 전 조회 1,717
16년 전 조회 2,238
16년 전 조회 2,432
16년 전 조회 1,582
16년 전 조회 1,376
16년 전 조회 2,301
16년 전 조회 5,013
16년 전 조회 2,288
16년 전 조회 2,939
16년 전 조회 1,828
16년 전 조회 3,672
16년 전 조회 4,514
16년 전 조회 3,168
16년 전 조회 2,422
16년 전 조회 2,516
16년 전 조회 2,753
16년 전 조회 2,253
16년 전 조회 5,591
16년 전 조회 3,442
16년 전 조회 1,438
16년 전 조회 1,777
16년 전 조회 5,147
16년 전 조회 2,393
16년 전 조회 3,485
16년 전 조회 2,726
16년 전 조회 1,634
16년 전 조회 5,440
16년 전 조회 2,545
16년 전 조회 6,044
16년 전 조회 2,019
16년 전 조회 4,094
16년 전 조회 3,109
16년 전 조회 2,298
16년 전 조회 2,309
16년 전 조회 4,453
16년 전 조회 3,375
16년 전 조회 2,901
16년 전 조회 3,046
16년 전 조회 2,166
16년 전 조회 1,848
16년 전 조회 1,763
16년 전 조회 1,483
16년 전 조회 1,751
16년 전 조회 1,980
16년 전 조회 1,674
16년 전 조회 4,917
16년 전 조회 3,900
16년 전 조회 1,870
16년 전 조회 1,614
16년 전 조회 2,359
16년 전 조회 4,590