From ba985f97e5a5a7e79f872d722c7a9c2e68c2241a Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Sun, 3 Feb 2019 02:33:29 +0100 Subject: [PATCH] removes the pt of face down cards (#3542) * removes the pt of face down cards Instead of setting the pt of a hidden card to the value only known to you, it's reset to nothing. Resetting a card while it's already reset does nothing. Removing the pt of a card is logged as "player removes the pt of card." instead of "player sets the pt of card to ." (note the missing value). * reset unknown cards to nothing instead * replace cardname with card id for unknown cards fixes #3543 * prefix # --- cockatrice/src/messagelogwidget.cpp | 21 +++++++++++++++------ cockatrice/src/player.cpp | 13 +++++++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/messagelogwidget.cpp b/cockatrice/src/messagelogwidget.cpp index 7a29e879..533a5911 100644 --- a/cockatrice/src/messagelogwidget.cpp +++ b/cockatrice/src/messagelogwidget.cpp @@ -694,13 +694,22 @@ void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool do void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT) { - if (currentContext == MessageContext_MoveCard) + if (currentContext == MessageContext_MoveCard) { moveCardPT.insert(card, newPT); - else - appendHtmlServerMessage(tr("%1 sets PT of %2 to %3.") - .arg(sanitizeHtml(player->getName())) - .arg(cardLink(card->getName())) - .arg(QString("%1").arg(sanitizeHtml(newPT)))); + } else { + QString name = card->getName(); + if (name.isEmpty()) { + name = QString("card #%1").arg(sanitizeHtml(QString::number(card->getId()))); + } else { + name = cardLink(name); + } + if (newPT.isEmpty()) { + appendHtmlServerMessage(tr("%1 removes the PT of %2.").arg(sanitizeHtml(player->getName())).arg(name)); + } else { + appendHtmlServerMessage( + tr("%1 sets PT of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(name).arg(newPT)); + } + } } void MessageLogWidget::logSetSideboardLock(Player *player, bool locked) diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 12e5c7d5..802b6628 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -2514,16 +2514,21 @@ void Player::actResetPT() QListIterator selected(scene()->selectedItems()); while (selected.hasNext()) { auto *card = static_cast(selected.next()); - CardInfoPtr info = card->getInfo(); - if (!info) { + QString ptString; + if (!card->getFaceDown()) { // leave the pt empty if the card is face down + CardInfoPtr info = card->getInfo(); + if (info) { + ptString = info->getPowTough(); + } + } + if (ptString == card->getPT()) { continue; } - auto *cmd = new Command_SetCardAttr; QString zoneName = card->getZone()->getName(); + auto *cmd = new Command_SetCardAttr; cmd->set_zone(zoneName.toStdString()); cmd->set_card_id(card->getId()); cmd->set_attribute(AttrPT); - QString ptString = info->getPowTough(); cmd->set_attr_value(ptString.toStdString()); commandList.append(cmd);