only invalidate undoDrawList up to moved card (#4280)

This commit is contained in:
ebbit1q 2021-03-13 20:41:09 +01:00 committed by GitHub
parent 06bfc0291a
commit 1811f7305e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -426,11 +426,13 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges,
int position = startzone->removeCard(card); int position = startzone->removeCard(card);
// "Undo draw" should only remain valid if the just-drawn card stays within the user's hand (e.g., they only // "Undo draw" should only remain valid if the just-drawn card stays within the user's hand (e.g., they only
// reorder their hand). If a just-drawn card leaves the hand then clear lastDrawList to invalidate "undo draw." // reorder their hand). If a just-drawn card leaves the hand then remove cards before it from the list
// (Ignore the case where the card is currently being un-drawn.) // (Ignore the case where the card is currently being un-drawn.)
if (startzone->getName() == "hand" && targetzone->getName() != "hand" && lastDrawList.contains(card->getId()) && if (startzone->getName() == "hand" && targetzone->getName() != "hand" && !undoingDraw) {
!undoingDraw) { int index = lastDrawList.lastIndexOf(card->getId());
lastDrawList.clear(); if (index != -1) {
lastDrawList.erase(lastDrawList.begin(), lastDrawList.begin() + index);
}
} }
// Attachment relationships can be retained when moving a card onto the opponent's table // Attachment relationships can be retained when moving a card onto the opponent's table