p/t changes
This commit is contained in:
parent
713ebece78
commit
d05603f83b
8 changed files with 157 additions and 24 deletions
|
@ -34,6 +34,18 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _reve
|
|||
connect(aAttach, SIGNAL(triggered()), this, SLOT(actAttach()));
|
||||
aUnattach = new QAction(this);
|
||||
connect(aUnattach, SIGNAL(triggered()), this, SLOT(actUnattach()));
|
||||
aIncP = new QAction(this);
|
||||
connect(aIncP, SIGNAL(triggered()), this, SLOT(actIncP()));
|
||||
aDecP = new QAction(this);
|
||||
connect(aDecP, SIGNAL(triggered()), this, SLOT(actDecP()));
|
||||
aIncT = new QAction(this);
|
||||
connect(aIncT, SIGNAL(triggered()), this, SLOT(actIncT()));
|
||||
aDecT = new QAction(this);
|
||||
connect(aDecT, SIGNAL(triggered()), this, SLOT(actDecT()));
|
||||
aIncPT = new QAction(this);
|
||||
connect(aIncPT, SIGNAL(triggered()), this, SLOT(actIncPT()));
|
||||
aDecPT = new QAction(this);
|
||||
connect(aDecPT, SIGNAL(triggered()), this, SLOT(actDecPT()));
|
||||
aSetPT = new QAction(this);
|
||||
connect(aSetPT, SIGNAL(triggered()), this, SLOT(actSetPT()));
|
||||
aSetAnnotation = new QAction(this);
|
||||
|
@ -77,6 +89,17 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _reve
|
|||
connect(tempSetCounter, SIGNAL(triggered()), this, SLOT(actCardCounterTrigger()));
|
||||
}
|
||||
cardMenu = new QMenu;
|
||||
ptMenu = new QMenu;
|
||||
ptMenu->addAction(aIncP);
|
||||
ptMenu->addAction(aDecP);
|
||||
ptMenu->addSeparator();
|
||||
ptMenu->addAction(aIncT);
|
||||
ptMenu->addAction(aDecT);
|
||||
ptMenu->addSeparator();
|
||||
ptMenu->addAction(aIncPT);
|
||||
ptMenu->addAction(aDecPT);
|
||||
ptMenu->addSeparator();
|
||||
ptMenu->addAction(aSetPT);
|
||||
moveMenu = new QMenu;
|
||||
|
||||
retranslateUi();
|
||||
|
@ -144,7 +167,7 @@ void CardItem::updateCardMenu()
|
|||
if (attachedTo)
|
||||
cardMenu->addAction(aUnattach);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aSetPT);
|
||||
cardMenu->addMenu(ptMenu);
|
||||
cardMenu->addAction(aSetAnnotation);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aClone);
|
||||
|
@ -180,10 +203,25 @@ void CardItem::retranslateUi()
|
|||
aDoesntUntap->setText(tr("Toggle &normal untapping"));
|
||||
aFlip->setText(tr("&Flip"));
|
||||
aClone->setText(tr("&Clone"));
|
||||
aClone->setShortcut(tr("Ctrl+H"));
|
||||
aAttach->setText(tr("&Attach to card..."));
|
||||
aAttach->setShortcut(tr("Ctrl+A"));
|
||||
aUnattach->setText(tr("Unattac&h"));
|
||||
aSetPT->setText(tr("Set &P/T..."));
|
||||
ptMenu->setTitle(tr("&Power / toughness"));
|
||||
aIncP->setText(tr("&Increase power"));
|
||||
aIncP->setShortcut(tr("Ctrl++"));
|
||||
aDecP->setText(tr("&Decrease power"));
|
||||
aDecP->setShortcut(tr("Ctrl+-"));
|
||||
aIncT->setText(tr("I&ncrease toughness"));
|
||||
aIncT->setShortcut(tr("Alt++"));
|
||||
aDecT->setText(tr("D&ecrease toughness"));
|
||||
aDecT->setShortcut(tr("Alt+-"));
|
||||
aIncPT->setText(tr("In&crease power and toughness"));
|
||||
aIncPT->setShortcut(tr("Ctrl+Alt++"));
|
||||
aDecPT->setText(tr("Dec&rease power and toughness"));
|
||||
aDecPT->setShortcut(tr("Ctrl+Alt+-"));
|
||||
aSetPT->setText(tr("Set &power and toughness..."));
|
||||
aSetPT->setShortcut(tr("Ctrl+P"));
|
||||
aSetAnnotation->setText(tr("&Set annotation..."));
|
||||
QStringList counterColors;
|
||||
counterColors.append(tr("red"));
|
||||
|
@ -219,11 +257,13 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
paintNumberEllipse(counterIterator.value(), 14, color, i, counters.size(), painter);
|
||||
++i;
|
||||
}
|
||||
|
||||
QSizeF translatedSize = getTranslatedSize(painter);
|
||||
qreal scaleFactor = translatedSize.width() / boundingRect().width();
|
||||
|
||||
if (!pt.isEmpty()) {
|
||||
painter->save();
|
||||
QSizeF translatedSize = getTranslatedSize(painter);
|
||||
|
||||
qreal scaleFactor = translatedSize.width() / boundingRect().width();
|
||||
transformPainter(painter, translatedSize, tapAngle);
|
||||
painter->setBackground(Qt::black);
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
|
@ -232,6 +272,17 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
painter->drawText(QRectF(4 * scaleFactor, 4 * scaleFactor, translatedSize.width() - 8 * scaleFactor, translatedSize.height() - 8 * scaleFactor), Qt::AlignRight | Qt::AlignBottom, pt);
|
||||
painter->restore();
|
||||
}
|
||||
if (!annotation.isEmpty()) {
|
||||
painter->save();
|
||||
|
||||
transformPainter(painter, translatedSize, tapAngle);
|
||||
painter->setBackground(Qt::black);
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
painter->setPen(Qt::white);
|
||||
|
||||
painter->drawText(QRectF(4 * scaleFactor, 4 * scaleFactor, translatedSize.width() - 8 * scaleFactor, translatedSize.height() - 8 * scaleFactor), Qt::AlignCenter | Qt::TextWrapAnywhere, annotation);
|
||||
painter->restore();
|
||||
}
|
||||
if (getBeingPointedAt())
|
||||
painter->fillRect(boundingRect(), QBrush(QColor(255, 0, 0, 100)));
|
||||
painter->restore();
|
||||
|
@ -263,7 +314,6 @@ void CardItem::setCounter(int _id, int _value)
|
|||
void CardItem::setAnnotation(const QString &_annotation)
|
||||
{
|
||||
annotation = _annotation;
|
||||
setToolTip(annotation);
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -477,6 +527,36 @@ void CardItem::actUnattach()
|
|||
owner->actUnattach(static_cast<QAction *>(sender()));
|
||||
}
|
||||
|
||||
void CardItem::actIncP()
|
||||
{
|
||||
owner->actIncPT(1, 0);
|
||||
}
|
||||
|
||||
void CardItem::actDecP()
|
||||
{
|
||||
owner->actIncPT(-1, 0);
|
||||
}
|
||||
|
||||
void CardItem::actIncT()
|
||||
{
|
||||
owner->actIncPT(0, 1);
|
||||
}
|
||||
|
||||
void CardItem::actDecT()
|
||||
{
|
||||
owner->actIncPT(0, -1);
|
||||
}
|
||||
|
||||
void CardItem::actIncPT()
|
||||
{
|
||||
owner->actIncPT(1, 1);
|
||||
}
|
||||
|
||||
void CardItem::actDecPT()
|
||||
{
|
||||
owner->actIncPT(-1, -1);
|
||||
}
|
||||
|
||||
void CardItem::actSetPT()
|
||||
{
|
||||
owner->actSetPT(static_cast<QAction *>(sender()));
|
||||
|
|
|
@ -33,9 +33,9 @@ private:
|
|||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
QAction *aPlay,
|
||||
*aHide,
|
||||
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aSetPT, *aSetAnnotation, *aFlip, *aClone,
|
||||
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aClone,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile;
|
||||
QMenu *cardMenu, *moveMenu;
|
||||
QMenu *cardMenu, *ptMenu, *moveMenu;
|
||||
|
||||
void playCard(bool faceDown);
|
||||
void prepareDelete();
|
||||
|
@ -45,6 +45,12 @@ private slots:
|
|||
void actAttach();
|
||||
void actUnattach();
|
||||
void actSetPT();
|
||||
void actIncP();
|
||||
void actDecP();
|
||||
void actIncT();
|
||||
void actDecT();
|
||||
void actIncPT();
|
||||
void actDecPT();
|
||||
void actSetAnnotation();
|
||||
void actPlay();
|
||||
void actHide();
|
||||
|
|
|
@ -1365,6 +1365,16 @@ void Player::cardMenuAction(QAction *a)
|
|||
sendCommandContainer(new CommandContainer(commandList));
|
||||
}
|
||||
|
||||
void Player::actIncPT(int deltaP, int deltaT)
|
||||
{
|
||||
QString ptString = "+" + QString::number(deltaP) + "/+" + QString::number(deltaT);
|
||||
QListIterator<QGraphicsItem *> j(scene()->selectedItems());
|
||||
while (j.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(j.next());
|
||||
sendGameCommand(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "pt", ptString));
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actSetPT(QAction * /*a*/)
|
||||
{
|
||||
QString oldPT;
|
||||
|
|
|
@ -99,6 +99,7 @@ public slots:
|
|||
|
||||
void actAttach(QAction *action);
|
||||
void actUnattach(QAction *action);
|
||||
void actIncPT(int deltaP, int deltaT);
|
||||
void actSetPT(QAction *action);
|
||||
void actSetAnnotation(QAction *action);
|
||||
void cardMenuAction(QAction *action);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "server_card.h"
|
||||
|
||||
Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y)
|
||||
: id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), facedown(false), color(QString()), pt(QString()), annotation(QString()), destroyOnZoneChange(false), doesntUntap(false), parentCard(0)
|
||||
: 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)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,13 @@ void Server_Card::resetState()
|
|||
counters.clear();
|
||||
setTapped(false);
|
||||
setAttacking(false);
|
||||
setPT(QString());
|
||||
power = 0;
|
||||
toughness = 0;
|
||||
setAnnotation(QString());
|
||||
setDoesntUntap(false);
|
||||
}
|
||||
|
||||
bool Server_Card::setAttribute(const QString &aname, const QString &avalue, bool allCards)
|
||||
QString Server_Card::setAttribute(const QString &aname, const QString &avalue, bool allCards)
|
||||
{
|
||||
if (aname == "tapped") {
|
||||
bool value = avalue == "1";
|
||||
|
@ -58,14 +59,15 @@ bool Server_Card::setAttribute(const QString &aname, const QString &avalue, bool
|
|||
setColor(avalue);
|
||||
} else if (aname == "pt") {
|
||||
setPT(avalue);
|
||||
return getPT();
|
||||
} else if (aname == "annotation") {
|
||||
setAnnotation(avalue);
|
||||
} else if (aname == "doesnt_untap") {
|
||||
setDoesntUntap(avalue == "1");
|
||||
} else
|
||||
return false;
|
||||
return QString();
|
||||
|
||||
return true;
|
||||
return avalue;
|
||||
}
|
||||
|
||||
void Server_Card::setCounter(int id, int value)
|
||||
|
@ -76,6 +78,36 @@ void Server_Card::setCounter(int id, int value)
|
|||
counters.remove(id);
|
||||
}
|
||||
|
||||
void Server_Card::setPT(const QString &_pt)
|
||||
{
|
||||
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 (power < 0)
|
||||
power = 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)
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
bool attacking;
|
||||
bool facedown;
|
||||
QString color;
|
||||
QString pt;
|
||||
int power, toughness;
|
||||
QString annotation;
|
||||
bool destroyOnZoneChange;
|
||||
bool doesntUntap;
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
bool getAttacking() const { return attacking; }
|
||||
bool getFaceDown() const { return facedown; }
|
||||
QString getColor() const { return color; }
|
||||
QString getPT() const { return pt; }
|
||||
QString getPT() const;
|
||||
QString getAnnotation() const { return annotation; }
|
||||
bool getDoesntUntap() const { return doesntUntap; }
|
||||
bool getDestroyOnZoneChange() const { return destroyOnZoneChange; }
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
void setAttacking(bool _attacking) { attacking = _attacking; }
|
||||
void setFaceDown(bool _facedown) { facedown = _facedown; }
|
||||
void setColor(const QString &_color) { color = _color; }
|
||||
void setPT(const QString &_pt) { pt = _pt; }
|
||||
void setPT(const QString &_pt);
|
||||
void setAnnotation(const QString &_annotation) { annotation = _annotation; }
|
||||
void setDestroyOnZoneChange(bool _destroy) { destroyOnZoneChange = _destroy; }
|
||||
void setDoesntUntap(bool _doesntUntap) { doesntUntap = _doesntUntap; }
|
||||
|
@ -86,7 +86,7 @@ public:
|
|||
void removeAttachedCard(Server_Card *card) { attachedCards.removeAt(attachedCards.indexOf(card)); }
|
||||
|
||||
void resetState();
|
||||
bool setAttribute(const QString &aname, const QString &avalue, bool allCards);
|
||||
QString setAttribute(const QString &aname, const QString &avalue, bool allCards);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -436,21 +436,25 @@ ResponseCode Server_Player::setCardAttrHelper(CommandContainer *cont, const QStr
|
|||
if (!zone->hasCoords())
|
||||
return RespContextError;
|
||||
|
||||
QString result;
|
||||
if (cardId == -1) {
|
||||
QListIterator<Server_Card *> CardIterator(zone->cards);
|
||||
while (CardIterator.hasNext())
|
||||
if (!CardIterator.next()->setAttribute(attrName, attrValue, true))
|
||||
while (CardIterator.hasNext()) {
|
||||
result = CardIterator.next()->setAttribute(attrName, attrValue, true);
|
||||
if (result.isNull())
|
||||
return RespInvalidCommand;
|
||||
}
|
||||
} else {
|
||||
Server_Card *card = zone->getCard(cardId, false);
|
||||
if (!card)
|
||||
return RespNameNotFound;
|
||||
if (!card->setAttribute(attrName, attrValue, false))
|
||||
result = card->setAttribute(attrName, attrValue, false);
|
||||
if (result.isNull())
|
||||
return RespInvalidCommand;
|
||||
}
|
||||
cont->enqueueGameEventPrivate(new Event_SetCardAttr(getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId());
|
||||
cont->enqueueGameEventPublic(new Event_SetCardAttr(getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId());
|
||||
cont->enqueueGameEventOmniscient(new Event_SetCardAttr(getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId());
|
||||
cont->enqueueGameEventPrivate(new Event_SetCardAttr(getPlayerId(), zone->getName(), cardId, attrName, result), game->getGameId());
|
||||
cont->enqueueGameEventPublic(new Event_SetCardAttr(getPlayerId(), zone->getName(), cardId, attrName, result), game->getGameId());
|
||||
cont->enqueueGameEventOmniscient(new Event_SetCardAttr(getPlayerId(), zone->getName(), cardId, attrName, result), game->getGameId());
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ int OracleImporter::importTextSpoiler(CardSet *set, const QByteArray &data)
|
|||
else if (v1 == "Type:")
|
||||
cardType = v2.simplified();
|
||||
else if (v1 == "Pow/Tgh:")
|
||||
cardPT = v2.simplified();
|
||||
cardPT = v2.simplified().remove('(').remove(')');
|
||||
else if (v1 == "Rules Text:")
|
||||
cardText = v2.trimmed();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue