waiting for players

This commit is contained in:
mrbesen 2022-03-15 20:53:45 +01:00
parent 8a69fdc81f
commit 856b55c8a6
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 7 additions and 0 deletions

View File

@ -144,6 +144,8 @@ std::string Bot::gameToMessage(const Game& g, std::vector<TelegramAPI::MessageEn
} else {
out << "Winner: " << g.getWinner() << std::endl;
}
} else if(!g.ready()) {
out << "Waiting for players";
} else {
out << "nextturn: " << (g.getNextTurn() ? "X" : "O") << std::endl;
}
@ -204,6 +206,11 @@ Game* Bot::messageToGame(const TelegramAPI::Message& msg) const {
g->addPlayer(info);
}
// game not ready, just stop
if(!g->getPlayerB()) {
return g;
}
// read the next turn value
char nextturn = msg.text.at(msg.text.size()-1);
g->setNextTurn(nextturn == 'X');