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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
//GameMaster
#include "p5.h"
#include "phc.h"
#include "gamespace.h"
#include "board5.h"
#include "dice.h"
#include "cell.h"
#include<string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cctype>
#include <vector>
#include <algorithm>
#include "GameMaster.h"
using namespace std;
using namespace GameSpace;
int main()
{
Dice::ReadRollsFromFile();
GameMaster Game;
Game.GameSetup();
Game.PlayGame();
return 0;
}
void GameMaster::GameSetup()
{
cout << endl << "Game Setup Initiating..." << endl;
}
void GameMaster::PlayGame()
{
BoardSetUp();
LoadPlayers();
LoadQueue();
LoadArmament();
}
void GameMaster::BoardSetUp()
{
Board::CreateBoard(GameSpace::NUMROWS , GameSpace::NUMCOLS);
cout << endl << "Setting Up Board...";
}
void GameMaster::LoadPlayers()
{
char type , dir;
string name;
int coordX , coordY , squad = 0;
GameSpace::SquadType squadName;
cout << endl << "Loading Players...";
ifstream inFile;
inFile.open(GameSpace::PLAYERS_FILE.c_str());
while(!inFile.eof()){
inFile >> type;
if(type == 'q' || type == 'Q')
squad++;
if(!inFile)
break;
while(type!='q' && type!='Q'){
inFile>> name >> coordX >> coordY >> dir;
MakeSquad( type , name , coordX , coordY , dir , squad );
inFile >> type;
if(type == 'q' || type == 'Q')
squad++;
}
}
inFile.close();
}
void GameMaster::LoadQueue()
{
cout << endl << "Loading Queue...";
}
void GameMaster::LoadArmament()
{
cout << endl << "Loading Armanent...";
}
void GameMaster::GameCleanUp()
{
}
void GameMaster::PreTurn()
{
}
void GameMaster::BugTurn()
{
}
void GameMaster::HumanTurn()
{
}
void GameMaster::PostTurn()
{
}
void GameMaster::GameOver()
{
}
GameSpace::SquadType GameMaster::Squad(int x)
{
GameSpace::SquadType Squad;
switch(x)
{
case 0 : return ALPHA;
break;
case 1 : return BRAVO;
break;
case 2 : return CHARLIE;
break;
case 3 : return DELTA;
break;
case 4 : return ECHO;
break;
}
}
void GameMaster::MakeSquad(char type, string name, int coordX, int coordY, char dir, int squad)
{
//This is where i'm getting the segmentation fault.
MapOfSquads.insert(make_pair(name , Squad(squad));
}
Player::PlayerType GameMaster::SwitchType(char type)
{
switch(type)
{
case 'w' : return Player::WARRIOR;
break;
case 'e' : return Player::EXPLORER;
break;
case 's' : return Player::SPIDER;
break;
case 'h' : return Player::HORNET;
break;
case 'k' : return Player::KILLERANT;
break;
default : return Player::EXPLORER;
}
}
|