From 79e284ba9bd7ed00bf368e7675e6c50c6be3b3ed Mon Sep 17 00:00:00 2001 From: RickyRister Date: Fri, 3 Jan 2025 18:51:30 -0800 Subject: [PATCH] wip --- cockatrice/src/game/zones/card_zone.cpp | 4 ++-- cockatrice/src/game/zones/view_zone.cpp | 10 ++++++++-- cockatrice/src/game/zones/view_zone.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/cockatrice/src/game/zones/card_zone.cpp b/cockatrice/src/game/zones/card_zone.cpp index 7c5ef621f..4c3fd9db5 100644 --- a/cockatrice/src/game/zones/card_zone.cpp +++ b/cockatrice/src/game/zones/card_zone.cpp @@ -200,12 +200,12 @@ CardItem *CardZone::takeCard(int position, int cardId, bool /*canResize*/) if (position >= cards.size()) return nullptr; - CardItem *c = cards.takeAt(position); - for (auto *view : views) { view->removeCard(position); } + CardItem *c = cards.takeAt(position); + c->setId(cardId); reorganizeCards(); diff --git a/cockatrice/src/game/zones/view_zone.cpp b/cockatrice/src/game/zones/view_zone.cpp index 8b4050b8f..f64dcf23a 100644 --- a/cockatrice/src/game/zones/view_zone.cpp +++ b/cockatrice/src/game/zones/view_zone.cpp @@ -33,7 +33,7 @@ ZoneViewZone::ZoneViewZone(Player *_p, : SelectZone(_p, _origZone->getName(), false, false, true, parent, true), bRect(QRectF()), minRows(0), numberCards(_numberCards), origZone(_origZone), revealZone(_revealZone), writeableRevealZone(_writeableRevealZone), groupBy(CardList::NoSort), sortBy(CardList::NoSort), - isReversed(_isReversed), firstCardId(-1) + isReversed(_isReversed), firstCardId(-1), previousOrigSize(-1) { if (!(revealZone && !writeableRevealZone)) { origZone->getViews().append(this); @@ -107,6 +107,7 @@ void ZoneViewZone::zoneDumpReceived(const Response &r) firstCardId = cardInfo.id(); } } + previousOrigSize = origZone->getCards().size(); reorganizeCards(); emit cardCountChanged(); } @@ -126,6 +127,11 @@ void ZoneViewZone::reorganizeCards() if (cards.first()->getId() != firstCardId) { startId -= 1; } + if (origZone->getCards().size() != previousOrigSize) { + qDebug() << "TRACK origZoneSize changed" << "orig" << origZone->getCards().size() << "prev" + << previousOrigSize; + previousOrigSize = origZone->getCards().size(); + } } for (int i = 0; i < cardCount; ++i) { @@ -231,7 +237,7 @@ ZoneViewZone::GridSize ZoneViewZone::positionCardsForDisplay(CardList &cards, Ca if (cols < 2) cols = 2; - qDebug() << "reorganizeCards: rows=" << rows << "cols=" << cols; + qDebug() << "reorganizeCards: rows=" << rows << "cols=" << cols; for (int i = 0; i < cardCount; i++) { CardItem *c = cards.at(i); diff --git a/cockatrice/src/game/zones/view_zone.h b/cockatrice/src/game/zones/view_zone.h index db875958e..48808a9ec 100644 --- a/cockatrice/src/game/zones/view_zone.h +++ b/cockatrice/src/game/zones/view_zone.h @@ -36,6 +36,7 @@ private: bool pileView; bool isReversed; int firstCardId; + int previousOrigSize; struct GridSize {