Smile I think I fried my brain with what little I have come up with, lol I need some ideas as to finishing the rest and if the code I currently have written out will work?
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <fstream>
#include <string>
#include "dice.h"
using namespace std;
const int MAX_BOARD = 40; //Maximum possible number of square on board
const int MAX_CARD = 25; //Maximum possible number of cards in deck
enum squareKind {S_NOP, S_GO, S_ISJAIL, S_TOJAIL, S_PROP, //Specifies square types
S_UTIL, S_RR, S_CHANCE, S_CHEST};
enum cardKind {C_NOP, C_ABS, C_REL, C_UTIL, C_RR, C_JAIL};//Specifies card types
enum gameMode {GAME, SIM}; //Specifies program modes
enum deckType {CHANCE, CHEST}; //Specifies card decks
struct square_t { //Describes information on each square
enum squareKind sKind;
string sLabel;
};
struct card_t { //Describes possible information on each card
int cNum; //cNum only described in ABS or REL cards
enum cardKind cKind;
string cLabel;
};
struct board_t { //Describes information related to entire board.
int locateGo; //Position of the Go square.
int locateJail; //Position of the Jail square.
int boardSize; //Number of squares on the board.
int totalChance; //Number of Chance cards in the Chance deck.
int totalChest; //Number of Chest cards in Community Chest deck
struct square_t squares[MAX_BOARD]; //Array contains info on each square
struct card_t chance[MAX_CARD]; //Array contains info on each Chance card
struct card_t chest[MAX_CARD]; //Array contains info on each Chest card
};
struct player_t { //Describes statistics related to player movement
bool inJail; //True if player in Jail; false otherwise
int lastBrdPosition; //Player's position on board
int lastChanceDrawn; //Chance card to be picked up next
int lastChestDrawn; //Chest card to be picked up next
int countJailTn; //Number of consecutive turns spent in Jail
int countDouble; //Number of consecutive doubles rolled
int countFreq[MAX_BOARD]; //Array contains frequency of each square (Sim Mode)
};
//Functions described completely at function definitions
// (.. come up with this on your own ..)
int main(int argc, char * argv[]) {
int menuChoice; //User's input; chooses between Game and Sim
enum gameMode modeChoice; //User's mode choice converted to enum gameMode
board_t gameBoard; //Board info
player_t playerStats; //Player's statistics
//Load board data
gameBoard = getBoard(gameBoard, argv);
//Initialize player statistics relevant to both Game and Sim modes
playerStats.inJail = false;
playerStats.lastBrdPosition = gameBoard.locateGo;
playerStats.lastChanceDrawn = 0;
playerStats.lastChestDrawn = 0;
playerStats.countJailTn = 0;
playerStats.countDouble = 0;
//Print menu
cout << "MENU" << endl;
cout << "----" << endl;
cout << "1. Game Mode" << endl;
cout << "2. Simulation Mode" << endl;
try {
do {
//Input menuChoice
cout << endl << "Enter Menu Choice: ";
cin >> menuChoice;
if(cin.eof())
throw menuChoice;
if (menuChoice != 1 && menuChoice != 2)
cout << "Invalid Choice." << endl;
else {
//Convert menuChoice to enum gameMode
if (menuChoice == 1)
modeChoice = GAME;
else if (menuChoice == 2)
modeChoice = SIM;
}
} while (menuChoice != 1 && menuChoice != 2);
cout << "Let the game begin." << endl;
if (modeChoice == GAME) //Play Game
doGame(gameBoard, playerStats, modeChoice);
else if (modeChoice == SIM) //Perform Simulation
doSim(gameBoard, playerStats, modeChoice);
}
catch(...) {
//EOF encountered somewhere in program
cout << "\nEnd of file reached." << endl;
}
getch();
return 0;
}
// (.. the rest of the functions ?..)
From this point on im lost or my brain is just fried I dont even know if what I have will work?

New Topic/Question
Reply




MultiQuote





|