mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 00:54:53 -07:00
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:
parent
aa85a39d6a
commit
3a62dfb3dc
9 changed files with 360 additions and 161 deletions
|
|
@ -54,7 +54,7 @@ MessageLogWidget::getFromStr(CardZoneLogic *zone, QString cardName, int position
|
|||
fromStr = tr(" from the top of their library");
|
||||
}
|
||||
}
|
||||
} else if (position >= zone->getCards().size() - 1) {
|
||||
} else if (position == zone->getCards().size()) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (ownerChange) {
|
||||
cardName = tr("the bottom card of %1's library").arg(zone->getPlayer()->getPlayerInfo()->getName());
|
||||
|
|
|
|||
|
|
@ -664,6 +664,7 @@ void PlayerActions::moveBottomCardsTo(const QString &targetZone, const QString &
|
|||
cmd.set_target_zone(targetZone.toStdString());
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
cmd.set_is_from_bottom(true);
|
||||
|
||||
for (int i = maxCards - number; i < maxCards; ++i) {
|
||||
auto card = cmd.mutable_cards_to_move()->add_card();
|
||||
|
|
@ -785,6 +786,7 @@ void PlayerActions::actDrawBottomCards()
|
|||
cmd.set_target_zone(ZoneNames::HAND);
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
cmd.set_is_from_bottom(true);
|
||||
|
||||
for (int i = maxCards - number; i < maxCards; ++i) {
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue