~keith-penguin/kdegames/trunk

« back to all changes in this revision

Viewing changes to konquest/player.h

  • Committer: Keith Worrell
  • Date: 2009-03-18 05:35:28 UTC
  • Revision ID: keith.worrell@gmail.com-20090318053528-mx6x9c0ngmg0kg6p
imported project

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright Russell Steffen <rsteffen@bayarea.net>
 
3
    Copyright Stephan Zehetner <s.zehetner@nevox.org>
 
4
    Copyright Dmitry Suzdalev <dimsuz@gmail.com>
 
5
    Copyright <inge@lysator.liu.se>
 
6
    Copyright <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 __PLAYER_H__
 
23
#define __PLAYER_H__
 
24
 
 
25
 
 
26
#include <QColor>
 
27
 
 
28
#include "planet.h"
 
29
#include "fleet.h"
 
30
 
 
31
class GameLogic;
 
32
class Map;
 
33
 
 
34
//**************************************************************
 
35
// class Player
 
36
//**************************************************************
 
37
 
 
38
class Player
 
39
{
 
40
public:
 
41
    Player( Map *map, const QString &newName, const QColor &color, int number );
 
42
    virtual ~Player();
 
43
 
 
44
    bool operator==( const Player &otherPlayer ) const
 
45
        { return m_playerNum == otherPlayer.m_playerNum; }
 
46
 
 
47
    enum { NEUTRAL_PLAYER_NUMBER = -1 };
 
48
    
 
49
    // Getters for some fundamental properties.
 
50
    QString name()        const { return m_name; }
 
51
    QString coloredName() const;
 
52
    QColor& color()             { return m_color; }
 
53
    bool    isNeutral()   const { return m_playerNum == NEUTRAL_PLAYER_NUMBER; }
 
54
    AttackFleetList &attackList() { return m_attackList; }
 
55
    AttackFleetList &newAttacks() { return m_newAttacks; }
 
56
 
 
57
    // factory functions
 
58
    static Player *createPlayer( Map *map, const QString &name, 
 
59
                                 const QColor &color, 
 
60
                                 int playerNum, bool isAi  );
 
61
    static Player *createNeutralPlayer( Map *map );
 
62
 
 
63
    bool NewAttack( Planet *sourcePlanet, Planet *destPlanet, int shipCount, int departureTurn );
 
64
 
 
65
    bool isInPlay()               const { return m_inPlay; }
 
66
    void setInPlay( bool status )       { m_inPlay = status; }
 
67
    virtual bool  isAiPlayer()    const { return false; }
 
68
    
 
69
 
 
70
    // Statistics collection
 
71
    void statShipsBuilt( int x )           { m_shipsBuilt           += x; }
 
72
    void statPlanetsConquered( int x )     { m_planetsConquered     += x; }
 
73
    void statFleetsLaunched( int x )       { m_fleetsLaunched       += x; }
 
74
    void statEnemyFleetsDestroyed( int x ) { m_enemyFleetsDestroyed += x; }
 
75
    void statEnemyShipsDestroyed( int x )  { m_enemyShipsDestroyed  += x; }
 
76
 
 
77
    int  shipsBuilt()           const { return m_shipsBuilt;           }
 
78
    int  planetsConquered()     const { return m_planetsConquered;     }
 
79
    int  fleetsLaunched()       const { return m_fleetsLaunched;       }
 
80
    int  enemyFleetsDestroyed() const { return m_enemyFleetsDestroyed; }
 
81
    int  enemyShipsDestroyed()  const { return m_enemyShipsDestroyed;  }
 
82
 
 
83
private:
 
84
    // Points to the Map we're playing on.
 
85
    Map     *m_map;
 
86
 
 
87
    // Some fundamental properties.
 
88
    QString  m_name;
 
89
    QColor   m_color;
 
90
    int      m_playerNum;
 
91
    bool     m_inPlay;
 
92
 
 
93
    // Attack fleets sent by this player that are still moving
 
94
    AttackFleetList  m_attackList;
 
95
    // Fleets to send at the end of this turn
 
96
    AttackFleetList  m_newAttacks;
 
97
 
 
98
    // statistics counters
 
99
    int  m_shipsBuilt;
 
100
    int  m_planetsConquered;
 
101
    int  m_fleetsLaunched;
 
102
    int  m_enemyFleetsDestroyed;
 
103
    int  m_enemyShipsDestroyed;
 
104
};
 
105
 
 
106
 
 
107
class AIPlayer : public Player
 
108
{
 
109
    public:
 
110
        AIPlayer( Map *map, const QString &name, const QColor &color, int number );
 
111
        virtual ~AIPlayer();
 
112
    
 
113
        virtual bool  isAiPlayer() const { return true; }
 
114
    
 
115
        void  doMove( GameLogic *gameLogic);
 
116
        
 
117
        int getAiLevel() { return m_AiLevel; }
 
118
    private:
 
119
        int m_AiLevel;
 
120
};
 
121
 
 
122
 
 
123
#endif