-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.h
41 lines (30 loc) · 998 Bytes
/
Player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef PLAYER_INCLUDED
#define PLAYER_INCLUDED
#include <string>
class Point;
class Board;
class Game;
class Player
{
public:
Player(std::string nm, const Game& g)
: m_name(nm), m_game(g)
{}
virtual ~Player() {}
std::string name() const { return m_name; }
const Game& game() const { return m_game; }
virtual bool isHuman() const { return false; }
virtual bool placeShips(Board& b) = 0;
virtual Point recommendAttack() = 0;
virtual void recordAttackResult(Point p, bool validShot, bool shotHit,
bool shipDestroyed, int shipId) = 0;
virtual void recordAttackByOpponent(Point p) = 0;
// We prevent any kind of Player object from being copied or assigned
Player(const Player&) = delete;
Player& operator=(const Player&) = delete;
private:
std::string m_name;
const Game& m_game;
};
Player* createPlayer(std::string type, std::string nm, const Game& g);
#endif // PLAYER_INCLUDED