- #ifdef GRAPHICS
- Board::theBoard.Draw();
- if (CheckForQuitWhilstWaiting(0.2))
- {
- red->SendMessage("QUIT");
- blue->SendMessage("QUIT");
- exit(EXIT_SUCCESS);
+ case 'o':
+ if (argc - ii <= 1)
+ {
+ fprintf(stderr, "Expected filename or \"stdout\" after -o switch!\n");
+ exit(EXIT_FAILURE);
+ }
+ if (log != NULL)
+ {
+ fprintf(stderr, "Expected at most ONE -o switch!\n");
+ exit(EXIT_FAILURE);
+ }
+ if (strcmp(argv[ii+1], "stdout") == 0)
+ log = stdout;
+ else
+ log = fopen(argv[ii+1], "w");
+ setbuf(log, NULL);
+
+ ++ii;
+ break;
+
+ case 'r':
+ if (reveal == Piece::BOTH)
+ reveal = Piece::BLUE;
+ else
+ reveal = Piece::NONE;
+ break;
+ case 'b':
+ if (reveal == Piece::BOTH)
+ reveal = Piece::RED;
+ else
+ reveal = Piece::NONE;
+ break;
+ case 'm':
+ if (argc - ii <= 1)
+ {
+ fprintf(stderr, "Expected max_turns value after -m switch!\n");
+ exit(EXIT_FAILURE);
+ }
+ if (strcmp(argv[ii+1], "inf"))
+ maxTurns = -1;
+ else
+ maxTurns = atoi(argv[ii+1]);
+ ++ii;
+ break;
+ case 'f':
+ if (argc - ii <= 1)
+ {
+ fprintf(stderr, "Expected filename after -f switch!\n");
+ exit(EXIT_FAILURE);
+ }
+ if (log != NULL)
+ {
+ fprintf(stderr, "Expected at most ONE -f switch!\n");
+ exit(EXIT_FAILURE);
+ }
+ red = (char*)("file");
+ blue = (char*)("file");
+ inputFile = argv[ii+1];
+ ++ii;
+ break;
+ case 'h':
+ system("clear");
+ system("less manual.txt");
+ exit(EXIT_SUCCESS);
+ break;
+ case '-':
+ if (strcmp(argv[ii]+2, "help") == 0)
+ {
+ system("clear");
+ system("less manual.txt");
+ exit(EXIT_SUCCESS);
+ }
+ else
+ {
+ fprintf(stderr, "Unrecognised switch \"%s\"...\n", argv[ii]);
+ exit(EXIT_FAILURE);
+ }