Exemplo n.º 1
0
 public function begin()
 {
     // Launch first step for tournament (draft, build ...)
     // DB
     shuffle($this->players);
     // Give random numbers to players
     foreach ($this->players as $i => $player) {
         $player->insert($i);
     }
     // And store them now we're sure to start
     // TS3
     if ($this->observer->ts3) {
         ts3_co();
         $cid = ts3_chan('Tournament ' . $this->id, $this->name);
         // Create chan
         ts3_invite($this->players, $cid);
         // Move each tournament's player to chan
         ts3_disco();
     }
     // Unicity
     $upool = array();
     // All cards in current tournament's players pools
     //that comes from a "uniq" extension
     switch ($this->format) {
         case 'draft':
             $number = 0;
             foreach ($this->data->boosters as $ext) {
                 $number++;
                 // Number of current booster in draft for player
                 //$booster = null ;
                 foreach ($this->players as $player) {
                     //if ( ( $booster == null ) || ! $this->data->clone_sealed ) {
                     $booster = new Booster($this, $player->order, $number);
                     $booster->generate($ext, $upool);
                     /*} else {
                     			$boost = new Booster($this, $player->order, $number) ;
                     			$boost->get_content($booster->content) ;
                     			$boost->insert() ;
                     		}*/
                     $this->boosters[] = $booster;
                 }
             }
             $this->set_status(3);
             $this->timer_goon(Tournament::draft_time());
             $this->log('', 'draft', '');
             break;
         case 'sealed':
             foreach ($this->data->boosters as $ext) {
                 $ext_obj = Extension::get($ext);
                 if ($ext_obj == null) {
                     $this->say("Extension {$ext} not found in sealed generation");
                     continue;
                 }
                 $booster = null;
                 foreach ($this->players as $player) {
                     if ($booster == null || !$this->data->clone_sealed) {
                         $booster = $ext_obj->booster($upool);
                     }
                     // Only need object in memory for sealed
                     foreach ($booster as $card) {
                         $player->pick($card);
                     }
                 }
             }
             foreach ($this->players as $player) {
                 $player->summarize(true);
             }
             $this->build();
             break;
         default:
             $this->start();
     }
 }