[Refactor] Retype card containers and zone logic onto CardState (#7434)

* [Refactor] Retype card containers and zone logic onto CardState

* [Game] Restore attach bookkeeping via CardItem and repaint on state change

* [Refactor] Give custom zones a hidden graphics owner

Custom PileZoneLogic zones had no CardZone, so moving a card into one
left the CardItem drawn at its old spot. Create a hidden PileZone in
onCustomZoneAdded so cards are reparented and hidden.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-10-31 18:44:14 +01:00 • committed by GitHub
parent 5d0d466930
commit 65e9f1b370
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 232 additions and 159 deletions

View file

@ -1,8 +1,8 @@
#include "view_zone_logic.h"
#include "../../client/settings/cache_settings.h"
#include "../../game_graphics/board/card_item.h"
#include "../board/card_list.h"
#include "../board/card_state.h"
#include "../player/player_actions.h"
#include "../player/player_logic.h"
@ -77,7 +77,7 @@ bool ZoneViewZoneLogic::prepareAddCard(int x)
* Make sure prepareAddCard() was called before calling addCard().
* This method assumes we already checked that the card is being inserted into the visible portion
*/
void ZoneViewZoneLogic::addCardImpl(CardItem *card, int x, int /*y*/)
void ZoneViewZoneLogic::addCardImpl(CardState *card, int x, int /*y*/)
{
if (!isReversed) {
// if x is negative set it to add at end
@ -146,8 +146,8 @@ void ZoneViewZoneLogic::removeCard(int position, bool toNewZone)
return;
}
CardItem *card = cards.takeAt(position);
card->getState()->deleteView();
CardState *card = cards.takeAt(position);
card->deleteView();
// The toNewZone check is to prevent the view from auto-closing if the view contains only a single card and that
// card gets dragged within the view.
@ -170,7 +170,7 @@ void ZoneViewZoneLogic::requestClose()
void ZoneViewZoneLogic::clearCards()
{
for (auto card : cards) {
card->getState()->deleteView();
card->deleteView();
}
cards.clear();
emit cardCountChanged();