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

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

자주 쓰이는 경기방식중에는
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년 전 조회 609
15년 전 조회 1,098
15년 전 조회 1,067
15년 전 조회 2,860
15년 전 조회 3,175
15년 전 조회 1,850
15년 전 조회 1,357
15년 전 조회 1,976
15년 전 조회 1,479
15년 전 조회 1,085
15년 전 조회 3,777
15년 전 조회 1,422
15년 전 조회 1,517
15년 전 조회 2,747
15년 전 조회 1,445
15년 전 조회 4,170
15년 전 조회 2,381
15년 전 조회 3,161
15년 전 조회 1,777
15년 전 조회 2,004
15년 전 조회 1,305
15년 전 조회 4,383
15년 전 조회 3,959
15년 전 조회 3,785
15년 전 조회 5,201
15년 전 조회 3,423
15년 전 조회 1,802
15년 전 조회 1,761
15년 전 조회 1,906
15년 전 조회 1,599
15년 전 조회 4,002
15년 전 조회 2,914
15년 전 조회 2,095
15년 전 조회 1,675
15년 전 조회 1,911
15년 전 조회 2,393
15년 전 조회 1,474
15년 전 조회 2,408
15년 전 조회 1,742
15년 전 조회 1,840
15년 전 조회 1,493
15년 전 조회 2,181
15년 전 조회 1,516
15년 전 조회 1,928
16년 전 조회 2,118
16년 전 조회 1,190
16년 전 조회 1,256
16년 전 조회 1,905
16년 전 조회 5,346
16년 전 조회 1,645
16년 전 조회 2,157
16년 전 조회 2,357
16년 전 조회 1,508
16년 전 조회 1,312
16년 전 조회 2,229
16년 전 조회 4,942
16년 전 조회 2,216
16년 전 조회 2,873
16년 전 조회 1,755
16년 전 조회 3,609
16년 전 조회 4,445
16년 전 조회 3,110
16년 전 조회 2,357
16년 전 조회 2,445
16년 전 조회 2,689
16년 전 조회 2,178
16년 전 조회 5,517
16년 전 조회 3,373
16년 전 조회 1,365
16년 전 조회 1,708
16년 전 조회 5,079
16년 전 조회 2,317
16년 전 조회 3,418
16년 전 조회 2,655
16년 전 조회 1,572
16년 전 조회 5,365
16년 전 조회 2,480
16년 전 조회 5,972
16년 전 조회 1,950
16년 전 조회 4,022
16년 전 조회 3,041
16년 전 조회 2,224
16년 전 조회 2,244
16년 전 조회 4,409
16년 전 조회 3,306
16년 전 조회 2,841
16년 전 조회 2,980
16년 전 조회 2,096
16년 전 조회 1,777
16년 전 조회 1,691
16년 전 조회 1,412
16년 전 조회 1,683
16년 전 조회 1,913
16년 전 조회 1,606
16년 전 조회 4,849
16년 전 조회 3,835
16년 전 조회 1,801
16년 전 조회 1,546
16년 전 조회 2,285
16년 전 조회 4,524