I am trying to create the game Stratego by using code. Here is what I have now and what I still have to do:
cpp
#include <iostream>
using namespace std;
enum color {red,blue};
const int ROWS=10;
const int COLS=10;
// this is the definition of what a 'piece' is
struct basicPiece{
color team;
int value;
};
void handlePlace(basicPiece *[ROWS][COLS]);
void handleMove(basicPiece *[ROWS][COLS]);
void handleDisplay(basicPiece *[ROWS][COLS]);
int main(){
int i,j;
// the following is the definition of the board
// for the assignment, it must be an array of pointers
basicPiece *board[ROWS][COLS]; //board
bool quittingTime = false;
// this array is used as a temporary place to
// store the first word of the input sequence
// that will be interpreted as a command.
// if all goes well with the input file,
// command will have "p" or "m" or "d" or
// "q" in it. I'm using an array here so as
// not to confuse cin. If I were to use a
// char, surrounding white space
// might or might not be ignored, depending on
// the input file. I am using an array of 256
// elements because, hey, memory is cheap.
char command[256];
for(i=0;i<ROWS;++i)for(j=0;j<COLS;++j)board[i][j]=0;
while(!quittingTime){
handleDisplay(board);
cin >> command;
switch(command[0]){
case 'p': handlePlace(board); break;
case 'm': handleMove(board); break;
case 'd': handleDisplay(board); break;
case 'q': quittingTime = true; break;
default: cout << "huh?" << endl;
}
}
cout << "I'm outta here!" << endl;
return 0;
}
// I'll even throw in a bonus function stub
void handlePlace(basicPiece * board[ROWS][COLS]){
char inputColor[256];
int inputVal, inputRow, inputCol;
// the "p" was gotten from the input in main()
// now, get the rest of the command
cin >> inputColor >> inputVal >> inputRow >> inputCol;
// todo: check for errors in the input values
// todo: check to see if the spot is occupied
// todo: make a new official piece and get the board to point to it
// todo: set the values of the piece correctly
// todo: notify the user of the result
// todo: return to main
return;
}
// todo: write more functions!
*edit: Please use code tags in the future, thanks!

Any help would be greatly appreciated!!
This post has been edited by Martyr2: 6 Sep, 2008 - 08:46 PM