From b3c89167c53673ade34f376f60769dd5ff6355c8 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Mon, 25 May 2026 08:19:27 +0200 Subject: [PATCH] [Game][Arrows] Hook up to the state zone change properly. (#6937) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 17 minutes Took 3 seconds Took 2 minutes Took 10 minutes Co-authored-by: Lukas BrĂ¼bach --- cockatrice/src/game/board/card_item.h | 4 ++++ cockatrice/src/game/board/card_state.cpp | 2 +- cockatrice/src/game/board/card_state.h | 2 +- cockatrice/src/game/game_scene.cpp | 2 +- cockatrice/src/interface/widgets/tabs/tab_game.cpp | 5 +++++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/game/board/card_item.h b/cockatrice/src/game/board/card_item.h index 451fed0c6..87f9667de 100644 --- a/cockatrice/src/game/board/card_item.h +++ b/cockatrice/src/game/board/card_item.h @@ -55,6 +55,10 @@ public: CardZoneLogic *_zone = nullptr); void retranslateUi(); + [[nodiscard]] CardState *getState() const + { + return state; + } [[nodiscard]] CardZoneLogic *getZone() const { return state->getZone(); diff --git a/cockatrice/src/game/board/card_state.cpp b/cockatrice/src/game/board/card_state.cpp index fe1aa9b73..4319400d7 100644 --- a/cockatrice/src/game/board/card_state.cpp +++ b/cockatrice/src/game/board/card_state.cpp @@ -18,7 +18,7 @@ void CardState::setZone(CardZoneLogic *_zone) } zone = _zone; - emit zoneChanged(zone); + emit zoneChanged(this, zone); emit stateChanged(); } diff --git a/cockatrice/src/game/board/card_state.h b/cockatrice/src/game/board/card_state.h index ef17f408c..0498b1aa2 100644 --- a/cockatrice/src/game/board/card_state.h +++ b/cockatrice/src/game/board/card_state.h @@ -31,7 +31,7 @@ signals: void doesntUntapChanged(bool newValue); void destroyOnZoneChangeChanged(bool newValue); void attachedToChanged(CardItem *newAttachedTo); - void zoneChanged(CardZoneLogic *newZone); + void zoneChanged(CardState *changedCard, CardZoneLogic *newZone); public: explicit CardState(QObject *parent, CardZoneLogic *_zone) : QObject(parent), zone(_zone) diff --git a/cockatrice/src/game/game_scene.cpp b/cockatrice/src/game/game_scene.cpp index 500c1cbe0..9f466c2ac 100644 --- a/cockatrice/src/game/game_scene.cpp +++ b/cockatrice/src/game/game_scene.cpp @@ -432,7 +432,7 @@ void GameScene::onCardZoneChanged(CardItem *card, bool sameZone) } } for (auto *arrow : toDelete) { - emit requestArrowDeletion(arrow->getId()); + onArrowDeleted(arrow->getId()); } } diff --git a/cockatrice/src/interface/widgets/tabs/tab_game.cpp b/cockatrice/src/interface/widgets/tabs/tab_game.cpp index dd5df72a1..3da3685dd 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_game.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_game.cpp @@ -895,6 +895,11 @@ void TabGame::newCardAdded(AbstractCardItem *card) connect(card, &AbstractCardItem::showCardInfoPopup, this, &TabGame::showCardInfoPopup); connect(card, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString))); connect(card, &AbstractCardItem::cardShiftClicked, this, &TabGame::linkCardToChat); + CardItem *cardItem = qobject_cast(card); + if (cardItem) { + connect(cardItem->getState(), &CardState::zoneChanged, scene, + [this, cardItem]() { scene->onCardZoneChanged(cardItem, false); }); + } } QString TabGame::getTabText() const