Пример #1
0
 /**
  * read the object information from the db
  */
 private function load($id)
 {
     $db = new DB();
     $sql = "SELECT pp.idplayer, pp.idtable, pp.stack, pp.c1, pp.c2, pp.position, u.username, pa.idaction, pp.bet, pp.pjoin, pp.pleave, pp.pot, pa.idgame AS pagame, pt.idgame AS ptgame\n                  FROM poker_players AS pp\n            INNER JOIN users AS u ON u.iduser = pp.iduser\n            INNER JOIN poker_tables AS pt ON pt.idtable = pp.idtable \n             LEFT JOIN poker_actions AS pa ON (pa.idplayer = pp.idplayer AND pa.action NOT LIKE 'deal' AND pa.action NOT LIKE 'join' AND pa.action NOT LIKE 'leave')\n                 WHERE pp.idplayer = '{$id}'\n              ORDER BY pa.idaction DESC\n                 LIMIT 1";
     $result = $db->query($sql);
     if ($result->length() > 0) {
         // hand
         $cards = false;
         if ($result->c1 != '') {
             $cards = array(new PokerCard($result->c1), new PokerCard($result->c2));
         }
         // general information
         $table = PokerTable::getInstance($result->idtable);
         $action = PokerAction::getInstance($result->idaction);
         $this->info = array("user" => User::getInstance($result->username), 'table' => $table, 'position' => $result->position, 'stack' => $result->stack, 'bet' => $result->bet, 'cards' => $cards, 'pot' => $result->pot, 'last_action' => $result->pagame === $result->ptgame ? $action : NULL, 'join' => $result->pjoin == 1 ? TRUE : FALSE, 'leave' => $result->pleave == 1 ? TRUE : FALSE);
         $this->id = $id;
         return true;
     }
     return false;
 }
Пример #2
0
 /**
  * Get all actions on this table since given $idaction.
  *
  * @param int $idaction The idaction from which to look for new actions.
  * @param int $id The id of the table.
  */
 public static function getTableActions($idaction, $id)
 {
     $db = new DB();
     $sql = "SELECT pa.idaction\n                  FROM poker_actions AS pa\n            INNER JOIN poker_tables AS pt ON pt.idtable = pa.idtable\n                 WHERE pa.idaction >= '" . $idaction . "'\n                   AND pa.idtable = '" . $id . "'\n                   AND pt.tlock = 0\n              ORDER BY pa.idaction ASC";
     $result = $db->query($sql);
     if ($result->length() > 0) {
         $actions = array();
         do {
             $actions[] = PokerAction::getInstance($result->idaction);
         } while ($result->next());
         return $actions;
     }
     return false;
 }
Пример #3
0
 /**
  * Post Blinds.
  * 
  * @param object $player The player object.
  * @param string $blind Blind type (big, small).
  */
 private function postBlind($player, $blind)
 {
     $value = $player->table->blinds[$blind];
     $player->bet = $value;
     $player->stack -= $value;
     $player->save();
     // new action
     $action = new PokerAction($player->table->game, 'blind', array('blind' => $blind, 'value' => $value), $player);
     $action->save();
 }