소스 정리하다가 옛날에 축구관련 사이트 작업한게 있었는데 있길래 한번 올려봅니다.
작업당시에 기존 존재하는 소스가 있나 싶어서 찾아봤는데 없는거 같길래 만들었어요~
자주 쓰이는 경기방식중에는
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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2430 | 15년 전 | 2512 | ||
| 2429 | 15년 전 | 5501 | ||
| 2428 | 15년 전 | 1462 | ||
| 2427 |
Sizkein
|
15년 전 | 4229 | |
| 2426 | 15년 전 | 1357 | ||
| 2425 | 15년 전 | 1657 | ||
| 2424 | 15년 전 | 1634 | ||
| 2423 |
haejuksun
|
15년 전 | 1624 | |
| 2422 |
haejuksun
|
15년 전 | 1129 | |
| 2421 |
haejuksun
|
15년 전 | 1373 | |
| 2420 |
haejuksun
|
15년 전 | 1519 | |
| 2419 |
|
15년 전 | 1418 | |
| 2418 |
|
15년 전 | 2143 | |
| 2417 |
원더풀라입
|
15년 전 | 1295 | |
| 2416 |
원더풀라입
|
15년 전 | 1350 | |
| 2415 |
원더풀라입
|
15년 전 | 881 | |
| 2414 |
원더풀라입
|
15년 전 | 998 | |
| 2413 |
원더풀라입
|
15년 전 | 962 | |
| 2412 |
원더풀라입
|
15년 전 | 924 | |
| 2411 |
원더풀라입
|
15년 전 | 874 | |
| 2410 |
원더풀라입
|
15년 전 | 927 | |
| 2409 |
원더풀라입
|
15년 전 | 1075 | |
| 2408 |
원더풀라입
|
15년 전 | 1088 | |
| 2407 |
원더풀라입
|
15년 전 | 2609 | |
| 2406 |
원더풀라입
|
15년 전 | 949 | |
| 2405 |
원더풀라입
|
15년 전 | 1603 | |
| 2404 |
원더풀라입
|
15년 전 | 1466 | |
| 2403 | 15년 전 | 1594 | ||
| 2402 | 15년 전 | 1295 | ||
| 2401 |
나도빌더만들까
|
15년 전 | 1776 | |
| 2400 | 15년 전 | 599 | ||
| 2399 | 15년 전 | 1095 | ||
| 2398 | 15년 전 | 1055 | ||
| 2397 | 15년 전 | 2841 | ||
| 2396 | 15년 전 | 3154 | ||
| 2395 | 15년 전 | 1831 | ||
| 2394 | 15년 전 | 1337 | ||
| 2393 |
gamebomb
|
15년 전 | 1962 | |
| 2392 |
gamebomb
|
15년 전 | 1472 | |
| 2391 |
gamebomb
|
15년 전 | 1076 | |
| 2390 | 15년 전 | 3767 | ||
| 2389 |
leadK
|
15년 전 | 1412 | |
| 2388 |
kim7031
|
15년 전 | 1528 | |
| 2387 | 15년 전 | 2741 | ||
| 2386 | 15년 전 | 1452 | ||
| 2385 | 15년 전 | 4172 | ||
| 2384 |
확실한방법
|
15년 전 | 2377 | |
| 2383 |
intel
|
15년 전 | 3154 | |
| 2382 |
확실한방법
|
15년 전 | 1768 | |
| 2381 |
|
15년 전 | 1991 | |
| 2380 |
|
15년 전 | 1302 | |
| 2379 | 15년 전 | 4373 | ||
| 2378 | 15년 전 | 3951 | ||
| 2377 |
메가팩토리
|
15년 전 | 3782 | |
| 2376 | 15년 전 | 5192 | ||
| 2375 | 15년 전 | 3411 | ||
| 2374 | 15년 전 | 1791 | ||
| 2373 | 15년 전 | 1753 | ||
| 2372 | 15년 전 | 1890 | ||
| 2371 | 15년 전 | 1598 | ||
| 2370 | 15년 전 | 3992 | ||
| 2369 | 15년 전 | 2905 | ||
| 2368 | 15년 전 | 2097 | ||
| 2367 | 15년 전 | 1670 | ||
| 2366 | 15년 전 | 1913 | ||
| 2365 | 15년 전 | 2397 | ||
| 2364 | 15년 전 | 1488 | ||
| 2363 | 15년 전 | 2418 | ||
| 2362 | 15년 전 | 1744 | ||
| 2361 | 15년 전 | 1836 | ||
| 2360 | 15년 전 | 1485 | ||
| 2359 | 15년 전 | 2182 | ||
| 2358 | 15년 전 | 1509 | ||
| 2357 |
|
15년 전 | 1925 | |
| 2356 |
헐크매니아
|
15년 전 | 2121 | |
| 2355 |
WebRIA
|
15년 전 | 1200 | |
| 2354 |
WebRIA
|
15년 전 | 1251 | |
| 2353 |
WebRIA
|
15년 전 | 1893 | |
| 2352 |
WebRIA
|
15년 전 | 5339 | |
| 2351 | 15년 전 | 1637 | ||
| 2350 |
WebRIA
|
15년 전 | 2145 | |
| 2349 | 15년 전 | 2346 | ||
| 2348 |
WebRIA
|
15년 전 | 1493 | |
| 2347 |
WebRIA
|
15년 전 | 1304 | |
| 2346 |
WebRIA
|
15년 전 | 2220 | |
| 2345 |
WebRIA
|
15년 전 | 4937 | |
| 2344 | 15년 전 | 2208 | ||
| 2343 | 15년 전 | 2866 | ||
| 2342 | 15년 전 | 1756 | ||
| 2341 | 15년 전 | 3604 | ||
| 2340 | 15년 전 | 4441 | ||
| 2339 | 16년 전 | 3119 | ||
| 2338 | 16년 전 | 2356 | ||
| 2337 | 16년 전 | 2439 | ||
| 2336 | 16년 전 | 2689 | ||
| 2335 | 16년 전 | 2179 | ||
| 2334 |
Sizkein
|
16년 전 | 5520 | |
| 2333 | 16년 전 | 3372 | ||
| 2332 | 16년 전 | 1366 | ||
| 2331 | 16년 전 | 1700 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기