-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.h
113 lines (97 loc) · 2.56 KB
/
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
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
105
106
107
108
109
110
111
112
113
#ifndef _PLAYER_H
#define _PLAYER_H
#include "FaceUpPile.h"
#include "DrawPile.h"
#include "Hand.h"
#include <vector>
#include <string>
#include <istream>
/**
* A player.
*/
class Player {
public:
/**
* Non-default constructor for Player.
* Creates a player with a specified name.
*
* @param playerName is the string representation of the name
*/
Player(std::string playerName);
/**
* Destructor for Player.
*/
~Player();
/**
* Returns the name of the Player.
*
* @return the name
*/
std::string getName() const { return name; }
/**
* Adds a Card to the Player's stock pile.
*
* @param c is the Card to add
*/
void addToStock(Card c) { stock.addCard(c); }
/**
* Adds a Card to the Player's Hand.
*
* @param c is the Card to add
*/
void addToHand(Card c) { hand.addCard(c); }
/**
* Moves a Card from the Player's stock pile.
*
* @param dest is the destination of the Card to move
* @param build is a reference to the build pile
*
* @return 1 if sucessfully moved, 0 otherwise
*/
int stockMove(int dest, std::vector<FaceUpPile>& build);
/**
* Moves a Card from the Player's discard pile.
*
* @param orig is the original position of the Card (i.e. which discard pile)
* @param dest is the destination of the Card to move
* @param build is a reference to the build pile
*
* @return 1 if successfully moved, 0 otherwise
*/
int discardMove(int orig, int dest, std::vector<FaceUpPile>& build);
/**
* Moves a Card from the Player's Hand.
*
* @param orig is the original position of the Card (i.e. which Hand position)
* @param dest is the destination of the Card to move
* @param build is a reference object to the build pile
*
* @return 1 if successfully moved to a build pile
* 2 if successfully moved to a discard pile
* 0 otherwise
*/
int handMove(int orig, int dest, std::vector<FaceUpPile>& build);
/**
* Converts Player into a string representation.
*
* @return the string Player
*/
std::string toString() const;
/**
* Reads in a Player from an input stream (when loading a game).
*
* @param is is the input stream
*/
void readIn(std::istream& is);
/**
* Displays Player during gameplay.
*/
void display() const;
protected:
friend class SkipBoGame; // SkipBoGame has access to Player fields
std::string name; // Player's name
FaceUpPile stock; // Player's stock pile
std::vector<FaceUpPile> discard; // Player's discard pile
Hand hand; // Player's hand
};
#endif