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