Ejemplo n.º 1
0
 /**
  * Spin slot
  *
  * @param array $params = array('bet'=>int, 'denomination'=>float, 'lines'=>int)
  * @return array | FALSE
  */
 public function spin($params)
 {
     if (!$this->_checkGame()) {
         return false;
     }
     if ($this->_game->getBonusCount() <= 0) {
         $this->_game->setBonusGame(false);
     }
     if (!$this->_game->getIsBonus()) {
         $this->_lines_count = intval($params['lines']);
         $this->_bet = $params['bet'];
         $this->_denomination = $params['denomination'];
     }
     $lines_count = $this->_lines_count;
     $bet = $this->_bet;
     $denomination = $this->_denomination;
     if ($this->_game->checkBet($bet, $denomination, $lines_count)) {
         $bet = new ItemBet($this->_client->get_user()->getAPI(), $this->_game, $denomination, $bet, $lines_count);
         if ($bet->save()) {
             $this->_game->spin($lines_count);
             if (!$bet->won($this->_game->getWins())) {
                 $this->pushError($bet);
             }
             if ($this->_game->getIsBonus()) {
                 if (!$bet->won($this->_game->getBonusWins(), true)) {
                     $this->pushError($bet);
                 }
             }
         }
     }
     $this->pushError($bet);
     if (!$this->hasErrors()) {
         $res = $this->_game->getScreenArray();
         if ($this->_game->getIsBonus()) {
             $res['bonus_won'] = $bet->getBonusWinningAmount();
             $this->_bonus_won = $res['bonus_won'];
         }
         $res['won'] = $bet->getWinningAmount();
         $this->_won = $res['won'];
         $res['balance'] = $this->_client->get_user()->getAPI()->get_balance();
         return $res;
     }
     return false;
 }