/* * Copyright 2007-2009 Ben Boeckel * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ /** * \file sigmod/Game.h */ #ifndef SIGMOD_GAME #define SIGMOD_GAME // Sigcore includes #include #include #include // Sigmod includes #include "Object.h" #include "Subclass.h" // Qt includes #include #include #include namespace Sigmod { // Forward declarations class Ability; class Author; class Badge; class CoinList; class EggGroup; class GlobalScript; class Item; class ItemType; class Map; class Move; class Nature; class Rules; class Skin; class Sound; class Specie; class Sprite; class Status; class Store; class Tile; class Time; class Trainer; class Type; class Weather; /** * \class Sigmod::Game Game.h sigmod/Game.h * \brief Main class that describes a Sigmod. * * The Game class describes an entire set of objects for use with the game engine. * Games will refuse to run if the \link Game::validate validate \endlink method * returns any errors. Warnings will not stop the engine from running the Sigmod, * but they should be minimized. */ class SIGMOD_EXPORT Game : public Object { Q_OBJECT public: typedef Subclass Abilities; typedef Subclass Authors; typedef Subclass Badges; typedef Subclass CoinLists; typedef Subclass EggGroups; typedef Subclass GlobalScripts; typedef Subclass Items; typedef Subclass ItemTypes; typedef Subclass Maps; typedef Subclass Moves; typedef Subclass Natures; typedef Subclass Skins; typedef Subclass Sounds; typedef Subclass Species; typedef Subclass Sprites; typedef Subclass Statuses; typedef Subclass Stores; typedef Subclass Tiles; typedef Subclass Times; typedef Subclass Trainers; typedef Subclass Types; typedef Subclass Weathers; /** * Default constructor. */ Game(); /** * Copy constructor. * * \param sigmod The game to copy. */ Game(const Game& game); /** * XML data constructor. * * \param xml The XML structure to extract the data from. */ Game(const QDomElement& xml); /** * Destructor. */ ~Game(); /** * Check to make sure the game is valid. */ void validate(); /** * Load data from XML. * * \param xml The XML structure to extract data from. */ void load(const QDomElement& xml); /** * Get the data for the badge in XML format. * * \return The XML structure representing the badge. */ QDomElement save() const; void setTitle(const QString& title); void setVersion(const QString& version); void setDescription(const QString& description); void setSinglePlayer(const bool singlePlayer); void setStartScript(const Sigcore::Script& startScript); void setTypechart(const int attack, const int defense, const Sigcore::Fraction& multiplier); void setMapPosition(const int map, const QPoint& position, const bool remove = false); void setRules(const Rules& rules); void setRules(const QDomElement& xml); QString title() const; QString version() const; QString description() const; bool singlePlayer() const; Sigcore::Script startScript() const; const Sigcore::Matrix& typechart() const; Sigcore::Matrix& typechart(); Sigcore::Fraction typechart(const int attack, const int defense) const; QPoint mapPosition(const int map) const; QMap mapPosition() const; const Rules* rules() const; Rules* rules(); const Abilities& abilities() const; Abilities& abilities(); const Authors& authors() const; Authors& authors(); const Badges& badges() const; Badges& badges(); const CoinLists& coinLists() const; CoinLists& coinLists(); const EggGroups& eggGroups() const; EggGroups& eggGroups(); const GlobalScripts& globalScripts() const; GlobalScripts& globalScripts(); const Items& items() const; Items& items(); const ItemTypes& itemTypes() const; ItemTypes& itemTypes(); const Maps& maps() const; Maps& maps(); const Moves& moves() const; Moves& moves(); const Natures& natures() const; Natures& natures(); const Skins& skins() const; Skins& skins(); const Sounds& sounds() const; Sounds& sounds(); const Species& species() const; Species& species(); const Sprites& sprites() const; Sprites& sprites(); const Statuses& statuses() const; Statuses& statuses(); const Stores& stores() const; Stores& stores(); const Tiles& tiles() const; Tiles& tiles(); const Trainers& times() const; Trainers& trainers(); const Types& types() const; Types& types(); const Weathers& weathers() const; Weathers& weathers(); bool titleCheck(const QString& title) const; bool versionCheck(const QString& version) const; bool descriptionCheck(const QString& description) const; bool singlePlayerCheck(const bool singlePlayer) const; bool startScriptCheck(const Sigcore::Script& startScript) const; bool mapPositionCheck(const QPoint& position) const; bool typechartCheck(const Sigcore::Fraction& multiplier) const; Game& operator=(const Game& rhs); private: void clear(); void typeAdded(const int newSize); void typeRemoved(const int index); // FIXME: friend the class for callbacks friend class Subclass; // friend Type* Subclass::add(Type*); // friend void Subclass::deleteAt(const int); QString m_title; QString m_version; QString m_description; bool m_singlePlayer; Sigcore::Script m_startScript; Sigcore::Matrix m_typechart; QMap m_mapPosition; Rules* m_rules; Abilities m_abilities; Authors m_authors; Badges m_badges; CoinLists m_coinLists; EggGroups m_eggGroups; GlobalScripts m_globalScripts; Items m_items; ItemTypes m_itemTypes; Maps m_maps; Moves m_moves; Natures m_natures; Skins m_skins; Sounds m_sounds; Species m_species; Sprites m_sprites; Statuses m_statuses; Stores m_stores; Tiles m_tiles; Times m_times; Trainers m_trainers; Types m_types; Weathers m_weathers; }; } #endif