/* * File: gameinfoctx.h * * Copyright © 2019 Stefano Marsili, * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, see */ #ifndef STMG_GAME_INFO_CTX_H #define STMG_GAME_INFO_CTX_H #include "xmlconditionalparser.h" #include #include #include namespace stmg { class GameInfoCtx : public ConditionalCtx { public: GameInfoCtx(const shared_ptr& refAppConfig, const File& oGameFile, XmlConditionalParser& oXmlConditionalParser) : ConditionalCtx(refAppConfig, s_oDummy, oXmlConditionalParser) { m_oGameInfo.m_oGameFile = oGameFile; s_oDummy.clear(); } GameInfoCtx(const shared_ptr& refAppPreferences, Named& oNamed, const File& oGameFile, XmlConditionalParser& oXmlConditionalParser) : ConditionalCtx(refAppPreferences, oNamed, oXmlConditionalParser) { m_oGameInfo.m_oGameFile = oGameFile; } const GameConstraints& getGameConstraints() const { return m_oGameInfo.m_oGameConstraints; } const shared_ptr& getHighscoresDefinition() const { return m_oGameInfo.m_refHighscoresDefinition; } inline const NamedObjIndex& getGameVariableTypes() const { return m_oGameVariableTypes; } inline const NamedObjIndex& getTeamVariableTypes() const { return m_oTeamVariableTypes; } inline const NamedObjIndex& getMateVariableTypes() const { return m_oMateVariableTypes; } const NamedObjIndex& getVariableTypes(OwnerType eOwnerType) const { if (eOwnerType == OwnerType::GAME) { // } else if (eOwnerType == OwnerType::TEAM) { return m_oTeamVariableTypes; } else if (eOwnerType == OwnerType::PLAYER) { return m_oMateVariableTypes; } else { assert(false); } return m_oGameVariableTypes; } double getMinGameInterval() const { return m_fMinGameInterval; } double getInitialGameInterval() const { return m_fInitialGameInterval; } protected: std::string err(const std::string& sErr) override { std::string sExtError; assert(!m_oGameInfo.m_oGameFile.isBuffered()); sExtError.append(m_oGameInfo.m_oGameFile.getFullPath()); sExtError.append(": "); sExtError.append(sErr); return ConditionalCtx::err(sExtError); } private: friend class XmlGameInfoParser; GameLoader::GameInfo m_oGameInfo; NamedObjIndex m_oGameVariableTypes; NamedObjIndex m_oTeamVariableTypes; NamedObjIndex m_oMateVariableTypes; double m_fMinGameInterval; double m_fInitialGameInterval; static AssignableNamed s_oDummy; private: GameInfoCtx() = delete; GameInfoCtx(const GameInfoCtx& oSource) = delete; GameInfoCtx& operator=(const GameInfoCtx& oSource) = delete; }; } // namespace stmg #endif /* STMG_GAME_INFO_CTX_H */