1 | /* |
2 | Copyright 2003 Russell Steffen <rsteffen@bayarea.net> |
3 | Copyright 2003 Stephan Zehetner <s.zehetner@nevox.org> |
4 | Copyright 2006 Dmitry Suzdalev <dimsuz@gmail.com> |
5 | Copyright 2006 Inge Wallin <inge@lysator.liu.se> |
6 | Copyright 2006 Pierre Ducroquet <pinaraf@gmail.com> |
7 | |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
21 | */ |
22 | #ifndef KONQUEST_PLANET_H |
23 | #define KONQUEST_PLANET_H |
24 | |
25 | #include <QObject> |
26 | #include "fleet.h" |
27 | |
28 | class Sector; |
29 | class Player; |
30 | class GameOptions; |
31 | |
32 | //************************************************************** |
33 | // class Planet |
34 | //************************************************************** |
35 | |
36 | class Planet : public QObject |
37 | { |
38 | Q_OBJECT |
39 | |
40 | public: |
41 | Planet( const QString &planetName, Sector *sector, |
42 | Player *initialOwner, int newProd, |
43 | double newKillP ); |
44 | |
45 | // FIXME: Nobody inherits Planet. Why virtual? /iw |
46 | virtual ~Planet(); |
47 | |
48 | static Planet *createPlayerPlanet( Sector *sector, |
49 | Player *initialOwner, const QString &planetName ); |
50 | static Planet *createNeutralPlanet( Sector *sector, |
51 | Player *initialOwner, const QString &planetName ); |
52 | |
53 | Sector *sector() const { return m_sector; } |
54 | Player *player() const { return m_owner; } |
55 | const QString &name() const { return m_name; } |
56 | DefenseFleet &fleet() { return m_homeFleet; } |
57 | |
58 | double killPercentage() const { return m_killPercentage; } |
59 | void setKillPercentage(double value) { m_killPercentage = value; } |
60 | |
61 | int production() const { return m_productionRate; } |
62 | void setProduction(int value) |
63 | { |
64 | m_originalProductionRate = m_productionRate = value; |
65 | } |
66 | |
67 | int planetLook() const { return m_planetLook; } |
68 | int ships() const { return m_showCurShips ? m_homeFleet.shipCount() : m_oldShips; } |
69 | |
70 | void showOldShips() { m_showCurShips=false; } |
71 | void conquer( AttackFleet *conqueringFleet ); |
72 | void setOwner(Player* player) { m_owner = player; } |
73 | void turn(const GameOptions &); |
74 | |
75 | //void select() { Q_ASSERT(false); } |
76 | signals: |
77 | void update(); |
78 | |
79 | private: |
80 | QString m_name; |
81 | Player *m_owner; |
82 | Sector *m_sector; |
83 | DefenseFleet m_homeFleet; |
84 | |
85 | double m_killPercentage; |
86 | int m_productionRate, m_originalProductionRate; |
87 | int m_planetLook; |
88 | int m_oldShips; |
89 | bool m_showCurShips; |
90 | bool m_justconquered; |
91 | }; |
92 | |
93 | #endif // KONQUEST_PLANET_H |
94 | |