usedUnits[(int)(type)]++;
if (usedUnits[type] > Piece::maxUnits[(int)type])
{
- fprintf(stderr, "Too many units of type %c\n", Piece::tokens[(int)(type)]);
+ //fprintf(stderr, "Too many units of type %c\n", Piece::tokens[(int)(type)]);
return MovementResult::BAD_RESPONSE;
}
Game::theGame->theBoard.AddPiece(x, yStart+y, type, colour);
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);
}
else
{
- fprintf(stderr, "BAD_RESPONSE \"%s\"\n", buffer.c_str());
+ //fprintf(stderr, "BAD_RESPONSE \"%s\"\n", buffer.c_str());
return MovementResult::BAD_RESPONSE; //Player gave bogus direction - it will lose by default.
}
}
- 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;
}