00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <time.h>
00010 #include <iostream.h>
00011 #include <fstream.h>
00012 #include <stdio.h>
00013 #include <string.h>
00014 #include <stdlib.h>
00015 #include "AFreecellGameBoard.h"
00016
00017 int main(int argc, char **argv)
00018 {
00019 int Seed = time(NULL);
00020 char GameName[GAME_NAME_LENGTH];
00021 char* GameBoardString;
00022 GameName[0] = NULL;
00023 ofstream Write;
00024 bool Display10AsT = false;
00025
00026
00027 for (int arg = 1;arg<argc;arg++)
00028 {
00029 if (!strcmp(argv[arg], "-n"))
00030 {
00031 arg++;
00032 if (arg != argc)
00033 Seed = atoi(argv[arg]);
00034 }
00035 else if (!strcmp(argv[arg], "-t"))
00036 {
00037 Display10AsT = true;
00038 }
00039 else if (!strcmp(argv[arg], "-g"))
00040 {
00041 arg++;
00042 if (arg != argc)
00043 strcpy(GameName, argv[arg]);
00044 }
00045 else
00046 {
00047 break;
00048 }
00049 }
00050
00051 AFreecellGameBoard* GameBoard = CreateAFreecellGameBoard(GameName, Display10AsT);
00052 if (GameBoard == NULL)
00053 {
00054 cerr << "Invalid game name!" << endl;
00055 exit(-1);
00056 }
00057
00058 GameBoardString = new char[GameBoard->GetGameBoardSize()+1];
00059 GameBoardString[0] = NULL;
00060 GameBoard->Shuffle(Seed);
00061 GameBoard->Deal(GameBoardString);
00062
00063 if (arg == argc)
00064 {
00065
00066 cout << GameBoardString << endl;
00067 }
00068 else
00069 {
00070
00071 Write.open(argv[arg]);
00072 Write << GameBoardString << endl;
00073 Write.close();
00074 }
00075
00076 return 0;
00077 }