mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 14:32:15 -07:00
set cardRef in CardItem
This commit is contained in:
parent
2f5b4d46bf
commit
e2a6fc581b
9 changed files with 25 additions and 37 deletions
|
|
@ -184,22 +184,9 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||
painter->restore();
|
||||
}
|
||||
|
||||
void AbstractCardItem::setName(const QString &_name)
|
||||
void AbstractCardItem::setCardRef(const CardRef &_cardRef)
|
||||
{
|
||||
if (cardRef.name == _name)
|
||||
return;
|
||||
|
||||
emit deleteCardInfoPopup(cardRef.name);
|
||||
if (info)
|
||||
disconnect(info.data(), nullptr, this, nullptr);
|
||||
cardRef.name = _name;
|
||||
|
||||
refreshCardInfo();
|
||||
}
|
||||
|
||||
void AbstractCardItem::setProviderId(const QString &_providerId)
|
||||
{
|
||||
if (cardRef.providerId == _providerId) {
|
||||
if (cardRef == _cardRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +194,7 @@ void AbstractCardItem::setProviderId(const QString &_providerId)
|
|||
if (info) {
|
||||
disconnect(info.data(), nullptr, this, nullptr);
|
||||
}
|
||||
cardRef.providerId = _providerId;
|
||||
cardRef = _cardRef;
|
||||
|
||||
refreshCardInfo();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,12 +74,11 @@ public:
|
|||
{
|
||||
return cardRef.name;
|
||||
}
|
||||
void setName(const QString &_name = QString());
|
||||
QString getProviderId() const
|
||||
{
|
||||
return cardRef.providerId;
|
||||
}
|
||||
void setProviderId(const QString &_providerId = QString());
|
||||
void setCardRef(const CardRef &_cardRef);
|
||||
CardRef getCardRef() const
|
||||
{
|
||||
return cardRef;
|
||||
|
|
|
|||
|
|
@ -241,8 +241,7 @@ void CardItem::processCardInfo(const ServerInfo_Card &_info)
|
|||
}
|
||||
|
||||
setId(_info.id());
|
||||
setProviderId(QString::fromStdString(_info.provider_id()));
|
||||
setName(QString::fromStdString(_info.name()));
|
||||
setCardRef({QString::fromStdString(_info.name()), QString::fromStdString(_info.provider_id())});
|
||||
setAttacking(_info.attacking());
|
||||
setFaceDown(_info.face_down());
|
||||
setPT(QString::fromStdString(_info.pt()));
|
||||
|
|
|
|||
|
|
@ -2197,7 +2197,7 @@ void Player::eventShuffle(const Event_Shuffle &event)
|
|||
|
||||
// remove revealed card name on top of decks
|
||||
if (absStart == 0 && !cardList.isEmpty()) {
|
||||
cardList.first()->setName("");
|
||||
cardList.first()->setCardRef({});
|
||||
zone->update();
|
||||
}
|
||||
|
||||
|
|
@ -2392,10 +2392,10 @@ void Player::eventMoveCard(const Event_MoveCard &event, const GameEventContext &
|
|||
card->deleteCardInfoPopup();
|
||||
}
|
||||
if (event.has_card_name()) {
|
||||
card->setName(QString::fromStdString(event.card_name()));
|
||||
}
|
||||
if (event.has_new_card_provider_id()) {
|
||||
card->setProviderId(QString::fromStdString(event.new_card_provider_id()));
|
||||
QString name = QString::fromStdString(event.card_name());
|
||||
QString providerId =
|
||||
event.has_new_card_provider_id() ? QString::fromStdString(event.new_card_provider_id()) : "";
|
||||
card->setCardRef({name, providerId});
|
||||
}
|
||||
|
||||
if (card->getAttachedTo() && (startZone != targetZone)) {
|
||||
|
|
@ -2555,8 +2555,9 @@ void Player::eventDrawCards(const Event_DrawCards &event)
|
|||
for (int i = 0; i < listSize; ++i) {
|
||||
const ServerInfo_Card &cardInfo = event.cards(i);
|
||||
CardItem *card = _deck->takeCard(0, cardInfo.id());
|
||||
card->setProviderId(QString::fromStdString(cardInfo.provider_id()));
|
||||
card->setName(QString::fromStdString(cardInfo.name()));
|
||||
QString cardName = QString::fromStdString(cardInfo.name());
|
||||
QString providerId = QString::fromStdString(cardInfo.provider_id());
|
||||
card->setCardRef({cardName, providerId});
|
||||
_hand->addCard(card, false, -1);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2599,11 +2600,12 @@ void Player::eventRevealCards(const Event_RevealCards &event, EventProcessingOpt
|
|||
if (peeking) {
|
||||
for (const auto &card : cardList) {
|
||||
QString cardName = QString::fromStdString(card->name());
|
||||
QString providerId = QString::fromStdString(card->provider_id());
|
||||
CardItem *cardItem = zone->getCard(card->id(), QString());
|
||||
if (!cardItem) {
|
||||
continue;
|
||||
}
|
||||
cardItem->setName(cardName);
|
||||
cardItem->setCardRef({cardName, providerId});
|
||||
emit logRevealCards(this, zone, card->id(), cardName, this, true, 1);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2616,8 +2618,8 @@ void Player::eventRevealCards(const Event_RevealCards &event, EventProcessingOpt
|
|||
// Handle case of revealing top card of library in-place
|
||||
if (cardId == 0 && dynamic_cast<PileZone *>(zone)) {
|
||||
auto card = zone->getCards().first();
|
||||
card->setName(cardName);
|
||||
card->setProviderId(QString::fromStdString(cardList.first()->provider_id()));
|
||||
QString providerId = QString::fromStdString(cardList.first()->provider_id());
|
||||
card->setCardRef({cardName, providerId});
|
||||
zone->update();
|
||||
showZoneView = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ CardItem *CardZone::getCard(int cardId, const QString &cardName)
|
|||
// It can be assumed that in an invisible zone, all cards are equal.
|
||||
if ((c->getId() == -1) || (c->getName().isEmpty())) {
|
||||
c->setId(cardId);
|
||||
c->setName(cardName);
|
||||
// TODO: also set providerId
|
||||
c->setCardRef({cardName});
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
|
||||
if (!cards.getContentsKnown()) {
|
||||
card->setId(-1);
|
||||
card->setName();
|
||||
card->setCardRef({});
|
||||
}
|
||||
card->setParentItem(this);
|
||||
card->resetState();
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
cards.insert(x, card);
|
||||
card->setPos(0, 0);
|
||||
if (!contentsKnown()) {
|
||||
card->setName(QString());
|
||||
card->setCardRef({});
|
||||
card->setId(-1);
|
||||
// If we obscure a previously revealed card, its name has to be forgotten
|
||||
if (cards.size() > x + 1)
|
||||
cards.at(x + 1)->setName(QString());
|
||||
cards.at(x + 1)->setCardRef({});
|
||||
}
|
||||
card->setVisible(false);
|
||||
card->resetState();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void StackZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
|
||||
if (!cards.getContentsKnown()) {
|
||||
card->setId(-1);
|
||||
card->setName();
|
||||
card->setCardRef({});
|
||||
}
|
||||
card->setParentItem(this);
|
||||
card->resetState(true);
|
||||
|
|
|
|||
|
|
@ -149,9 +149,9 @@ public:
|
|||
coord_x = x;
|
||||
coord_y = y;
|
||||
}
|
||||
void setName(const QString &_name)
|
||||
void setCardRef(const CardRef &_cardRef)
|
||||
{
|
||||
cardRef.name = _name;
|
||||
cardRef = _cardRef;
|
||||
}
|
||||
void setCounter(int _id, int value, Event_SetCardCounter *event = nullptr);
|
||||
void setTapped(bool _tapped)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue