-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWinDrawPacket.h
90 lines (74 loc) · 3.26 KB
/
WinDrawPacket.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
/********************************************************************************************
*********************************************************************************************
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 <string>
#include <map>
#include "SoundEngine.h"
#include "ExceptionClass.h"
#include "ErrorTypes.h"
typedef std::map<const std::string, int> ConstList;
class WinDrawPacket
{
public:
WinDrawPacket(const ConstList &cList) throw();
//This used to create the packet that will get sent from the board object to the game object
void CreatePacket(const int gameOutcome, const int winningPiece, const int winLocation, const int winDiagonalLocation, const int winRowLocation, const int winColumnLocation);
//----Const notes----
//Adding const before a function makes the compiler catch assignment errors in things like if statements
//Adding const after the function is basically guaranteeing the compiler that it is a inspector function and not a mutator function
//Get variables
const int GetGameState() const;
const int GetPlayerPiece() const;
const int GetWinType() const;
const int GetDiagType() const;
const int GetRow() const;
const int GetColumn() const;
//----Constants List Variables----//
private:
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;
//Constants for sound
static const std::string fatalErrorSound;
//Local Class Constants
private:
//Local Error String -- Unique to the WinDrawPacket object
static const std::string packetUnreadable;
//Container Variables
private:
ConstList constantsList;
ErrorTypes err;
//Regular variables
private:
int gameState_;
int playerPiece_;
int winType_;
int diagonalType_;
int rowAcross_;
int columnDown_;
bool packetCreated_; //This makes the packet unreadable until CreatePacket has been run
//Private Functions
private:
int GetConstantFromList(std::string request) const;
};