/** * deletes all tables,rows from database for this game * * @param int $id_game * @return bool - true if successfull * @throws GameAdministrationException - if game isn't loaded or the game isn't new */ public static function deleteGame($id_game) { try { $_Game = self::getGame($id_game); } catch (NullPointerException $ex) { throw new GameAdministrationException('Game not found.'); } if ($_Game->getStatus() !== GAME_STATUS_NEW) { throw new GameAdministrationException('Only new games can be deleted.'); } self::setGameSpecificQueries($id_game); try { DataSource::Singleton()->epp('drop_areas_table', array()); DataSource::Singleton()->epp('drop_moves_table', array()); DataSource::Singleton()->epp('drop_moves_areas_table', array()); DataSource::Singleton()->epp('drop_moves_units_table', array()); DataSource::Singleton()->epp('drop_units_table', array()); } catch (DataSourceException $ex) { if (!isset(self::$logger)) { self::$logger = Logger::getLogger('ModelGame'); } self::$logger->error($ex); } $dict = array(':id_game' => $id_game); DataSource::Singleton()->epp('delete_game', $dict); ModelIsInGameInfo::deleteIsInGameInfos(null, $id_game); ModelInGamePhaseInfo::deleteInGamePhaseInfos(null, $id_game); unset(self::$games[$id_game]); return true; }
/** * delete user from game (also deletes notification infos) * * @param int $id_game * @param int $id_user * @return void */ public static function leaveGame($id_user, $id_game) { self::deleteIsInGameInfos($id_user, $id_game); ModelInGamePhaseInfo::deleteInGamePhaseInfos($id_user, $id_game); }