소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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;
}
}
?>
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 7530 | 10년 전 | 744 | ||
| 7529 |
파랑새1597
|
10년 전 | 1184 | |
| 7528 |
파랑새1597
|
10년 전 | 1278 | |
| 7527 |
integrity7
|
10년 전 | 1360 | |
| 7526 | 10년 전 | 2393 | ||
| 7525 |
다빈치코드777
|
10년 전 | 1082 | |
| 7524 | 10년 전 | 1550 | ||
| 7523 | 10년 전 | 952 | ||
| 7522 |
|
10년 전 | 972 | |
| 7521 |
blackkil
|
10년 전 | 1844 | |
| 7520 | 10년 전 | 1262 | ||
| 7519 |
Gaumi
|
10년 전 | 1061 | |
| 7518 | 10년 전 | 1469 | ||
| 7517 | 10년 전 | 806 | ||
| 7516 | 10년 전 | 1264 | ||
| 7515 | 10년 전 | 1389 | ||
| 7514 |
|
10년 전 | 4475 | |
| 7513 |
멋진남자임
|
10년 전 | 1126 | |
| 7512 |
다빈치코드777
|
10년 전 | 855 | |
| 7511 |
|
10년 전 | 3379 | |
| 7510 | 10년 전 | 1346 | ||
| 7509 | 10년 전 | 1116 | ||
| 7508 | 10년 전 | 702 | ||
| 7507 |
senseme
|
10년 전 | 719 | |
| 7506 |
멋진남자임
|
10년 전 | 1616 | |
| 7505 | 10년 전 | 3976 | ||
| 7504 | 10년 전 | 2131 | ||
| 7503 | 10년 전 | 978 | ||
| 7502 | 10년 전 | 509 | ||
| 7501 | 10년 전 | 1429 | ||
| 7500 | 10년 전 | 1471 | ||
| 7499 | 10년 전 | 3357 | ||
| 7498 | 10년 전 | 1167 | ||
| 7497 |
dethos79
|
10년 전 | 2950 | |
| 7496 | 10년 전 | 2109 | ||
| 7495 | 10년 전 | 816 | ||
| 7494 |
CHAVO
|
10년 전 | 1099 | |
| 7493 | 10년 전 | 2623 | ||
| 7492 | 10년 전 | 1211 | ||
| 7491 | 10년 전 | 1432 | ||
| 7490 | 10년 전 | 2312 | ||
| 7489 | 10년 전 | 2103 | ||
| 7488 |
toptopon
|
10년 전 | 872 | |
| 7487 |
|
10년 전 | 1015 | |
| 7486 | 10년 전 | 3336 | ||
| 7485 | 10년 전 | 1295 | ||
| 7484 | 10년 전 | 1354 | ||
| 7483 | 10년 전 | 1009 | ||
| 7482 | 10년 전 | 636 | ||
| 7481 | 10년 전 | 851 | ||
| 7480 | 10년 전 | 1210 | ||
| 7479 | 10년 전 | 2581 | ||
| 7478 | 10년 전 | 1131 | ||
| 7477 |
멋진남자임
|
10년 전 | 1480 | |
| 7476 |
zeppeto
|
10년 전 | 1132 | |
| 7475 |
200점아빠
|
10년 전 | 905 | |
| 7474 | 10년 전 | 3995 | ||
| 7473 | 10년 전 | 971 | ||
| 7472 |
나르시스1
|
10년 전 | 1211 | |
| 7471 | 10년 전 | 867 | ||
| 7470 | 10년 전 | 1258 | ||
| 7469 |
플라이SINJI
|
10년 전 | 934 | |
| 7468 |
|
10년 전 | 517 | |
| 7467 |
|
10년 전 | 632 | |
| 7466 | 10년 전 | 1092 | ||
| 7465 | 10년 전 | 1164 | ||
| 7464 |
|
10년 전 | 1173 | |
| 7463 | 10년 전 | 1222 | ||
| 7462 |
진짜별사탕
|
10년 전 | 836 | |
| 7461 | 10년 전 | 922 | ||
| 7460 | 10년 전 | 3705 | ||
| 7459 |
멋진남자임
|
10년 전 | 1536 | |
| 7458 |
멋진남자임
|
10년 전 | 474 | |
| 7457 | 10년 전 | 906 | ||
| 7456 | 10년 전 | 747 | ||
| 7455 | 10년 전 | 2128 | ||
| 7454 | 10년 전 | 618 | ||
| 7453 | 10년 전 | 803 | ||
| 7452 |
중국어사이트제작
|
10년 전 | 498 | |
| 7451 | 10년 전 | 892 | ||
| 7450 | 10년 전 | 616 | ||
| 7449 |
울라라라우
|
10년 전 | 924 | |
| 7448 | 10년 전 | 1624 | ||
| 7447 |
멋진남자임
|
10년 전 | 480 | |
| 7446 | 10년 전 | 525 | ||
| 7445 |
네이비칼라
|
10년 전 | 1647 | |
| 7444 |
senseme
|
10년 전 | 1386 | |
| 7443 | 10년 전 | 1321 | ||
| 7442 | 10년 전 | 701 | ||
| 7441 |
멋진남자임
|
10년 전 | 1419 | |
| 7440 | 10년 전 | 878 | ||
| 7439 |
|
10년 전 | 735 | |
| 7438 |
|
10년 전 | 911 | |
| 7437 |
basement
|
10년 전 | 1019 | |
| 7436 |
잘살아보자
|
10년 전 | 1106 | |
| 7435 | 10년 전 | 1053 | ||
| 7434 | 10년 전 | 3778 | ||
| 7433 |
|
10년 전 | 2715 | |
| 7432 |
alexkim
|
10년 전 | 841 | |
| 7431 |
이웃집초보
|
10년 전 | 1293 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기