mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-09 11:33:25 -08:00
[Game] Restore attach bookkeeping via CardItem and repaint on state change
This commit is contained in:
parent
f321132cce
commit
50a5884606
3 changed files with 31 additions and 3 deletions
|
|
@ -33,6 +33,11 @@
|
|||
#include <qalgorithms.h>
|
||||
#include <string>
|
||||
|
||||
static CardItem *toCardItem(CardState *card)
|
||||
{
|
||||
return card == nullptr ? nullptr : qobject_cast<CardItem *>(card->parent());
|
||||
}
|
||||
|
||||
PlayerLogic::PlayerLogic(const ServerInfo_User &info, int _id, bool _local, bool _judge, AbstractGame *_parent)
|
||||
: QObject(_parent), game(_parent), playerInfo(new PlayerInfo(info, _id, _local, _judge)),
|
||||
playerEventHandler(new PlayerEventHandler(this)), playerActions(new PlayerActions(this)), active(false),
|
||||
|
|
@ -227,7 +232,13 @@ void PlayerLogic::processCardAttachment(const ServerInfo_Player &info)
|
|||
continue;
|
||||
}
|
||||
|
||||
startCard->setAttachedTo(targetCard);
|
||||
// Route through CardItem::setAttachedTo to maintain the attachedCards graph and reparenting;
|
||||
// CardState::setAttachedTo alone only repoints the pointer.
|
||||
if (CardItem *startItem = toCardItem(startCard)) {
|
||||
startItem->setAttachedTo(toCardItem(targetCard));
|
||||
} else {
|
||||
startCard->setAttachedTo(targetCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue