-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.hpp
67 lines (53 loc) · 2.12 KB
/
Player.hpp
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
#ifndef PLAYER_HPP
#define PLAYER_HPP
/* Player.hpp
*
* Euchre player interface
*
* by Andrew DeOrio
* 2014-12-21
*/
#include "Card.hpp"
#include <string>
#include <vector>
#include <cassert>
class Player {
public:
//EFFECTS returns player's name
virtual const std::string & get_name() const = 0;
//REQUIRES player has less than MAX_HAND_SIZE cards
//EFFECTS adds Card c to Player's hand
virtual void add_card(const Card &c) = 0;
//REQUIRES round is 1 or 2
//MODIFIES order_up_suit
//EFFECTS If Player wishes to order up a trump suit then return true and
// change order_up_suit to desired suit. If Player wishes to pass, then do
// not modify order_up_suit and return false.
virtual bool make_trump(const Card &upcard, bool is_dealer,
int round, Suit &order_up_suit) const = 0;
//REQUIRES Player has at least one card
//EFFECTS Player adds one card to hand and removes one card from hand.
virtual void add_and_discard(const Card &upcard) = 0;
//REQUIRES Player has at least one card
//EFFECTS Leads one Card from Player's hand according to their strategy
// "Lead" means to play the first Card in a trick. The card
// is removed the player's hand.
virtual Card lead_card(Suit trump) = 0;
//REQUIRES Player has at least one card
//EFFECTS Plays one Card from Player's hand according to their strategy.
// The card is removed from the player's hand.
virtual Card play_card(const Card &led_card, Suit trump) = 0;
// Maximum number of cards in a player's hand
static const int MAX_HAND_SIZE = 5;
// Needed to avoid some compiler errors
virtual ~Player() {}
};
//EFFECTS: Returns a pointer to a player with the given name and strategy
//To create an object that won't go out of scope when the function returns,
//use "return new Simple(name)" or "return new Human(name)"
//Don't forget to call "delete" on each Player* after the game is over
Player * Player_factory(const std::string &name, const std::string &strategy);
//EFFECTS: Prints player's name to os
std::ostream & operator<<(std::ostream &os, const Player &p);
#endif // PLAYER_HPP