File indexing completed on 2024-04-14 04:00:52

0001 /*
0002     SPDX-FileCopyrightText: 2003 Russell Steffen <rsteffen@bayarea.net>
0003     SPDX-FileCopyrightText: 2003 Stephan Zehetner <s.zehetner@nevox.org>
0004     SPDX-FileCopyrightText: 2006 Dmitry Suzdalev <dimsuz@gmail.com>
0005     SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
0006     SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 
0011 #ifndef KONQUEST_PLANET_H
0012 #define KONQUEST_PLANET_H
0013 
0014 #include <QObject>
0015 #include "fleet.h"
0016 
0017 class Sector;
0018 class Player;
0019 struct GameOptions;
0020 
0021 //**************************************************************
0022 // class Planet
0023 //**************************************************************
0024 
0025 class Planet : public QObject
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     Planet( const QString &planetName, Sector *sector,
0031             Player *initialOwner, int newProd,
0032             double newKillP );
0033 
0034     // FIXME: Nobody inherits Planet.  Why virtual?  /iw
0035     ~Planet() override;
0036 
0037     static Planet *createPlayerPlanet( Sector *sector,
0038                                        Player *initialOwner, const QString &planetName );
0039     static Planet *createNeutralPlanet( Sector *sector,
0040                                         Player *initialOwner, const QString &planetName );
0041 
0042     Sector        *sector()     const { return m_sector; }
0043     Player        *player()     const { return m_owner; }
0044     const QString &name()       const { return m_name; }
0045     DefenseFleet  &fleet()            { return m_homeFleet; }
0046 
0047     double         killPercentage() const { return m_killPercentage; }
0048     void           setKillPercentage(double value) { m_killPercentage = value; }
0049 
0050     int            production() const { return m_productionRate; }
0051     void           setProduction(int value)
0052     {
0053        m_originalProductionRate = m_productionRate = value;
0054     }
0055 
0056     int            planetLook() const { return m_planetLook; }
0057     int            ships()      const { return m_showCurShips ? m_homeFleet.shipCount() : m_oldShips; }
0058 
0059     void  showOldShips() { m_showCurShips=false; }
0060     void  conquer( AttackFleet *conqueringFleet );
0061     void  setOwner(Player* player) { m_owner = player; }
0062     void  turn(const GameOptions &);
0063 
0064     //void select() { Q_ASSERT(false); }
0065 Q_SIGNALS:
0066     void  update();
0067 
0068 private:
0069     QString       m_name;
0070     Player       *m_owner;
0071     Sector       *m_sector;
0072     DefenseFleet  m_homeFleet;
0073 
0074     double        m_killPercentage;
0075     int           m_productionRate, m_originalProductionRate;
0076     int           m_planetLook;
0077     int           m_oldShips;
0078     bool          m_showCurShips;
0079     bool          m_justconquered;
0080 };
0081 
0082 #endif // KONQUEST_PLANET_H