mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-19 17:02:15 -07:00
Support Flip Cards with related art
This commit is contained in:
parent
db53066d89
commit
aea52a4857
8 changed files with 50 additions and 10 deletions
|
|
@ -1807,9 +1807,9 @@ void TabGame::createDeckViewContainerWidget(bool bReplay)
|
|||
deckViewContainerWidget->setLayout(deckViewContainerLayout);
|
||||
}
|
||||
|
||||
void TabGame::viewCardInfo(const QString &cardName)
|
||||
void TabGame::viewCardInfo(const QString &cardName, const QString &providerId) const
|
||||
{
|
||||
cardInfoFrameWidget->setCard(cardName);
|
||||
cardInfoFrameWidget->setCard(cardName, providerId);
|
||||
}
|
||||
|
||||
void TabGame::createCardInfoDock(bool bReplay)
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ public:
|
|||
public slots:
|
||||
void sendGameCommand(PendingCommand *pend, int playerId = -1);
|
||||
void sendGameCommand(const ::google::protobuf::Message &command, int playerId = -1);
|
||||
void viewCardInfo(const QString &cardName);
|
||||
void viewCardInfo(const QString &cardName, const QString &providerId = "") const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -707,6 +707,25 @@ bool CardDatabase::isProviderIdForPreferredPrinting(const QString &cardName, con
|
|||
return providerId == getPreferredPrintingProviderIdForCard(cardName);
|
||||
}
|
||||
|
||||
CardInfoPerSet CardDatabase::getSetInfoForCard(const CardInfoPtr &_card)
|
||||
{
|
||||
const CardInfoPerSetMap &setMap = _card->getSets();
|
||||
if (setMap.empty()) {
|
||||
return CardInfoPerSet(nullptr);
|
||||
}
|
||||
|
||||
for (const auto &x : setMap) {
|
||||
for (auto &cardInfoForSet : x) {
|
||||
if (QLatin1String("card_") + _card->getName() + QString("_") + cardInfoForSet.getProperty("uuid") ==
|
||||
_card->getPixmapCacheKey()) {
|
||||
return cardInfoForSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return CardInfoPerSet(nullptr);
|
||||
}
|
||||
|
||||
void CardDatabase::refreshCachedReverseRelatedCards()
|
||||
{
|
||||
for (const CardInfoPtr &card : cards)
|
||||
|
|
|
|||
|
|
@ -487,6 +487,7 @@ public:
|
|||
|
||||
CardSetPtr getSet(const QString &setName);
|
||||
bool isProviderIdForPreferredPrinting(const QString &cardName, const QString &providerId);
|
||||
static CardInfoPerSet getSetInfoForCard(const CardInfoPtr &_card);
|
||||
QList<CardInfoPtr> getCardList() const
|
||||
{
|
||||
return cards.values();
|
||||
|
|
|
|||
|
|
@ -1740,7 +1740,8 @@ void Player::actCreateRelatedCard()
|
|||
* then let's allow it to be created via "create another token"
|
||||
*/
|
||||
if (createRelatedFromRelation(sourceCard, cardRelation) && cardRelation->getCanCreateAnother()) {
|
||||
CardInfoPtr cardInfo = CardDatabaseManager::getInstance()->getCard(cardRelation->getName());
|
||||
CardInfoPtr cardInfo = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
||||
cardRelation->getName(), sourceCard->getProviderId());
|
||||
setLastToken(cardInfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -1903,11 +1904,13 @@ void Player::createCard(const CardItem *sourceCard,
|
|||
case CardRelation::AttachTo:
|
||||
cmd.set_target_card_id(sourceCard->getId());
|
||||
cmd.set_target_mode(Command_CreateToken::ATTACH_TO);
|
||||
cmd.set_card_provider_id(sourceCard->getProviderId().toStdString());
|
||||
break;
|
||||
|
||||
case CardRelation::TransformInto:
|
||||
cmd.set_target_card_id(sourceCard->getId());
|
||||
cmd.set_target_mode(Command_CreateToken::TRANSFORM_INTO);
|
||||
cmd.set_card_provider_id(sourceCard->getProviderId().toStdString());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2066,7 +2069,8 @@ void Player::eventCreateToken(const Event_CreateToken &event)
|
|||
return;
|
||||
}
|
||||
|
||||
CardItem *card = new CardItem(this, nullptr, QString::fromStdString(event.card_name()), QString(), event.card_id());
|
||||
CardItem *card = new CardItem(this, nullptr, QString::fromStdString(event.card_name()),
|
||||
QString::fromStdString(event.card_provider_id()), event.card_id());
|
||||
// use db PT if not provided in event
|
||||
if (!QString::fromStdString(event.pt()).isEmpty()) {
|
||||
card->setPT(QString::fromStdString(event.pt()));
|
||||
|
|
@ -3712,13 +3716,17 @@ void Player::addRelatedCardView(const CardItem *card, QMenu *cardMenu)
|
|||
return;
|
||||
}
|
||||
|
||||
const auto ¤tCardSet = CardDatabase::getSetInfoForCard(cardInfo);
|
||||
|
||||
cardMenu->addSeparator();
|
||||
auto viewRelatedCards = new QMenu(tr("View related cards"));
|
||||
cardMenu->addMenu(viewRelatedCards);
|
||||
for (const CardRelation *relatedCard : relatedCards) {
|
||||
QString relatedCardName = relatedCard->getName();
|
||||
QAction *viewCard = viewRelatedCards->addAction(relatedCardName);
|
||||
connect(viewCard, &QAction::triggered, game, [this, relatedCardName] { game->viewCardInfo(relatedCardName); });
|
||||
connect(viewCard, &QAction::triggered, game, [this, relatedCardName, currentCardSet] {
|
||||
game->viewCardInfo(relatedCardName, currentCardSet.getProperty("uuid"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3737,13 +3745,20 @@ void Player::addRelatedCardActions(const CardItem *card, QMenu *cardMenu)
|
|||
return;
|
||||
}
|
||||
|
||||
const auto ¤tCardSet = CardDatabase::getSetInfoForCard(cardInfo);
|
||||
|
||||
cardMenu->addSeparator();
|
||||
int index = 0;
|
||||
QAction *createRelatedCards = nullptr;
|
||||
for (const CardRelation *cardRelation : relatedCards) {
|
||||
CardInfoPtr relatedCard = CardDatabaseManager::getInstance()->getCard(cardRelation->getName());
|
||||
if (relatedCard == nullptr)
|
||||
CardInfoPtr relatedCard = CardDatabaseManager::getInstance()->getCardByNameAndProviderId(
|
||||
cardRelation->getName(), currentCardSet.getProperty("uuid"));
|
||||
if (relatedCard == nullptr) {
|
||||
relatedCard = CardDatabaseManager::getInstance()->getCard(cardRelation->getName());
|
||||
}
|
||||
if (relatedCard == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QString relatedCardName;
|
||||
if (relatedCard->getPowTough().size() > 0) {
|
||||
|
|
|
|||
|
|
@ -25,4 +25,6 @@ message Command_CreateToken {
|
|||
|
||||
// What to do with the target card. Ignored if there is no target card.
|
||||
optional TargetMode target_mode = 11;
|
||||
|
||||
optional string card_provider_id = 12;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,4 +14,5 @@ message Event_CreateToken {
|
|||
optional bool destroy_on_zone_change = 7;
|
||||
optional sint32 x = 8;
|
||||
optional sint32 y = 9;
|
||||
optional string card_provider_id = 10;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -391,6 +391,7 @@ static Event_CreateToken makeCreateTokenEvent(Server_CardZone *zone, Server_Card
|
|||
event.set_zone_name(zone->getName().toStdString());
|
||||
event.set_card_id(card->getId());
|
||||
event.set_card_name(card->getName().toStdString());
|
||||
event.set_card_provider_id(card->getProviderId().toStdString());
|
||||
event.set_color(card->getColor().toStdString());
|
||||
event.set_pt(card->getPT().toStdString());
|
||||
event.set_annotation(card->getAnnotation().toStdString());
|
||||
|
|
@ -1400,7 +1401,8 @@ Server_Player::cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer
|
|||
}
|
||||
}
|
||||
|
||||
QString cardName = nameFromStdString(cmd.card_name());
|
||||
const QString cardName = nameFromStdString(cmd.card_name());
|
||||
const QString cardProviderId = nameFromStdString(cmd.card_provider_id());
|
||||
if (zone->hasCoords()) {
|
||||
xCoord = zone->getFreeGridColumn(xCoord, yCoord, cardName, false);
|
||||
}
|
||||
|
|
@ -1411,7 +1413,7 @@ Server_Player::cmdCreateToken(const Command_CreateToken &cmd, ResponseContainer
|
|||
yCoord = 0;
|
||||
}
|
||||
|
||||
auto *card = new Server_Card(cardName, QString(), newCardId(), xCoord, yCoord);
|
||||
auto *card = new Server_Card(cardName, cardProviderId, newCardId(), xCoord, yCoord);
|
||||
card->moveToThread(thread());
|
||||
card->setPT(nameFromStdString(cmd.pt()));
|
||||
card->setColor(nameFromStdString(cmd.color()));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue