fixed bug with userinfo compare

This commit is contained in:
mrbesen 2022-02-28 12:21:09 +01:00
parent 36f27d8235
commit 08e105603c
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
4 changed files with 21 additions and 9 deletions

2
TAPI

@ -1 +1 @@
Subproject commit 1d99dc3e99afb192299e85804a2e6b194c480bf6 Subproject commit fdd1ab1a986473ec5fe97189e17e2f2ca012dc7a

View File

@ -24,9 +24,7 @@ public:
bool operator==(const UserInfo& other) const; bool operator==(const UserInfo& other) const;
constexpr bool operator!=(const UserInfo& other) const { bool operator!=(const UserInfo& other) const;
return other.id != id && other.username != username;
}
}; };
Game(); Game();

View File

@ -81,6 +81,8 @@ bool Bot::handleCallback(TelegramAPI::Manager* api, TelegramAPI::CallbackQuery&
delret; delret;
} }
#undef delret
void Bot::stop() { void Bot::stop() {
} }

View File

@ -14,6 +14,14 @@ bool Game::UserInfo::operator==(const UserInfo& other) const {
return username == other.username; return username == other.username;
} }
bool Game::UserInfo::operator!=(const UserInfo& other) const {
if(id != 0 && other.id != 0) {
return id != other.id;
}
return other.username != username;
}
Game::Game() { Game::Game() {
for(uint_fast8_t i = 0; i < SIZE * SIZE; ++i) { for(uint_fast8_t i = 0; i < SIZE * SIZE; ++i) {
field[i] = SYM::NONE; field[i] = SYM::NONE;
@ -65,12 +73,16 @@ bool Game::isFull() const {
} }
bool Game::turn(uint_fast8_t x, uint_fast8_t y, const UserInfo& player) { bool Game::turn(uint_fast8_t x, uint_fast8_t y, const UserInfo& player) {
if(!isInField(x, y)) return false; if(!isInField(x, y)) {
if(!ready()) return false; return false;
}
if(!ready()) {
return false;
}
Log::info << "turn player: " << player.id << " n: " << player.name << " u: " << player.username; // Log::info << "turn player: " << player.id << " n: " << player.name << " u: " << player.username;
Log::info << "playerA: " << playerA.id << " n: " << playerA.name << " u: " << playerA.username << " e: " << (player == playerA); // Log::info << "playerA: " << playerA.id << " n: " << playerA.name << " u: " << playerA.username << " e: " << (player == playerA);
Log::info << "playerB: " << playerB.id << " n: " << playerB.name << " u: " << playerB.username << " e: " << (player == playerB); // Log::info << "playerB: " << playerB.id << " n: " << playerB.name << " u: " << playerB.username << " e: " << (player == playerB);
// playerA // playerA