Fix #6659: Correct logging for bottom-of-library card moves

Cause:
- This issue happens due to logic of moving the card from the top of the
  deck being reused when moving from the bottom of the deck, in a way
  that makes it impossible to check if the card came from the bottom.

Resolution:
- Updated the logging logic in the client for card moves.
- Added a gRPC parameter ('is_from_bottom') for card moves.
- Updates the server logic to reverse the order of the card move if the
'is_from_bottom' parameter is true.
- Added a test to show the expected behaviour of the fix.

NOTE: While the changes in this patch seem big, this is due to changing
the loop in the moveCard function to a helper function, in order to make
the bug fix change. The only change to the loop was to pass a
variable attribution to the moveCard function because it was redundant
to be in the loop.
This commit is contained in:
Vasco Guerreiro Vintém Morais 2026-03-30 10:25:52 +01:00
parent aa85a39d6a
commit 3a62dfb3dc
9 changed files with 360 additions and 161 deletions

View file

@ -0,0 +1,42 @@
#include "server.h"
#include "server_database_interface.h"
class MockDatabaseInterface : public Server_DatabaseInterface
{
public:
AuthenticationResult checkUserPassword(Server_ProtocolHandler *,
const QString &,
const QString &,
const QString &,
QString &,
int &,
bool) override
{
return NotLoggedIn;
}
ServerInfo_User getUserData(const QString &, bool) override
{
return ServerInfo_User();
}
int getNextGameId() override
{
return 1;
}
int getNextReplayId() override
{
return 1;
}
int getActiveUserCount(QString) override
{
return 1;
}
};
class FakeServer : public Server
{
public:
FakeServer()
{
setDatabaseInterface(new MockDatabaseInterface());
}
};