@@ -446,7 +446,7 @@ class Tournament extends common_base implements Game{
446
446
var $ game_title ;
447
447
var $ scheduler_id ;
448
448
var $ conn ;
449
- function __construct ($ args ){
449
+ function __construct (){
450
450
$ this ->player = Array ();
451
451
$ this ->table = Array ();
452
452
$ this ->winner = Array ();
@@ -458,7 +458,8 @@ class Tournament extends common_base implements Game{
458
458
$ this ->player [$ entry [name]] = new Player ( $ entry );
459
459
}
460
460
461
- function lot2 (){
461
+ function lot (){
462
+ //初期実装
462
463
if ( !$ this ->current ){
463
464
$ this ->battle_cnt = 0 ;
464
465
$ l = array_keys ($ this ->player );
@@ -480,11 +481,12 @@ class Tournament extends common_base implements Game{
480
481
}
481
482
482
483
function start (){
483
- $ this ->lot ();
484
+ $ this ->lot3 ();
484
485
return $ this ->getTableString ('long ' );
485
486
}
486
487
487
- private function lot (){
488
+ private function lot2 (){
489
+ //1回戦で出来るだけ対戦を行なうモード
488
490
if ( !$ this ->current ){
489
491
$ this ->battle_cnt = 0 ;
490
492
$ l = array_keys ($ this ->player );
@@ -522,6 +524,31 @@ class Tournament extends common_base implements Game{
522
524
}
523
525
}
524
526
527
+ ///オーソドックスなトーナメント
528
+ private function lot3 (){
529
+ if ( !$ this ->current ){
530
+ $ this ->battle_cnt = 0 ;
531
+ $ l = array_keys ($ this ->player );
532
+ shuffle ($ l );
533
+
534
+ $ lengh = count ($ l );
535
+ for ($ s =1 ;$ lengh >$ s <<1 ;$ s =$ s <<1 );
536
+
537
+ $ new = Array ( $ l );
538
+
539
+ while ( true ){
540
+ $ current = array ();
541
+ foreach ( $ new as $ card ){
542
+ list ($ current [],$ current []) = array_chunk ( $ card , ceil (count ($ card )/2 ) );
543
+ }
544
+ $ new = $ current ;
545
+ if ( $ s <= count ($ new ) ){break ;}
546
+ }
547
+
548
+ $ this ->table [$ this ->current ] = array_reverse ($ new );
549
+ }
550
+ }
551
+
525
552
function win ($ name ){
526
553
if ( !isset ($ this ->player [$ name ]) ){ return RANBAT_PRIV_CANCEL_ERROR ;}
527
554
@@ -590,38 +617,80 @@ class Tournament extends common_base implements Game{
590
617
591
618
function getTableString ( $ type = 'short ' ){
592
619
if ( !count ( $ this ->table ) ){
593
- $ this ->lot ();
620
+ $ this ->lot2 ();
594
621
}
595
622
$ array = Array ();
596
623
597
- $ cnt = count ($ this ->table [$ this ->current ]);
598
- $ str = '■ ' ;
599
- if ( $ cnt == 1 ){
600
- $ str .= '決勝 ' ;
601
- }else if ( $ cnt == 2 ){
602
- $ str .= '準決勝 ' ;
603
- }else {
604
- $ str .= ($ this ->current +1 ).'回戦 ' ;
605
- }
606
- $ array [] = $ str ;
607
- $ i =0 ;
608
- foreach ( $ this ->table [$ this ->current ] as $ key => $ match ){
609
- $ str = ++$ i .': ' ;
610
- switch (count ($ match )){
611
- case 2 :
612
- $ str .= $ match [0 ].' vs ' .$ match [1 ];
613
- if ( isset ( $ this ->winner [ $ key ] ) ){
614
- $ str .= '(win: ' .$ this ->winner [$ key ].') ' ;
624
+ switch ( $ type ){
625
+ case 'html ' :
626
+ $ cnt = count ($ this ->table [$ this ->current ]);
627
+ $ str = '■ ' ;
628
+ if ( $ cnt == 1 ){
629
+ $ str .= '決勝 ' ;
630
+ }else if ( $ cnt == 2 ){
631
+ $ str .= '準決勝 ' ;
632
+ }else {
633
+ $ str .= ($ this ->current +1 ).'回戦 ' ;
634
+ }
635
+ $ array [] = $ str ;
636
+ $ i =0 ;
637
+ foreach ( $ this ->table [$ this ->current ] as $ key => $ match ){
638
+ $ str = ++$ i .': ' ;
639
+ switch (count ($ match )){
640
+ case 2 :
641
+ if ( !isset ( $ this ->winner [ $ key ] ) ){
642
+ $ str .= $ match [0 ].' vs ' .$ match [1 ];
643
+ }else {
644
+ if ( $ this ->winner [ $ key ] == $ match [0 ] ){
645
+ $ str .= '<span class="winner" > ' .$ match [0 ].'</span> vs ' .$ match [1 ];
646
+ }else {
647
+ $ str .= $ match [0 ].' vs <span class="winner" > ' .$ match [1 ].'</span> ' ;
648
+ }
649
+ }
650
+ break ;
651
+ case 1 :
652
+ $ str .= 'seed: ' .$ match [0 ];
653
+ break ;
654
+ case 0 :
655
+ continue 2 ;
656
+ //$str .= ' ';
657
+ break ;
615
658
}
616
- break ;
617
- case 1 :
618
- $ str .= 'seed: ' .$ match [0 ];
619
- break ;
620
- case 0 :
621
- $ str .= ' ' ;
622
- break ;
623
- }
624
- $ array [] = $ str ;
659
+ $ array [] = $ str ;
660
+ }
661
+ break ;
662
+ default :
663
+ $ cnt = count ($ this ->table [$ this ->current ]);
664
+ $ str = '■ ' ;
665
+ if ( $ cnt == 1 ){
666
+ $ str .= '決勝 ' ;
667
+ }else if ( $ cnt == 2 ){
668
+ $ str .= '準決勝 ' ;
669
+ }else {
670
+ $ str .= ($ this ->current +1 ).'回戦 ' ;
671
+ }
672
+ $ array [] = $ str ;
673
+ $ i =0 ;
674
+ foreach ( $ this ->table [$ this ->current ] as $ key => $ match ){
675
+ $ str = ++$ i .': ' ;
676
+ switch (count ($ match )){
677
+ case 2 :
678
+ $ str .= $ match [0 ].' vs ' .$ match [1 ];
679
+ if ( isset ( $ this ->winner [ $ key ] ) ){
680
+ $ str .= '(win: ' .$ this ->winner [$ key ].') ' ;
681
+ }
682
+ break ;
683
+ case 1 :
684
+ $ str .= 'seed: ' .$ match [0 ];
685
+ break ;
686
+ case 0 :
687
+ continue ;
688
+ //$str .= ' ';
689
+ break ;
690
+ }
691
+ $ array [] = $ str ;
692
+ }
693
+ break ;
625
694
}
626
695
return join ("\n" ,$ array );
627
696
}
@@ -777,7 +846,7 @@ class Kohaku extends common_base implements Game{
777
846
}
778
847
779
848
function setPlayer ($ name ,$ nick ){
780
- if ( $ nick != $ this ->team [$ this ->wait_leader ]['leader ' ]['nick ' ] && array_search ( $ nick ,Array ('swirhen ' ,'tyoro ' ) ) === FALSE ){
849
+ if ( $ nick != $ this ->team [$ this ->wait_leader ]['leader ' ]['nick ' ] && array_search ( $ nick ,Array ('swirhen ' ,'tyoro ' , ' tuskdon ' ) ) === FALSE ){
781
850
return ;
782
851
}
783
852
if ( is_numeric ( $ name ) && isset ( $ this ->num_list [$ name ] ) ){
@@ -1018,7 +1087,10 @@ class Kohaku extends common_base implements Game{
1018
1087
}
1019
1088
$ str .= "\n" ;
1020
1089
break ;
1021
- case 'uragiri ' :
1090
+ /*case 'html':
1091
+
1092
+ break;
1093
+ */ case 'uragiri ' :
1022
1094
$ l = Array ();
1023
1095
$ this ->num_list = Array ();
1024
1096
$ i = 1 ;
@@ -1142,7 +1214,7 @@ class GameLog{
1142
1214
function end ( $ state = self ::GAME_STATUS_END ){
1143
1215
if ( !is_null ( $ this ->game_id ) ){
1144
1216
$ record ['status ' ] = $ state ;
1145
- $ record ['data ' ] = '' ;
1217
+ // $record['data'] = '';
1146
1218
$ this ->conn ->AutoExecute ( 'games ' , $ record , 'UPDATE ' , 'id = ' .$ this ->game_id );
1147
1219
}
1148
1220
}
0 commit comments