/** * @return bool */ public function endGame() { foreach ($this->Players as $player) { $this->SQL->update_stats($player); } $this->SQL->delete_game($this->chat_id, $this->game_id); return true; }
/** * @param PlayerMove $Move * @return bool|Game */ private function loadOrCreateGame(PlayerMove $Move) { if (!($Game = $this->SQL->select_game($this->chat->id))) { $this->SQL->insert_game($this->chat->id); $Game = $this->SQL->select_game($this->chat->id); $Game->addDealer($this->db); if (!$this->Bets->checkPlayerBet($Game, $this->user, $Game->Dealer->user, $this->bet)) { return false; } $this->bet = $this->Bets->bet; $this->free_bet = $this->Bets->free_bet; $player = $Game->addPlayer($this->user, $this->Bets, $this->bet, $this->free_bet); if ($Move == PlayerMove::JoinGame) { $this->Talk->join_game($player); } } return $Game; }