rework pt setting (#3584)

* rework pt setting

save pt as a string serverside
set the pt of cards that enter the battlefield to empty (was -1/0)
implement old behaviour as changePT clientside
display old pt to messagelog
add new keybind for new set behaviour (default ctrl+shift+p)
add flow pt actions and keybinds that increase while decreasing
put more braces everywhere
various refactors like adding consts and for loops
remove a single superfluous semicolon
does not change the way pt is displayed client side
does not fix 3455 fully

* fix drawing of pt

remove search for / in carditem's paint() (crash)
ptstring is now always orange unless it's a faceup card with a pt that
matches the cardinfo pt
set changept to remove the pt if the field is empty
set changept to keep the old value if one side is empty
return in changept for +0/+0
clean up some if statements

* return on change to +0/+0

* change log message for empty original pts

* typo

* remove changept

add parsept to unify reading pt strings
change setpt behavior to be an "upgraded" version of the old setpt
add arbitrary strings as anything that starts with /

* clangify

* remove debug lines

* add tip of the day

* add missing images

* clangify
This commit is contained in:
ebbit1q 2019-03-03 22:24:57 +01:00 committed by Zach H
parent 18ad3cf4a5
commit 9411396b97
13 changed files with 831 additions and 498 deletions

View file

@ -347,7 +347,6 @@
<file>resources/userlevels/admin_vip_buddy.svg</file> <file>resources/userlevels/admin_vip_buddy.svg</file>
<!-- ADD TIP OF THE DAY IMAGES HERE --> <!-- ADD TIP OF THE DAY IMAGES HERE -->
<file>resources/tips/tips_of_the_day.xml</file>
<file>resources/tips/images/accounts_tab.png</file> <file>resources/tips/images/accounts_tab.png</file>
<file>resources/tips/images/arrows.png</file> <file>resources/tips/images/arrows.png</file>
<file>resources/tips/images/cockatrice_register.png</file> <file>resources/tips/images/cockatrice_register.png</file>
@ -358,8 +357,11 @@
<file>resources/tips/images/filter_games.png</file> <file>resources/tips/images/filter_games.png</file>
<file>resources/tips/images/github_logo.png</file> <file>resources/tips/images/github_logo.png</file>
<file>resources/tips/images/gitter.png</file> <file>resources/tips/images/gitter.png</file>
<file>resources/tips/images/setpt.png</file>
<file>resources/tips/images/shortcuts.png</file>
<file>resources/tips/images/themes.png</file> <file>resources/tips/images/themes.png</file>
<file>resources/tips/images/tip_of_the_day.png</file> <file>resources/tips/images/tip_of_the_day.png</file>
<file>resources/tips/tips_of_the_day.xml</file>
<file>resources/help/search.md</file> <file>resources/help/search.md</file>
</qresource> </qresource>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -63,6 +63,7 @@
&lt;br&gt;Change Life: CTRL + L &lt;br&gt;Change Life: CTRL + L
&lt;br&gt;All shortcuts can be customized via Settings->Shortcuts! &lt;br&gt;All shortcuts can be customized via Settings->Shortcuts!
</text> </text>
<image>shortcuts.png</image>
<date>2018-03-01</date> <date>2018-03-01</date>
</tip> </tip>
<tip> <tip>
@ -89,4 +90,10 @@
<image>counter_expression.png</image> <image>counter_expression.png</image>
<date>2019-02-02</date> <date>2019-02-02</date>
</tip> </tip>
</tips> <tip>
<title>Power and Toughness</title>
<text>You can add and subtract to a creature's stats.&lt;br&gt;With a card selected, set the power and toughness ( default: ctrl + p ) and enter +3/-1 to increase power by three while decreasing toughness by one.&lt;br&gt;You can also reset it to the original value ( default: ctrl + alt + 0 ).</text>
<image>setpt.png</image>
<date>2019-03-02</date>
</tip>
</tips>

View file

@ -106,17 +106,12 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter->save(); painter->save();
transformPainter(painter, translatedSize, tapAngle); transformPainter(painter, translatedSize, tapAngle);
if (info) { if (!getFaceDown() && info && pt == info->getPowTough()) {
QStringList ptSplit = pt.split("/");
QStringList ptDbSplit = info->getPowTough().split("/");
if (getFaceDown() || ptDbSplit.at(0) != ptSplit.at(0) || ptDbSplit.at(1) != ptSplit.at(1))
painter->setPen(QColor(255, 150, 0));
else
painter->setPen(Qt::white);
} else {
painter->setPen(Qt::white); painter->setPen(Qt::white);
} else {
painter->setPen(QColor(255, 150, 0)); // dark orange
} }
painter->setBackground(Qt::black); painter->setBackground(Qt::black);
painter->setBackgroundMode(Qt::OpaqueMode); painter->setBackgroundMode(Qt::OpaqueMode);

View file

@ -68,54 +68,61 @@ MessageLogWidget::getFromStr(CardZone *zone, QString cardName, int position, boo
QString fromStr; QString fromStr;
QString zoneName = zone->getName(); QString zoneName = zone->getName();
if (zoneName == tableConstant()) if (zoneName == tableConstant()) {
fromStr = tr(" from play"); fromStr = tr(" from play");
else if (zoneName == graveyardConstant()) } else if (zoneName == graveyardConstant()) {
fromStr = tr(" from their graveyard"); fromStr = tr(" from their graveyard");
else if (zoneName == exileConstant()) } else if (zoneName == exileConstant()) {
fromStr = tr(" from exile"); fromStr = tr(" from exile");
else if (zoneName == handConstant()) } else if (zoneName == handConstant()) {
fromStr = tr(" from their hand"); fromStr = tr(" from their hand");
else if (zoneName == deckConstant()) { } else if (zoneName == deckConstant()) {
if (position == 0) { if (position == 0) {
if (cardName.isEmpty()) { if (cardName.isEmpty()) {
if (ownerChange) if (ownerChange) {
cardName = tr("the top card of %1's library").arg(zone->getPlayer()->getName()); cardName = tr("the top card of %1's library").arg(zone->getPlayer()->getName());
else } else {
cardName = tr("the top card of their library"); cardName = tr("the top card of their library");
}
cardNameContainsStartZone = true; cardNameContainsStartZone = true;
} else { } else {
if (ownerChange) if (ownerChange) {
fromStr = tr(" from the top of %1's library").arg(zone->getPlayer()->getName()); fromStr = tr(" from the top of %1's library").arg(zone->getPlayer()->getName());
else } else {
fromStr = tr(" from the top of their library"); fromStr = tr(" from the top of their library");
}
} }
} else if (position >= zone->getCards().size() - 1) { } else if (position >= zone->getCards().size() - 1) {
if (cardName.isEmpty()) { if (cardName.isEmpty()) {
if (ownerChange) if (ownerChange) {
cardName = tr("the bottom card of %1's library").arg(zone->getPlayer()->getName()); cardName = tr("the bottom card of %1's library").arg(zone->getPlayer()->getName());
else } else {
cardName = tr("the bottom card of their library"); cardName = tr("the bottom card of their library");
}
cardNameContainsStartZone = true; cardNameContainsStartZone = true;
} else { } else {
if (ownerChange) if (ownerChange) {
fromStr = tr(" from the bottom of %1's library").arg(zone->getPlayer()->getName()); fromStr = tr(" from the bottom of %1's library").arg(zone->getPlayer()->getName());
else } else {
fromStr = tr(" from the bottom of their library"); fromStr = tr(" from the bottom of their library");
}
} }
} else { } else {
if (ownerChange) if (ownerChange) {
fromStr = tr(" from %1's library").arg(zone->getPlayer()->getName()); fromStr = tr(" from %1's library").arg(zone->getPlayer()->getName());
else } else {
fromStr = tr(" from their library"); fromStr = tr(" from their library");
}
} }
} else if (zoneName == sideboardConstant()) } else if (zoneName == sideboardConstant()) {
fromStr = tr(" from sideboard"); fromStr = tr(" from sideboard");
else if (zoneName == stackConstant()) } else if (zoneName == stackConstant()) {
fromStr = tr(" from the stack"); fromStr = tr(" from the stack");
}
if (!cardNameContainsStartZone) if (!cardNameContainsStartZone) {
cardName.clear(); cardName.clear();
}
return QPair<QString, QString>(cardName, fromStr); return QPair<QString, QString>(cardName, fromStr);
} }
@ -123,9 +130,9 @@ void MessageLogWidget::containerProcessingDone()
{ {
if (currentContext == MessageContext_MoveCard) { if (currentContext == MessageContext_MoveCard) {
for (auto &i : moveCardQueue) for (auto &i : moveCardQueue) {
logDoMoveCard(i); logDoMoveCard(i);
}
moveCardQueue.clear(); moveCardQueue.clear();
moveCardTapped.clear(); moveCardTapped.clear();
moveCardExtras.clear(); moveCardExtras.clear();
@ -141,9 +148,9 @@ void MessageLogWidget::containerProcessingDone()
void MessageLogWidget::containerProcessingStarted(const GameEventContext &context) void MessageLogWidget::containerProcessingStarted(const GameEventContext &context)
{ {
if (context.HasExtension(Context_MoveCard::ext)) if (context.HasExtension(Context_MoveCard::ext)) {
currentContext = MessageContext_MoveCard; currentContext = MessageContext_MoveCard;
else if (context.HasExtension(Context_Mulligan::ext)) { } else if (context.HasExtension(Context_Mulligan::ext)) {
const Context_Mulligan &contextMulligan = context.GetExtension(Context_Mulligan::ext); const Context_Mulligan &contextMulligan = context.GetExtension(Context_Mulligan::ext);
currentContext = MessageContext_Mulligan; currentContext = MessageContext_Mulligan;
mulliganPlayer = nullptr; mulliganPlayer = nullptr;
@ -258,13 +265,14 @@ void MessageLogWidget::logCreateToken(Player *player, QString cardName, QString
void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideboardSize) void MessageLogWidget::logDeckSelect(Player *player, QString deckHash, int sideboardSize)
{ {
if (sideboardSize < 0) if (sideboardSize < 0) {
appendHtmlServerMessage(tr("%1 has loaded a deck (%2).").arg(sanitizeHtml(player->getName())).arg(deckHash)); appendHtmlServerMessage(tr("%1 has loaded a deck (%2).").arg(sanitizeHtml(player->getName())).arg(deckHash));
else } else {
appendHtmlServerMessage(tr("%1 has loaded a deck with %2 sideboard cards (%3).") appendHtmlServerMessage(tr("%1 has loaded a deck with %2 sideboard cards (%3).")
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg("<font class=\"blue\">" + QString::number(sideboardSize) + "</font>") .arg("<font class=\"blue\">" + QString::number(sideboardSize) + "</font>")
.arg(deckHash)); .arg(deckHash));
}
} }
void MessageLogWidget::logDestroyCard(Player *player, QString cardName) void MessageLogWidget::logDestroyCard(Player *player, QString cardName)
@ -282,21 +290,24 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
// do not log if moved within the same zone // do not log if moved within the same zone
if ((startZone == tableConstant() && targetZone == tableConstant() && !ownerChanged) || if ((startZone == tableConstant() && targetZone == tableConstant() && !ownerChanged) ||
(startZone == handConstant() && targetZone == handConstant()) || (startZone == handConstant() && targetZone == handConstant()) ||
(startZone == exileConstant() && targetZone == exileConstant())) (startZone == exileConstant() && targetZone == exileConstant())) {
return; return;
}
QString cardName = lmc.cardName; QString cardName = lmc.cardName;
QPair<QString, QString> nameFrom = getFromStr(lmc.startZone, cardName, lmc.oldX, ownerChanged); QPair<QString, QString> nameFrom = getFromStr(lmc.startZone, cardName, lmc.oldX, ownerChanged);
if (!nameFrom.first.isEmpty()) if (!nameFrom.first.isEmpty()) {
cardName = nameFrom.first; cardName = nameFrom.first;
}
QString cardStr; QString cardStr;
if (!nameFrom.first.isEmpty()) if (!nameFrom.first.isEmpty()) {
cardStr = cardName; cardStr = cardName;
else if (cardName.isEmpty()) } else if (cardName.isEmpty()) {
cardStr = tr("a card"); cardStr = tr("a card");
else } else {
cardStr = cardLink(cardName); cardStr = cardLink(cardName);
}
if (ownerChanged && (lmc.startZone->getPlayer() == lmc.player)) { if (ownerChanged && (lmc.startZone->getPlayer() == lmc.player)) {
appendHtmlServerMessage(tr("%1 gives %2 control over %3.") appendHtmlServerMessage(tr("%1 gives %2 control over %3.")
@ -310,17 +321,18 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
bool usesNewX = false; bool usesNewX = false;
if (targetZone == tableConstant()) { if (targetZone == tableConstant()) {
soundEngine->playSound("play_card"); soundEngine->playSound("play_card");
if (moveCardTapped.value(lmc.card)) if (moveCardTapped.value(lmc.card)) {
finalStr = tr("%1 puts %2 into play tapped%3."); finalStr = tr("%1 puts %2 into play tapped%3.");
else } else {
finalStr = tr("%1 puts %2 into play%3."); finalStr = tr("%1 puts %2 into play%3.");
} else if (targetZone == graveyardConstant()) }
} else if (targetZone == graveyardConstant()) {
finalStr = tr("%1 puts %2%3 into their graveyard."); finalStr = tr("%1 puts %2%3 into their graveyard.");
else if (targetZone == exileConstant()) } else if (targetZone == exileConstant()) {
finalStr = tr("%1 exiles %2%3."); finalStr = tr("%1 exiles %2%3.");
else if (targetZone == handConstant()) } else if (targetZone == handConstant()) {
finalStr = tr("%1 moves %2%3 to their hand."); finalStr = tr("%1 moves %2%3 to their hand.");
else if (targetZone == deckConstant()) { } else if (targetZone == deckConstant()) {
if (moveCardExtras.contains("shuffle_partial")) { if (moveCardExtras.contains("shuffle_partial")) {
finalStr = tr("%1 puts %2%3 on bottom of their library randomly."); finalStr = tr("%1 puts %2%3 on bottom of their library randomly.");
} else if (lmc.newX == -1) { } else if (lmc.newX == -1) {
@ -330,13 +342,13 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
} else if (lmc.newX == 0) { } else if (lmc.newX == 0) {
finalStr = tr("%1 puts %2%3 on top of their library."); finalStr = tr("%1 puts %2%3 on top of their library.");
} else { } else {
lmc.newX++; ++lmc.newX;
usesNewX = true; usesNewX = true;
finalStr = tr("%1 puts %2%3 into their library %4 cards from the top."); finalStr = tr("%1 puts %2%3 into their library %4 cards from the top.");
} }
} else if (targetZone == sideboardConstant()) } else if (targetZone == sideboardConstant()) {
finalStr = tr("%1 moves %2%3 to sideboard."); finalStr = tr("%1 moves %2%3 to sideboard.");
else if (targetZone == stackConstant()) { } else if (targetZone == stackConstant()) {
soundEngine->playSound("play_card"); soundEngine->playSound("play_card");
finalStr = tr("%1 plays %2%3."); finalStr = tr("%1 plays %2%3.");
} }
@ -351,9 +363,9 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
void MessageLogWidget::logDrawCards(Player *player, int number) void MessageLogWidget::logDrawCards(Player *player, int number)
{ {
if (currentContext == MessageContext_Mulligan) if (currentContext == MessageContext_Mulligan) {
mulliganPlayer = player; mulliganPlayer = player;
else { } else {
soundEngine->playSound("draw_card"); soundEngine->playSound("draw_card");
appendHtmlServerMessage(tr("%1 draws %2 card(s).", "", number) appendHtmlServerMessage(tr("%1 draws %2 card(s).", "", number)
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
@ -363,16 +375,17 @@ void MessageLogWidget::logDrawCards(Player *player, int number)
void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCards) void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCards)
{ {
if (numberCards == -1) if (numberCards == -1) {
appendHtmlServerMessage(tr("%1 is looking at %2.") appendHtmlServerMessage(tr("%1 is looking at %2.")
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg(zone->getTranslatedName(zone->getPlayer() == player, CaseLookAtZone))); .arg(zone->getTranslatedName(zone->getPlayer() == player, CaseLookAtZone)));
else } else {
appendHtmlServerMessage( appendHtmlServerMessage(
tr("%1 is looking at the top %3 card(s) %2.", "top card for singular, top %3 cards for plural", numberCards) tr("%1 is looking at the top %3 card(s) %2.", "top card for singular, top %3 cards for plural", numberCards)
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg(zone->getTranslatedName(zone->getPlayer() == player, CaseTopCardsOfZone)) .arg(zone->getTranslatedName(zone->getPlayer() == player, CaseTopCardsOfZone))
.arg("<font class=\"blue\">" + QString::number(numberCards) + "</font>")); .arg("<font class=\"blue\">" + QString::number(numberCards) + "</font>"));
}
} }
void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown) void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown)
@ -438,22 +451,25 @@ void MessageLogWidget::logMoveCard(Player *player,
int newX) int newX)
{ {
LogMoveCard attributes = {player, card, card->getName(), startZone, oldX, targetZone, newX}; LogMoveCard attributes = {player, card, card->getName(), startZone, oldX, targetZone, newX};
if (currentContext == MessageContext_MoveCard) if (currentContext == MessageContext_MoveCard) {
moveCardQueue.append(attributes); moveCardQueue.append(attributes);
else if (currentContext == MessageContext_Mulligan) } else if (currentContext == MessageContext_Mulligan) {
mulliganPlayer = player; mulliganPlayer = player;
else } else {
logDoMoveCard(attributes); logDoMoveCard(attributes);
}
} }
void MessageLogWidget::logMulligan(Player *player, int number) void MessageLogWidget::logMulligan(Player *player, int number)
{ {
if (!player) if (!player) {
return; return;
if (number > -1) }
if (number > -1) {
appendHtmlServerMessage(tr("%1 takes a mulligan to %2.").arg(sanitizeHtml(player->getName())).arg(number)); appendHtmlServerMessage(tr("%1 takes a mulligan to %2.").arg(sanitizeHtml(player->getName())).arg(number));
else } else {
appendHtmlServerMessage(tr("%1 draws their initial hand.").arg(sanitizeHtml(player->getName()))); appendHtmlServerMessage(tr("%1 draws their initial hand.").arg(sanitizeHtml(player->getName())));
}
} }
void MessageLogWidget::logReplayStarted(int gameId) void MessageLogWidget::logReplayStarted(int gameId)
@ -549,11 +565,12 @@ void MessageLogWidget::logRollDie(Player *player, int sides, int roll)
appendHtmlServerMessage(tr("%1 flipped a coin. It landed as %2.") appendHtmlServerMessage(tr("%1 flipped a coin. It landed as %2.")
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg("<font class=\"blue\">" + coinOptions[roll - 1] + "</font>")); .arg("<font class=\"blue\">" + coinOptions[roll - 1] + "</font>"));
} else } else {
appendHtmlServerMessage(tr("%1 rolls a %2 with a %3-sided die.") appendHtmlServerMessage(tr("%1 rolls a %2 with a %3-sided die.")
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg("<font class=\"blue\">" + QString::number(roll) + "</font>") .arg("<font class=\"blue\">" + QString::number(roll) + "</font>")
.arg("<font class=\"blue\">" + QString::number(sides) + "</font>")); .arg("<font class=\"blue\">" + QString::number(sides) + "</font>"));
}
soundEngine->playSound("roll_dice"); soundEngine->playSound("roll_dice");
} }
@ -567,7 +584,7 @@ void MessageLogWidget::logSetActivePhase(int phase)
{ {
QString phaseName; QString phaseName;
QString color; QString color;
switch (phase) { switch (phase) { // TODO: define phases
case 0: case 0:
phaseName = tr("Untap"); phaseName = tr("Untap");
soundEngine->playSound("untap_step"); soundEngine->playSound("untap_step");
@ -651,10 +668,11 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
{ {
QString finalStr; QString finalStr;
int delta = abs(oldValue - value); int delta = abs(oldValue - value);
if (value > oldValue) if (value > oldValue) {
finalStr = tr("%1 places %2 %3 on %4 (now %5)."); finalStr = tr("%1 places %2 %3 on %4 (now %5).");
else } else {
finalStr = tr("%1 removes %2 %3 from %4 (now %5)."); finalStr = tr("%1 removes %2 %3 from %4 (now %5).");
}
QString colorStr; QString colorStr;
switch (counterId) { switch (counterId) {
@ -679,8 +697,9 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
void MessageLogWidget::logSetCounter(Player *player, QString counterName, int value, int oldValue) void MessageLogWidget::logSetCounter(Player *player, QString counterName, int value, int oldValue)
{ {
if (counterName == "life") if (counterName == "life") {
soundEngine->playSound("life_change"); soundEngine->playSound("life_change");
}
appendHtmlServerMessage(tr("%1 sets counter %2 to %3 (%4%5).") appendHtmlServerMessage(tr("%1 sets counter %2 to %3 (%4%5).")
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
@ -693,10 +712,11 @@ void MessageLogWidget::logSetCounter(Player *player, QString counterName, int va
void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap) void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap)
{ {
QString str; QString str;
if (doesntUntap) if (doesntUntap) {
str = tr("%1 sets %2 to not untap normally."); str = tr("%1 sets %2 to not untap normally.");
else } else {
str = tr("%1 sets %2 to untap normally."); str = tr("%1 sets %2 to untap normally.");
}
appendHtmlServerMessage(str.arg(sanitizeHtml(player->getName())).arg(cardLink(card->getName()))); appendHtmlServerMessage(str.arg(sanitizeHtml(player->getName())).arg(cardLink(card->getName())));
} }
@ -712,40 +732,50 @@ void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT)
} else { } else {
name = cardLink(name); name = cardLink(name);
} }
QString playerName = sanitizeHtml(player->getName());
if (newPT.isEmpty()) { if (newPT.isEmpty()) {
appendHtmlServerMessage(tr("%1 removes the PT of %2.").arg(sanitizeHtml(player->getName())).arg(name)); appendHtmlServerMessage(tr("%1 removes the PT of %2.").arg(playerName).arg(name));
} else { } else {
appendHtmlServerMessage( QString oldPT = card->getPT();
tr("%1 sets PT of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(name).arg(newPT)); if (oldPT.isEmpty()) {
appendHtmlServerMessage(
tr("%1 changes the PT of %2 from nothing to %4.").arg(playerName).arg(name).arg(newPT));
} else {
appendHtmlServerMessage(
tr("%1 changes the PT of %2 from %3 to %4.").arg(playerName).arg(name).arg(oldPT).arg(newPT));
}
} }
} }
void MessageLogWidget::logSetSideboardLock(Player *player, bool locked) void MessageLogWidget::logSetSideboardLock(Player *player, bool locked)
{ {
if (locked) if (locked) {
appendHtmlServerMessage(tr("%1 has locked their sideboard.").arg(sanitizeHtml(player->getName()))); appendHtmlServerMessage(tr("%1 has locked their sideboard.").arg(sanitizeHtml(player->getName())));
else } else {
appendHtmlServerMessage(tr("%1 has unlocked their sideboard.").arg(sanitizeHtml(player->getName()))); appendHtmlServerMessage(tr("%1 has unlocked their sideboard.").arg(sanitizeHtml(player->getName())));
}
} }
void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped) void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped)
{ {
if (tapped) if (tapped) {
soundEngine->playSound("tap_card"); soundEngine->playSound("tap_card");
else } else {
soundEngine->playSound("untap_card"); soundEngine->playSound("untap_card");
}
if (currentContext == MessageContext_MoveCard) if (currentContext == MessageContext_MoveCard) {
moveCardTapped.insert(card, tapped); moveCardTapped.insert(card, tapped);
else { } else {
QString str; QString str;
if (!card) if (!card) {
appendHtmlServerMessage((tapped ? tr("%1 taps their permanents.") : tr("%1 untaps their permanents.")) appendHtmlServerMessage((tapped ? tr("%1 taps their permanents.") : tr("%1 untaps their permanents."))
.arg(sanitizeHtml(player->getName()))); .arg(sanitizeHtml(player->getName())));
else } else {
appendHtmlServerMessage((tapped ? tr("%1 taps %2.") : tr("%1 untaps %2.")) appendHtmlServerMessage((tapped ? tr("%1 taps %2.") : tr("%1 untaps %2."))
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg(cardLink(card->getName()))); .arg(cardLink(card->getName())));
}
} }
} }
@ -809,13 +839,14 @@ void MessageLogWidget::logUnattachCard(Player *player, QString cardName)
void MessageLogWidget::logUndoDraw(Player *player, QString cardName) void MessageLogWidget::logUndoDraw(Player *player, QString cardName)
{ {
if (cardName.isEmpty()) if (cardName.isEmpty()) {
appendHtmlServerMessage(tr("%1 undoes their last draw.").arg(sanitizeHtml(player->getName()))); appendHtmlServerMessage(tr("%1 undoes their last draw.").arg(sanitizeHtml(player->getName())));
else } else {
appendHtmlServerMessage( appendHtmlServerMessage(
tr("%1 undoes their last draw (%2).") tr("%1 undoes their last draw (%2).")
.arg(sanitizeHtml(player->getName())) .arg(sanitizeHtml(player->getName()))
.arg(QString("<a href=\"card://%1\">%2</a>").arg(sanitizeHtml(cardName)).arg(sanitizeHtml(cardName)))); .arg(QString("<a href=\"card://%1\">%2</a>").arg(sanitizeHtml(cardName)).arg(sanitizeHtml(cardName))));
}
} }
void MessageLogWidget::setContextJudgeName(QString name) void MessageLogWidget::setContextJudgeName(QString name)

View file

@ -410,6 +410,10 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
connect(aIncPT, SIGNAL(triggered()), this, SLOT(actIncPT())); connect(aIncPT, SIGNAL(triggered()), this, SLOT(actIncPT()));
aDecPT = new QAction(this); aDecPT = new QAction(this);
connect(aDecPT, SIGNAL(triggered()), this, SLOT(actDecPT())); connect(aDecPT, SIGNAL(triggered()), this, SLOT(actDecPT()));
aFlowP = new QAction(this);
connect(aFlowP, SIGNAL(triggered()), this, SLOT(actFlowP()));
aFlowT = new QAction(this);
connect(aFlowT, SIGNAL(triggered()), this, SLOT(actFlowT()));
aSetPT = new QAction(this); aSetPT = new QAction(this);
connect(aSetPT, SIGNAL(triggered()), this, SLOT(actSetPT())); connect(aSetPT, SIGNAL(triggered()), this, SLOT(actSetPT()));
aResetPT = new QAction(this); aResetPT = new QAction(this);
@ -466,8 +470,9 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
} }
const QList<Player *> &players = game->getPlayers().values(); const QList<Player *> &players = game->getPlayers().values();
for (auto player : players) for (const auto player : players) {
addPlayer(player); addPlayer(player);
}
rearrangeZones(); rearrangeZones();
retranslateUi(); retranslateUi();
@ -706,8 +711,9 @@ void Player::retranslateUi()
aCardMenu->setText(tr("C&ard")); aCardMenu->setText(tr("C&ard"));
for (auto &allPlayersAction : allPlayersActions) for (auto &allPlayersAction : allPlayersActions) {
allPlayersAction->setText(tr("&All players")); allPlayersAction->setText(tr("&All players"));
}
} }
if (local) { if (local) {
@ -735,6 +741,8 @@ void Player::retranslateUi()
aDecT->setText(tr("D&ecrease toughness")); aDecT->setText(tr("D&ecrease toughness"));
aIncPT->setText(tr("In&crease power and toughness")); aIncPT->setText(tr("In&crease power and toughness"));
aDecPT->setText(tr("Dec&rease power and toughness")); aDecPT->setText(tr("Dec&rease power and toughness"));
aFlowP->setText(tr("Increase power and decrease toughness"));
aFlowT->setText(tr("Decrease power and increase toughness"));
aSetPT->setText(tr("Set &power and toughness...")); aSetPT->setText(tr("Set &power and toughness..."));
aResetPT->setText(tr("Reset p&ower and toughness")); aResetPT->setText(tr("Reset p&ower and toughness"));
aSetAnnotation->setText(tr("&Set annotation...")); aSetAnnotation->setText(tr("&Set annotation..."));
@ -787,6 +795,8 @@ void Player::setShortcutsActive()
aDecT->setShortcuts(shortcuts.getShortcut("Player/aDecT")); aDecT->setShortcuts(shortcuts.getShortcut("Player/aDecT"));
aIncPT->setShortcuts(shortcuts.getShortcut("Player/aIncPT")); aIncPT->setShortcuts(shortcuts.getShortcut("Player/aIncPT"));
aDecPT->setShortcuts(shortcuts.getShortcut("Player/aDecPT")); aDecPT->setShortcuts(shortcuts.getShortcut("Player/aDecPT"));
aFlowP->setShortcuts(shortcuts.getShortcut("Player/aFlowP"));
aFlowT->setShortcuts(shortcuts.getShortcut("Player/aFlowT"));
aSetPT->setShortcuts(shortcuts.getShortcut("Player/aSetPT")); aSetPT->setShortcuts(shortcuts.getShortcut("Player/aSetPT"));
aResetPT->setShortcuts(shortcuts.getShortcut("Player/aResetPT")); aResetPT->setShortcuts(shortcuts.getShortcut("Player/aResetPT"));
aSetAnnotation->setShortcuts(shortcuts.getShortcut("Player/aSetAnnotation")); aSetAnnotation->setShortcuts(shortcuts.getShortcut("Player/aSetAnnotation"));
@ -1849,7 +1859,7 @@ void Player::eventRevealCards(const Event_RevealCards &event)
} }
if (peeking) { if (peeking) {
for (auto &card : cardList) { for (const auto &card : cardList) {
QString cardName = QString::fromStdString(card->name()); QString cardName = QString::fromStdString(card->name());
CardItem *cardItem = zone->getCard(card->id(), QString()); CardItem *cardItem = zone->getCard(card->id(), QString());
if (!cardItem) { if (!cardItem) {
@ -2245,11 +2255,9 @@ void Player::rearrangeCounters()
// Determine total height of bounding rectangles // Determine total height of bounding rectangles
qreal totalHeight = 0; qreal totalHeight = 0;
QMapIterator<int, AbstractCounter *> counterIterator(counters); for (const auto &counter : counters) {
while (counterIterator.hasNext()) { if (counter->getShownInCounterArea()) {
counterIterator.next(); totalHeight += counter->boundingRect().height();
if (counterIterator.value()->getShownInCounterArea()) {
totalHeight += counterIterator.value()->boundingRect().height();
} }
} }
@ -2257,8 +2265,8 @@ void Player::rearrangeCounters()
qreal ySize = boundingRect().y() + marginTop; qreal ySize = boundingRect().y() + marginTop;
// Place objects // Place objects
for (counterIterator.toFront(); counterIterator.hasNext();) { for (const auto &counter : counters) {
AbstractCounter *ctr = counterIterator.next().value(); AbstractCounter *ctr = counter;
if (!ctr->getShownInCounterArea()) { if (!ctr->getShownInCounterArea()) {
continue; continue;
@ -2351,6 +2359,10 @@ void Player::actMoveCardXCardsFromTop()
defaultNumberTopCardsToPlaceBelow = number; defaultNumberTopCardsToPlaceBelow = number;
QList<QGraphicsItem *> sel = scene()->selectedItems(); QList<QGraphicsItem *> sel = scene()->selectedItems();
if (sel.isEmpty()) {
return;
}
QList<CardItem *> cardList; QList<CardItem *> cardList;
while (!sel.isEmpty()) { while (!sel.isEmpty()) {
cardList.append(qgraphicsitem_cast<CardItem *>(sel.takeFirst())); cardList.append(qgraphicsitem_cast<CardItem *>(sel.takeFirst()));
@ -2358,14 +2370,10 @@ void Player::actMoveCardXCardsFromTop()
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
ListOfCardsToMove idList; ListOfCardsToMove idList;
for (auto &i : cardList) { for (const auto &i : cardList) {
idList.add_card()->set_card_id(i->getId()); idList.add_card()->set_card_id(i->getId());
} }
if (cardList.isEmpty()) {
return;
}
int startPlayerId = cardList[0]->getZone()->getPlayer()->getId(); int startPlayerId = cardList[0]->getZone()->getPlayer()->getId();
QString startZone = cardList[0]->getZone()->getName(); QString startZone = cardList[0]->getZone()->getName();
@ -2397,7 +2405,7 @@ void Player::cardMenuAction()
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
if (a->data().toInt() <= (int)cmClone) { if (a->data().toInt() <= (int)cmClone) {
for (auto card : cardList) { for (const auto &card : cardList) {
switch (static_cast<CardMenuActionType>(a->data().toInt())) { switch (static_cast<CardMenuActionType>(a->data().toInt())) {
// Leaving both for compatibility with server // Leaving both for compatibility with server
case cmUntap: case cmUntap:
@ -2461,7 +2469,7 @@ void Player::cardMenuAction()
} }
} else { } else {
ListOfCardsToMove idList; ListOfCardsToMove idList;
for (auto &i : cardList) { for (const auto &i : cardList) {
idList.add_card()->set_card_id(i->getId()); idList.add_card()->set_card_id(i->getId());
} }
int startPlayerId = cardList[0]->getZone()->getPlayer()->getId(); int startPlayerId = cardList[0]->getZone()->getPlayer()->getId();
@ -2552,18 +2560,28 @@ void Player::cardMenuAction()
void Player::actIncPT(int deltaP, int deltaT) void Player::actIncPT(int deltaP, int deltaT)
{ {
QString ptString = "+" + QString::number(deltaP) + "/+" + QString::number(deltaT);
int playerid = id; int playerid = id;
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
QListIterator<QGraphicsItem *> j(scene()->selectedItems()); for (const auto &item : scene()->selectedItems()) {
while (j.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(j.next()); QString pt = card->getPT();
const auto ptList = parsePT(pt);
QString newpt;
if (ptList.isEmpty()) {
newpt = QString::number(deltaP) + (deltaT ? "/" + QString::number(deltaT) : "");
} else if (ptList.size() == 1) {
newpt = QString::number(ptList.at(0).toInt() + deltaP) + (deltaT ? "/" + QString::number(deltaT) : "");
} else {
newpt =
QString::number(ptList.at(0).toInt() + deltaP) + "/" + QString::number(ptList.at(1).toInt() + deltaT);
}
auto *cmd = new Command_SetCardAttr; auto *cmd = new Command_SetCardAttr;
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
cmd->set_card_id(card->getId()); cmd->set_card_id(card->getId());
cmd->set_attribute(AttrPT); cmd->set_attribute(AttrPT);
cmd->set_attr_value(ptString.toStdString()); cmd->set_attr_value(newpt.toStdString());
commandList.append(cmd); commandList.append(cmd);
if (local) { if (local) {
@ -2578,9 +2596,8 @@ void Player::actResetPT()
{ {
int playerid = id; int playerid = id;
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
QListIterator<QGraphicsItem *> selected(scene()->selectedItems()); for (const auto &item : scene()->selectedItems()) {
while (selected.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(selected.next());
QString ptString; QString ptString;
if (!card->getFaceDown()) { // leave the pt empty if the card is face down if (!card->getFaceDown()) { // leave the pt empty if the card is face down
CardInfoPtr info = card->getInfo(); CardInfoPtr info = card->getInfo();
@ -2607,39 +2624,85 @@ void Player::actResetPT()
game->sendGameCommand(prepareGameCommand(commandList), playerid); game->sendGameCommand(prepareGameCommand(commandList), playerid);
} }
QVariantList Player::parsePT(const QString &pt)
{
QVariantList ptList = QVariantList();
if (!pt.isEmpty()) {
int sep = pt.indexOf('/');
if (sep == 0) {
ptList.append(QVariant(pt.mid(1))); // cut off starting '/' and take full string
} else {
int start = 0;
for (;;) {
QString item = pt.mid(start, sep - start);
if (item.isEmpty()) {
ptList.append(QVariant(QString()));
} else if (item[0] == '+') {
ptList.append(QVariant(item.mid(1).toInt())); // add as int
} else if (item[0] == '-') {
ptList.append(QVariant(item.toInt())); // add as int
} else {
ptList.append(QVariant(item)); // add as qstring
}
if (sep == -1) {
break;
}
start = sep + 1;
sep = pt.indexOf('/', start);
}
}
}
return ptList;
}
void Player::actSetPT() void Player::actSetPT()
{ {
QString oldPT; QString oldPT;
int playerid = id; int playerid = id;
QListIterator<QGraphicsItem *> i(scene()->selectedItems()); auto sel = scene()->selectedItems();
while (i.hasNext()) { for (const auto &item : sel) {
auto *card = static_cast<CardItem *>(i.next()); auto *card = static_cast<CardItem *>(item);
if (!card->getPT().isEmpty()) { if (!card->getPT().isEmpty()) {
oldPT = card->getPT(); oldPT = card->getPT();
} }
} }
bool ok; bool ok;
dialogSemaphore = true; dialogSemaphore = true;
QString pt = QInputDialog::getText(nullptr, tr("Set power/toughness"), tr("Please enter the new PT:"), QString pt = QInputDialog::getText(nullptr, tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
QLineEdit::Normal, oldPT, &ok); oldPT, &ok);
dialogSemaphore = false; dialogSemaphore = false;
if (clearCardsToDelete()) { if (clearCardsToDelete() || !ok) {
return;
}
if (!ok) {
return; return;
} }
const auto ptList = parsePT(pt);
bool empty = ptList.isEmpty();
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
QListIterator<QGraphicsItem *> j(scene()->selectedItems()); for (const auto &item : sel) {
while (j.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(j.next());
auto *cmd = new Command_SetCardAttr; auto *cmd = new Command_SetCardAttr;
QString newpt = QString();
if (!empty) {
const auto oldpt = parsePT(card->getPT());
int ptIter = 0;
for (const auto &item : ptList) {
if (item.type() == QVariant::Int) {
int oldItem = ptIter < oldpt.size() ? oldpt.at(ptIter).toInt() : 0;
newpt += '/' + QString::number(oldItem + item.toInt());
} else {
newpt += '/' + item.toString();
}
++ptIter;
}
newpt = newpt.mid(1);
}
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
cmd->set_card_id(card->getId()); cmd->set_card_id(card->getId());
cmd->set_attribute(AttrPT); cmd->set_attribute(AttrPT);
cmd->set_attr_value(pt.toStdString()); cmd->set_attr_value(newpt.toStdString());
commandList.append(cmd); commandList.append(cmd);
if (local) { if (local) {
@ -2689,12 +2752,22 @@ void Player::actDecPT()
actIncPT(-1, -1); actIncPT(-1, -1);
} }
void Player::actFlowP()
{
actIncPT(1, -1);
}
void Player::actFlowT()
{
actIncPT(-1, 1);
}
void Player::actSetAnnotation() void Player::actSetAnnotation()
{ {
QString oldAnnotation; QString oldAnnotation;
QListIterator<QGraphicsItem *> i(scene()->selectedItems()); auto sel = scene()->selectedItems();
while (i.hasNext()) { for (const auto &item : sel) {
auto *card = static_cast<CardItem *>(i.next()); auto *card = static_cast<CardItem *>(item);
if (!card->getAnnotation().isEmpty()) { if (!card->getAnnotation().isEmpty()) {
oldAnnotation = card->getAnnotation(); oldAnnotation = card->getAnnotation();
} }
@ -2705,17 +2778,13 @@ void Player::actSetAnnotation()
QString annotation = QInputDialog::getText(nullptr, tr("Set annotation"), tr("Please enter the new annotation:"), QString annotation = QInputDialog::getText(nullptr, tr("Set annotation"), tr("Please enter the new annotation:"),
QLineEdit::Normal, oldAnnotation, &ok); QLineEdit::Normal, oldAnnotation, &ok);
dialogSemaphore = false; dialogSemaphore = false;
if (clearCardsToDelete()) { if (clearCardsToDelete() || !ok) {
return;
}
if (!ok) {
return; return;
} }
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
i.toFront(); for (const auto &item : sel) {
while (i.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(i.next());
auto *cmd = new Command_SetCardAttr; auto *cmd = new Command_SetCardAttr;
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
cmd->set_card_id(card->getId()); cmd->set_card_id(card->getId());
@ -2728,11 +2797,12 @@ void Player::actSetAnnotation()
void Player::actAttach() void Player::actAttach()
{ {
if (!game->getActiveCard()) { auto *card = game->getActiveCard();
if (!card) {
return; return;
} }
auto *arrow = new ArrowAttachItem(game->getActiveCard()); auto *arrow = new ArrowAttachItem(card);
scene()->addItem(arrow); scene()->addItem(arrow);
arrow->grabMouse(); arrow->grabMouse();
} }
@ -2754,11 +2824,10 @@ void Player::actCardCounterTrigger()
auto *action = static_cast<QAction *>(sender()); auto *action = static_cast<QAction *>(sender());
int counterId = action->data().toInt() / 1000; int counterId = action->data().toInt() / 1000;
QList<const ::google::protobuf::Message *> commandList; QList<const ::google::protobuf::Message *> commandList;
switch (action->data().toInt() % 1000) { // TODO: define case numbers switch (action->data().toInt() % 1000) {
case 9: { case 9: { // increment counter
QListIterator<QGraphicsItem *> i(scene()->selectedItems()); for (const auto &item : scene()->selectedItems()) {
while (i.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(i.next());
if (card->getCounters().value(counterId, 0) < MAX_COUNTERS_ON_CARD) { if (card->getCounters().value(counterId, 0) < MAX_COUNTERS_ON_CARD) {
auto *cmd = new Command_SetCardCounter; auto *cmd = new Command_SetCardCounter;
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
@ -2770,10 +2839,9 @@ void Player::actCardCounterTrigger()
} }
break; break;
} }
case 10: { case 10: { // decrement counter
QListIterator<QGraphicsItem *> i(scene()->selectedItems()); for (const auto &item : scene()->selectedItems()) {
while (i.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(i.next());
if (card->getCounters().value(counterId, 0)) { if (card->getCounters().value(counterId, 0)) {
auto *cmd = new Command_SetCardCounter; auto *cmd = new Command_SetCardCounter;
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
@ -2785,7 +2853,7 @@ void Player::actCardCounterTrigger()
} }
break; break;
} }
case 11: { case 11: { // set counter with dialog
bool ok; bool ok;
dialogSemaphore = true; dialogSemaphore = true;
int number = int number =
@ -2795,9 +2863,8 @@ void Player::actCardCounterTrigger()
return; return;
} }
QListIterator<QGraphicsItem *> i(scene()->selectedItems()); for (const auto &item : scene()->selectedItems()) {
while (i.hasNext()) { auto *card = static_cast<CardItem *>(item);
auto *card = static_cast<CardItem *>(i.next());
auto *cmd = new Command_SetCardCounter; auto *cmd = new Command_SetCardCounter;
cmd->set_zone(card->getZone()->getName().toStdString()); cmd->set_zone(card->getZone()->getName().toStdString());
cmd->set_card_id(card->getId()); cmd->set_card_id(card->getId());
@ -2900,9 +2967,11 @@ void Player::updateCardMenu(const CardItem *card)
if (ptMenu->isEmpty()) { if (ptMenu->isEmpty()) {
ptMenu->addAction(aIncP); ptMenu->addAction(aIncP);
ptMenu->addAction(aDecP); ptMenu->addAction(aDecP);
ptMenu->addAction(aFlowP);
ptMenu->addSeparator(); ptMenu->addSeparator();
ptMenu->addAction(aIncT); ptMenu->addAction(aIncT);
ptMenu->addAction(aDecT); ptMenu->addAction(aDecT);
ptMenu->addAction(aFlowT);
ptMenu->addSeparator(); ptMenu->addSeparator();
ptMenu->addAction(aIncPT); ptMenu->addAction(aIncPT);
ptMenu->addAction(aDecPT); ptMenu->addAction(aDecPT);
@ -2986,11 +3055,15 @@ void Player::updateCardMenu(const CardItem *card)
void Player::addRelatedCardView(const CardItem *card, QMenu *cardMenu) void Player::addRelatedCardView(const CardItem *card, QMenu *cardMenu)
{ {
if (card == nullptr || cardMenu == nullptr || card->getInfo() == nullptr) { if (!card || !cardMenu) {
return;
}
auto cardInfo = card->getInfo();
if (!cardInfo) {
return; return;
} }
QList<CardRelation *> relatedCards = card->getInfo()->getRelatedCards(); QList<CardRelation *> relatedCards = cardInfo->getRelatedCards();
if (relatedCards.isEmpty()) { if (relatedCards.isEmpty()) {
return; return;
} }
@ -3009,13 +3082,16 @@ void Player::addRelatedCardView(const CardItem *card, QMenu *cardMenu)
void Player::addRelatedCardActions(const CardItem *card, QMenu *cardMenu) void Player::addRelatedCardActions(const CardItem *card, QMenu *cardMenu)
{ {
if (card == nullptr || cardMenu == nullptr || card->getInfo() == nullptr) { if (!card || !cardMenu) {
return;
}
auto cardInfo = card->getInfo();
if (!cardInfo) {
return; return;
} }
QList<CardRelation *> relatedCards(card->getInfo()->getRelatedCards()); QList<CardRelation *> relatedCards = cardInfo->getRelatedCards();
relatedCards.append(card->getInfo()->getReverseRelatedCards2Me()); if (relatedCards.isEmpty()) {
if (relatedCards.empty()) {
return; return;
} }

View file

@ -192,6 +192,8 @@ private slots:
void actDecT(); void actDecT();
void actIncPT(); void actIncPT();
void actDecPT(); void actDecPT();
void actFlowP();
void actFlowT();
void actSetAnnotation(); void actSetAnnotation();
void actPlay(); void actPlay();
void actHide(); void actHide();
@ -215,8 +217,9 @@ private:
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter; QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT, QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT,
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone, *aMoveToTopLibrary, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aFlowP, *aFlowT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
*aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToXfromTopOfLibrary; *aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile,
*aMoveToXfromTopOfLibrary;
bool shortcutsActive; bool shortcutsActive;
int defaultNumberTopCards; int defaultNumberTopCards;
@ -288,6 +291,8 @@ private:
void eventRevealCards(const Event_RevealCards &event); void eventRevealCards(const Event_RevealCards &event);
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event); void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
QVariantList parsePT(const QString &pt);
public: public:
static const int counterAreaWidth = 55; static const int counterAreaWidth = 55;
enum CardMenuActionType enum CardMenuActionType

View file

@ -199,26 +199,30 @@ public:
QVBoxLayout *verticalLayout; QVBoxLayout *verticalLayout;
QGroupBox *groupBox_12; QGroupBox *groupBox_12;
QGridLayout *gridLayout_12; QGridLayout *gridLayout_12;
SequenceEdit *Player_aDecPT;
SequenceEdit *Player_aIncPT;
QLabel *lbl_Player_aIncPT; QLabel *lbl_Player_aIncPT;
SequenceEdit *Player_aIncPT;
QLabel *lbl_Player_aDecPT; QLabel *lbl_Player_aDecPT;
SequenceEdit *Player_aSetPT; SequenceEdit *Player_aDecPT;
QLabel *lbl_Player_aSetPT; QLabel *lbl_Player_aSetPT;
SequenceEdit *Player_aResetPT; SequenceEdit *Player_aSetPT;
QLabel *lbl_Player_aResetPT; QLabel *lbl_Player_aResetPT;
SequenceEdit *Player_aResetPT;
QGroupBox *groupBox_11; QGroupBox *groupBox_11;
QGridLayout *gridLayout_11; QGridLayout *gridLayout_11;
QLabel *lbl_Player_aDecT; QLabel *lbl_Player_aDecT;
SequenceEdit *Player_aDecT; SequenceEdit *Player_aDecT;
QLabel *lbl_Player_aIncT; QLabel *lbl_Player_aIncT;
SequenceEdit *Player_aIncT; SequenceEdit *Player_aIncT;
QLabel *lbl_Player_aFlowT;
SequenceEdit *Player_aFlowT;
QGroupBox *groupBox_10; QGroupBox *groupBox_10;
QGridLayout *gridLayout_10; QGridLayout *gridLayout_10;
QLabel *lbl_Player_aDecP; QLabel *lbl_Player_aDecP;
SequenceEdit *Player_aDecP; SequenceEdit *Player_aDecP;
SequenceEdit *Player_aIncP;
QLabel *lbl_Player_aIncP; QLabel *lbl_Player_aIncP;
SequenceEdit *Player_aIncP;
QLabel *lbl_Player_aFlowP;
SequenceEdit *Player_aFlowP;
QGroupBox *groupBox_8; QGroupBox *groupBox_8;
QGridLayout *gridLayout_5; QGridLayout *gridLayout_5;
QLabel *lbl_TabGame_phase0; QLabel *lbl_TabGame_phase0;
@ -1083,36 +1087,20 @@ public:
verticalLayout->addWidget(groupBox_12); verticalLayout->addWidget(groupBox_12);
groupBox_11 = new QGroupBox(groupBox_9);
groupBox_11->setObjectName("groupBox_11");
gridLayout_11 = new QGridLayout(groupBox_11);
gridLayout_11->setObjectName("gridLayout_11");
lbl_Player_aDecT = new QLabel(groupBox_11);
lbl_Player_aDecT->setObjectName("lbl_Player_aDecT");
gridLayout_11->addWidget(lbl_Player_aDecT, 1, 0, 1, 1);
Player_aDecT = new SequenceEdit("Player/aDecT", groupBox_11);
Player_aDecT->setObjectName("Player_aDecT");
gridLayout_11->addWidget(Player_aDecT, 1, 1, 1, 1);
lbl_Player_aIncT = new QLabel(groupBox_11);
lbl_Player_aIncT->setObjectName("lbl_Player_aIncT");
gridLayout_11->addWidget(lbl_Player_aIncT, 0, 0, 1, 1);
Player_aIncT = new SequenceEdit("Player/aIncT", groupBox_11);
Player_aIncT->setObjectName("Player_aIncT");
gridLayout_11->addWidget(Player_aIncT, 0, 1, 1, 1);
verticalLayout->addWidget(groupBox_11);
groupBox_10 = new QGroupBox(groupBox_9); groupBox_10 = new QGroupBox(groupBox_9);
groupBox_10->setObjectName("groupBox_10"); groupBox_10->setObjectName("groupBox_10");
gridLayout_10 = new QGridLayout(groupBox_10); gridLayout_10 = new QGridLayout(groupBox_10);
gridLayout_10->setObjectName("gridLayout_10"); gridLayout_10->setObjectName("gridLayout_10");
lbl_Player_aIncP = new QLabel(groupBox_10);
lbl_Player_aIncP->setObjectName("lbl_Player_aIncP");
gridLayout_10->addWidget(lbl_Player_aIncP, 0, 0, 1, 1);
Player_aIncP = new SequenceEdit("Player/aIncP", groupBox_10);
Player_aIncP->setObjectName("Player_aIncP");
gridLayout_10->addWidget(Player_aIncP, 0, 1, 1, 1);
lbl_Player_aDecP = new QLabel(groupBox_10); lbl_Player_aDecP = new QLabel(groupBox_10);
lbl_Player_aDecP->setObjectName("lbl_Player_aDecP"); lbl_Player_aDecP->setObjectName("lbl_Player_aDecP");
@ -1123,18 +1111,54 @@ public:
gridLayout_10->addWidget(Player_aDecP, 1, 1, 1, 1); gridLayout_10->addWidget(Player_aDecP, 1, 1, 1, 1);
Player_aIncP = new SequenceEdit("Player/aIncP", groupBox_10); lbl_Player_aFlowP = new QLabel(groupBox_10);
Player_aIncP->setObjectName("Player_aIncP"); lbl_Player_aFlowP->setObjectName("lbl_Player_aFlowP");
gridLayout_10->addWidget(Player_aIncP, 0, 1, 1, 1); gridLayout_10->addWidget(lbl_Player_aFlowP, 2, 0, 1, 1);
lbl_Player_aIncP = new QLabel(groupBox_10); Player_aFlowP = new SequenceEdit("Player/aFlowP", groupBox_10);
lbl_Player_aIncP->setObjectName("lbl_Player_aIncP"); Player_aFlowP->setObjectName("Player_aFlowP");
gridLayout_10->addWidget(lbl_Player_aIncP, 0, 0, 1, 1); gridLayout_10->addWidget(Player_aFlowP, 2, 1, 1, 1);
verticalLayout->addWidget(groupBox_10); verticalLayout->addWidget(groupBox_10);
groupBox_11 = new QGroupBox(groupBox_9);
groupBox_11->setObjectName("groupBox_11");
gridLayout_11 = new QGridLayout(groupBox_11);
gridLayout_11->setObjectName("gridLayout_11");
lbl_Player_aIncT = new QLabel(groupBox_11);
lbl_Player_aIncT->setObjectName("lbl_Player_aIncT");
gridLayout_11->addWidget(lbl_Player_aIncT, 0, 0, 1, 1);
Player_aIncT = new SequenceEdit("Player/aIncT", groupBox_11);
Player_aIncT->setObjectName("Player_aIncT");
gridLayout_11->addWidget(Player_aIncT, 0, 1, 1, 1);
lbl_Player_aDecT = new QLabel(groupBox_11);
lbl_Player_aDecT->setObjectName("lbl_Player_aDecT");
gridLayout_11->addWidget(lbl_Player_aDecT, 1, 0, 1, 1);
Player_aDecT = new SequenceEdit("Player/aDecT", groupBox_11);
Player_aDecT->setObjectName("Player_aDecT");
gridLayout_11->addWidget(Player_aDecT, 1, 1, 1, 1);
lbl_Player_aFlowT = new QLabel(groupBox_11);
lbl_Player_aFlowT->setObjectName("lbl_Player_aFlowT");
gridLayout_11->addWidget(lbl_Player_aFlowT, 2, 0, 1, 1);
Player_aFlowT = new SequenceEdit("Player/aFlowT", groupBox_11);
Player_aFlowT->setObjectName("Player_aFlowT");
gridLayout_11->addWidget(Player_aFlowT, 2, 1, 1, 1);
verticalLayout->addWidget(groupBox_11);
gridLayout_17->addWidget(groupBox_9, 0, 1, 1, 1); gridLayout_17->addWidget(groupBox_9, 0, 1, 1, 1);
groupBox_8 = new QGroupBox(tab_2); groupBox_8 = new QGroupBox(tab_2);
@ -1929,9 +1953,11 @@ public:
groupBox_11->setTitle(QApplication::translate("shortcutsTab", "Toughness")); groupBox_11->setTitle(QApplication::translate("shortcutsTab", "Toughness"));
lbl_Player_aDecT->setText(QApplication::translate("shortcutsTab", "Remove (-0/-1)")); lbl_Player_aDecT->setText(QApplication::translate("shortcutsTab", "Remove (-0/-1)"));
lbl_Player_aIncT->setText(QApplication::translate("shortcutsTab", "Add (+0/+1)")); lbl_Player_aIncT->setText(QApplication::translate("shortcutsTab", "Add (+0/+1)"));
lbl_Player_aFlowT->setText(QApplication::translate("shortcutsTab", "Move (-1/+1)"));
groupBox_10->setTitle(QApplication::translate("shortcutsTab", "Power")); groupBox_10->setTitle(QApplication::translate("shortcutsTab", "Power"));
lbl_Player_aDecP->setText(QApplication::translate("shortcutsTab", "Remove (-1/-nullptr)")); lbl_Player_aDecP->setText(QApplication::translate("shortcutsTab", "Remove (-1/-0)"));
lbl_Player_aIncP->setText(QApplication::translate("shortcutsTab", "Add (+1/+nullptr)")); lbl_Player_aIncP->setText(QApplication::translate("shortcutsTab", "Add (+1/+0)"));
lbl_Player_aFlowP->setText(QApplication::translate("shortcutsTab", "Move (+1/-1)"));
groupBox_8->setTitle(QApplication::translate("shortcutsTab", "Game Phases")); groupBox_8->setTitle(QApplication::translate("shortcutsTab", "Game Phases"));
lbl_TabGame_phase0->setText(QApplication::translate("shortcutsTab", "Untap")); lbl_TabGame_phase0->setText(QApplication::translate("shortcutsTab", "Untap"));
lbl_TabGame_phase1->setText(QApplication::translate("shortcutsTab", "Upkeep")); lbl_TabGame_phase1->setText(QApplication::translate("shortcutsTab", "Upkeep"));

View file

@ -139,6 +139,8 @@ private:
{"Player/aIncT", parseSequenceString("Alt++")}, {"Player/aIncT", parseSequenceString("Alt++")},
{"Player/aSetPT", parseSequenceString("Ctrl+P")}, {"Player/aSetPT", parseSequenceString("Ctrl+P")},
{"Player/aResetPT", parseSequenceString("Ctrl+Alt+0")}, {"Player/aResetPT", parseSequenceString("Ctrl+Alt+0")},
{"Player/aFlowP", parseSequenceString("")},
{"Player/aFlowT", parseSequenceString("")},
{"Player/aConcede", parseSequenceString("F2")}, {"Player/aConcede", parseSequenceString("F2")},
{"Player/aLeaveGame", parseSequenceString("Ctrl+Q")}, {"Player/aLeaveGame", parseSequenceString("Ctrl+Q")},

View file

@ -24,8 +24,7 @@
Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone) Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone)
: zone(_zone), id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), : zone(_zone), id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false),
facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false), facedown(false), color(), ptString(), annotation(), destroyOnZoneChange(false), doesntUntap(false), parentCard(0)
doesntUntap(false), parentCard(0)
{ {
} }
@ -44,8 +43,7 @@ void Server_Card::resetState()
counters.clear(); counters.clear();
setTapped(false); setTapped(false);
setAttacking(false); setAttacking(false);
power = -1; setPT(QString());
toughness = -1;
setAnnotation(QString()); setAnnotation(QString());
setDoesntUntap(false); setDoesntUntap(false);
} }
@ -89,40 +87,6 @@ void Server_Card::setCounter(int id, int value)
counters.remove(id); counters.remove(id);
} }
void Server_Card::setPT(const QString &_pt)
{
if (_pt.isEmpty()) {
power = 0;
toughness = -1;
} else {
int sep = _pt.indexOf('/');
QString p1 = _pt.left(sep);
QString p2 = _pt.mid(sep + 1);
if (p1.isEmpty() || p2.isEmpty())
return;
if ((p1[0] == '+') || (p2[0] == '+'))
if (toughness < 0)
toughness = 0;
if (p1[0] == '+')
power += p1.mid(1).toInt();
else
power = p1.toInt();
if (p2[0] == '+')
toughness += p2.mid(1).toInt();
else
toughness = p2.toInt();
}
}
QString Server_Card::getPT() const
{
if (toughness < 0)
return QString("");
return QString::number(power) + "/" + QString::number(toughness);
}
void Server_Card::setParentCard(Server_Card *_parentCard) void Server_Card::setParentCard(Server_Card *_parentCard)
{ {
if (parentCard) if (parentCard)
@ -140,24 +104,28 @@ void Server_Card::getInfo(ServerInfo_Card *info)
info->set_name(displayedName.toStdString()); info->set_name(displayedName.toStdString());
info->set_x(coord_x); info->set_x(coord_x);
info->set_y(coord_y); info->set_y(coord_y);
QString ptStr = getPT();
if (facedown) { if (facedown) {
info->set_face_down(true); info->set_face_down(true);
ptStr = getPT();
} }
info->set_tapped(tapped); info->set_tapped(tapped);
if (attacking) if (attacking) {
info->set_attacking(true); info->set_attacking(true);
if (!color.isEmpty()) }
if (!color.isEmpty()) {
info->set_color(color.toStdString()); info->set_color(color.toStdString());
if (!ptStr.isEmpty()) }
info->set_pt(ptStr.toStdString()); if (!ptString.isEmpty()) {
if (!annotation.isEmpty()) info->set_pt(ptString.toStdString());
}
if (!annotation.isEmpty()) {
info->set_annotation(annotation.toStdString()); info->set_annotation(annotation.toStdString());
if (destroyOnZoneChange) }
if (destroyOnZoneChange) {
info->set_destroy_on_zone_change(true); info->set_destroy_on_zone_change(true);
if (doesntUntap) }
if (doesntUntap) {
info->set_doesnt_untap(true); info->set_doesnt_untap(true);
}
QMapIterator<int, int> cardCounterIterator(counters); QMapIterator<int, int> cardCounterIterator(counters);
while (cardCounterIterator.hasNext()) { while (cardCounterIterator.hasNext()) {
@ -172,4 +140,4 @@ void Server_Card::getInfo(ServerInfo_Card *info)
info->set_attach_zone(parentCard->getZone()->getName().toStdString()); info->set_attach_zone(parentCard->getZone()->getName().toStdString());
info->set_attach_card_id(parentCard->getId()); info->set_attach_card_id(parentCard->getId());
} }
} }

View file

@ -41,7 +41,7 @@ private:
bool attacking; bool attacking;
bool facedown; bool facedown;
QString color; QString color;
int power, toughness; QString ptString;
QString annotation; QString annotation;
bool destroyOnZoneChange; bool destroyOnZoneChange;
bool doesntUntap; bool doesntUntap;
@ -102,7 +102,10 @@ public:
{ {
return color; return color;
} }
QString getPT() const; QString getPT() const
{
return ptString;
}
QString getAnnotation() const QString getAnnotation() const
{ {
return annotation; return annotation;
@ -154,7 +157,10 @@ public:
{ {
color = _color; color = _color;
} }
void setPT(const QString &_pt); void setPT(const QString &_pt)
{
ptString = _pt;
}
void setAnnotation(const QString &_annotation) void setAnnotation(const QString &_annotation)
{ {
annotation = _annotation; annotation = _annotation;

File diff suppressed because it is too large Load diff