mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[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:
parent
2335e064ac
commit
edb5caec8a
9 changed files with 84 additions and 39 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#include "player_event_handler.h"
|
||||
|
||||
#include "../../game_graphics/board/card_item.h"
|
||||
#include "../../game_graphics/zones/view_zone.h"
|
||||
#include "../abstract_game.h"
|
||||
#include "../board/arrow_data.h"
|
||||
#include "../board/card_list.h"
|
||||
|
|
@ -9,6 +8,7 @@
|
|||
#include "../zones/card_zone_logic.h"
|
||||
#include "../zones/hand_zone_logic.h"
|
||||
#include "../zones/pile_zone_logic.h"
|
||||
#include "../zones/view_zone_logic.h"
|
||||
#include "libcockatrice/card/card_info.h"
|
||||
#include "libcockatrice/card/printing/exact_card.h"
|
||||
#include "libcockatrice/protocol/pb/card_attributes.pb.h"
|
||||
|
|
@ -76,12 +76,12 @@ void PlayerEventHandler::eventShuffle(const Event_Shuffle &event)
|
|||
}
|
||||
|
||||
// close all views that contain shuffled cards
|
||||
for (ZoneViewZone *view : zone->getViews()) {
|
||||
if (view != nullptr) {
|
||||
int length = view->getLogic()->getCards().length();
|
||||
for (auto *viewLogic : zone->getViews()) {
|
||||
if (viewLogic != nullptr) {
|
||||
int length = viewLogic->getCards().length();
|
||||
// we want to close empty views as well
|
||||
if (length == 0 || length > absStart) { // note this assumes views always start at the top of the library
|
||||
view->close();
|
||||
viewLogic->requestClose();
|
||||
}
|
||||
} else {
|
||||
qWarning() << zone->getName() << "of" << player->getPlayerInfo()->getName() << "holds empty zoneview!";
|
||||
|
|
@ -345,9 +345,9 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv
|
|||
if (card == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (startZone != targetZone) {
|
||||
card->deleteCardInfoPopup();
|
||||
}
|
||||
const bool zoneChanged = startZone != targetZone;
|
||||
const bool ownerChanged = zoneChanged && startZone->getPlayer() != targetZone->getPlayer();
|
||||
emit cardViewRefreshRequested(card->getState(), zoneChanged, ownerChanged ? targetZone->getPlayer() : nullptr);
|
||||
if (event.has_card_name()) {
|
||||
QString name = QString::fromStdString(event.card_name());
|
||||
QString providerId =
|
||||
|
|
@ -361,22 +361,13 @@ void PlayerEventHandler::eventMoveCard(const Event_MoveCard &event, const GameEv
|
|||
parentCard->getZone()->reorganizeCards();
|
||||
}
|
||||
|
||||
card->deleteDragItem();
|
||||
|
||||
card->setId(event.new_card_id());
|
||||
card->setFaceDown(event.face_down());
|
||||
if (startZone != targetZone) {
|
||||
card->setBeingPointedAt(false);
|
||||
card->setHovered(false);
|
||||
|
||||
const QList<CardItem *> &attachedCards = card->getAttachedCards();
|
||||
for (auto attachedCard : attachedCards) {
|
||||
emit targetZone->cardAdded(attachedCard);
|
||||
}
|
||||
|
||||
if (startZone->getPlayer() != targetZone->getPlayer()) {
|
||||
card->setOwner(targetZone->getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
// The log event has to be sent before the card is added to the target zone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue