-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathPiece.h
60 lines (39 loc) · 1.4 KB
/
Piece.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Created by Ivo Georgiev on 11/22/15.
//
#ifndef PA5GAME_GAMEUNIT_H
#define PA5GAME_GAMEUNIT_H
#include <string>
#include "Game.h"
namespace Gaming {
class Resource;
class Piece {
private:
static unsigned int __idGen;
bool __finished;
bool __turned;
Position __position;
protected:
const Game &__game; // note: a reference to the Game object
unsigned int __id;
virtual void print(std::ostream &os) const = 0;
void finish() { __finished = true; }
bool isFinished() const { return __finished; }
public:
Piece(const Game &g, const Position &p);
virtual ~Piece();
const Position getPosition() const { return __position; }
void setPosition(const Position &p) { __position = p; }
bool getTurned() const { return __turned; }
void setTurned(bool turned) { __turned = turned; }
virtual void age() = 0;
virtual bool isViable() const = 0;
virtual PieceType getType() const = 0;
virtual ActionType takeTurn(const Surroundings &surr) const = 0; // note: doesn't actually change the object
virtual Piece &operator*(Piece &other) = 0;
virtual Piece &interact(Agent *) = 0;
virtual Piece &interact(Resource *) = 0;
friend std::ostream &operator<<(std::ostream &os, const Piece &piece);
};
}
#endif //PA5GAME_GAMEUNIT_H