improved cipt handling, initial p/t for cards
This commit is contained in:
parent
d05603f83b
commit
ce80d29f50
24 changed files with 226 additions and 118 deletions
|
@ -171,9 +171,9 @@ void CardZone::moveAllToZone()
|
||||||
QString targetZone = data[0].toString();
|
QString targetZone = data[0].toString();
|
||||||
int targetX = data[1].toInt();
|
int targetX = data[1].toInt();
|
||||||
|
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < cards.size(); ++i)
|
for (int i = 0; i < cards.size(); ++i)
|
||||||
idList.append(new CardId(cards[i]->getId()));
|
idList.append(new CardToMove(cards[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, getName(), idList, player->getId(), targetZone, targetX));
|
player->sendGameCommand(new Command_MoveCard(-1, getName(), idList, player->getId(), targetZone, targetX));
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
|
|
||||||
void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||||
{
|
{
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardId(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), cards.size(), -1, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), cards.size(), -1, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "cardzone.h"
|
#include "cardzone.h"
|
||||||
#include "cardinfowidget.h"
|
#include "cardinfowidget.h"
|
||||||
|
#include "protocol_items.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
@ -182,13 +183,14 @@ QPair<QString, QString> MessageLogWidget::getFromStr(CardZone *zone, QString car
|
||||||
return QPair<QString, QString>(cardName, fromStr);
|
return QPair<QString, QString>(cardName, fromStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
|
void MessageLogWidget::doMoveCard(LogMoveCard &attributes)
|
||||||
{
|
{
|
||||||
QString startName = startZone->getName();
|
QString startName = attributes.startZone->getName();
|
||||||
QString targetName = targetZone->getName();
|
QString targetName = attributes.targetZone->getName();
|
||||||
if (((startName == "table") && (targetName == "table") && (startZone == targetZone)) || ((startName == "hand") && (targetName == "hand")))
|
if (((startName == "table") && (targetName == "table") && (attributes.startZone == attributes.targetZone)) || ((startName == "hand") && (targetName == "hand")))
|
||||||
return;
|
return;
|
||||||
QPair<QString, QString> temp = getFromStr(startZone, cardName, oldX);
|
QString cardName = attributes.card->getName();
|
||||||
|
QPair<QString, QString> temp = getFromStr(attributes.startZone, cardName, attributes.oldX);
|
||||||
bool cardNameContainsStartZone = false;
|
bool cardNameContainsStartZone = false;
|
||||||
if (!temp.first.isEmpty()) {
|
if (!temp.first.isEmpty()) {
|
||||||
cardNameContainsStartZone = true;
|
cardNameContainsStartZone = true;
|
||||||
|
@ -203,26 +205,29 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
||||||
else
|
else
|
||||||
cardStr = QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName));
|
cardStr = QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName));
|
||||||
|
|
||||||
if (startZone->getPlayer() != targetZone->getPlayer()) {
|
if (attributes.startZone->getPlayer() != attributes.targetZone->getPlayer()) {
|
||||||
append(tr("%1 gives %2 control over %3.").arg(sanitizeHtml(player->getName())).arg(sanitizeHtml(targetZone->getPlayer()->getName())).arg(cardStr));
|
append(tr("%1 gives %2 control over %3.").arg(sanitizeHtml(attributes.player->getName())).arg(sanitizeHtml(attributes.targetZone->getPlayer()->getName())).arg(cardStr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString finalStr;
|
QString finalStr;
|
||||||
if (targetName == "table")
|
if (targetName == "table") {
|
||||||
|
if (moveCardTapped.value(attributes.card))
|
||||||
|
finalStr = tr("%1 puts %2 into play tapped%3.");
|
||||||
|
else
|
||||||
finalStr = tr("%1 puts %2 into play%3.");
|
finalStr = tr("%1 puts %2 into play%3.");
|
||||||
else if (targetName == "grave")
|
} else if (targetName == "grave")
|
||||||
finalStr = tr("%1 puts %2%3 into graveyard.");
|
finalStr = tr("%1 puts %2%3 into graveyard.");
|
||||||
else if (targetName == "rfg")
|
else if (targetName == "rfg")
|
||||||
finalStr = tr("%1 exiles %2%3.");
|
finalStr = tr("%1 exiles %2%3.");
|
||||||
else if (targetName == "hand")
|
else if (targetName == "hand")
|
||||||
finalStr = tr("%1 moves %2%3 to hand.");
|
finalStr = tr("%1 moves %2%3 to hand.");
|
||||||
else if (targetName == "deck") {
|
else if (targetName == "deck") {
|
||||||
if (newX == -1)
|
if (attributes.newX == -1)
|
||||||
finalStr = tr("%1 puts %2%3 into his library.");
|
finalStr = tr("%1 puts %2%3 into his library.");
|
||||||
else if (newX == targetZone->getCards().size())
|
else if (attributes.newX == attributes.targetZone->getCards().size())
|
||||||
finalStr = tr("%1 puts %2%3 on bottom of his library.");
|
finalStr = tr("%1 puts %2%3 on bottom of his library.");
|
||||||
else if (newX == 0)
|
else if (attributes.newX == 0)
|
||||||
finalStr = tr("%1 puts %2%3 on top of his library.");
|
finalStr = tr("%1 puts %2%3 on top of his library.");
|
||||||
else
|
else
|
||||||
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
finalStr = tr("%1 puts %2%3 into his library at position %4.");
|
||||||
|
@ -231,7 +236,16 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
||||||
else if (targetName == "stack")
|
else if (targetName == "stack")
|
||||||
finalStr = tr("%1 plays %2%3.");
|
finalStr = tr("%1 plays %2%3.");
|
||||||
|
|
||||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr).arg(newX));
|
append(finalStr.arg(sanitizeHtml(attributes.player->getName())).arg(cardStr).arg(fromStr).arg(attributes.newX));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageLogWidget::logMoveCard(Player *player, CardItem *card, CardZone *startZone, int oldX, CardZone *targetZone, int newX)
|
||||||
|
{
|
||||||
|
LogMoveCard attributes = {player, card, startZone, oldX, targetZone, newX};
|
||||||
|
if (currentContext == MessageContext_MoveCard)
|
||||||
|
moveCardQueue.append(attributes);
|
||||||
|
else
|
||||||
|
doMoveCard(attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown)
|
void MessageLogWidget::logFlipCard(Player *player, QString cardName, bool faceDown)
|
||||||
|
@ -301,39 +315,46 @@ void MessageLogWidget::logSetCardCounter(Player *player, QString cardName, int c
|
||||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(colorStr).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(value));
|
append(finalStr.arg(sanitizeHtml(player->getName())).arg(colorStr).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSetTapped(Player *player, QString cardName, bool tapped)
|
void MessageLogWidget::logSetTapped(Player *player, CardItem *card, bool tapped)
|
||||||
{
|
{
|
||||||
|
if (currentContext == MessageContext_MoveCard)
|
||||||
|
moveCardTapped.insert(card, tapped);
|
||||||
|
else {
|
||||||
QString cardStr;
|
QString cardStr;
|
||||||
if (cardName == "-1")
|
if (!card)
|
||||||
cardStr = tr("his permanents");
|
cardStr = tr("his permanents");
|
||||||
else
|
else
|
||||||
cardStr = QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName));
|
cardStr = QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(card->getName()));
|
||||||
append(tr("%1 %2 %3.").arg(sanitizeHtml(player->getName())).arg(tapped ? tr("taps") : tr("untaps")).arg(cardStr));
|
append(tr("%1 %2 %3.").arg(sanitizeHtml(player->getName())).arg(tapped ? tr("taps") : tr("untaps")).arg(cardStr));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSetCounter(Player *player, QString counterName, int value, int oldValue)
|
void MessageLogWidget::logSetCounter(Player *player, QString counterName, int value, int oldValue)
|
||||||
{
|
{
|
||||||
append(tr("%1 sets counter %2 to %3 (%4%5).").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(counterName))).arg(QString("<font color=\"blue\">%1</font>").arg(value)).arg(value > oldValue ? "+" : "").arg(value - oldValue));
|
append(tr("%1 sets counter %2 to %3 (%4%5).").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(counterName))).arg(QString("<font color=\"blue\">%1</font>").arg(value)).arg(value > oldValue ? "+" : "").arg(value - oldValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap)
|
void MessageLogWidget::logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap)
|
||||||
{
|
{
|
||||||
QString finalStr;
|
QString finalStr;
|
||||||
if (doesntUntap)
|
if (doesntUntap)
|
||||||
finalStr = tr("%1 sets %2 to not untap normally.");
|
finalStr = tr("%1 sets %2 to not untap normally.");
|
||||||
else
|
else
|
||||||
finalStr = tr("%1 sets %2 to untap normally.");
|
finalStr = tr("%1 sets %2 to untap normally.");
|
||||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))));
|
append(finalStr.arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(card->getName()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSetPT(Player *player, QString cardName, QString newPT)
|
void MessageLogWidget::logSetPT(Player *player, CardItem *card, QString newPT)
|
||||||
{
|
{
|
||||||
append(tr("%1 sets PT of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(newPT))));
|
if (currentContext == MessageContext_MoveCard)
|
||||||
|
moveCardPT.insert(card, newPT);
|
||||||
|
else
|
||||||
|
append(tr("%1 sets PT of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(card->getName()))).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(newPT))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logSetAnnotation(Player *player, QString cardName, QString newAnnotation)
|
void MessageLogWidget::logSetAnnotation(Player *player, CardItem *card, QString newAnnotation)
|
||||||
{
|
{
|
||||||
append(tr("%1 sets annotation of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(newAnnotation))));
|
append(tr("%1 sets annotation of %2 to %3.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(card->getName()))).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(newAnnotation))));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCards)
|
void MessageLogWidget::logDumpZone(Player *player, CardZone *zone, int numberCards)
|
||||||
|
@ -412,6 +433,25 @@ void MessageLogWidget::logSetActivePhase(int phase)
|
||||||
append("<font color=\"green\"><b>" + tr("It is now the %1.").arg(phaseName) + "</b></font>");
|
append("<font color=\"green\"><b>" + tr("It is now the %1.").arg(phaseName) + "</b></font>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLogWidget::containerProcessingStarted(GameEventContext *_context)
|
||||||
|
{
|
||||||
|
if (qobject_cast<Context_MoveCard *>(_context))
|
||||||
|
currentContext = MessageContext_MoveCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageLogWidget::containerProcessingDone()
|
||||||
|
{
|
||||||
|
if (currentContext == MessageContext_MoveCard) {
|
||||||
|
for (int i = 0; i < moveCardQueue.size(); ++i)
|
||||||
|
doMoveCard(moveCardQueue[i]);
|
||||||
|
moveCardQueue.clear();
|
||||||
|
moveCardPT.clear();
|
||||||
|
moveCardTapped.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentContext = MessageContext_None;
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::connectToPlayer(Player *player)
|
void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
{
|
{
|
||||||
connect(player, SIGNAL(logSay(Player *, QString)), this, SLOT(logSay(Player *, QString)));
|
connect(player, SIGNAL(logSay(Player *, QString)), this, SLOT(logSay(Player *, QString)));
|
||||||
|
@ -421,11 +461,11 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
||||||
connect(player, SIGNAL(logCreateToken(Player *, QString, QString)), this, SLOT(logCreateToken(Player *, QString, QString)));
|
connect(player, SIGNAL(logCreateToken(Player *, QString, QString)), this, SLOT(logCreateToken(Player *, QString, QString)));
|
||||||
connect(player, SIGNAL(logSetCounter(Player *, QString, int, int)), this, SLOT(logSetCounter(Player *, QString, int, int)));
|
connect(player, SIGNAL(logSetCounter(Player *, QString, int, int)), this, SLOT(logSetCounter(Player *, QString, int, int)));
|
||||||
connect(player, SIGNAL(logSetCardCounter(Player *, QString, int, int, int)), this, SLOT(logSetCardCounter(Player *, QString, int, int, int)));
|
connect(player, SIGNAL(logSetCardCounter(Player *, QString, int, int, int)), this, SLOT(logSetCardCounter(Player *, QString, int, int, int)));
|
||||||
connect(player, SIGNAL(logSetTapped(Player *, QString, bool)), this, SLOT(logSetTapped(Player *, QString, bool)));
|
connect(player, SIGNAL(logSetTapped(Player *, CardItem *, bool)), this, SLOT(logSetTapped(Player *, CardItem *, bool)));
|
||||||
connect(player, SIGNAL(logSetDoesntUntap(Player *, QString, bool)), this, SLOT(logSetDoesntUntap(Player *, QString, bool)));
|
connect(player, SIGNAL(logSetDoesntUntap(Player *, CardItem *, bool)), this, SLOT(logSetDoesntUntap(Player *, CardItem *, bool)));
|
||||||
connect(player, SIGNAL(logSetPT(Player *, QString, QString)), this, SLOT(logSetPT(Player *, QString, QString)));
|
connect(player, SIGNAL(logSetPT(Player *, CardItem *, QString)), this, SLOT(logSetPT(Player *, CardItem *, QString)));
|
||||||
connect(player, SIGNAL(logSetAnnotation(Player *, QString, QString)), this, SLOT(logSetAnnotation(Player *, QString, QString)));
|
connect(player, SIGNAL(logSetAnnotation(Player *, CardItem *, QString)), this, SLOT(logSetAnnotation(Player *, CardItem *, QString)));
|
||||||
connect(player, SIGNAL(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)), this, SLOT(logMoveCard(Player *, QString, CardZone *, int, CardZone *, int)));
|
connect(player, SIGNAL(logMoveCard(Player *, CardItem *, CardZone *, int, CardZone *, int)), this, SLOT(logMoveCard(Player *, CardItem *, CardZone *, int, CardZone *, int)));
|
||||||
connect(player, SIGNAL(logFlipCard(Player *, QString, bool)), this, SLOT(logFlipCard(Player *, QString, bool)));
|
connect(player, SIGNAL(logFlipCard(Player *, QString, bool)), this, SLOT(logFlipCard(Player *, QString, bool)));
|
||||||
connect(player, SIGNAL(logDestroyCard(Player *, QString)), this, SLOT(logDestroyCard(Player *, QString)));
|
connect(player, SIGNAL(logDestroyCard(Player *, QString)), this, SLOT(logDestroyCard(Player *, QString)));
|
||||||
connect(player, SIGNAL(logAttachCard(Player *, QString, Player *, QString)), this, SLOT(logAttachCard(Player *, QString, Player *, QString)));
|
connect(player, SIGNAL(logAttachCard(Player *, QString, Player *, QString)), this, SLOT(logAttachCard(Player *, QString, Player *, QString)));
|
||||||
|
|
|
@ -11,14 +11,31 @@ class CardZone;
|
||||||
class QMouseEvent;
|
class QMouseEvent;
|
||||||
class QEvent;
|
class QEvent;
|
||||||
class CardInfoWidget;
|
class CardInfoWidget;
|
||||||
|
class GameEventContext;
|
||||||
|
class CardItem;
|
||||||
|
|
||||||
|
struct LogMoveCard {
|
||||||
|
Player *player;
|
||||||
|
CardItem *card;
|
||||||
|
CardZone *startZone;
|
||||||
|
int oldX;
|
||||||
|
CardZone *targetZone;
|
||||||
|
int newX;
|
||||||
|
};
|
||||||
|
|
||||||
class MessageLogWidget : public QTextEdit {
|
class MessageLogWidget : public QTextEdit {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
|
enum MessageContext { MessageContext_None, MessageContext_MoveCard };
|
||||||
|
|
||||||
CardInfoWidget *infoWidget;
|
CardInfoWidget *infoWidget;
|
||||||
QString sanitizeHtml(QString dirty) const;
|
QString sanitizeHtml(QString dirty) const;
|
||||||
QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position) const;
|
QPair<QString, QString> getFromStr(CardZone *zone, QString cardName, int position) const;
|
||||||
QString getCardNameUnderMouse(const QPoint &pos) const;
|
QString getCardNameUnderMouse(const QPoint &pos) const;
|
||||||
|
MessageContext currentContext;
|
||||||
|
QList<LogMoveCard> moveCardQueue;
|
||||||
|
QMap<CardItem *, QString> moveCardPT;
|
||||||
|
QMap<CardItem *, bool> moveCardTapped;
|
||||||
signals:
|
signals:
|
||||||
void cardNameHovered(QString cardName);
|
void cardNameHovered(QString cardName);
|
||||||
void showCardInfoPopup(QPoint pos, QString cardName);
|
void showCardInfoPopup(QPoint pos, QString cardName);
|
||||||
|
@ -48,7 +65,8 @@ public slots:
|
||||||
void logRollDie(Player *player, int sides, int roll);
|
void logRollDie(Player *player, int sides, int roll);
|
||||||
void logDrawCards(Player *player, int number);
|
void logDrawCards(Player *player, int number);
|
||||||
void logUndoDraw(Player *player, QString cardName);
|
void logUndoDraw(Player *player, QString cardName);
|
||||||
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
void doMoveCard(LogMoveCard &attributes);
|
||||||
|
void logMoveCard(Player *player, CardItem *card, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||||
void logFlipCard(Player *player, QString cardName, bool faceDown);
|
void logFlipCard(Player *player, QString cardName, bool faceDown);
|
||||||
void logDestroyCard(Player *player, QString cardName);
|
void logDestroyCard(Player *player, QString cardName);
|
||||||
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
||||||
|
@ -56,16 +74,18 @@ public slots:
|
||||||
void logCreateToken(Player *player, QString cardName, QString pt);
|
void logCreateToken(Player *player, QString cardName, QString pt);
|
||||||
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard, bool playerTarget);
|
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard, bool playerTarget);
|
||||||
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
||||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
void logSetTapped(Player *player, CardItem *card, bool tapped);
|
||||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap);
|
||||||
void logSetPT(Player *player, QString cardName, QString newPT);
|
void logSetPT(Player *player, CardItem *card, QString newPT);
|
||||||
void logSetAnnotation(Player *player, QString cardName, QString newAnnotation);
|
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation);
|
||||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||||
void logStopDumpZone(Player *player, CardZone *zone);
|
void logStopDumpZone(Player *player, CardZone *zone);
|
||||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||||
void logSetActivePlayer(Player *player);
|
void logSetActivePlayer(Player *player);
|
||||||
void logSetActivePhase(int phase);
|
void logSetActivePhase(int phase);
|
||||||
|
void containerProcessingStarted(GameEventContext *context);
|
||||||
|
void containerProcessingDone();
|
||||||
public:
|
public:
|
||||||
void connectToPlayer(Player *player);
|
void connectToPlayer(Player *player);
|
||||||
MessageLogWidget(QWidget *parent = 0);
|
MessageLogWidget(QWidget *parent = 0);
|
||||||
|
|
|
@ -50,9 +50,9 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
|
|
||||||
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||||
{
|
{
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardId(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -591,9 +591,9 @@ void Player::actMoveTopCardsToGrave()
|
||||||
const int maxCards = zones.value("deck")->getCards().size();
|
const int maxCards = zones.value("deck")->getCards().size();
|
||||||
if (number > maxCards)
|
if (number > maxCards)
|
||||||
number = maxCards;
|
number = maxCards;
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < number; ++i)
|
for (int i = 0; i < number; ++i)
|
||||||
idList.append(new CardId(i));
|
idList.append(new CardToMove(i));
|
||||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "grave", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "grave", 0, 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,15 +607,15 @@ void Player::actMoveTopCardsToExile()
|
||||||
const int maxCards = zones.value("deck")->getCards().size();
|
const int maxCards = zones.value("deck")->getCards().size();
|
||||||
if (number > maxCards)
|
if (number > maxCards)
|
||||||
number = maxCards;
|
number = maxCards;
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < number; ++i)
|
for (int i = 0; i < number; ++i)
|
||||||
idList.append(new CardId(i));
|
idList.append(new CardToMove(i));
|
||||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "rfg", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "rfg", 0, 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actMoveTopCardToBottom()
|
void Player::actMoveTopCardToBottom()
|
||||||
{
|
{
|
||||||
sendGameCommand(new Command_MoveCard(-1, "deck", QList<CardId *>() << new CardId(0), getId(), "deck", -1, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, "deck", QList<CardToMove *>() << new CardToMove(0), getId(), "deck", -1, 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actUntapAll()
|
void Player::actUntapAll()
|
||||||
|
@ -658,28 +658,29 @@ void Player::actSayMessage()
|
||||||
sendGameCommand(new Command_Say(-1, a->text()));
|
sendGameCommand(new Command_Say(-1, a->text()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QString &avalue, bool allCards)
|
void Player::setCardAttrHelper(GameEventContext *context, CardItem *card, const QString &aname, const QString &avalue, bool allCards)
|
||||||
{
|
{
|
||||||
|
bool moveCardContext = qobject_cast<Context_MoveCard *>(context);
|
||||||
if (aname == "tapped") {
|
if (aname == "tapped") {
|
||||||
bool tapped = avalue == "1";
|
bool tapped = avalue == "1";
|
||||||
if (!(!tapped && card->getDoesntUntap() && allCards)) {
|
if (!(!tapped && card->getDoesntUntap() && allCards)) {
|
||||||
if (!allCards)
|
if (!allCards)
|
||||||
emit logSetTapped(this, card->getName(), tapped);
|
emit logSetTapped(this, card, tapped);
|
||||||
card->setTapped(tapped, true);
|
card->setTapped(tapped, !moveCardContext);
|
||||||
}
|
}
|
||||||
} else if (aname == "attacking")
|
} else if (aname == "attacking")
|
||||||
card->setAttacking(avalue == "1");
|
card->setAttacking(avalue == "1");
|
||||||
else if (aname == "facedown")
|
else if (aname == "facedown")
|
||||||
card->setFaceDown(avalue == "1");
|
card->setFaceDown(avalue == "1");
|
||||||
else if (aname == "annotation") {
|
else if (aname == "annotation") {
|
||||||
emit logSetAnnotation(this, card->getName(), avalue);
|
emit logSetAnnotation(this, card, avalue);
|
||||||
card->setAnnotation(avalue);
|
card->setAnnotation(avalue);
|
||||||
} else if (aname == "doesnt_untap") {
|
} else if (aname == "doesnt_untap") {
|
||||||
bool value = (avalue == "1");
|
bool value = (avalue == "1");
|
||||||
emit logSetDoesntUntap(this, card->getName(), value);
|
emit logSetDoesntUntap(this, card, value);
|
||||||
card->setDoesntUntap(value);
|
card->setDoesntUntap(value);
|
||||||
} else if (aname == "pt") {
|
} else if (aname == "pt") {
|
||||||
emit logSetPT(this, card->getName(), avalue);
|
emit logSetPT(this, card, avalue);
|
||||||
card->setPT(avalue);
|
card->setPT(avalue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -738,7 +739,7 @@ void Player::eventCreateToken(Event_CreateToken *event)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::eventSetCardAttr(Event_SetCardAttr *event)
|
void Player::eventSetCardAttr(Event_SetCardAttr *event, GameEventContext *context)
|
||||||
{
|
{
|
||||||
CardZone *zone = zones.value(event->getZone(), 0);
|
CardZone *zone = zones.value(event->getZone(), 0);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
|
@ -747,16 +748,16 @@ void Player::eventSetCardAttr(Event_SetCardAttr *event)
|
||||||
if (event->getCardId() == -1) {
|
if (event->getCardId() == -1) {
|
||||||
const CardList &cards = zone->getCards();
|
const CardList &cards = zone->getCards();
|
||||||
for (int i = 0; i < cards.size(); i++)
|
for (int i = 0; i < cards.size(); i++)
|
||||||
setCardAttrHelper(cards.at(i), event->getAttrName(), event->getAttrValue(), true);
|
setCardAttrHelper(context, cards.at(i), event->getAttrName(), event->getAttrValue(), true);
|
||||||
if (event->getAttrName() == "tapped")
|
if (event->getAttrName() == "tapped")
|
||||||
emit logSetTapped(this, QString("-1"), event->getAttrValue() == "1");
|
emit logSetTapped(this, 0, event->getAttrValue() == "1");
|
||||||
} else {
|
} else {
|
||||||
CardItem *card = zone->getCard(event->getCardId(), QString());
|
CardItem *card = zone->getCard(event->getCardId(), QString());
|
||||||
if (!card) {
|
if (!card) {
|
||||||
qDebug() << "Player::eventSetCardAttr: card id=" << event->getCardId() << "not found";
|
qDebug() << "Player::eventSetCardAttr: card id=" << event->getCardId() << "not found";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCardAttrHelper(card, event->getAttrName(), event->getAttrValue(), false);
|
setCardAttrHelper(context, card, event->getAttrName(), event->getAttrValue(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,10 +870,11 @@ void Player::eventMoveCard(Event_MoveCard *event, GameEventContext *context)
|
||||||
if (context)
|
if (context)
|
||||||
switch (context->getItemId()) {
|
switch (context->getItemId()) {
|
||||||
case ItemId_Context_UndoDraw: emit logUndoDraw(this, card->getName()); break;
|
case ItemId_Context_UndoDraw: emit logUndoDraw(this, card->getName()); break;
|
||||||
|
case ItemId_Context_MoveCard: emit logMoveCard(this, card, startZone, logPosition, targetZone, logX);
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
emit logMoveCard(this, card->getName(), startZone, logPosition, targetZone, logX);
|
emit logMoveCard(this, card, startZone, logPosition, targetZone, logX);
|
||||||
|
|
||||||
targetZone->addCard(card, true, x, y);
|
targetZone->addCard(card, true, x, y);
|
||||||
|
|
||||||
|
@ -1021,7 +1023,7 @@ void Player::processGameEvent(GameEvent *event, GameEventContext *context)
|
||||||
case ItemId_Event_CreateArrows: eventCreateArrows(static_cast<Event_CreateArrows *>(event)); break;
|
case ItemId_Event_CreateArrows: eventCreateArrows(static_cast<Event_CreateArrows *>(event)); break;
|
||||||
case ItemId_Event_DeleteArrow: eventDeleteArrow(static_cast<Event_DeleteArrow *>(event)); break;
|
case ItemId_Event_DeleteArrow: eventDeleteArrow(static_cast<Event_DeleteArrow *>(event)); break;
|
||||||
case ItemId_Event_CreateToken: eventCreateToken(static_cast<Event_CreateToken *>(event)); break;
|
case ItemId_Event_CreateToken: eventCreateToken(static_cast<Event_CreateToken *>(event)); break;
|
||||||
case ItemId_Event_SetCardAttr: eventSetCardAttr(static_cast<Event_SetCardAttr *>(event)); break;
|
case ItemId_Event_SetCardAttr: eventSetCardAttr(static_cast<Event_SetCardAttr *>(event), context); break;
|
||||||
case ItemId_Event_SetCardCounter: eventSetCardCounter(static_cast<Event_SetCardCounter *>(event)); break;
|
case ItemId_Event_SetCardCounter: eventSetCardCounter(static_cast<Event_SetCardCounter *>(event)); break;
|
||||||
case ItemId_Event_CreateCounters: eventCreateCounters(static_cast<Event_CreateCounters *>(event)); break;
|
case ItemId_Event_CreateCounters: eventCreateCounters(static_cast<Event_CreateCounters *>(event)); break;
|
||||||
case ItemId_Event_SetCounter: eventSetCounter(static_cast<Event_SetCounter *>(event)); break;
|
case ItemId_Event_SetCounter: eventSetCounter(static_cast<Event_SetCounter *>(event)); break;
|
||||||
|
@ -1129,10 +1131,10 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
||||||
{
|
{
|
||||||
CardInfo *ci = c->getInfo();
|
CardInfo *ci = c->getInfo();
|
||||||
if (ci->getTableRow() == 3)
|
if (ci->getTableRow() == 3)
|
||||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardId *>() << new CardId(c->getId()), getId(), "stack", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId()), getId(), "stack", 0, 0, false));
|
||||||
else {
|
else {
|
||||||
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
||||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardId *>() << new CardId(c->getId()), getId(), "table", gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId(), ci->getPowTough(), tapped), getId(), "table", gridPoint.x(), gridPoint.y(), faceDown));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1341,9 +1343,9 @@ void Player::cardMenuAction(QAction *a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < cardList.size(); ++i)
|
for (int i = 0; i < cardList.size(); ++i)
|
||||||
idList.append(new CardId(cardList[i]->getId()));
|
idList.append(new CardToMove(cardList[i]->getId()));
|
||||||
QString startZone = cardList[0]->getZone()->getName();
|
QString startZone = cardList[0]->getZone()->getName();
|
||||||
|
|
||||||
switch (a->data().toInt()) {
|
switch (a->data().toInt()) {
|
||||||
|
|
|
@ -58,17 +58,17 @@ signals:
|
||||||
void logCreateToken(Player *player, QString cardName, QString pt);
|
void logCreateToken(Player *player, QString cardName, QString pt);
|
||||||
void logDrawCards(Player *player, int number);
|
void logDrawCards(Player *player, int number);
|
||||||
void logUndoDraw(Player *player, QString cardName);
|
void logUndoDraw(Player *player, QString cardName);
|
||||||
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
void logMoveCard(Player *player, CardItem *card, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||||
void logFlipCard(Player *player, QString cardName, bool faceDown);
|
void logFlipCard(Player *player, QString cardName, bool faceDown);
|
||||||
void logDestroyCard(Player *player, QString cardName);
|
void logDestroyCard(Player *player, QString cardName);
|
||||||
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
||||||
void logUnattachCard(Player *player, QString cardName);
|
void logUnattachCard(Player *player, QString cardName);
|
||||||
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
||||||
void logSetTapped(Player *player, QString cardName, bool tapped);
|
void logSetTapped(Player *player, CardItem *card, bool tapped);
|
||||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||||
void logSetDoesntUntap(Player *player, QString cardName, bool doesntUntap);
|
void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap);
|
||||||
void logSetPT(Player *player, QString cardName, QString newPT);
|
void logSetPT(Player *player, CardItem *card, QString newPT);
|
||||||
void logSetAnnotation(Player *player, QString cardName, QString newAnnotation);
|
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation);
|
||||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||||
void logStopDumpZone(Player *player, CardZone *zone);
|
void logStopDumpZone(Player *player, CardZone *zone);
|
||||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||||
|
@ -147,7 +147,7 @@ private:
|
||||||
HandZone *hand;
|
HandZone *hand;
|
||||||
PlayerTarget *playerTarget;
|
PlayerTarget *playerTarget;
|
||||||
|
|
||||||
void setCardAttrHelper(CardItem *card, const QString &aname, const QString &avalue, bool allCards);
|
void setCardAttrHelper(GameEventContext *context, CardItem *card, const QString &aname, const QString &avalue, bool allCards);
|
||||||
|
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
QRectF bRect;
|
QRectF bRect;
|
||||||
|
@ -164,7 +164,7 @@ private:
|
||||||
void eventCreateArrows(Event_CreateArrows *event);
|
void eventCreateArrows(Event_CreateArrows *event);
|
||||||
void eventDeleteArrow(Event_DeleteArrow *event);
|
void eventDeleteArrow(Event_DeleteArrow *event);
|
||||||
void eventCreateToken(Event_CreateToken *event);
|
void eventCreateToken(Event_CreateToken *event);
|
||||||
void eventSetCardAttr(Event_SetCardAttr *event);
|
void eventSetCardAttr(Event_SetCardAttr *event, GameEventContext *context);
|
||||||
void eventSetCardCounter(Event_SetCardCounter *event);
|
void eventSetCardCounter(Event_SetCardCounter *event);
|
||||||
void eventCreateCounters(Event_CreateCounters *event);
|
void eventCreateCounters(Event_CreateCounters *event);
|
||||||
void eventSetCounter(Event_SetCounter *event);
|
void eventSetCounter(Event_SetCounter *event);
|
||||||
|
|
|
@ -57,9 +57,9 @@ void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
|
||||||
if (startZone == this)
|
if (startZone == this)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardId(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -391,6 +391,7 @@ void TabGame::processGameEventContainer(GameEventContainer *cont, AbstractClient
|
||||||
{
|
{
|
||||||
const QList<GameEvent *> &eventList = cont->getEventList();
|
const QList<GameEvent *> &eventList = cont->getEventList();
|
||||||
GameEventContext *context = cont->getContext();
|
GameEventContext *context = cont->getContext();
|
||||||
|
messageLog->containerProcessingStarted(context);
|
||||||
for (int i = 0; i < eventList.size(); ++i) {
|
for (int i = 0; i < eventList.size(); ++i) {
|
||||||
GameEvent *event = eventList[i];
|
GameEvent *event = eventList[i];
|
||||||
|
|
||||||
|
@ -430,6 +431,7 @@ void TabGame::processGameEventContainer(GameEventContainer *cont, AbstractClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
messageLog->containerProcessingDone();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::sendGameCommand(GameCommand *command, int playerId)
|
void TabGame::sendGameCommand(GameCommand *command, int playerId)
|
||||||
|
|
|
@ -138,6 +138,8 @@ signals:
|
||||||
void gameClosing(TabGame *tab);
|
void gameClosing(TabGame *tab);
|
||||||
void playerAdded(Player *player);
|
void playerAdded(Player *player);
|
||||||
void playerRemoved(Player *player);
|
void playerRemoved(Player *player);
|
||||||
|
void containerProcessingStarted(GameEventContext *context);
|
||||||
|
void containerProcessingDone();
|
||||||
private slots:
|
private slots:
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void newCardAdded(AbstractCardItem *card);
|
||||||
void showCardInfoPopup(const QPoint &pos, const QString &cardName);
|
void showCardInfoPopup(const QPoint &pos, const QString &cardName);
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
#include "arrowitem.h"
|
#include "arrowitem.h"
|
||||||
#include "carddragitem.h"
|
#include "carddragitem.h"
|
||||||
|
#include "carddatabase.h"
|
||||||
|
|
||||||
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
||||||
: SelectZone(_p, "table", true, false, true, parent), active(false)
|
: SelectZone(_p, "table", true, false, true, parent), active(false)
|
||||||
|
@ -92,11 +93,11 @@ void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
|
||||||
|
|
||||||
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint, bool faceDown, bool tapped)
|
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint, bool faceDown, bool tapped)
|
||||||
{
|
{
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardId(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId(), startZone->getName() == name ? QString() : dragItems[i]->getItem()->getInfo()->getPowTough(), tapped));
|
||||||
|
|
||||||
startZone->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
startZone->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), gridPoint.x(), gridPoint.y(), faceDown));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::reorganizeCards()
|
void TableZone::reorganizeCards()
|
||||||
|
|
|
@ -126,9 +126,9 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
|
|
||||||
void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
||||||
{
|
{
|
||||||
QList<CardId *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardId(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ void ProtocolItem::initializeHash()
|
||||||
registerSerializableItem("player_ping", ServerInfo_PlayerPing::newItem);
|
registerSerializableItem("player_ping", ServerInfo_PlayerPing::newItem);
|
||||||
registerSerializableItem("file", DeckList_File::newItem);
|
registerSerializableItem("file", DeckList_File::newItem);
|
||||||
registerSerializableItem("directory", DeckList_Directory::newItem);
|
registerSerializableItem("directory", DeckList_Directory::newItem);
|
||||||
registerSerializableItem("card_id", CardId::newItem);
|
registerSerializableItem("card_to_move", CardToMove::newItem);
|
||||||
registerSerializableItem("game_type_id", GameTypeId::newItem);
|
registerSerializableItem("game_type_id", GameTypeId::newItem);
|
||||||
|
|
||||||
registerSerializableItem("containercmd", CommandContainer::newItem);
|
registerSerializableItem("containercmd", CommandContainer::newItem);
|
||||||
|
@ -224,7 +224,7 @@ QList<MoveCardToZone *> Command_SetSideboardPlan::getMoveList() const
|
||||||
return typecastItemList<MoveCardToZone *>();
|
return typecastItemList<MoveCardToZone *>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const QList<CardId *> &_cardIds, int _targetPlayerId, const QString &_targetZone, int _x, int _y, bool _faceDown, bool _tapped)
|
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayerId, const QString &_targetZone, int _x, int _y, bool _faceDown)
|
||||||
: GameCommand("move_card", _gameId)
|
: GameCommand("move_card", _gameId)
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_String("start_zone", _startZone));
|
insertItem(new SerializableItem_String("start_zone", _startZone));
|
||||||
|
@ -233,10 +233,9 @@ Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const
|
||||||
insertItem(new SerializableItem_Int("x", _x));
|
insertItem(new SerializableItem_Int("x", _x));
|
||||||
insertItem(new SerializableItem_Int("y", _y));
|
insertItem(new SerializableItem_Int("y", _y));
|
||||||
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
||||||
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
|
||||||
|
|
||||||
for (int i = 0; i < _cardIds.size(); ++i)
|
for (int i = 0; i < _cards.size(); ++i)
|
||||||
itemList.append(_cardIds[i]);
|
itemList.append(_cards[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, ResponseCode> ProtocolResponse::responseHash;
|
QHash<QString, ResponseCode> ProtocolResponse::responseHash;
|
||||||
|
|
|
@ -116,6 +116,7 @@ private:
|
||||||
// XXX Move these out. They are only for processing inside the server.
|
// XXX Move these out. They are only for processing inside the server.
|
||||||
ProtocolResponse *resp;
|
ProtocolResponse *resp;
|
||||||
QList<ProtocolItem *> itemQueue;
|
QList<ProtocolItem *> itemQueue;
|
||||||
|
GameEventContext *gameEventContext;
|
||||||
GameEventContainer *gameEventQueuePublic;
|
GameEventContainer *gameEventQueuePublic;
|
||||||
GameEventContainer *gameEventQueueOmniscient;
|
GameEventContainer *gameEventQueueOmniscient;
|
||||||
GameEventContainer *gameEventQueuePrivate;
|
GameEventContainer *gameEventQueuePrivate;
|
||||||
|
@ -222,15 +223,14 @@ public:
|
||||||
class Command_MoveCard : public GameCommand {
|
class Command_MoveCard : public GameCommand {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Command_MoveCard(int _gameId = -1, const QString &_startZone = QString(), const QList<CardId *> &_cardIds = QList<CardId *>(), int _targetPlayerId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1, bool _faceDown = false, bool _tapped = false);
|
Command_MoveCard(int _gameId = -1, const QString &_startZone = QString(), const QList<CardToMove *> &_cards = QList<CardToMove *>(), int _targetPlayerId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1, bool _faceDown = false);
|
||||||
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); }
|
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); }
|
||||||
QList<CardId *> getCardIds() const { return typecastItemList<CardId *>(); }
|
QList<CardToMove *> getCards() const { return typecastItemList<CardToMove *>(); }
|
||||||
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_id"))->getData(); }
|
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_id"))->getData(); }
|
||||||
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); }
|
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); }
|
||||||
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); }
|
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); }
|
||||||
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); }
|
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); }
|
||||||
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("face_down"))->getData(); }
|
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("face_down"))->getData(); }
|
||||||
bool getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); }
|
|
||||||
static SerializableItem *newItem() { return new Command_MoveCard; }
|
static SerializableItem *newItem() { return new Command_MoveCard; }
|
||||||
int getItemId() const { return ItemId_Command_MoveCard; }
|
int getItemId() const { return ItemId_Command_MoveCard; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
|
CardToMove::CardToMove(int _cardId, const QString &_pt, bool _tapped)
|
||||||
|
: SerializableItem_Map("card_to_move")
|
||||||
|
{
|
||||||
|
insertItem(new SerializableItem_Int("card_id", _cardId));
|
||||||
|
insertItem(new SerializableItem_String("pt", _pt));
|
||||||
|
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
||||||
|
}
|
||||||
|
|
||||||
ServerInfo_User::ServerInfo_User(const QString &_name, int _userLevel, const QString &_realName, const QString &_country, const QByteArray &_avatarBmp)
|
ServerInfo_User::ServerInfo_User(const QString &_name, int _userLevel, const QString &_realName, const QString &_country, const QByteArray &_avatarBmp)
|
||||||
: SerializableItem_Map("user")
|
: SerializableItem_Map("user")
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,11 +20,15 @@ enum ResponseCode { RespNothing, RespOk, RespInvalidCommand, RespInvalidData, Re
|
||||||
// list index, whereas cards in any other zone are referenced by their ids.
|
// list index, whereas cards in any other zone are referenced by their ids.
|
||||||
enum ZoneType { PrivateZone, PublicZone, HiddenZone };
|
enum ZoneType { PrivateZone, PublicZone, HiddenZone };
|
||||||
|
|
||||||
class CardId : public SerializableItem_Int {
|
class CardToMove : public SerializableItem_Map {
|
||||||
public:
|
public:
|
||||||
CardId(int _cardId = -1) : SerializableItem_Int("card_id", _cardId) { }
|
CardToMove(int _cardId = -1, const QString &_pt = QString(), bool _tapped = false);
|
||||||
static SerializableItem *newItem() { return new CardId; }
|
static SerializableItem *newItem() { return new CardToMove; }
|
||||||
|
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); }
|
||||||
|
QString getPT() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); }
|
||||||
|
bool getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class GameTypeId : public SerializableItem_Int {
|
class GameTypeId : public SerializableItem_Int {
|
||||||
public:
|
public:
|
||||||
GameTypeId(int _gameTypeId = -1) : SerializableItem_Int("game_type_id", _gameTypeId) { }
|
GameTypeId(int _gameTypeId = -1) : SerializableItem_Int("game_type_id", _gameTypeId) { }
|
||||||
|
|
|
@ -69,6 +69,7 @@ ItemId_Context_ReadyStart = 1067,
|
||||||
ItemId_Context_Concede = 1068,
|
ItemId_Context_Concede = 1068,
|
||||||
ItemId_Context_DeckSelect = 1069,
|
ItemId_Context_DeckSelect = 1069,
|
||||||
ItemId_Context_UndoDraw = 1070,
|
ItemId_Context_UndoDraw = 1070,
|
||||||
ItemId_Command_UpdateServerMessage = 1071,
|
ItemId_Context_MoveCard = 1071,
|
||||||
ItemId_Other = 1072
|
ItemId_Command_UpdateServerMessage = 1072,
|
||||||
|
ItemId_Other = 1073
|
||||||
};
|
};
|
||||||
|
|
|
@ -422,6 +422,10 @@ Context_UndoDraw::Context_UndoDraw()
|
||||||
: GameEventContext("undo_draw")
|
: GameEventContext("undo_draw")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Context_MoveCard::Context_MoveCard()
|
||||||
|
: GameEventContext("move_card")
|
||||||
|
{
|
||||||
|
}
|
||||||
Command_UpdateServerMessage::Command_UpdateServerMessage()
|
Command_UpdateServerMessage::Command_UpdateServerMessage()
|
||||||
: AdminCommand("update_server_message")
|
: AdminCommand("update_server_message")
|
||||||
{
|
{
|
||||||
|
@ -498,5 +502,6 @@ void ProtocolItem::initializeHashAuto()
|
||||||
itemNameHash.insert("game_event_contextconcede", Context_Concede::newItem);
|
itemNameHash.insert("game_event_contextconcede", Context_Concede::newItem);
|
||||||
itemNameHash.insert("game_event_contextdeck_select", Context_DeckSelect::newItem);
|
itemNameHash.insert("game_event_contextdeck_select", Context_DeckSelect::newItem);
|
||||||
itemNameHash.insert("game_event_contextundo_draw", Context_UndoDraw::newItem);
|
itemNameHash.insert("game_event_contextundo_draw", Context_UndoDraw::newItem);
|
||||||
|
itemNameHash.insert("game_event_contextmove_card", Context_MoveCard::newItem);
|
||||||
itemNameHash.insert("cmdupdate_server_message", Command_UpdateServerMessage::newItem);
|
itemNameHash.insert("cmdupdate_server_message", Command_UpdateServerMessage::newItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,4 +68,5 @@
|
||||||
6:concede
|
6:concede
|
||||||
6:deck_select:i,deck_id
|
6:deck_select:i,deck_id
|
||||||
6:undo_draw
|
6:undo_draw
|
||||||
|
6:move_card
|
||||||
7:update_server_message
|
7:update_server_message
|
||||||
|
|
|
@ -634,6 +634,13 @@ public:
|
||||||
static SerializableItem *newItem() { return new Context_UndoDraw; }
|
static SerializableItem *newItem() { return new Context_UndoDraw; }
|
||||||
int getItemId() const { return ItemId_Context_UndoDraw; }
|
int getItemId() const { return ItemId_Context_UndoDraw; }
|
||||||
};
|
};
|
||||||
|
class Context_MoveCard : public GameEventContext {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Context_MoveCard();
|
||||||
|
static SerializableItem *newItem() { return new Context_MoveCard; }
|
||||||
|
int getItemId() const { return ItemId_Context_MoveCard; }
|
||||||
|
};
|
||||||
class Command_UpdateServerMessage : public AdminCommand {
|
class Command_UpdateServerMessage : public AdminCommand {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -155,7 +155,11 @@ bool Server_CardZone::isColumnEmpty(int x, int y) const
|
||||||
void Server_CardZone::moveCard(CommandContainer *cont, QMap<int, Server_Card *> &coordMap, Server_Card *card, int x, int y)
|
void Server_CardZone::moveCard(CommandContainer *cont, QMap<int, Server_Card *> &coordMap, Server_Card *card, int x, int y)
|
||||||
{
|
{
|
||||||
coordMap.remove(card->getY() * 10000 + card->getX());
|
coordMap.remove(card->getY() * 10000 + card->getX());
|
||||||
player->moveCard(cont, this, QList<int>() << card->getId(), this, x, y, card->getFaceDown(), false, false);
|
|
||||||
|
CardToMove *cardToMove = new CardToMove(card->getId());
|
||||||
|
player->moveCard(cont, this, QList<CardToMove *>() << cardToMove, this, x, y, card->getFaceDown(), false);
|
||||||
|
delete cardToMove;
|
||||||
|
|
||||||
coordMap.insert(y * 10000 + x, card);
|
coordMap.insert(y * 10000 + x, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,10 +231,14 @@ ResponseCode Server_Player::undoDraw(CommandContainer *cont)
|
||||||
if (lastDrawList.isEmpty())
|
if (lastDrawList.isEmpty())
|
||||||
return RespContextError;
|
return RespContextError;
|
||||||
|
|
||||||
return moveCard(cont, zones.value("hand"), QList<int>() << lastDrawList.takeLast(), zones.value("deck"), 0, 0, false, false, false, true);
|
ResponseCode retVal;
|
||||||
|
CardToMove *cardToMove = new CardToMove(lastDrawList.takeLast());
|
||||||
|
retVal = moveCard(cont, zones.value("hand"), QList<CardToMove *>() << cardToMove, zones.value("deck"), 0, 0, false, false, true);
|
||||||
|
delete cardToMove;
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_startZone, const QList<int> &_cardIds, int targetPlayerId, const QString &_targetZone, int x, int y, bool faceDown, bool tapped)
|
ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_startZone, const QList<CardToMove *> &_cards, int targetPlayerId, const QString &_targetZone, int x, int y, bool faceDown)
|
||||||
{
|
{
|
||||||
Server_CardZone *startzone = getZones().value(_startZone);
|
Server_CardZone *startzone = getZones().value(_startZone);
|
||||||
Server_Player *targetPlayer = game->getPlayers().value(targetPlayerId);
|
Server_Player *targetPlayer = game->getPlayers().value(targetPlayerId);
|
||||||
|
@ -244,7 +248,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_sta
|
||||||
if ((!startzone) || (!targetzone))
|
if ((!startzone) || (!targetzone))
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
|
|
||||||
return moveCard(cont, startzone, _cardIds, targetzone, x, y, faceDown, tapped);
|
return moveCard(cont, startzone, _cards, targetzone, x, y, faceDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Server_Player::MoveCardCompareFunctor {
|
class Server_Player::MoveCardCompareFunctor {
|
||||||
|
@ -268,7 +272,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<int> &_cardIds, Server_CardZone *targetzone, int x, int y, bool faceDown, bool tapped, bool fixFreeSpaces, bool undoingDraw)
|
ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool faceDown, bool fixFreeSpaces, bool undoingDraw)
|
||||||
{
|
{
|
||||||
// Disallow controller change to other zones than the table.
|
// Disallow controller change to other zones than the table.
|
||||||
if (((targetzone->getType() != PublicZone) || !targetzone->hasCoords()) && (startzone->getPlayer() != targetzone->getPlayer()))
|
if (((targetzone->getType() != PublicZone) || !targetzone->hasCoords()) && (startzone->getPlayer() != targetzone->getPlayer()))
|
||||||
|
@ -278,14 +282,16 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
x = targetzone->cards.size();
|
x = targetzone->cards.size();
|
||||||
|
|
||||||
QList<QPair<Server_Card *, int> > cardsToMove;
|
QList<QPair<Server_Card *, int> > cardsToMove;
|
||||||
for (int i = 0; i < _cardIds.size(); ++i) {
|
QMap<Server_Card *, CardToMove *> cardProperties;
|
||||||
|
for (int i = 0; i < _cards.size(); ++i) {
|
||||||
int position;
|
int position;
|
||||||
Server_Card *card = startzone->getCard(_cardIds[i], false, &position);
|
Server_Card *card = startzone->getCard(_cards[i]->getCardId(), false, &position);
|
||||||
if (!card)
|
if (!card)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
if (!card->getAttachedCards().isEmpty() && !targetzone->isColumnEmpty(x, y))
|
if (!card->getAttachedCards().isEmpty() && !targetzone->isColumnEmpty(x, y))
|
||||||
return RespContextError;
|
return RespContextError;
|
||||||
cardsToMove.append(QPair<Server_Card *, int>(card, position));
|
cardsToMove.append(QPair<Server_Card *, int>(card, position));
|
||||||
|
cardProperties.insert(card, _cards[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveCardCompareFunctor cmp(startzone == targetzone ? -1 : x);
|
MoveCardCompareFunctor cmp(startzone == targetzone ? -1 : x);
|
||||||
|
@ -295,6 +301,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
int xIndex = -1;
|
int xIndex = -1;
|
||||||
for (int cardIndex = 0; cardIndex < cardsToMove.size(); ++cardIndex) {
|
for (int cardIndex = 0; cardIndex < cardsToMove.size(); ++cardIndex) {
|
||||||
Server_Card *card = cardsToMove[cardIndex].first;
|
Server_Card *card = cardsToMove[cardIndex].first;
|
||||||
|
CardToMove *thisCardProperties = cardProperties.value(card);
|
||||||
int originalPosition = cardsToMove[cardIndex].second;
|
int originalPosition = cardsToMove[cardIndex].second;
|
||||||
int position = startzone->removeCard(card);
|
int position = startzone->removeCard(card);
|
||||||
if (startzone->getName() == "hand") {
|
if (startzone->getName() == "hand") {
|
||||||
|
@ -345,8 +352,8 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
|
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
|
||||||
cont->enqueueGameEventPrivate(new Event_DestroyCard(getPlayerId(), startzone->getName(), card->getId()), game->getGameId());
|
cont->enqueueGameEventPrivate(new Event_DestroyCard(getPlayerId(), startzone->getName(), card->getId()), game->getGameId(), -1, new Context_MoveCard);
|
||||||
cont->enqueueGameEventPublic(new Event_DestroyCard(getPlayerId(), startzone->getName(), card->getId()), game->getGameId());
|
cont->enqueueGameEventPublic(new Event_DestroyCard(getPlayerId(), startzone->getName(), card->getId()), game->getGameId(), new Context_MoveCard);
|
||||||
card->deleteLater();
|
card->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
if (!targetzone->hasCoords()) {
|
if (!targetzone->hasCoords()) {
|
||||||
|
@ -388,8 +395,8 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
int privatePosition = -1;
|
int privatePosition = -1;
|
||||||
if (startzone->getType() == HiddenZone)
|
if (startzone->getType() == HiddenZone)
|
||||||
privatePosition = position;
|
privatePosition = position;
|
||||||
cont->enqueueGameEventPrivate(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, faceDown), game->getGameId(), -1, undoingDraw ? new Context_UndoDraw : 0);
|
cont->enqueueGameEventPrivate(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, faceDown), game->getGameId(), -1, undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
cont->enqueueGameEventOmniscient(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, faceDown), game->getGameId(), undoingDraw ? new Context_UndoDraw : 0);
|
cont->enqueueGameEventOmniscient(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, faceDown), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
|
|
||||||
// Other players do not get to see the start and/or target position of the card if the respective
|
// Other players do not get to see the start and/or target position of the card if the respective
|
||||||
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
|
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
|
||||||
|
@ -403,12 +410,14 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
newX = -1;
|
newX = -1;
|
||||||
|
|
||||||
if ((startzone->getType() == PublicZone) || (targetzone->getType() == PublicZone))
|
if ((startzone->getType() == PublicZone) || (targetzone->getType() == PublicZone))
|
||||||
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), oldCardId, publicCardName, startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, card->getId(), faceDown), game->getGameId(), undoingDraw ? new Context_UndoDraw : 0);
|
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), oldCardId, publicCardName, startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, card->getId(), faceDown), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
else
|
else
|
||||||
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), -1, QString(), startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, -1, false), game->getGameId(), undoingDraw ? new Context_UndoDraw : 0);
|
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), -1, QString(), startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, -1, false), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
|
|
||||||
if (tapped)
|
if (thisCardProperties->getTapped())
|
||||||
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "tapped", "1");
|
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "tapped", "1");
|
||||||
|
if (!thisCardProperties->getPT().isEmpty())
|
||||||
|
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "pt", thisCardProperties->getPT());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (startzone->hasCoords() && fixFreeSpaces)
|
if (startzone->hasCoords() && fixFreeSpaces)
|
||||||
|
@ -425,7 +434,9 @@ void Server_Player::unattachCard(CommandContainer *cont, Server_Card *card)
|
||||||
cont->enqueueGameEventPrivate(new Event_AttachCard(getPlayerId(), zone->getName(), card->getId(), -1, QString(), -1), game->getGameId());
|
cont->enqueueGameEventPrivate(new Event_AttachCard(getPlayerId(), zone->getName(), card->getId(), -1, QString(), -1), game->getGameId());
|
||||||
cont->enqueueGameEventPublic(new Event_AttachCard(getPlayerId(), zone->getName(), card->getId(), -1, QString(), -1), game->getGameId());
|
cont->enqueueGameEventPublic(new Event_AttachCard(getPlayerId(), zone->getName(), card->getId(), -1, QString(), -1), game->getGameId());
|
||||||
|
|
||||||
moveCard(cont, zone, QList<int>() << card->getId(), zone, -1, card->getY(), card->getFaceDown(), false);
|
CardToMove *cardToMove = new CardToMove(card->getId());
|
||||||
|
moveCard(cont, zone, QList<CardToMove *>() << cardToMove, zone, -1, card->getY(), card->getFaceDown());
|
||||||
|
delete cardToMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_Player::setCardAttrHelper(CommandContainer *cont, const QString &zoneName, int cardId, const QString &attrName, const QString &attrValue)
|
ResponseCode Server_Player::setCardAttrHelper(CommandContainer *cont, const QString &zoneName, int cardId, const QString &attrName, const QString &attrValue)
|
||||||
|
|
|
@ -78,8 +78,8 @@ public:
|
||||||
|
|
||||||
ResponseCode drawCards(CommandContainer *cont, int number);
|
ResponseCode drawCards(CommandContainer *cont, int number);
|
||||||
ResponseCode undoDraw(CommandContainer *cont);
|
ResponseCode undoDraw(CommandContainer *cont);
|
||||||
ResponseCode moveCard(CommandContainer *cont, const QString &_startZone, const QList<int> &_cardId, int _targetPlayer, const QString &_targetZone, int _x, int _y, bool _faceDown, bool _tapped);
|
ResponseCode moveCard(CommandContainer *cont, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayer, const QString &_targetZone, int _x, int _y, bool _faceDown);
|
||||||
ResponseCode moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<int> &_cardId, Server_CardZone *targetzone, int x, int y, bool faceDown, bool tapped, bool fixFreeSpaces = true, bool undoingDraw = false);
|
ResponseCode moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool faceDown, bool fixFreeSpaces = true, bool undoingDraw = false);
|
||||||
void unattachCard(CommandContainer *cont, Server_Card *card);
|
void unattachCard(CommandContainer *cont, Server_Card *card);
|
||||||
ResponseCode setCardAttrHelper(CommandContainer *cont, const QString &zone, int cardId, const QString &attrName, const QString &attrValue);
|
ResponseCode setCardAttrHelper(CommandContainer *cont, const QString &zone, int cardId, const QString &attrName, const QString &attrValue);
|
||||||
|
|
||||||
|
|
|
@ -510,8 +510,11 @@ ResponseCode Server_ProtocolHandler::cmdMulligan(Command_Mulligan * /*cmd*/, Com
|
||||||
int number = (hand->cards.size() <= 1) ? player->getInitialCards() : hand->cards.size() - 1;
|
int number = (hand->cards.size() <= 1) ? player->getInitialCards() : hand->cards.size() - 1;
|
||||||
|
|
||||||
Server_CardZone *deck = player->getZones().value("deck");
|
Server_CardZone *deck = player->getZones().value("deck");
|
||||||
while (!hand->cards.isEmpty())
|
while (!hand->cards.isEmpty()) {
|
||||||
player->moveCard(cont, hand, QList<int>() << hand->cards.first()->getId(), deck, 0, 0, false, false);
|
CardToMove *cardToMove = new CardToMove(hand->cards.first()->getId());
|
||||||
|
player->moveCard(cont, hand, QList<CardToMove *>() << cardToMove, deck, 0, 0, false);
|
||||||
|
delete cardToMove;
|
||||||
|
}
|
||||||
|
|
||||||
deck->shuffle();
|
deck->shuffle();
|
||||||
cont->enqueueGameEventPrivate(new Event_Shuffle(player->getPlayerId()), game->getGameId());
|
cont->enqueueGameEventPrivate(new Event_Shuffle(player->getPlayerId()), game->getGameId());
|
||||||
|
@ -569,12 +572,7 @@ ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, CommandC
|
||||||
if (player->getConceded())
|
if (player->getConceded())
|
||||||
return RespContextError;
|
return RespContextError;
|
||||||
|
|
||||||
QList<int> cardIds;
|
return player->moveCard(cont, cmd->getStartZone(), cmd->getCards(), cmd->getTargetPlayerId(), cmd->getTargetZone(), cmd->getX(), cmd->getY(), cmd->getFaceDown());
|
||||||
const QList<CardId *> &temp = cmd->getCardIds();
|
|
||||||
for (int i = 0; i < temp.size(); ++i)
|
|
||||||
cardIds.append(temp[i]->getData());
|
|
||||||
|
|
||||||
return player->moveCard(cont, cmd->getStartZone(), cardIds, cmd->getTargetPlayerId(), cmd->getTargetZone(), cmd->getX(), cmd->getY(), cmd->getFaceDown(), cmd->getTapped());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdFlipCard(Command_FlipCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::cmdFlipCard(Command_FlipCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
|
@ -678,8 +676,11 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm
|
||||||
for (int i = 0; i < attachedList.size(); ++i)
|
for (int i = 0; i < attachedList.size(); ++i)
|
||||||
player->unattachCard(cont, attachedList[i]);
|
player->unattachCard(cont, attachedList[i]);
|
||||||
|
|
||||||
if (targetzone->isColumnStacked(targetCard->getX(), targetCard->getY()))
|
if (targetzone->isColumnStacked(targetCard->getX(), targetCard->getY())) {
|
||||||
targetPlayer->moveCard(cont, targetzone, QList<int>() << targetCard->getId(), targetzone, targetzone->getFreeGridColumn(-2, targetCard->getY(), targetCard->getName()), targetCard->getY(), targetCard->getFaceDown(), false);
|
CardToMove *cardToMove = new CardToMove(targetCard->getId());
|
||||||
|
targetPlayer->moveCard(cont, targetzone, QList<CardToMove *>() << cardToMove, targetzone, targetzone->getFreeGridColumn(-2, targetCard->getY(), targetCard->getName()), targetCard->getY(), targetCard->getFaceDown());
|
||||||
|
delete cardToMove;
|
||||||
|
}
|
||||||
|
|
||||||
card->setParentCard(targetCard);
|
card->setParentCard(targetCard);
|
||||||
card->setCoords(-1, card->getY());
|
card->setCoords(-1, card->getY());
|
||||||
|
|
Loading…
Reference in a new issue