Debian Codegraph @

src/players.h

raw symbols SCIP
1 // Copyright 2005 by Anthony Liekens [email protected]
2
3 #ifndef PLAYERS_H
4 #define PLAYERS_H
5
6 #include <vector>
7 #include <list>
8
9 #include "actions.h"
10
11 class Ships;
12 class Universe;
13 class Planet;
14 class Selection;
15 class Game;
16
17 class Player {
18 public:
19 enum PlayerTypes { HUMAN, COMPUTER, NEUTRAL };
20 enum PlayerStates { ALIVE, DEAD };
21 protected:
22 Universe* universe;
23 Ships* ships;
24 PlayerTypes playerType;
25 PlayerStates playerState;
26 Uint32 color;
27 std::vector< int > stats;
28 std::list< Planet * > occupiedPlanets;
29 bool visible;
30 int team;
31
32 public:
33 Player(Universe *, Uint32, int);
34 virtual ~Player() {}
35
36 void addShip(Uint32, Planet * const);
37 void removeDeadShips();
38
39 void render();
40
41 void setVisible(bool vis) { visible = vis; };
42 void updateStats( double maximumPoints );
43 bool renderStats( int height );
44 void renderStatsLog( );
45 virtual void update(Game *game) = 0;
46
47 PlayerTypes getPlayerType();
48
49 void setColor( const Uint32& );
50 Uint32 getColor();
51 Universe* getUniverse() { return universe; }
52 double getPoints();
53
54 void addPlanet(Planet *);
55 void removePlanet(Planet *);
56
57 int getTeam() const { return team; }
58
59 };
60
61 class HumanPlayer : public Player {
62 private:
63 int fleetStrength;
64 public:
65 HumanPlayer( Universe* universe, Uint32 color, int team );
66
67 void update(Game *game);
68
69 void selectAllPlanets();
70
71 void setFleetStrength(int);
72
73 int getFleetStrength() const { return fleetStrength; }
74
75 void selectPlanetAt(int, int);
76
77 void selectNearestPlanet(int, int);
78
79 void moveToNearestPlanet(Uint32, int, int);
80 };
81
82 class ComputerPlayer : public Player {
83 private:
84 // strategy related
85
86 double proportionResidents; // proportion of all ships to reside on planets
87 double moonPriority, enemyPriority, preferredPriority, neutralPriority, weakerEnemyPriority, strongerEnemyPriority;
88
89 std::list< Planet* > preferredPlanets;
90
91 public:
92 ComputerPlayer( Universe* universe, Uint32 color, int team );
93
94 void update(Game *);
95
96 void action( const Uint32& time );
97
98 bool isAPreferredPlanet( Planet* );
99 Planet* getRandomNearbyPlanet( Planet* );
100 void printStats();
101 };
102
103 class NeutralPlayer : public Player {
104 public:
105 NeutralPlayer( Universe* universe, Uint32 color);
106
107 void update(Game *);
108
109 };
110
111 class Players : public std::list< Player* > {
112 protected:
113 Universe* universe;
114 Player* bestPlayer;
115 public:
116 Players( Universe* universe );
117
118 void render( );
119 double getSumOfScores();
120 void updateStats( int time );
121 void renderStats( );
122
123 void update(Game *);
124 };
125
126 class ComputerPlayerAction : public Action {
127 private:
128 ComputerPlayer* player;
129 public:
130 ComputerPlayerAction();
131 ComputerPlayerAction( ComputerPlayer* player );
132 void execute( const Uint32& time );
133 };
134
135 class UpdatePlayersStatsAction : public Action {
136 private:
137 Players* players;
138 public:
139 UpdatePlayersStatsAction();
140 UpdatePlayersStatsAction( Players* players );
141 void execute( const Uint32& time );
142 };
143
144 #endif