Mari's Tarot
 All Classes Files Functions Variables Enumerations Enumerator Friends
Card.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 <iostream>
25 #include <memory>
26 
27 #include "Suits.hpp"
28 
29 using namespace std;
30 
32 class Card
33 {
35  friend ostream& operator<< ( ostream&, const Card& );
36 
37 public:
39 
45  Card( const Suits suit, const int value, const double points, const bool oudler );
46 
48  int computeIndex() const;
49 
51  inline double getPoints () const { return points; }
52 
54  inline Suits getSuit () const { return suit; }
55 
57  inline int getValue () const { return value; }
58 
60 
66  inline bool isComparable( const Card& card ) const
67  {
68  return this->suit == card.suit || this->suit == 4 || card.suit == 4;
69  }
70 
72  inline bool isFaceCard () const { return value > 10; }
73 
75  inline bool isFool () const { return suit == Suits::fool; }
76 
78  inline bool isOudler () const { return oudler; }
79 
81  inline bool isTrump () const { return suit == Suits::trump; }
82 
84 
89  bool operator>( const Card& card ) const;
90 
92 
97  bool operator<( const Card& card ) const;
98 
100 
104  bool operator==( const Card& card ) const;
105 
106 private:
107  Suits suit;
108  int value;
109  double points;
110  bool oudler;
111 };
bool isComparable(const Card &card) const
A function to decide if two cards are comparable.
Definition: Card.hpp:66
bool isFaceCard() const
Inline function returning true iif the card is a face card.
Definition: Card.hpp:72
Definition: Suits.hpp:32
bool isFool() const
Inline function returning true iif the card is the Fool.
Definition: Card.hpp:75
Suits
The enum containing all suits, plus the Fool as a special suit.
Definition: Suits.hpp:25
double getPoints() const
Inline assessor to get the card's points.
Definition: Card.hpp:51
Card is the class compiling all useful information on cards: points, suit, value...
Definition: Card.hpp:32
ostream & operator<<(ostream &os, const Card &card)
Definition: Card.cpp:74
int getValue() const
Inline assessor to get the card's value.
Definition: Card.hpp:57
bool isTrump() const
Inline function returning true iif the card is a trump.
Definition: Card.hpp:81
Definition: Suits.hpp:31
bool isOudler() const
Inline function returning true iif the card is an oudler.
Definition: Card.hpp:78
Suits getSuit() const
Inline assessor to get the card's suit.
Definition: Card.hpp:54