Exemplo n.º 1
0
 /**
  * read the object information from the db
  */
 private function load($id)
 {
     $db = new DB();
     $sql = "SELECT pt.idgame, pt.title, pp.idplayer, pt.d, pt.sb, pt.bb, pt.seats, pt.blind, pt.iduser, pt.idspot\n                  FROM poker_tables AS pt\n             LEFT JOIN poker_players AS pp ON (pp.idtable = pt.idtable AND pp.pactive = 1)\n                 WHERE pt.idtable = '{$id}'\n              ORDER BY pp.position";
     $result = $db->query($sql);
     if ($result->length() > 0) {
         $players = array();
         if ($result->idplayer != '') {
             $prev = false;
             do {
                 $player = PokerPlayer::getInstance($result->idplayer);
                 $player->prev = $prev;
                 if (is_object($prev)) {
                     $prev->next = $player;
                 }
                 $players[$player->position] = $player;
                 $prev = $player;
             } while ($result->next());
             $first = reset($players);
             $first->prev = $prev;
             $prev->next = $first;
         }
         // general information
         $this->info = array("game" => $result->idgame != 0 && $result->idgame != '' ? Poker::getInstance($result->idgame) : FALSE, "spot" => $result->idspot != 0 && $result->idspot != '' ? PokerSpot::getInstance($result->idspot) : FALSE, 'title' => $result->title, 'players' => $players, 'positions' => array('smallblind' => $result->sb, 'bigblind' => $result->bb, 'dealer' => $result->d), 'blinds' => array('big' => 2 * $result->blind, 'small' => $result->blind), 'seats' => $result->seats, 'user' => $result->iduser);
         $this->info['free'] = $this->info['seats'] - count($this->info['players']);
         $this->id = $id;
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * create form for editing / creating a house
  *
  * @return string HTML code
  * @author Elias Müller
  **/
 private function getForm($id = '')
 {
     $path = 'poker_spot-' . $this->s->action . ($this->s->element != '' ? '/' . $this->s->element : '');
     if ($id != '') {
         $spot = PokerSpot::getInstance($id);
         $spot->ranges[0] = is_array($spot->ranges[0]) ? implode(',', $spot->ranges[0]) : '';
         $spot->ranges[1] = is_array($spot->ranges[1]) ? implode(',', $spot->ranges[1]) : '';
         //$spot->actions = array_reverse($spot->actions, true);
     } else {
         $spot = new PokerSpot();
     }
     /*$cards = array('A','K','Q','J','T','9','8','7','6','5','4','3','2');
     		$hands = array();
     		foreach ($cards as $key => $value) {
     			foreach ($cards as $k => $v) {
     				if ($v == $value) {
     					$hands[$key][$k] = $value.$v;
     				} elseif ($key > $k) {
     					$hands[$key][$k] = $v.$value.'o';
     				} else {
     					$hands[$key][$k] = $value.$v.'s';
     				}
     			}
     		}//*/
     $tpl = new Template('poker');
     $tpl->assign('path', $path);
     $tpl->assign('spot', $spot);
     //$tpl->assign('hands', $hands);
     return $tpl->fetch('form_spot.html');
 }
Exemplo n.º 3
0
 /**
  * create form for editing / creating a house
  *
  * @return string HTML code
  * @author Elias Müller
  **/
 private function getForm($id = '')
 {
     $path = 'poker_table-' . $this->s->action . ($this->s->element != '' ? '/' . $this->s->element : '');
     if ($id != '') {
         $table = PokerTable::getInstance($id);
     } else {
         $table = new PokerTable();
     }
     $spots = PokerSpot::getAll();
     $tpl = new Template('poker');
     $tpl->assign('path', $path);
     $tpl->assign('spots', $spots);
     $tpl->assign('table', $table);
     return $tpl->fetch('form_table.html');
 }
Exemplo n.º 4
0
 /**
  * read the object information from the db
  */
 private function load($id)
 {
     $db = new DB();
     $sql = "SELECT pa.idspot, pa.action, pa.params, pa.idplayer\n                  FROM poker_actions AS pa \n                 WHERE pa.idaction = '{$id}'";
     $result = $db->query($sql);
     if ($result->length() > 0) {
         // general information
         $this->info = array('action' => $result->action, 'params' => unserialize($result->params), 'player' => $result->idplayer, 'spot' => PokerSpot::getInstance($result->idspot));
         $this->id = $id;
         return true;
     }
     return false;
 }