Fixed error in asmodeus.py due to stupidity
[progcomp2012.git] / manager / human_controller.cpp
1 #include "human_controller.h"
2
3 #include "game.h"
4
5 #include <iostream> //Really I can't be bothered with fscanf any more
6
7 using namespace std;
8
9 MovementResult Human_Controller::QuerySetup(const char * opponentName, string setup[])
10 {
11         
12         static bool shownMessage = false;
13         if (!shownMessage)
14         {
15                 if (graphicsEnabled)
16                         fprintf(stderr, "GUI not yet supported! Please use CLI\n");
17                 fprintf(stdout,"Enter %d x %d Setup grid\n", Game::theGame->theBoard.Width(), 4);
18                 fprintf(stdout,"Please enter one line at a time, using the following allowed characters:\n");
19                 for (Piece::Type rank = Piece::FLAG; rank <= Piece::BOMB; rank = Piece::Type((int)(rank) + 1))
20                 {
21                         fprintf(stdout,"%c x %d\n", Piece::tokens[(int)rank], Piece::maxUnits[(int)rank]);
22                 }
23                 fprintf(stdout, "You must place at least the Flag (%c). Use '%c' for empty squares.\n", Piece::tokens[(int)Piece::FLAG], Piece::tokens[(int)Piece::NOTHING]);
24                 fprintf(stdout, "NOTE: Player RED occupies the top four rows, and BLUE occupies the bottom four rows.\n");
25                 
26                 shownMessage = true;
27         }
28                 
29         
30
31         for (int y = 0; y < 4; ++y)
32                 cin >> setup[y];
33         assert(cin.get() == '\n');
34         
35         return MovementResult::OK;
36 }
37
38 MovementResult Human_Controller::QueryMove(string & buffer)
39 {
40         static bool shownMessage = false;
41         if (!shownMessage)
42         {
43                 if (graphicsEnabled)
44                         fprintf(stderr, "GUI not yet supported! Please use the CLI\n");
45                 fprintf(stdout, "Please enter your move in the format:\n X Y DIRECTION [MULTIPLIER=1]\n");
46                 fprintf(stdout, "Where X and Y indicate the coordinates of the piece to move;\n DIRECTION is one of UP, DOWN, LEFT or RIGHT\n and MULTIPLIER is optional (and only valid for scouts (%c))\n", Piece::tokens[(int)(Piece::SCOUT)]);
47                 shownMessage = true;
48         }
49
50         
51
52
53         buffer.clear();
54         for (char in = fgetc(stdin); in != '\n'; in = fgetc(stdin))
55         {
56                 buffer += in;
57         }
58         
59         
60
61         return MovementResult::OK;
62         
63 }

UCC git Repository :: git.ucc.asn.au