File indexing completed on 2024-10-06 06:48:46

0001 /* This file is part of KsirK.
0002    Copyright (C) 2002-2007 Gael de Chalendar <kleag@free.fr>
0003 
0004    KsirK is free software; you can redistribute it and/or
0005    modify it under the terms of the GNU General Public
0006    License as published by the Free Software Foundation, either version 2
0007    of the License, or (at your option) any later version.
0008 
0009    This program is distributed in the hope that it will be useful,
0010    but WITHOUT ANY WARRANTY; without even the implied warranty of
0011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012    General Public License for more details.
0013 
0014    You should have received a copy of the GNU General Public License
0015    along with this program; if not, write to the Free Software
0016    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017    02110-1301, USA
0018 */
0019 
0020 #ifndef CONTINENT_H
0021 #define CONTINENT_H
0022 
0023 #include "country.h"
0024 
0025 namespace Ksirk
0026 {
0027 
0028 namespace GameLogic
0029 {
0030 
0031 /**
0032   * This class represents a continent of the world. Each country belongs to 
0033   * a continent. When a player owns all the countries of a continent, he wins 
0034   * more armies. It is the basic object on which the strategies are based.
0035   * @author Gael de Chalendar (aka Kleag)
0036   */
0037 class Continent
0038 {
0039 public:
0040   /** 
0041     * The constructor-initializer.
0042     * @param myName The name of this continent.
0043     * @param myCountries The countries that will be member of this continent.
0044     * @param myBonus The bonus of armies at end of turn for the player owning 
0045     * all this continent.
0046     * @param id The unique integer id of this continent.
0047     */
0048   Continent (const QString &myName, const QList<Country*>& myCountries, const int myBonus);
0049 
0050   /** Default destructor. */
0051   virtual ~Continent();
0052 
0053   /**
0054     * Read property of m_members, the countries of this continent.
0055     */
0056   virtual const QList<Country*>& getMembers() const;
0057 
0058   /** Return the name of this continent. */
0059   virtual const QString& name() const;
0060 
0061   /** 
0062     * Return the bonus of armies at end of turn for the player owning all this 
0063     * continent.
0064     */
0065   virtual const int& getBonus() const;
0066 
0067   /** 
0068     * Returns the player that owns all the countries of this continent. 0 if 
0069     * none.
0070     */
0071   const Player* owner() const;
0072 
0073   /**
0074     * Saves a XML representation of this continent for game saving purpose
0075     * @param xmlStream The stream to write on
0076     */
0077   void saveXml(QTextStream& xmlStream);
0078 
0079   //@{
0080   /** Accessors to the unique integer identifier of this continent. */
0081 /*  inline unsigned int id() const {return m_id;}
0082   inline unsigned int id() {return m_id;}
0083   inline void id(unsigned int id) {m_id = id;}*/
0084   //@}
0085 
0086   /** Returns the list of countries of this continent owned by @ref player */
0087   QList<Country*> countriesOwnedBy(const Player* player);
0088 
0089 private: // Private attributes
0090 
0091   /** This is the list of the countries that forms this continent. This member
0092     * is constant as it will not change during the game.
0093     */
0094   QList<Country*> m_members;
0095 
0096   /** The name of the continent */
0097   const QString m_name;
0098 
0099   /** The bonus armies got by a user that owns all this continent */
0100   const int bonus;
0101 
0102   /** The unique integer identifier of this continent. */
0103 //   unsigned int m_id;
0104 };
0105 
0106 }
0107 }
0108 #endif