works now

This commit is contained in:
RickyRister 2025-01-04 02:25:16 -08:00
parent 0ed883883a
commit a06fc6adb1

View file

@ -278,20 +278,24 @@ void ZoneViewZone::setPileView(int _pileView)
void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/) void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
{ {
// if x is negative set it to add at end if (!isReversed) {
if (x < 0 || x >= cards.size()) { // if x is negative set it to add at end
x = cards.size(); if (x < 0) {
} x = cards.size();
}
if (isReversed) { cards.insert(x, card);
if (x != 0) { } else {
cards.append(card); // map x (which is in origZone indexes) to this viewZone's cardList index
int firstId = cards.isEmpty() ? origZone->getCards().size() : cards.front()->getId();
int insertionIndex = x - firstId;
if (insertionIndex >= 0) {
// card was put into a portion of the deck that's in the view
cards.insert(insertionIndex, card);
} else { } else {
// card was put into a portion of the deck that's not in the view
updateCardIds(ADD_CARD); updateCardIds(ADD_CARD);
return; return;
} }
} else {
cards.insert(x, card);
} }
card->setParentItem(this); card->setParentItem(this);