66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
/* This takes the general graph code and does stuff specific to the game
|
|
* with it. It stores the current turn, selected vertex and other useful
|
|
* information
|
|
*/
|
|
|
|
#ifndef _GAMEDATA_H_
|
|
#define _GAMEDATA_H_
|
|
|
|
#include "graph.h"
|
|
#include "player.h"
|
|
#include "gamevertex.h"
|
|
|
|
enum Mode {MODE_MOVE=0x1, MODE_ATTACK=0x2, MODE_BUILD=0x4, MODE_SELECT=0x8};
|
|
|
|
class GameData : public Graph
|
|
{
|
|
public:
|
|
GameData();
|
|
~GameData();
|
|
|
|
GameVertex* get_current_vertex(bool only_mine = false) const;
|
|
void clear_current_vertex();
|
|
|
|
// select or add vertex, as appropriate
|
|
void handle_click(int x, int y);
|
|
bool select_vertex(int x, int y);
|
|
void attack_vertex(GameVertex* target);
|
|
|
|
bool add_vertex(int x, int y, int z, int r, int colour);
|
|
|
|
Mode get_mode() const { return mode; }
|
|
void set_mode(Mode m);
|
|
|
|
VertexType get_build_type() const { return build_type; }
|
|
void set_build_type(VertexType type) { build_type = type; }
|
|
|
|
// returns the move/attack range for the specified node
|
|
// (or the selected node if node == NULL)
|
|
int get_range(GameVertex* node = NULL);
|
|
|
|
// check for (and set, if needed) winner
|
|
bool endgame();
|
|
void toggle_turn();
|
|
Player* get_turn() const { return turn; }
|
|
|
|
private:
|
|
int num_vertices_by_type(VertexType type, Player* player = NULL);
|
|
void produce_energy();
|
|
|
|
|
|
GameVertex* current;
|
|
Player player1, player2;
|
|
Player* turn;
|
|
|
|
Mode mode;
|
|
VertexType build_type;
|
|
|
|
static int PLAYER1_COLOUR;
|
|
static int PLAYER2_COLOUR;
|
|
|
|
static int BASE_BUILD_RADIUS;
|
|
static int NODE_RADIUS;
|
|
};
|
|
|
|
#endif
|