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"
|
|
|
|
|
|
|
|
enum Turn {PLAYER1, PLAYER2, WIN1, WIN2};
|
|
|
|
|
2011-06-24 14:19:41 +00:00
|
|
|
|
2011-06-23 21:28:49 +00:00
|
|
|
class GameData : public Graph
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GameData();
|
|
|
|
~GameData();
|
|
|
|
|
|
|
|
Vertex* get_current_vertex() const { return current; }
|
|
|
|
void clear_current_vertex() { current = NULL; }
|
|
|
|
|
|
|
|
void toggle_turn();
|
|
|
|
|
|
|
|
// select or add vertex, as appropriate
|
|
|
|
void do_vertex(int x, int y, int r);
|
|
|
|
void select_vertex(int x, int y);
|
|
|
|
|
|
|
|
bool add_vertex(int x, int y, int r, int colour);
|
|
|
|
|
|
|
|
private:
|
2011-06-24 15:32:50 +00:00
|
|
|
float calculate_strength(Vertex* node);
|
|
|
|
float calculate_strength_r(Vertex* node, unsigned int depth, list<Vertex*>& visited);
|
2011-06-24 15:03:40 +00:00
|
|
|
|
2011-06-23 21:28:49 +00:00
|
|
|
Vertex* current;
|
|
|
|
Turn player;
|
|
|
|
bool player1_played;
|
|
|
|
bool player2_played;
|
|
|
|
|
|
|
|
static int PLAYER1_COLOUR;
|
|
|
|
static int PLAYER2_COLOUR;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|