-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGamestate.h
93 lines (69 loc) · 1.91 KB
/
Gamestate.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//Gamestate.h
#ifndef _GAMESTATE_H_
#define _GAMESTATE_H_
#include<vector>
#include<iostream>
#include<fstream>
#include<iostream>
#include "Card.h"
#include "Deck.h"
#include "hand.h"
class Gamestate
{
//State Variables
protected:
//self explanatory
int playTo = 5;
int score[2];
int overall_score[2];
//makes code easier to read
int turn;
//Deck class
Deck deck;
//Essentially the deck
Card * cards[52];
//Pointers to the hand class
Hand * hands[4];
public:
//Default Constructor
Gamestate();
//Constructor (if needed)
//Entire round
int tricksPlayed = 0;
Card * allCardsPlayed[52];
int allWhoPlayed[52];
void set_allCardPlayed(int i, Card* c){allCardsPlayed[i]=c;}
void set_allWhoPlayed(int i, int v){allWhoPlayed[i]=v;}
//This trick (renamed slightly for convenience)
int numTurns = 0;
Card * cards_played[4];
int who_played[4];
void set_cards_played(int i, Card* c){cards_played[i] = c;}
void set_who_played(int i, int v){who_played[i] = v;}
//Needs to record the score, and the hands
void save_game(int);
//Reads the save_game file and sets up the game as such
void load_game(int);
//Deals out a shuffled deck into four hands (helper)
void deal();
//Returns the current turn.
int getTurn(){ return turn; }
//Increments the turn, or if it is == 3, reset it.
void nextTurn();
//Finds the winner of the trick and adds score
void chkWinner();
//Finds the winner of the whole hand, and resets the game, if applicable.
void chkWinnerH();
//Empties all hands
void emptyHands();
//sets up a new round
void newRound();
//Is this play a legal move?
bool isLegal(Card * c,int s, int h);
//return a requested card in a requested hand
//0 = user, 1 = ai1, etc; <- for int h
Hand * get_hand(int h){return hands[h];}
Card * get_card(int h, int c){return hands[h]->getCard(c);}
int get_handLen(int h){return hands[h]->getLen();}
};
#endif //_GAMESTATE_H_