fixed bug with userinfo compare
This commit is contained in:
parent
36f27d8235
commit
08e105603c
2
TAPI
2
TAPI
|
@ -1 +1 @@
|
|||
Subproject commit 1d99dc3e99afb192299e85804a2e6b194c480bf6
|
||||
Subproject commit fdd1ab1a986473ec5fe97189e17e2f2ca012dc7a
|
|
@ -24,9 +24,7 @@ public:
|
|||
|
||||
bool operator==(const UserInfo& other) const;
|
||||
|
||||
constexpr bool operator!=(const UserInfo& other) const {
|
||||
return other.id != id && other.username != username;
|
||||
}
|
||||
bool operator!=(const UserInfo& other) const;
|
||||
};
|
||||
|
||||
Game();
|
||||
|
|
|
@ -81,6 +81,8 @@ bool Bot::handleCallback(TelegramAPI::Manager* api, TelegramAPI::CallbackQuery&
|
|||
delret;
|
||||
}
|
||||
|
||||
#undef delret
|
||||
|
||||
void Bot::stop() {
|
||||
|
||||
}
|
||||
|
|
22
src/game.cpp
22
src/game.cpp
|
@ -14,6 +14,14 @@ bool Game::UserInfo::operator==(const UserInfo& other) const {
|
|||
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() {
|
||||
for(uint_fast8_t i = 0; i < SIZE * SIZE; ++i) {
|
||||
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) {
|
||||
if(!isInField(x, y)) return false;
|
||||
if(!ready()) return false;
|
||||
if(!isInField(x, y)) {
|
||||
return false;
|
||||
}
|
||||
if(!ready()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
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 << "playerB: " << playerB.id << " n: " << playerB.name << " u: " << playerB.username << " e: " << (player == playerB);
|
||||
// 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 << "playerB: " << playerB.id << " n: " << playerB.name << " u: " << playerB.username << " e: " << (player == playerB);
|
||||
|
||||
|
||||
// playerA
|
||||
|
|
Loading…
Reference in New Issue