X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=manager%2Fcontroller.cpp;h=982f0fc94a0a86ee859c861cdfedf2b39d2ba390;hp=b7ab105bb17f22f77a42d53dfd4a5a39b524c15c;hb=17a20de4017ccfadef219d830a28ecccfe6f5106;hpb=b563784f7e8b559fc100e174331c99fc6a1beda8 diff --git a/manager/controller.cpp b/manager/controller.cpp index b7ab105..982f0fc 100644 --- a/manager/controller.cpp +++ b/manager/controller.cpp @@ -80,6 +80,16 @@ MovementResult Controller::MakeMove(string & buffer) if (query != MovementResult::OK) return query; + if (buffer == "NO_MOVE") + { + buffer += " OK"; + return MovementResult::OK; + } + if (buffer == "SURRENDER") + { + buffer += " OK"; + return MovementResult::SURRENDER; + } int x; int y; string direction=""; stringstream s(buffer); @@ -148,9 +158,20 @@ MovementResult Controller::MakeMove(string & buffer) } - if (Game::theGame->allowIllegalMoves && !Board::LegalResult(moveResult)) - return MovementResult::OK; //HACK - Legal results returned! - else - return moveResult; + if (!Board::LegalResult(moveResult)) + { + if (Game::theGame->allowIllegalMoves) + return MovementResult::OK; //HACK - Illegal results returned as legal! (Move not made) + else if (this->HumanController()) //Cut human controllers some slack and let them try again... + { + //Yes, checking type of object is "not the C++ way" + // But sometimes its bloody useful to know!!! + Message("Bad move: \'" + buffer + "\' <- Please try again!"); + buffer = ""; + return this->MakeMove(buffer); + } + } + + return moveResult; }