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

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

자주 쓰이는 경기방식중에는
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년 전 조회 1,106
15년 전 조회 1,603
15년 전 조회 1,579
15년 전 조회 3,365
15년 전 조회 3,702
15년 전 조회 2,397
15년 전 조회 1,854
15년 전 조회 2,467
15년 전 조회 1,956
15년 전 조회 1,576
15년 전 조회 4,263
15년 전 조회 1,919
15년 전 조회 2,002
15년 전 조회 3,262
15년 전 조회 1,967
15년 전 조회 4,679
15년 전 조회 2,861
15년 전 조회 3,662
15년 전 조회 2,259
15년 전 조회 2,499
15년 전 조회 1,813
15년 전 조회 4,871
15년 전 조회 4,479
16년 전 조회 4,278
16년 전 조회 5,702
16년 전 조회 3,921
16년 전 조회 2,276
16년 전 조회 2,242
16년 전 조회 2,390
16년 전 조회 2,091
16년 전 조회 4,517
16년 전 조회 3,421
16년 전 조회 2,588
16년 전 조회 2,179
16년 전 조회 2,378
16년 전 조회 2,879
16년 전 조회 1,974
16년 전 조회 2,891
16년 전 조회 2,222
16년 전 조회 2,340
16년 전 조회 1,963
16년 전 조회 2,682
16년 전 조회 1,997
16년 전 조회 2,420
16년 전 조회 2,593
16년 전 조회 1,660
16년 전 조회 1,728
16년 전 조회 2,401
16년 전 조회 5,811
16년 전 조회 2,129
16년 전 조회 2,649
16년 전 조회 2,830
16년 전 조회 1,993
16년 전 조회 1,780
16년 전 조회 2,694
16년 전 조회 5,410
16년 전 조회 2,684
16년 전 조회 3,336
16년 전 조회 2,209
16년 전 조회 4,093
16년 전 조회 4,895
16년 전 조회 3,539
16년 전 조회 2,794
16년 전 조회 2,911
16년 전 조회 3,125
16년 전 조회 2,639
16년 전 조회 5,991
16년 전 조회 3,813
16년 전 조회 1,817
16년 전 조회 2,146
16년 전 조회 5,515
16년 전 조회 2,765
16년 전 조회 3,843
16년 전 조회 3,117
16년 전 조회 2,019
16년 전 조회 5,830
16년 전 조회 2,933
16년 전 조회 6,423
16년 전 조회 2,399
16년 전 조회 4,453
16년 전 조회 3,455
16년 전 조회 2,650
16년 전 조회 2,673
16년 전 조회 4,806
16년 전 조회 3,742
16년 전 조회 3,267
16년 전 조회 3,421
16년 전 조회 2,533
16년 전 조회 2,206
16년 전 조회 2,128
16년 전 조회 1,836
16년 전 조회 2,117
16년 전 조회 2,328
16년 전 조회 2,032
16년 전 조회 5,282
16년 전 조회 4,272
16년 전 조회 2,224
16년 전 조회 1,966
16년 전 조회 2,722
16년 전 조회 4,970