Add more sort options to hand sort (#6279)

* Add more sort options to hand sort


Took 14 minutes

* Move defaultOptions up a level

* Directly pass sort order as param

* fix include

* revert

* fallback expandSortOption
This commit is contained in:
RickyRister 2025-11-08 14:03:44 -08:00 committed by GitHub
parent 6bc2293292
commit 757e9f3415
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 74 additions and 14 deletions

View file

@ -139,9 +139,36 @@ void PlayerActions::actViewHand()
player->getGameScene()->toggleZoneView(player, "hand", -1);
}
/**
* @brief The sortHand actions only pass along a single SortOption in its data.
* This method fills out the rest of the sort priority list given that option.
* @param option The single sort option
* @return The sort priority list
*/
static QList<CardList::SortOption> expandSortOption(CardList::SortOption option)
{
switch (option) {
case CardList::SortByName:
return {};
case CardList::SortByMainType:
return {CardList::SortByMainType, CardList::SortByManaValue};
case CardList::SortByManaValue:
return {CardList::SortByManaValue, CardList::SortByColors};
default:
return {option};
}
}
void PlayerActions::actSortHand()
{
player->getGraphicsItem()->getHandZoneGraphicsItem()->sortHand();
auto *action = qobject_cast<QAction *>(sender());
CardList::SortOption option = static_cast<CardList::SortOption>(action->data().toInt());
QList<CardList::SortOption> sortOptions = expandSortOption(option);
static QList defaultOptions = {CardList::SortByName, CardList::SortByPrinting};
player->getGraphicsItem()->getHandZoneGraphicsItem()->sortHand(sortOptions + defaultOptions);
}
void PlayerActions::actViewTopCards()