58 lines
1.4 KiB
C++
58 lines
1.4 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"
|
|
|
|
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);
|
|
void attack_vertex(Vertex* target);
|
|
|
|
bool add_vertex(int x, int y, int r, int colour);
|
|
|
|
Mode get_mode() const { return mode; }
|
|
Mode set_mode(Mode m) { mode = m; }
|
|
|
|
// returns the move/attack range for the specified node
|
|
// (or the selected node if node == NULL)
|
|
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;
|
|
};
|
|
|
|
#endif
|