[Refactor] Retype card containers and zone logic onto CardState

This commit is contained in:
Lukas Brübach 2026-10-07 09:27:34 +02:00 • committed by GitHub
parent 893aeb7bae
commit f321132cce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 184 additions and 158 deletions

View file

@ -1,10 +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 "../player/player_actions.h"
#include "../player/player_logic.h"
#include "../board/card_state.h"
#include <QtGlobal>
#include <libcockatrice/settings/interface_settings.h>
@ -77,7 +75,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 +144,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 +168,7 @@ void ZoneViewZoneLogic::requestClose()
void ZoneViewZoneLogic::clearCards()
{
for (auto card : cards) {
card->getState()->deleteView();
card->deleteView();
}
cards.clear();
emit cardCountChanged();