summaryrefslogtreecommitdiffstats
path: root/Player.h
blob: 0719c70c8d8668886165de96dc9557c4905cfb0d (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef _PLAYER_H
#define _PLAYER_H

#include <vector>
#include <string>
#include <stdlib.h>
#include "types.h"
#include "Cell.h"

class Controller;

class Player
{
public:
	/**
	 * Constructor.
	 **/
	Player(void);
	/**
	 * Constructor with initial values.
	 **/
	Player(PlayerNumber PlayerID, Coordinates InitialPoint, VelocityVector initialVel);
	/**
	 * Destructor.
	 **/
	virtual ~Player(void);

public:
	/**
	 * Moves the player along the velocity vector and returns a vector
	 * of all the crossed cells.
	 **/
	std::vector<Coordinates> move();
	/**
	 * Changes the direction (and possibly speed) the player is facing.
	 **/
	void setVelocity(VelocityVector v);
	/**
	 * Apply new coordinates to the player. This is used when starting/restarting the game.
	 **/
	void setCoordinates(Coordinates c);
	/**
	 * Defines the Player ID.
	 **/
	void setNumber(PlayerNumber n);
	/**
	 * Returns the player ID.
	 **/
	PlayerNumber getNumber();
	/**
	 * Sets the player alive.
	 * It's alive ! ALIIIIIIIIIIIIVE !!!
	 **/
	void revive();
	/**
	 * (self explanatory)
	 **/
	void kill();
	/**
	 * Tries to change the direction the player is facing.
	 * Returns false and do nothing if the player is heading the opposite
	 * or the same way. Only possible change is 90°.
	 **/
	bool changeDirection(VelocityVector v);
	/**
	 *Turns toward left
	 **/
	void turnLeft();
	/**
	 * Turns toward right
	 **/
	void turnRight();
	/**
	 * Returns the current velocity vector.
	 **/
	VelocityVector getVelocity();
	/**
	 * Returns the current coordinates.
	 **/
	Coordinates getCoordinates();
	/**
	 * Returns true if the player is alive.
	 **/
	bool isAlive();
	/**
	 * Returns the current controller.
	 * NULL when initialized, it is assigned later.
	 **/
	Controller* getController(); // may be NULL
	/**
	 * Defines the controller.
	 **/
	void setController(Controller* pController);

private:
	PlayerNumber    m_playerID;
	std::string     m_name;
	Coordinates     m_currentCoordinates;
	VelocityVector  m_velocityVector;
	bool            m_alive;
	Controller*     m_pController;
};

#endif