[Game] Allow dropping cards at bottom of stack zone (#7230)
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions

This commit is contained in:
RickyRister 2026-09-01 03:11:31 -07:00 committed by GitHub
parent 45c7ff6f87
commit 425b16ea0d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 7 deletions

View file

@ -41,7 +41,8 @@ void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
} }
} }
} else { } else {
x = calcDropIndexFromY(dropPoint.y()); bool sameZone = startZone == getLogic();
x = calcDropIndexFromY(dropPoint.y(), !sameZone);
} }
Command_MoveCard cmd; Command_MoveCard cmd;

View file

@ -83,7 +83,7 @@ SelectZone::StackLayoutParams SelectZone::buildStackParams(qreal minOffset) cons
return {cardCount, boundingRect().height(), cardHeight, offset, minOffset}; return {cardCount, boundingRect().height(), cardHeight, offset, minOffset};
} }
int SelectZone::calcDropIndexFromY(qreal dropY, qreal minOffset) const int SelectZone::calcDropIndexFromY(qreal dropY, bool allowCountExpand, qreal minOffset) const
{ {
const auto &cards = getLogic()->getCards(); const auto &cards = getLogic()->getCards();
if (cards.isEmpty()) { if (cards.isEmpty()) {
@ -94,7 +94,8 @@ int SelectZone::calcDropIndexFromY(qreal dropY, qreal minOffset) const
if (effectiveOffset <= 0.0) { if (effectiveOffset <= 0.0) {
return 0; return 0;
} }
return qBound(0, qRound((dropY - start) / effectiveOffset), params.cardCount - 1); int max = allowCountExpand ? params.cardCount : params.cardCount - 1;
return qBound(0, qRound((dropY - start) / effectiveOffset), max);
} }
void SelectZone::restoreStaleEscapedCards() void SelectZone::restoreStaleEscapedCards()

View file

@ -104,8 +104,12 @@ protected:
/** /**
* @brief Computes the card index at a given y-coordinate within the zone's vertical layout. * @brief Computes the card index at a given y-coordinate within the zone's vertical layout.
* Returns 0 if the zone has no cards or the offset is zero. * Returns 0 if the zone has no cards or the offset is zero.
*
* @param dropY The y-coordinate that the card was dropped at
* @param allowCountExpand If false, clamps the index at the number of cards minus 1
* @param minOffset Minimum offset to preserve
*/ */
int calcDropIndexFromY(qreal dropY, qreal minOffset = 0.0) const; int calcDropIndexFromY(qreal dropY, bool allowCountExpand, qreal minOffset = 0.0) const;
/** /**
* @brief Positions cards vertically with alternating left/right x-offsets. * @brief Positions cards vertically with alternating left/right x-offsets.

View file

@ -57,10 +57,11 @@ void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems,
return; return;
} }
const auto &cards = getLogic()->getCards(); bool sameZone = startZone == getLogic();
int index = calcDropIndexFromY(dropPoint.y(), MIN_CARD_VISIBLE); int index = calcDropIndexFromY(dropPoint.y(), !sameZone, MIN_CARD_VISIBLE);
if (startZone == getLogic()) { if (sameZone) {
// Same-zone no-op: don't move a card onto itself // Same-zone no-op: don't move a card onto itself
const auto &cards = getLogic()->getCards();
if (!cards.isEmpty() && cards.at(index)->getId() == dragItems.at(0)->getId()) { if (!cards.isEmpty() && cards.at(index)->getId() == dragItems.at(0)->getId()) {
return; return;
} }