treewars/gamedata.h

60 lines
1.4 KiB
C
Raw Normal View History

/* 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};
enum Mode {MODE_MOVE, MODE_ATTACK};
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);
2011-06-24 16:18:52 +00:00
void attack_vertex(Vertex* target);
bool add_vertex(int x, int y, int z, int r, int colour);
Mode get_mode() const { return mode; }
Mode set_mode(Mode m) { mode = m; }
2011-06-24 16:18:52 +00:00
// returns the move/attack range for the specified node
// (or the selected node if node == NULL)
2011-06-24 16:18:52 +00:00
int get_range(Vertex* node = NULL);
// check for (and set, if needed) winner
bool endgame();
Turn get_turn() const { return player; }
private:
float calculate_strength(Vertex* node);
float calculate_strength_r(Vertex* node, unsigned int depth, list<Vertex*>& visited);
Vertex* current;
Turn player;
Mode mode;
bool player1_played;
bool player2_played;
static int PLAYER1_COLOUR;
static int PLAYER2_COLOUR;
static int BASE_MOVE_RADIUS;
};
#endif