-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
109 lines (94 loc) · 3.78 KB
/
Game.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/********************************************************************************************
*********************************************************************************************
Aaron's Tic-Tac-Toe Clone
A 2 player verison of Tic-Tac-Toe game that's played on a console screen.
Copyright (C) 2012 Aaron Gagern
This file is part of Aaron's Tic-Tac-Toe Clone.
Aaron's Tic-Tac-Toe Clone is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Aaron's Tic-Tac-Toe Clone is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Aaron's Tic-Tac-Toe Clone. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************************
********************************************************************************************/
#pragma once
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <conio.h>
#include <string>
#include <memory>
#include <map>
#include <array>
#include <Windows.h>
#include "Board.h"
#include "Player.h"
#include "WinDrawPacket.h"
#include "SoundEngine.h"
#include "ExceptionClass.h"
#include "ErrorTypes.h"
typedef std::unique_ptr<WinDrawPacket> WDPacketPtr;
typedef std::map<const std::string, int> ConstList;
class Game
{
public:
Game() throw();
void StartGame();
bool GameLoop(); //All the different states that the game could be in are listed as
bool EndGame(); //functions here. These are called as is necessary through the game loop
void ResetGame(); //in the main.
void DisplayFinalStats();
void DisplayLastRoundStats();
//----Message Constants----
private:
//Win/Draw Messages
static const std::string gameDrawMessage, playerOneWinMessage, playerTwoWinMessage;
//Other Messages
static const std::string anyKey;
//----Constants Strings----
private:
//These are used while creating the constantsList
static const std::string noWinDrawState, winState, drawState;
static const std::string acrossWinType, downWinType, diagonalWinType, diagonalLeftSubType, diagonalRightSubType;
static const std::string noPlayerPiece, oPlayerPiece, xPlayerPiece;
static const std::string columnOne, columnTwo, columnThree, columnFour, columnFive;
static const std::string rowOne, rowTwo, rowThree, rowFour, rowFive;
static const std::string nullConstant;
static const std::string fatalError;
//Used in accessing the sounds
static const std::string playerOneWinSound, playerTwoWinSound, gameOverSound, pieceClickSound, badMoveErrorSound, fatalErrorSound, clickSound, endOfGameSound, minorErrorSound;
//Object Variables
private:
Player playerOne_, playerTwo_;
Board board_;
HANDLE hConsole_;
HWND hWnd_;
//Container Variables
private:
ConstList constantsList;
ErrorTypes err;
//Regular Variables
private:
bool firstPlay_;
int roundsPlayed_; //Keeps track of total number of games played
int boundsLimit_;
int gameDraws_; //Used to keep track of how many times all of the rounds played closed with a draw
int playOrder_; //Dictates which player goes first
int turnCounter_; //This gets incremented by 1 everytime both players have taken their turns. Resets after each new game...
//Private Functions
private:
bool GetPlayerMove(int order);
bool CheckGameState(WDPacketPtr packet);
int GetConstantFromList(std::string request) const;
void DecidePlayOrder();
void DisplayGameInstructions();
void DisplayNotices();
void DisplayNoticeFile(char noticeType);
void SetGameFullscreen();
void SetGameWindowed();
};