Mari's Tarot
 All Classes Files Functions Variables Enumerations Enumerator Friends
Trick.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 <map>
25 #include <set>
26 #include <memory>
27 
28 #include "Player.hpp"
29 #include "Card.hpp"
30 
31 using namespace std;
32 
34 class Trick
35 {
36 public:
38  Trick();
39 
41  set< shared_ptr<Card> > getAllCards() const;
42 
44 
48  void setCard( const shared_ptr<Player> player, const shared_ptr<Card> card );
49 
51  double getScore() const;
52 
54  inline int getNumberOfCards() const { return trickCards.empty() ? 0 : trickCards.size(); }
55 
57  void showAllCards() const;
58 
60  void clearTrick();
61 
63  inline shared_ptr<Card> getCard ( const shared_ptr<Player> player ) const { return trickCards.at(player); }
64 
66  inline shared_ptr<Card> getWinCard () const { return trickCards.at(leader); }
67 
68  // Inline assessor to get the pointer on the leader.
69  inline shared_ptr<Player> getLeader () const { return leader; }
70 
71  // Inline assessor to get the pointer on the player who played the Fool.
72  inline shared_ptr<Player> getFoolPlayer () const { return foolPlayer; }
73 
74  // Inline assessor to get the pointer on the greatest trump of the current trick.
75  inline shared_ptr<Card> getGreaterTrump () const { return greaterTrump; }
76 
77  // Inline assessor to get the pointer on the greatest trump of the current trick.
78  inline Suits getReferenceSuit() const { return referenceSuit; }
79 
80 private:
81  shared_ptr<Player> leader;
82  shared_ptr<Player> foolPlayer;
83  shared_ptr<Card> greaterTrump;
84  Suits referenceSuit;
85  map< shared_ptr<Player>, shared_ptr<Card> > trickCards;
86 };
int getNumberOfCards() const
Inline function returning the number of cards composing the trick.
Definition: Trick.hpp:54
shared_ptr< Card > getWinCard() const
Inline function returning the card which takes the trick.
Definition: Trick.hpp:66
shared_ptr< Player > getLeader() const
Definition: Trick.hpp:69
Suits
The enum containing all suits, plus the Fool as a special suit.
Definition: Suits.hpp:25
shared_ptr< Card > getCard(const shared_ptr< Player > player) const
Inline assessor to the card played of the given player during the current trick.
Definition: Trick.hpp:63
shared_ptr< Card > getGreaterTrump() const
Definition: Trick.hpp:75
Suits getReferenceSuit() const
Definition: Trick.hpp:78
This class manages the current and previously played tricks.
Definition: Trick.hpp:34
shared_ptr< Player > getFoolPlayer() const
Definition: Trick.hpp:72