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

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

자주 쓰이는 경기방식중에는
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년 전 조회 592
15년 전 조회 1,079
15년 전 조회 1,049
15년 전 조회 2,841
15년 전 조회 3,155
15년 전 조회 1,832
15년 전 조회 1,337
15년 전 조회 1,955
15년 전 조회 1,461
15년 전 조회 1,064
15년 전 조회 3,758
15년 전 조회 1,400
15년 전 조회 1,499
15년 전 조회 2,725
15년 전 조회 1,426
15년 전 조회 4,151
15년 전 조회 2,364
15년 전 조회 3,142
15년 전 조회 1,760
15년 전 조회 1,987
15년 전 조회 1,288
15년 전 조회 4,365
15년 전 조회 3,940
15년 전 조회 3,769
15년 전 조회 5,183
15년 전 조회 3,402
15년 전 조회 1,782
15년 전 조회 1,745
15년 전 조회 1,888
15년 전 조회 1,583
15년 전 조회 3,981
15년 전 조회 2,893
15년 전 조회 2,078
15년 전 조회 1,656
15년 전 조회 1,893
15년 전 조회 2,374
15년 전 조회 1,457
15년 전 조회 2,391
15년 전 조회 1,725
15년 전 조회 1,821
15년 전 조회 1,475
15년 전 조회 2,165
15년 전 조회 1,495
15년 전 조회 1,909
15년 전 조회 2,102
15년 전 조회 1,179
15년 전 조회 1,238
15년 전 조회 1,883
15년 전 조회 5,327
16년 전 조회 1,629
16년 전 조회 2,136
16년 전 조회 2,337
16년 전 조회 1,486
16년 전 조회 1,294
16년 전 조회 2,208
16년 전 조회 4,924
16년 전 조회 2,200
16년 전 조회 2,856
16년 전 조회 1,737
16년 전 조회 3,589
16년 전 조회 4,426
16년 전 조회 3,095
16년 전 조회 2,342
16년 전 조회 2,423
16년 전 조회 2,672
16년 전 조회 2,159
16년 전 조회 5,502
16년 전 조회 3,352
16년 전 조회 1,345
16년 전 조회 1,690
16년 전 조회 5,061
16년 전 조회 2,298
16년 전 조회 3,403
16년 전 조회 2,636
16년 전 조회 1,556
16년 전 조회 5,347
16년 전 조회 2,464
16년 전 조회 5,954
16년 전 조회 1,930
16년 전 조회 4,007
16년 전 조회 3,021
16년 전 조회 2,208
16년 전 조회 2,227
16년 전 조회 4,403
16년 전 조회 3,286
16년 전 조회 2,823
16년 전 조회 2,955
16년 전 조회 2,075
16년 전 조회 1,761
16년 전 조회 1,671
16년 전 조회 1,393
16년 전 조회 1,665
16년 전 조회 1,894
16년 전 조회 1,587
16년 전 조회 4,835
16년 전 조회 3,817
16년 전 조회 1,783
16년 전 조회 1,527
16년 전 조회 2,262
16년 전 조회 4,510
🐛 버그신고