2011-06-23 21:28:49 +00:00
|
|
|
/* 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"
|
2011-07-01 18:10:45 +00:00
|
|
|
#include "player.h"
|
2011-07-03 20:37:07 +00:00
|
|
|
#include "gamevertex.h"
|
2011-06-23 21:28:49 +00:00
|
|
|
|
2011-07-03 14:26:46 +00:00
|
|
|
enum Mode {MODE_MOVE=0x1, MODE_ATTACK=0x2, MODE_BUILD=0x4, MODE_SELECT=0x8};
|
2011-07-02 02:04:58 +00:00
|
|
|
|
2011-06-23 21:28:49 +00:00
|
|
|
class GameData : public Graph
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GameData();
|
|
|
|
~GameData();
|
|
|
|
|
2011-07-03 20:57:47 +00:00
|
|
|
GameVertex* get_current_vertex(bool only_mine = false) const;
|
2011-07-02 00:00:19 +00:00
|
|
|
void clear_current_vertex();
|
2011-06-23 21:28:49 +00:00
|
|
|
|
|
|
|
// select or add vertex, as appropriate
|
2011-07-01 18:10:45 +00:00
|
|
|
void handle_click(int x, int y);
|
2011-07-02 03:24:41 +00:00
|
|
|
bool select_vertex(int x, int y);
|
2011-07-03 20:57:47 +00:00
|
|
|
void attack_vertex(GameVertex* target);
|
2011-06-23 21:28:49 +00:00
|
|
|
|
2011-07-01 16:24:52 +00:00
|
|
|
bool add_vertex(int x, int y, int z, int r, int colour);
|
2011-06-23 21:28:49 +00:00
|
|
|
|
2011-06-24 16:02:53 +00:00
|
|
|
Mode get_mode() const { return mode; }
|
2011-07-01 22:23:01 +00:00
|
|
|
void set_mode(Mode m);
|
2011-06-24 16:02:53 +00:00
|
|
|
|
2011-07-03 14:26:46 +00:00
|
|
|
VertexType get_build_type() const { return build_type; }
|
2011-07-06 20:17:30 +00:00
|
|
|
void set_build_type(VertexType type);
|
2011-07-03 14:12:47 +00:00
|
|
|
|
2011-06-24 16:18:52 +00:00
|
|
|
// returns the move/attack range for the specified node
|
2011-06-24 16:02:53 +00:00
|
|
|
// (or the selected node if node == NULL)
|
2011-07-03 20:57:47 +00:00
|
|
|
int get_range(GameVertex* node = NULL);
|
2011-06-24 16:02:53 +00:00
|
|
|
|
2011-06-24 18:59:18 +00:00
|
|
|
// check for (and set, if needed) winner
|
|
|
|
bool endgame();
|
2011-07-03 21:45:11 +00:00
|
|
|
void toggle_turn();
|
2011-07-01 18:10:45 +00:00
|
|
|
Player* get_turn() const { return turn; }
|
2011-06-24 18:59:18 +00:00
|
|
|
|
2011-07-06 20:17:30 +00:00
|
|
|
bool can_build(VertexType type);
|
|
|
|
int get_energy_cost(VertexType type);
|
|
|
|
|
|
|
|
|
2011-06-23 21:28:49 +00:00
|
|
|
private:
|
2011-07-04 05:27:56 +00:00
|
|
|
int num_vertices_by_type(VertexType type, Player* player = NULL);
|
|
|
|
void produce_energy();
|
|
|
|
|
|
|
|
|
2011-07-03 20:57:47 +00:00
|
|
|
GameVertex* current;
|
2011-07-01 18:10:45 +00:00
|
|
|
Player player1, player2;
|
|
|
|
Player* turn;
|
2011-06-23 21:28:49 +00:00
|
|
|
|
2011-07-03 14:12:47 +00:00
|
|
|
Mode mode;
|
|
|
|
VertexType build_type;
|
|
|
|
|
2011-06-23 21:28:49 +00:00
|
|
|
static int PLAYER1_COLOUR;
|
|
|
|
static int PLAYER2_COLOUR;
|
2011-07-01 18:10:45 +00:00
|
|
|
static int NODE_RADIUS;
|
2011-07-06 20:17:30 +00:00
|
|
|
static int BASE_BUILD_RADIUS;
|
2011-06-23 21:28:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|