Mari's Tarot
 All Classes Files Functions Variables Enumerations Enumerator Friends
Player.hpp
Go to the documentation of this file.
1 /*
2  * Tarot is an application for Android system to play to French Tarot.
3  * Please visit https://github.com/richoux/Tarot for further information.
4  *
5  * Copyright (C) 2013-2016 Florian Richoux
6  *
7  * This file is part of Tarot.
8  * Tarot is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * Tarot is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17 
18  * You should have received a copy of the GNU General Public License
19  * along with Tarot. If not, see http://www.gnu.org/licenses/.
20  */
21 
22 #pragma once
23 
24 #include <set>
25 #include <vector>
26 #include <memory>
27 
28 #include "Card.hpp"
29 #include "Deck.hpp"
30 #include "Biddings.hpp"
31 #include "Announcements.hpp"
32 
33 using namespace std;
34 
36 class Player
37 {
38 public:
40 
43  Player( const string& name );
44 
46 
49  void addCard( const shared_ptr<Card> card );
50 
52 
57  virtual Biddings bid( const Biddings bestBid, const bool chelemAnnounced ) const = 0;
58 
60 
64  virtual shared_ptr<Card> chooseKing( const Deck &deck ) const = 0;
65 
67 
70  vector< shared_ptr<Card> > getAllCards() const;
71 
73  inline set< Announcements > getAnnounced() const { return announced; }
74 
76  inline vector< shared_ptr<Card> > getInitialCards() const { return initialCards; }
77 
79  inline int getNumberOudlers() const { return numberOudlers; }
80 
82 
86  virtual set< shared_ptr<Card> > makeEcart( const int dogSize ) = 0;
87 
89  virtual void newGame() = 0;
90 
92 
97  virtual shared_ptr<Card> playCard( const Suits referenceSuit, const shared_ptr<Card> highTrump ) = 0;
98 
100  void showCards() const;
101 
103 
108  vector< shared_ptr<Card> > validCards ( const Suits referenceSuit, const shared_ptr<Card> greaterTrump ) const;
109 
110  string name;
111  double score;
112 
113 protected:
115 
119  vector< shared_ptr<Card> > callableCards( const Deck &deck ) const;
120 
122 
125  void delCard( const shared_ptr<Card> card );
126 
128  struct cardOrder {
129  bool operator() ( const shared_ptr<Card> lhs, const shared_ptr<Card> rhs) const
130  {
131  return lhs->getValue() < rhs->getValue();
132  }
133  };
134 
135  set< shared_ptr<Card>, cardOrder > hearts;
136  set< shared_ptr<Card>, cardOrder > spades;
137  set< shared_ptr<Card>, cardOrder > diamonds;
138  set< shared_ptr<Card>, cardOrder > clubs;
139  set< shared_ptr<Card>, cardOrder > trumps;
140  shared_ptr<Card> fool;
141  vector< shared_ptr<Card> > initialCards;
143  double initialPoints;
144  set< Announcements > announced;
145 
146 private:
147  bool hasCard( const shared_ptr<Card> card ) const;
148 };
set< shared_ptr< Card >, cardOrder > trumps
The set of trumps owned by the player.
Definition: Player.hpp:139
double initialPoints
The number of points the player has with his/her initial cards.
Definition: Player.hpp:143
set< shared_ptr< Card >, cardOrder > hearts
The set of Hearts owned by the player.
Definition: Player.hpp:135
Suits
The enum containing all suits, plus the Fool as a special suit.
Definition: Suits.hpp:25
double score
The player's score.
Definition: Player.hpp:111
Deck is the class managing the deck of cards. Used as well as for the game deck, but also for a count...
Definition: Deck.hpp:32
set< Announcements > getAnnounced() const
Inline assessor to the set of announcements.
Definition: Player.hpp:73
set< shared_ptr< Card >, cardOrder > spades
The set of Spades owned by the player.
Definition: Player.hpp:136
Biddings
The enum containing all official biddings.
Definition: Biddings.hpp:35
set< shared_ptr< Card >, cardOrder > clubs
The set of Clubs owned by the player.
Definition: Player.hpp:138
int numberOudlers
The number of oudlers the player has among his/her initial cards.
Definition: Player.hpp:142
A structure to automatically fix an insert order into cards' sets.
Definition: Player.hpp:128
vector< shared_ptr< Card > > initialCards
The vector of player's initial cards, from his/her starting hand.
Definition: Player.hpp:141
set< shared_ptr< Card >, cardOrder > diamonds
The set of Diamonds owned by the player.
Definition: Player.hpp:137
string name
The player's name.
Definition: Player.hpp:110
set< Announcements > announced
The set of announcements (for what?).
Definition: Player.hpp:144
vector< shared_ptr< Card > > getInitialCards() const
Inline assessor to the player's initial cards.
Definition: Player.hpp:76
shared_ptr< Card > fool
The pointer toward the Fool, if owned by the player.
Definition: Player.hpp:140
int getNumberOudlers() const
Inline assessor to the number of oudlers the player has with his/her initial hand.
Definition: Player.hpp:79
Player is an abstract class presenting a common interface for AI and Human players.
Definition: Player.hpp:36