forked from trolley813/OpenFool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.h
72 lines (64 loc) · 1.84 KB
/
table.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
#ifndef TABLE_H
#define TABLE_H
#include <QObject>
#include <QGraphicsScene>
#include <QGraphicsSimpleTextItem>
#include <QMap>
#include <QPushButton>
#include <QSettings>
#include "carddeck.h"
#include "playerbubbleitem.h"
class Player;
enum SortingMode : unsigned char;
class Table : public QGraphicsScene
{
Q_OBJECT
public:
Table(QSettings *settings, QObject *parent = nullptr);
void newGame();
void endTurn(int playerIdx);
int cardsRemaining() { return _deck->cards().length(); }
QList<Player *> players() const;
Suit trumpSuit() const;
Player *currentAttacker();
Player *currentDefender();
bool beats(Card playerCard, Card tableCard);
Player *currentThrower();
QList<Card> attackCards() const;
QList<Card> defenseCards() const;
bool isGameOver();
void updateNameLabels();
void sortPlayerCards(int playerIdx);
signals:
void setGameStatusText(QString);
public slots:
void onCardClick(Card c);
void onPlayerDone(int playerIdx);
void onPlayerThrows(int playerIdx, Card c);
void onPlayerBeats(int playerIdx, Card c);
void onPlayerTakes(int playerIdx);
void onQuitRequest();
protected:
CardDeck *_deck;
QMap<Card, CardItem *> _cardItems;
Suit _trumpSuit;
QList<Player *> _players;
QList<QGraphicsSimpleTextItem *> _nameItems;
QGraphicsSimpleTextItem *_deckCardsItem;
void drawCardsFromDeck(int playerIdx, int cardCount);
int _currentAttacker;
int _currentThrower;
bool _isPlayerTaking;
int _playersSaidDone;
QList<bool> _outOfPlay;
QList<Card> _discardPile;
QList<Card> _attackCards;
QList<Card> _defenseCards;
QPushButton *_actionButton;
QList<QString> _playerNames;
QList<PlayerBubbleItem *> _playerBubbles;
SortingMode _sortingMode;
protected slots:
void _updateDeckCardsLabel();
};
#endif // TABLE_H