[Refactor] Hold zone views and card view teardown outside game graphics (#7429)

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
BruebachL 2026-10-31 18:44:13 +01:00 • committed by GitHub
parent 2335e064ac
commit edb5caec8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 84 additions and 39 deletions

View file

@ -2,9 +2,6 @@
#include "../../client/translation.h"
#include "../../game_graphics/board/card_item.h"
#include "../../game_graphics/zones/card_zone.h"
#include "../../game_graphics/zones/view_zone.h"
#include "../board/card_list.h"
#include "../player/player_actions.h"
#include "../player/player_info.h"
#include "../player/player_logic.h"
@ -47,16 +44,16 @@ CardZoneLogic::CardZoneLogic(PlayerLogic *_player,
void CardZoneLogic::addCard(CardItem *card, const bool reorganize, const int x, const int y)
{
if (!card) {
qCWarning(CardZoneLog) << "CardZoneLogic::addCard() card is null; this shouldn't normally happen";
qCWarning(CardZoneLogicLog) << "CardZoneLogic::addCard() card is null; this shouldn't normally happen";
return;
}
for (auto *view : views) {
if (qobject_cast<ZoneViewZoneLogic *>(view->getLogic())->prepareAddCard(x)) {
for (auto *viewLogic : views) {
if (viewLogic->prepareAddCard(x)) {
auto copy = new CardItem(player, nullptr, card->getCardRef(), card->getId());
copy->setFaceDown(card->getFaceDown());
view->getLogic()->addCard(copy, reorganize, x, y);
viewLogic->addCard(copy, reorganize, x, y);
}
}
@ -90,8 +87,8 @@ CardItem *CardZoneLogic::takeCard(int position, int cardId, bool toNewZone)
return nullptr;
}
for (auto *view : views) {
qobject_cast<ZoneViewZoneLogic *>(view->getLogic())->removeCard(position, toNewZone);
for (auto *viewLogic : views) {
viewLogic->removeCard(position, toNewZone);
}
CardItem *c = cards.takeAt(position);
@ -107,7 +104,7 @@ CardItem *CardZoneLogic::getCard(int cardId)
{
CardItem *c = cards.findCard(cardId);
if (!c) {
qCWarning(CardZoneLog) << "CardZoneLogic::getCard: card id=" << cardId << "not found";
qCWarning(CardZoneLogicLog) << "CardZoneLogic::getCard: card id=" << cardId << "not found";
return nullptr;
}
// If the card's id is -1, this zone is invisible,
@ -122,7 +119,7 @@ CardItem *CardZoneLogic::getCard(int cardId)
void CardZoneLogic::removeCard(CardItem *card)
{
if (!card) {
qCWarning(CardZoneLog) << "CardZoneLogic::removeCard: card is null, this shouldn't normally happen";
qCWarning(CardZoneLogicLog) << "CardZoneLogic::removeCard: card is null, this shouldn't normally happen";
return;
}