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:
parent
18ad3cf4a5
commit
9411396b97
13 changed files with 831 additions and 498 deletions
|
@ -347,7 +347,6 @@
|
|||
<file>resources/userlevels/admin_vip_buddy.svg</file>
|
||||
|
||||
<!-- 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/arrows.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/github_logo.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/tip_of_the_day.png</file>
|
||||
<file>resources/tips/tips_of_the_day.xml</file>
|
||||
|
||||
<file>resources/help/search.md</file>
|
||||
</qresource>
|
||||
|
|
BIN
cockatrice/resources/tips/images/setpt.png
Normal file
BIN
cockatrice/resources/tips/images/setpt.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
cockatrice/resources/tips/images/shortcuts.png
Normal file
BIN
cockatrice/resources/tips/images/shortcuts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
|
@ -63,6 +63,7 @@
|
|||
<br>Change Life: CTRL + L
|
||||
<br>All shortcuts can be customized via Settings->Shortcuts!
|
||||
</text>
|
||||
<image>shortcuts.png</image>
|
||||
<date>2018-03-01</date>
|
||||
</tip>
|
||||
<tip>
|
||||
|
@ -89,4 +90,10 @@
|
|||
<image>counter_expression.png</image>
|
||||
<date>2019-02-02</date>
|
||||
</tip>
|
||||
<tip>
|
||||
<title>Power and Toughness</title>
|
||||
<text>You can add and subtract to a creature's stats.<br>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.<br>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>
|
|
@ -106,17 +106,12 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
painter->save();
|
||||
transformPainter(painter, translatedSize, tapAngle);
|
||||
|
||||
if (info) {
|
||||
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 {
|
||||
if (!getFaceDown() && info && pt == info->getPowTough()) {
|
||||
painter->setPen(Qt::white);
|
||||
} else {
|
||||
painter->setPen(QColor(255, 150, 0)); // dark orange
|
||||
}
|
||||
|
||||
painter->setBackground(Qt::black);
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
|
||||
|
|
|
@ -68,54 +68,61 @@ MessageLogWidget::getFromStr(CardZone *zone, QString cardName, int position, boo
|
|||
QString fromStr;
|
||||
QString zoneName = zone->getName();
|
||||
|
||||
if (zoneName == tableConstant())
|
||||
if (zoneName == tableConstant()) {
|
||||
fromStr = tr(" from play");
|
||||
else if (zoneName == graveyardConstant())
|
||||
} else if (zoneName == graveyardConstant()) {
|
||||
fromStr = tr(" from their graveyard");
|
||||
else if (zoneName == exileConstant())
|
||||
} else if (zoneName == exileConstant()) {
|
||||
fromStr = tr(" from exile");
|
||||
else if (zoneName == handConstant())
|
||||
} else if (zoneName == handConstant()) {
|
||||
fromStr = tr(" from their hand");
|
||||
else if (zoneName == deckConstant()) {
|
||||
} else if (zoneName == deckConstant()) {
|
||||
if (position == 0) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (ownerChange)
|
||||
if (ownerChange) {
|
||||
cardName = tr("the top card of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
} else {
|
||||
cardName = tr("the top card of their library");
|
||||
}
|
||||
cardNameContainsStartZone = true;
|
||||
} else {
|
||||
if (ownerChange)
|
||||
if (ownerChange) {
|
||||
fromStr = tr(" from the top of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
} else {
|
||||
fromStr = tr(" from the top of their library");
|
||||
}
|
||||
}
|
||||
} else if (position >= zone->getCards().size() - 1) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (ownerChange)
|
||||
if (ownerChange) {
|
||||
cardName = tr("the bottom card of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
} else {
|
||||
cardName = tr("the bottom card of their library");
|
||||
}
|
||||
cardNameContainsStartZone = true;
|
||||
} else {
|
||||
if (ownerChange)
|
||||
if (ownerChange) {
|
||||
fromStr = tr(" from the bottom of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
} else {
|
||||
fromStr = tr(" from the bottom of their library");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (ownerChange)
|
||||
if (ownerChange) {
|
||||
fromStr = tr(" from %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
} else {
|
||||
fromStr = tr(" from their library");
|
||||
}
|
||||
}
|
||||
} else if (zoneName == sideboardConstant())
|
||||
} else if (zoneName == sideboardConstant()) {
|
||||
fromStr = tr(" from sideboard");
|
||||
else if (zoneName == stackConstant())
|
||||
} else if (zoneName == stackConstant()) {
|
||||
fromStr = tr(" from the stack");
|
||||
}
|
||||
|
||||
if (!cardNameContainsStartZone)
|
||||
if (!cardNameContainsStartZone) {
|
||||
cardName.clear();
|
||||
}
|
||||
return QPair<QString, QString>(cardName, fromStr);
|
||||
}
|
||||
|
||||
|
@ -123,9 +130,9 @@ void MessageLogWidget::containerProcessingDone()
|
|||
{
|
||||
|
||||
if (currentContext == MessageContext_MoveCard) {
|
||||
for (auto &i : moveCardQueue)
|
||||
for (auto &i : moveCardQueue) {
|
||||
logDoMoveCard(i);
|
||||
|
||||
}
|
||||
moveCardQueue.clear();
|
||||
moveCardTapped.clear();
|
||||
moveCardExtras.clear();
|
||||
|
@ -141,9 +148,9 @@ void MessageLogWidget::containerProcessingDone()
|
|||
|
||||
void MessageLogWidget::containerProcessingStarted(const GameEventContext &context)
|
||||
{
|
||||
if (context.HasExtension(Context_MoveCard::ext))
|
||||
if (context.HasExtension(Context_MoveCard::ext)) {
|
||||
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);
|
||||
currentContext = MessageContext_Mulligan;
|
||||
mulliganPlayer = nullptr;
|
||||
|
@ -258,13 +265,14 @@ void MessageLogWidget::logCreateToken(Player *player, QString cardName, QString
|
|||
|
||||
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));
|
||||
else
|
||||
} else {
|
||||
appendHtmlServerMessage(tr("%1 has loaded a deck with %2 sideboard cards (%3).")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font class=\"blue\">" + QString::number(sideboardSize) + "</font>")
|
||||
.arg(deckHash));
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
if ((startZone == tableConstant() && targetZone == tableConstant() && !ownerChanged) ||
|
||||
(startZone == handConstant() && targetZone == handConstant()) ||
|
||||
(startZone == exileConstant() && targetZone == exileConstant()))
|
||||
(startZone == exileConstant() && targetZone == exileConstant())) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString cardName = lmc.cardName;
|
||||
QPair<QString, QString> nameFrom = getFromStr(lmc.startZone, cardName, lmc.oldX, ownerChanged);
|
||||
if (!nameFrom.first.isEmpty())
|
||||
if (!nameFrom.first.isEmpty()) {
|
||||
cardName = nameFrom.first;
|
||||
}
|
||||
|
||||
QString cardStr;
|
||||
if (!nameFrom.first.isEmpty())
|
||||
if (!nameFrom.first.isEmpty()) {
|
||||
cardStr = cardName;
|
||||
else if (cardName.isEmpty())
|
||||
} else if (cardName.isEmpty()) {
|
||||
cardStr = tr("a card");
|
||||
else
|
||||
} else {
|
||||
cardStr = cardLink(cardName);
|
||||
}
|
||||
|
||||
if (ownerChanged && (lmc.startZone->getPlayer() == lmc.player)) {
|
||||
appendHtmlServerMessage(tr("%1 gives %2 control over %3.")
|
||||
|
@ -310,17 +321,18 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
|
|||
bool usesNewX = false;
|
||||
if (targetZone == tableConstant()) {
|
||||
soundEngine->playSound("play_card");
|
||||
if (moveCardTapped.value(lmc.card))
|
||||
if (moveCardTapped.value(lmc.card)) {
|
||||
finalStr = tr("%1 puts %2 into play tapped%3.");
|
||||
else
|
||||
} else {
|
||||
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.");
|
||||
else if (targetZone == exileConstant())
|
||||
} else if (targetZone == exileConstant()) {
|
||||
finalStr = tr("%1 exiles %2%3.");
|
||||
else if (targetZone == handConstant())
|
||||
} else if (targetZone == handConstant()) {
|
||||
finalStr = tr("%1 moves %2%3 to their hand.");
|
||||
else if (targetZone == deckConstant()) {
|
||||
} else if (targetZone == deckConstant()) {
|
||||
if (moveCardExtras.contains("shuffle_partial")) {
|
||||
finalStr = tr("%1 puts %2%3 on bottom of their library randomly.");
|
||||
} else if (lmc.newX == -1) {
|
||||
|
@ -330,13 +342,13 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
|
|||
} else if (lmc.newX == 0) {
|
||||
finalStr = tr("%1 puts %2%3 on top of their library.");
|
||||
} else {
|
||||
lmc.newX++;
|
||||
++lmc.newX;
|
||||
usesNewX = true;
|
||||
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.");
|
||||
else if (targetZone == stackConstant()) {
|
||||
} else if (targetZone == stackConstant()) {
|
||||
soundEngine->playSound("play_card");
|
||||
finalStr = tr("%1 plays %2%3.");
|
||||
}
|
||||
|
@ -351,9 +363,9 @@ void MessageLogWidget::logDoMoveCard(LogMoveCard &lmc)
|
|||
|
||||
void MessageLogWidget::logDrawCards(Player *player, int number)
|
||||
{
|
||||
if (currentContext == MessageContext_Mulligan)
|
||||
if (currentContext == MessageContext_Mulligan) {
|
||||
mulliganPlayer = player;
|
||||
else {
|
||||
} else {
|
||||
soundEngine->playSound("draw_card");
|
||||
appendHtmlServerMessage(tr("%1 draws %2 card(s).", "", number)
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
|
@ -363,16 +375,17 @@ void MessageLogWidget::logDrawCards(Player *player, int number)
|
|||
|
||||
void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCards)
|
||||
{
|
||||
if (numberCards == -1)
|
||||
if (numberCards == -1) {
|
||||
appendHtmlServerMessage(tr("%1 is looking at %2.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(zone->getTranslatedName(zone->getPlayer() == player, CaseLookAtZone)));
|
||||
else
|
||||
} else {
|
||||
appendHtmlServerMessage(
|
||||
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(zone->getTranslatedName(zone->getPlayer() == player, CaseTopCardsOfZone))
|
||||
.arg("<font class=\"blue\">" + QString::number(numberCards) + "</font>"));
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown)
|
||||
|
@ -438,22 +451,25 @@ void MessageLogWidget::logMoveCard(Player *player,
|
|||
int newX)
|
||||
{
|
||||
LogMoveCard attributes = {player, card, card->getName(), startZone, oldX, targetZone, newX};
|
||||
if (currentContext == MessageContext_MoveCard)
|
||||
if (currentContext == MessageContext_MoveCard) {
|
||||
moveCardQueue.append(attributes);
|
||||
else if (currentContext == MessageContext_Mulligan)
|
||||
} else if (currentContext == MessageContext_Mulligan) {
|
||||
mulliganPlayer = player;
|
||||
else
|
||||
} else {
|
||||
logDoMoveCard(attributes);
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLogWidget::logMulligan(Player *player, int number)
|
||||
{
|
||||
if (!player)
|
||||
if (!player) {
|
||||
return;
|
||||
if (number > -1)
|
||||
}
|
||||
if (number > -1) {
|
||||
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())));
|
||||
}
|
||||
}
|
||||
|
||||
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.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font class=\"blue\">" + coinOptions[roll - 1] + "</font>"));
|
||||
} else
|
||||
} else {
|
||||
appendHtmlServerMessage(tr("%1 rolls a %2 with a %3-sided die.")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg("<font class=\"blue\">" + QString::number(roll) + "</font>")
|
||||
.arg("<font class=\"blue\">" + QString::number(sides) + "</font>"));
|
||||
}
|
||||
soundEngine->playSound("roll_dice");
|
||||
}
|
||||
|
||||
|
@ -567,7 +584,7 @@ void MessageLogWidget::logSetActivePhase(int phase)
|
|||
{
|
||||
QString phaseName;
|
||||
QString color;
|
||||
switch (phase) {
|
||||
switch (phase) { // TODO: define phases
|
||||
case 0:
|
||||
phaseName = tr("Untap");
|
||||
soundEngine->playSound("untap_step");
|
||||
|
@ -651,10 +668,11 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
|
|||
{
|
||||
QString finalStr;
|
||||
int delta = abs(oldValue - value);
|
||||
if (value > oldValue)
|
||||
if (value > oldValue) {
|
||||
finalStr = tr("%1 places %2 %3 on %4 (now %5).");
|
||||
else
|
||||
} else {
|
||||
finalStr = tr("%1 removes %2 %3 from %4 (now %5).");
|
||||
}
|
||||
|
||||
QString colorStr;
|
||||
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)
|
||||
{
|
||||
if (counterName == "life")
|
||||
if (counterName == "life") {
|
||||
soundEngine->playSound("life_change");
|
||||
}
|
||||
|
||||
appendHtmlServerMessage(tr("%1 sets counter %2 to %3 (%4%5).")
|
||||
.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)
|
||||
{
|
||||
QString str;
|
||||
if (doesntUntap)
|
||||
if (doesntUntap) {
|
||||
str = tr("%1 sets %2 to not untap normally.");
|
||||
else
|
||||
} else {
|
||||
str = tr("%1 sets %2 to untap normally.");
|
||||
}
|
||||
appendHtmlServerMessage(str.arg(sanitizeHtml(player->getName())).arg(cardLink(card->getName())));
|
||||
}
|
||||
|
||||
|
@ -712,40 +732,50 @@ void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT)
|
|||
} else {
|
||||
name = cardLink(name);
|
||||
}
|
||||
QString playerName = sanitizeHtml(player->getName());
|
||||
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 {
|
||||
appendHtmlServerMessage(
|
||||
tr("%1 sets PT of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(name).arg(newPT));
|
||||
QString oldPT = card->getPT();
|
||||
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)
|
||||
{
|
||||
if (locked)
|
||||
if (locked) {
|
||||
appendHtmlServerMessage(tr("%1 has locked their sideboard.").arg(sanitizeHtml(player->getName())));
|
||||
else
|
||||
} else {
|
||||
appendHtmlServerMessage(tr("%1 has unlocked their sideboard.").arg(sanitizeHtml(player->getName())));
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped)
|
||||
{
|
||||
if (tapped)
|
||||
if (tapped) {
|
||||
soundEngine->playSound("tap_card");
|
||||
else
|
||||
} else {
|
||||
soundEngine->playSound("untap_card");
|
||||
}
|
||||
|
||||
if (currentContext == MessageContext_MoveCard)
|
||||
if (currentContext == MessageContext_MoveCard) {
|
||||
moveCardTapped.insert(card, tapped);
|
||||
else {
|
||||
} else {
|
||||
QString str;
|
||||
if (!card)
|
||||
if (!card) {
|
||||
appendHtmlServerMessage((tapped ? tr("%1 taps their permanents.") : tr("%1 untaps their permanents."))
|
||||
.arg(sanitizeHtml(player->getName())));
|
||||
else
|
||||
} else {
|
||||
appendHtmlServerMessage((tapped ? tr("%1 taps %2.") : tr("%1 untaps %2."))
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(cardLink(card->getName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -809,13 +839,14 @@ void MessageLogWidget::logUnattachCard(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())));
|
||||
else
|
||||
} else {
|
||||
appendHtmlServerMessage(
|
||||
tr("%1 undoes their last draw (%2).")
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(QString("<a href=\"card://%1\">%2</a>").arg(sanitizeHtml(cardName)).arg(sanitizeHtml(cardName))));
|
||||
}
|
||||
}
|
||||
|
||||
void MessageLogWidget::setContextJudgeName(QString name)
|
||||
|
|
|
@ -410,6 +410,10 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
|||
connect(aIncPT, SIGNAL(triggered()), this, SLOT(actIncPT()));
|
||||
aDecPT = new QAction(this);
|
||||
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);
|
||||
connect(aSetPT, SIGNAL(triggered()), this, SLOT(actSetPT()));
|
||||
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();
|
||||
for (auto player : players)
|
||||
for (const auto player : players) {
|
||||
addPlayer(player);
|
||||
}
|
||||
|
||||
rearrangeZones();
|
||||
retranslateUi();
|
||||
|
@ -706,8 +711,9 @@ void Player::retranslateUi()
|
|||
|
||||
aCardMenu->setText(tr("C&ard"));
|
||||
|
||||
for (auto &allPlayersAction : allPlayersActions)
|
||||
for (auto &allPlayersAction : allPlayersActions) {
|
||||
allPlayersAction->setText(tr("&All players"));
|
||||
}
|
||||
}
|
||||
|
||||
if (local) {
|
||||
|
@ -735,6 +741,8 @@ void Player::retranslateUi()
|
|||
aDecT->setText(tr("D&ecrease toughness"));
|
||||
aIncPT->setText(tr("In&crease 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..."));
|
||||
aResetPT->setText(tr("Reset p&ower and toughness"));
|
||||
aSetAnnotation->setText(tr("&Set annotation..."));
|
||||
|
@ -787,6 +795,8 @@ void Player::setShortcutsActive()
|
|||
aDecT->setShortcuts(shortcuts.getShortcut("Player/aDecT"));
|
||||
aIncPT->setShortcuts(shortcuts.getShortcut("Player/aIncPT"));
|
||||
aDecPT->setShortcuts(shortcuts.getShortcut("Player/aDecPT"));
|
||||
aFlowP->setShortcuts(shortcuts.getShortcut("Player/aFlowP"));
|
||||
aFlowT->setShortcuts(shortcuts.getShortcut("Player/aFlowT"));
|
||||
aSetPT->setShortcuts(shortcuts.getShortcut("Player/aSetPT"));
|
||||
aResetPT->setShortcuts(shortcuts.getShortcut("Player/aResetPT"));
|
||||
aSetAnnotation->setShortcuts(shortcuts.getShortcut("Player/aSetAnnotation"));
|
||||
|
@ -1849,7 +1859,7 @@ void Player::eventRevealCards(const Event_RevealCards &event)
|
|||
}
|
||||
|
||||
if (peeking) {
|
||||
for (auto &card : cardList) {
|
||||
for (const auto &card : cardList) {
|
||||
QString cardName = QString::fromStdString(card->name());
|
||||
CardItem *cardItem = zone->getCard(card->id(), QString());
|
||||
if (!cardItem) {
|
||||
|
@ -2245,11 +2255,9 @@ void Player::rearrangeCounters()
|
|||
|
||||
// Determine total height of bounding rectangles
|
||||
qreal totalHeight = 0;
|
||||
QMapIterator<int, AbstractCounter *> counterIterator(counters);
|
||||
while (counterIterator.hasNext()) {
|
||||
counterIterator.next();
|
||||
if (counterIterator.value()->getShownInCounterArea()) {
|
||||
totalHeight += counterIterator.value()->boundingRect().height();
|
||||
for (const auto &counter : counters) {
|
||||
if (counter->getShownInCounterArea()) {
|
||||
totalHeight += counter->boundingRect().height();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2257,8 +2265,8 @@ void Player::rearrangeCounters()
|
|||
qreal ySize = boundingRect().y() + marginTop;
|
||||
|
||||
// Place objects
|
||||
for (counterIterator.toFront(); counterIterator.hasNext();) {
|
||||
AbstractCounter *ctr = counterIterator.next().value();
|
||||
for (const auto &counter : counters) {
|
||||
AbstractCounter *ctr = counter;
|
||||
|
||||
if (!ctr->getShownInCounterArea()) {
|
||||
continue;
|
||||
|
@ -2351,6 +2359,10 @@ void Player::actMoveCardXCardsFromTop()
|
|||
defaultNumberTopCardsToPlaceBelow = number;
|
||||
|
||||
QList<QGraphicsItem *> sel = scene()->selectedItems();
|
||||
if (sel.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<CardItem *> cardList;
|
||||
while (!sel.isEmpty()) {
|
||||
cardList.append(qgraphicsitem_cast<CardItem *>(sel.takeFirst()));
|
||||
|
@ -2358,14 +2370,10 @@ void Player::actMoveCardXCardsFromTop()
|
|||
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
ListOfCardsToMove idList;
|
||||
for (auto &i : cardList) {
|
||||
for (const auto &i : cardList) {
|
||||
idList.add_card()->set_card_id(i->getId());
|
||||
}
|
||||
|
||||
if (cardList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int startPlayerId = cardList[0]->getZone()->getPlayer()->getId();
|
||||
QString startZone = cardList[0]->getZone()->getName();
|
||||
|
||||
|
@ -2397,7 +2405,7 @@ void Player::cardMenuAction()
|
|||
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
if (a->data().toInt() <= (int)cmClone) {
|
||||
for (auto card : cardList) {
|
||||
for (const auto &card : cardList) {
|
||||
switch (static_cast<CardMenuActionType>(a->data().toInt())) {
|
||||
// Leaving both for compatibility with server
|
||||
case cmUntap:
|
||||
|
@ -2461,7 +2469,7 @@ void Player::cardMenuAction()
|
|||
}
|
||||
} else {
|
||||
ListOfCardsToMove idList;
|
||||
for (auto &i : cardList) {
|
||||
for (const auto &i : cardList) {
|
||||
idList.add_card()->set_card_id(i->getId());
|
||||
}
|
||||
int startPlayerId = cardList[0]->getZone()->getPlayer()->getId();
|
||||
|
@ -2552,18 +2560,28 @@ void Player::cardMenuAction()
|
|||
|
||||
void Player::actIncPT(int deltaP, int deltaT)
|
||||
{
|
||||
QString ptString = "+" + QString::number(deltaP) + "/+" + QString::number(deltaT);
|
||||
int playerid = id;
|
||||
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
QListIterator<QGraphicsItem *> j(scene()->selectedItems());
|
||||
while (j.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(j.next());
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
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;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_attribute(AttrPT);
|
||||
cmd->set_attr_value(ptString.toStdString());
|
||||
cmd->set_attr_value(newpt.toStdString());
|
||||
commandList.append(cmd);
|
||||
|
||||
if (local) {
|
||||
|
@ -2578,9 +2596,8 @@ void Player::actResetPT()
|
|||
{
|
||||
int playerid = id;
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
QListIterator<QGraphicsItem *> selected(scene()->selectedItems());
|
||||
while (selected.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(selected.next());
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
QString ptString;
|
||||
if (!card->getFaceDown()) { // leave the pt empty if the card is face down
|
||||
CardInfoPtr info = card->getInfo();
|
||||
|
@ -2607,39 +2624,85 @@ void Player::actResetPT()
|
|||
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()
|
||||
{
|
||||
QString oldPT;
|
||||
int playerid = id;
|
||||
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(i.next());
|
||||
auto sel = scene()->selectedItems();
|
||||
for (const auto &item : sel) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
if (!card->getPT().isEmpty()) {
|
||||
oldPT = card->getPT();
|
||||
}
|
||||
}
|
||||
bool ok;
|
||||
dialogSemaphore = true;
|
||||
QString pt = QInputDialog::getText(nullptr, tr("Set power/toughness"), tr("Please enter the new PT:"),
|
||||
QLineEdit::Normal, oldPT, &ok);
|
||||
QString pt = QInputDialog::getText(nullptr, tr("Change power/toughness"), tr("Change stats to:"), QLineEdit::Normal,
|
||||
oldPT, &ok);
|
||||
dialogSemaphore = false;
|
||||
if (clearCardsToDelete()) {
|
||||
return;
|
||||
}
|
||||
if (!ok) {
|
||||
if (clearCardsToDelete() || !ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto ptList = parsePT(pt);
|
||||
bool empty = ptList.isEmpty();
|
||||
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
QListIterator<QGraphicsItem *> j(scene()->selectedItems());
|
||||
while (j.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(j.next());
|
||||
for (const auto &item : sel) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
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_card_id(card->getId());
|
||||
cmd->set_attribute(AttrPT);
|
||||
cmd->set_attr_value(pt.toStdString());
|
||||
cmd->set_attr_value(newpt.toStdString());
|
||||
commandList.append(cmd);
|
||||
|
||||
if (local) {
|
||||
|
@ -2689,12 +2752,22 @@ void Player::actDecPT()
|
|||
actIncPT(-1, -1);
|
||||
}
|
||||
|
||||
void Player::actFlowP()
|
||||
{
|
||||
actIncPT(1, -1);
|
||||
}
|
||||
|
||||
void Player::actFlowT()
|
||||
{
|
||||
actIncPT(-1, 1);
|
||||
}
|
||||
|
||||
void Player::actSetAnnotation()
|
||||
{
|
||||
QString oldAnnotation;
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(i.next());
|
||||
auto sel = scene()->selectedItems();
|
||||
for (const auto &item : sel) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
if (!card->getAnnotation().isEmpty()) {
|
||||
oldAnnotation = card->getAnnotation();
|
||||
}
|
||||
|
@ -2705,17 +2778,13 @@ void Player::actSetAnnotation()
|
|||
QString annotation = QInputDialog::getText(nullptr, tr("Set annotation"), tr("Please enter the new annotation:"),
|
||||
QLineEdit::Normal, oldAnnotation, &ok);
|
||||
dialogSemaphore = false;
|
||||
if (clearCardsToDelete()) {
|
||||
return;
|
||||
}
|
||||
if (!ok) {
|
||||
if (clearCardsToDelete() || !ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
i.toFront();
|
||||
while (i.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(i.next());
|
||||
for (const auto &item : sel) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
auto *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
|
@ -2728,11 +2797,12 @@ void Player::actSetAnnotation()
|
|||
|
||||
void Player::actAttach()
|
||||
{
|
||||
if (!game->getActiveCard()) {
|
||||
auto *card = game->getActiveCard();
|
||||
if (!card) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto *arrow = new ArrowAttachItem(game->getActiveCard());
|
||||
auto *arrow = new ArrowAttachItem(card);
|
||||
scene()->addItem(arrow);
|
||||
arrow->grabMouse();
|
||||
}
|
||||
|
@ -2754,11 +2824,10 @@ void Player::actCardCounterTrigger()
|
|||
auto *action = static_cast<QAction *>(sender());
|
||||
int counterId = action->data().toInt() / 1000;
|
||||
QList<const ::google::protobuf::Message *> commandList;
|
||||
switch (action->data().toInt() % 1000) { // TODO: define case numbers
|
||||
case 9: {
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(i.next());
|
||||
switch (action->data().toInt() % 1000) {
|
||||
case 9: { // increment counter
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
if (card->getCounters().value(counterId, 0) < MAX_COUNTERS_ON_CARD) {
|
||||
auto *cmd = new Command_SetCardCounter;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
|
@ -2770,10 +2839,9 @@ void Player::actCardCounterTrigger()
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 10: {
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(i.next());
|
||||
case 10: { // decrement counter
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
if (card->getCounters().value(counterId, 0)) {
|
||||
auto *cmd = new Command_SetCardCounter;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
|
@ -2785,7 +2853,7 @@ void Player::actCardCounterTrigger()
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 11: {
|
||||
case 11: { // set counter with dialog
|
||||
bool ok;
|
||||
dialogSemaphore = true;
|
||||
int number =
|
||||
|
@ -2795,9 +2863,8 @@ void Player::actCardCounterTrigger()
|
|||
return;
|
||||
}
|
||||
|
||||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
auto *card = static_cast<CardItem *>(i.next());
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
auto *cmd = new Command_SetCardCounter;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
|
@ -2900,9 +2967,11 @@ void Player::updateCardMenu(const CardItem *card)
|
|||
if (ptMenu->isEmpty()) {
|
||||
ptMenu->addAction(aIncP);
|
||||
ptMenu->addAction(aDecP);
|
||||
ptMenu->addAction(aFlowP);
|
||||
ptMenu->addSeparator();
|
||||
ptMenu->addAction(aIncT);
|
||||
ptMenu->addAction(aDecT);
|
||||
ptMenu->addAction(aFlowT);
|
||||
ptMenu->addSeparator();
|
||||
ptMenu->addAction(aIncPT);
|
||||
ptMenu->addAction(aDecPT);
|
||||
|
@ -2986,11 +3055,15 @@ void Player::updateCardMenu(const CardItem *card)
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
QList<CardRelation *> relatedCards = card->getInfo()->getRelatedCards();
|
||||
QList<CardRelation *> relatedCards = cardInfo->getRelatedCards();
|
||||
if (relatedCards.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
@ -3009,13 +3082,16 @@ void Player::addRelatedCardView(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;
|
||||
}
|
||||
|
||||
QList<CardRelation *> relatedCards(card->getInfo()->getRelatedCards());
|
||||
relatedCards.append(card->getInfo()->getReverseRelatedCards2Me());
|
||||
if (relatedCards.empty()) {
|
||||
QList<CardRelation *> relatedCards = cardInfo->getRelatedCards();
|
||||
if (relatedCards.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,6 +192,8 @@ private slots:
|
|||
void actDecT();
|
||||
void actIncPT();
|
||||
void actDecPT();
|
||||
void actFlowP();
|
||||
void actFlowT();
|
||||
void actSetAnnotation();
|
||||
void actPlay();
|
||||
void actHide();
|
||||
|
@ -215,8 +217,9 @@ private:
|
|||
|
||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aResetPT,
|
||||
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone, *aMoveToTopLibrary,
|
||||
*aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToXfromTopOfLibrary;
|
||||
*aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aFlowP, *aFlowT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile,
|
||||
*aMoveToXfromTopOfLibrary;
|
||||
|
||||
bool shortcutsActive;
|
||||
int defaultNumberTopCards;
|
||||
|
@ -288,6 +291,8 @@ private:
|
|||
void eventRevealCards(const Event_RevealCards &event);
|
||||
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
|
||||
|
||||
QVariantList parsePT(const QString &pt);
|
||||
|
||||
public:
|
||||
static const int counterAreaWidth = 55;
|
||||
enum CardMenuActionType
|
||||
|
|
|
@ -199,26 +199,30 @@ public:
|
|||
QVBoxLayout *verticalLayout;
|
||||
QGroupBox *groupBox_12;
|
||||
QGridLayout *gridLayout_12;
|
||||
SequenceEdit *Player_aDecPT;
|
||||
SequenceEdit *Player_aIncPT;
|
||||
QLabel *lbl_Player_aIncPT;
|
||||
SequenceEdit *Player_aIncPT;
|
||||
QLabel *lbl_Player_aDecPT;
|
||||
SequenceEdit *Player_aSetPT;
|
||||
SequenceEdit *Player_aDecPT;
|
||||
QLabel *lbl_Player_aSetPT;
|
||||
SequenceEdit *Player_aResetPT;
|
||||
SequenceEdit *Player_aSetPT;
|
||||
QLabel *lbl_Player_aResetPT;
|
||||
SequenceEdit *Player_aResetPT;
|
||||
QGroupBox *groupBox_11;
|
||||
QGridLayout *gridLayout_11;
|
||||
QLabel *lbl_Player_aDecT;
|
||||
SequenceEdit *Player_aDecT;
|
||||
QLabel *lbl_Player_aIncT;
|
||||
SequenceEdit *Player_aIncT;
|
||||
QLabel *lbl_Player_aFlowT;
|
||||
SequenceEdit *Player_aFlowT;
|
||||
QGroupBox *groupBox_10;
|
||||
QGridLayout *gridLayout_10;
|
||||
QLabel *lbl_Player_aDecP;
|
||||
SequenceEdit *Player_aDecP;
|
||||
SequenceEdit *Player_aIncP;
|
||||
QLabel *lbl_Player_aIncP;
|
||||
SequenceEdit *Player_aIncP;
|
||||
QLabel *lbl_Player_aFlowP;
|
||||
SequenceEdit *Player_aFlowP;
|
||||
QGroupBox *groupBox_8;
|
||||
QGridLayout *gridLayout_5;
|
||||
QLabel *lbl_TabGame_phase0;
|
||||
|
@ -1083,36 +1087,20 @@ public:
|
|||
|
||||
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->setObjectName("groupBox_10");
|
||||
gridLayout_10 = new QGridLayout(groupBox_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->setObjectName("lbl_Player_aDecP");
|
||||
|
||||
|
@ -1123,18 +1111,54 @@ public:
|
|||
|
||||
gridLayout_10->addWidget(Player_aDecP, 1, 1, 1, 1);
|
||||
|
||||
Player_aIncP = new SequenceEdit("Player/aIncP", groupBox_10);
|
||||
Player_aIncP->setObjectName("Player_aIncP");
|
||||
lbl_Player_aFlowP = new QLabel(groupBox_10);
|
||||
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);
|
||||
lbl_Player_aIncP->setObjectName("lbl_Player_aIncP");
|
||||
Player_aFlowP = new SequenceEdit("Player/aFlowP", groupBox_10);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
groupBox_8 = new QGroupBox(tab_2);
|
||||
|
@ -1929,9 +1953,11 @@ public:
|
|||
groupBox_11->setTitle(QApplication::translate("shortcutsTab", "Toughness"));
|
||||
lbl_Player_aDecT->setText(QApplication::translate("shortcutsTab", "Remove (-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"));
|
||||
lbl_Player_aDecP->setText(QApplication::translate("shortcutsTab", "Remove (-1/-nullptr)"));
|
||||
lbl_Player_aIncP->setText(QApplication::translate("shortcutsTab", "Add (+1/+nullptr)"));
|
||||
lbl_Player_aDecP->setText(QApplication::translate("shortcutsTab", "Remove (-1/-0)"));
|
||||
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"));
|
||||
lbl_TabGame_phase0->setText(QApplication::translate("shortcutsTab", "Untap"));
|
||||
lbl_TabGame_phase1->setText(QApplication::translate("shortcutsTab", "Upkeep"));
|
||||
|
|
|
@ -139,6 +139,8 @@ private:
|
|||
{"Player/aIncT", parseSequenceString("Alt++")},
|
||||
{"Player/aSetPT", parseSequenceString("Ctrl+P")},
|
||||
{"Player/aResetPT", parseSequenceString("Ctrl+Alt+0")},
|
||||
{"Player/aFlowP", parseSequenceString("")},
|
||||
{"Player/aFlowT", parseSequenceString("")},
|
||||
|
||||
{"Player/aConcede", parseSequenceString("F2")},
|
||||
{"Player/aLeaveGame", parseSequenceString("Ctrl+Q")},
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
|
||||
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),
|
||||
facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false),
|
||||
doesntUntap(false), parentCard(0)
|
||||
facedown(false), color(), ptString(), annotation(), destroyOnZoneChange(false), doesntUntap(false), parentCard(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -44,8 +43,7 @@ void Server_Card::resetState()
|
|||
counters.clear();
|
||||
setTapped(false);
|
||||
setAttacking(false);
|
||||
power = -1;
|
||||
toughness = -1;
|
||||
setPT(QString());
|
||||
setAnnotation(QString());
|
||||
setDoesntUntap(false);
|
||||
}
|
||||
|
@ -89,40 +87,6 @@ void Server_Card::setCounter(int id, int value)
|
|||
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)
|
||||
{
|
||||
if (parentCard)
|
||||
|
@ -140,24 +104,28 @@ void Server_Card::getInfo(ServerInfo_Card *info)
|
|||
info->set_name(displayedName.toStdString());
|
||||
info->set_x(coord_x);
|
||||
info->set_y(coord_y);
|
||||
QString ptStr = getPT();
|
||||
if (facedown) {
|
||||
info->set_face_down(true);
|
||||
ptStr = getPT();
|
||||
}
|
||||
info->set_tapped(tapped);
|
||||
if (attacking)
|
||||
if (attacking) {
|
||||
info->set_attacking(true);
|
||||
if (!color.isEmpty())
|
||||
}
|
||||
if (!color.isEmpty()) {
|
||||
info->set_color(color.toStdString());
|
||||
if (!ptStr.isEmpty())
|
||||
info->set_pt(ptStr.toStdString());
|
||||
if (!annotation.isEmpty())
|
||||
}
|
||||
if (!ptString.isEmpty()) {
|
||||
info->set_pt(ptString.toStdString());
|
||||
}
|
||||
if (!annotation.isEmpty()) {
|
||||
info->set_annotation(annotation.toStdString());
|
||||
if (destroyOnZoneChange)
|
||||
}
|
||||
if (destroyOnZoneChange) {
|
||||
info->set_destroy_on_zone_change(true);
|
||||
if (doesntUntap)
|
||||
}
|
||||
if (doesntUntap) {
|
||||
info->set_doesnt_untap(true);
|
||||
}
|
||||
|
||||
QMapIterator<int, int> cardCounterIterator(counters);
|
||||
while (cardCounterIterator.hasNext()) {
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
bool attacking;
|
||||
bool facedown;
|
||||
QString color;
|
||||
int power, toughness;
|
||||
QString ptString;
|
||||
QString annotation;
|
||||
bool destroyOnZoneChange;
|
||||
bool doesntUntap;
|
||||
|
@ -102,7 +102,10 @@ public:
|
|||
{
|
||||
return color;
|
||||
}
|
||||
QString getPT() const;
|
||||
QString getPT() const
|
||||
{
|
||||
return ptString;
|
||||
}
|
||||
QString getAnnotation() const
|
||||
{
|
||||
return annotation;
|
||||
|
@ -154,7 +157,10 @@ public:
|
|||
{
|
||||
color = _color;
|
||||
}
|
||||
void setPT(const QString &_pt);
|
||||
void setPT(const QString &_pt)
|
||||
{
|
||||
ptString = _pt;
|
||||
}
|
||||
void setAnnotation(const QString &_annotation)
|
||||
{
|
||||
annotation = _annotation;
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue