treewars/gamedata.h

45 lines
971 B
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"
enum Turn {PLAYER1, PLAYER2, WIN1, WIN2};
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:
float calculate_strength(Vertex* node);
float calculate_strength_r(Vertex* node, unsigned int depth, list<Vertex*>& visited);
Vertex* current;
Turn player;
bool player1_played;
bool player2_played;
static int PLAYER1_COLOUR;
static int PLAYER2_COLOUR;
};
#endif