mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-22 23:26:14 -08:00
improved token dialog
This commit is contained in:
@@ -10,6 +10,7 @@ QT += network svg
|
|||||||
HEADERS += src/counter.h \
|
HEADERS += src/counter.h \
|
||||||
src/dlg_creategame.h \
|
src/dlg_creategame.h \
|
||||||
src/dlg_connect.h \
|
src/dlg_connect.h \
|
||||||
|
src/dlg_create_token.h \
|
||||||
src/gamesmodel.h \
|
src/gamesmodel.h \
|
||||||
src/client.h \
|
src/client.h \
|
||||||
src/window_main.h \
|
src/window_main.h \
|
||||||
@@ -64,6 +65,7 @@ HEADERS += src/counter.h \
|
|||||||
SOURCES += src/counter.cpp \
|
SOURCES += src/counter.cpp \
|
||||||
src/dlg_creategame.cpp \
|
src/dlg_creategame.cpp \
|
||||||
src/dlg_connect.cpp \
|
src/dlg_connect.cpp \
|
||||||
|
src/dlg_create_token.cpp \
|
||||||
src/client.cpp \
|
src/client.cpp \
|
||||||
src/main.cpp \
|
src/main.cpp \
|
||||||
src/window_main.cpp \
|
src/window_main.cpp \
|
||||||
|
|||||||
@@ -53,48 +53,47 @@ void AbstractCardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *
|
|||||||
} else {
|
} else {
|
||||||
QFont f("Serif");
|
QFont f("Serif");
|
||||||
f.setStyleHint(QFont::Serif);
|
f.setStyleHint(QFont::Serif);
|
||||||
f.setPixelSize(11);
|
f.setPixelSize(12);
|
||||||
painter->setFont(f);
|
painter->setFont(f);
|
||||||
painter->setBrush(QColor(230, 230, 230));
|
QString colorStr;
|
||||||
qDebug() <<"COLORS:::::" << info->getColors();
|
if (!color.isEmpty())
|
||||||
QString color;
|
colorStr = color;
|
||||||
QPen pen;
|
else if (info->getColors().size() > 1)
|
||||||
if(!info->getColors().empty())
|
colorStr = "m";
|
||||||
{
|
else
|
||||||
color = info->getColors().first();
|
colorStr = info->getColors().first().toLower();
|
||||||
if(color == "B")
|
|
||||||
painter->setBrush(QColor(0,0,0));
|
|
||||||
if(color == "U")
|
|
||||||
painter->setBrush(QColor(0,140,180));
|
|
||||||
if(color == "W")
|
|
||||||
painter->setBrush(QColor(255,250,140));
|
|
||||||
if(color == "R")
|
|
||||||
painter->setBrush(QColor(230,0,0));
|
|
||||||
if(color == "G")
|
|
||||||
painter->setBrush(QColor(0,160,0));
|
|
||||||
if(info->getColors().size() > 1)
|
|
||||||
{
|
|
||||||
painter->setBrush(QColor(250,190,30));
|
|
||||||
color = "M"; // Multicolor
|
|
||||||
}
|
|
||||||
|
|
||||||
|
QColor bgColor;
|
||||||
|
QColor textColor = Qt::white;
|
||||||
|
if (colorStr == "b")
|
||||||
|
bgColor = QColor(0, 0, 0);
|
||||||
|
else if (colorStr == "u")
|
||||||
|
bgColor = QColor(0, 140, 180);
|
||||||
|
else if (colorStr == "w") {
|
||||||
|
bgColor = QColor(255, 250, 140);
|
||||||
|
textColor = Qt::black;
|
||||||
|
} else if (colorStr == "r")
|
||||||
|
bgColor = QColor(230, 0, 0);
|
||||||
|
else if (colorStr == "g")
|
||||||
|
bgColor = QColor(0, 160, 0);
|
||||||
|
else if (colorStr == "m") {
|
||||||
|
bgColor = QColor(250, 190, 30);
|
||||||
|
textColor = Qt::black;
|
||||||
|
} else {
|
||||||
|
bgColor = QColor(230, 230, 230);
|
||||||
|
textColor = Qt::black;
|
||||||
}
|
}
|
||||||
|
painter->setBrush(bgColor);
|
||||||
painter->setPen(Qt::black);
|
QPen pen(Qt::black);
|
||||||
|
painter->setPen(pen);
|
||||||
|
|
||||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||||
|
|
||||||
pen.setWidth(3);
|
pen.setWidth(3);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->drawRect(QRectF(3, 3, CARD_WIDTH - 6, CARD_HEIGHT - 6));
|
painter->drawRect(QRectF(3, 3, CARD_WIDTH - 6, CARD_HEIGHT - 6));
|
||||||
painter->setPen(Qt::white);
|
painter->setPen(textColor);
|
||||||
if(color == "W" || color == "" || color == "M")
|
|
||||||
painter->setPen(Qt::black);
|
|
||||||
painter->drawText(QRectF(5, 5, CARD_WIDTH - 15, CARD_HEIGHT - 15), Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap, name);
|
painter->drawText(QRectF(5, 5, CARD_WIDTH - 15, CARD_HEIGHT - 15), Qt::AlignTop | Qt::AlignLeft | Qt::TextWordWrap, name);
|
||||||
if(info->getCardType().contains("Creature"))
|
|
||||||
{
|
|
||||||
painter->drawText(QRectF(CARD_WIDTH - 40, CARD_HEIGHT - 25, 30, 30), Qt::AlignTop | Qt::AlignRight | Qt::TextWordWrap, info->getPowTough());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
@@ -115,6 +114,12 @@ void AbstractCardItem::setName(const QString &_name)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AbstractCardItem::setColor(const QString &_color)
|
||||||
|
{
|
||||||
|
color = _color;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
void AbstractCardItem::setTapped(bool _tapped)
|
void AbstractCardItem::setTapped(bool _tapped)
|
||||||
{
|
{
|
||||||
tapped = _tapped;
|
tapped = _tapped;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ protected:
|
|||||||
CardInfo *info;
|
CardInfo *info;
|
||||||
QString name;
|
QString name;
|
||||||
bool tapped;
|
bool tapped;
|
||||||
|
QString color;
|
||||||
private slots:
|
private slots:
|
||||||
void pixmapUpdated();
|
void pixmapUpdated();
|
||||||
signals:
|
signals:
|
||||||
@@ -35,6 +36,8 @@ public:
|
|||||||
CardInfo *getInfo() const { return info; }
|
CardInfo *getInfo() const { return info; }
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
void setName(const QString &_name = QString());
|
void setName(const QString &_name = QString());
|
||||||
|
QString getColor() const { return color; }
|
||||||
|
void setColor(const QString &_color);
|
||||||
bool getTapped() const { return tapped; }
|
bool getTapped() const { return tapped; }
|
||||||
void setTapped(bool _tapped);
|
void setTapped(bool _tapped);
|
||||||
void processHoverEvent();
|
void processHoverEvent();
|
||||||
|
|||||||
@@ -202,9 +202,9 @@ void MessageLogWidget::logMoveCard(Player *player, QString cardName, CardZone *s
|
|||||||
append(finalStr.arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr).arg(newX));
|
append(finalStr.arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr).arg(newX));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logCreateToken(Player *player, QString cardName)
|
void MessageLogWidget::logCreateToken(Player *player, QString cardName, QString pt)
|
||||||
{
|
{
|
||||||
append(tr("%1 creates token: %2.").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))));
|
append(tr("%1 creates token: %2 (%3).").arg(sanitizeHtml(player->getName())).arg(QString("<font color=\"blue\">%1</font>").arg(sanitizeHtml(cardName))).arg(sanitizeHtml(pt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard)
|
void MessageLogWidget::logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard)
|
||||||
@@ -319,7 +319,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||||||
connect(player, SIGNAL(logShuffle(Player *)), this, SLOT(logShuffle(Player *)));
|
connect(player, SIGNAL(logShuffle(Player *)), this, SLOT(logShuffle(Player *)));
|
||||||
connect(player, SIGNAL(logRollDie(Player *, int, int)), this, SLOT(logRollDie(Player *, int, int)));
|
connect(player, SIGNAL(logRollDie(Player *, int, int)), this, SLOT(logRollDie(Player *, int, int)));
|
||||||
connect(player, SIGNAL(logCreateArrow(Player *, Player *, QString, Player *, QString)), this, SLOT(logCreateArrow(Player *, Player *, QString, Player *, QString)));
|
connect(player, SIGNAL(logCreateArrow(Player *, Player *, QString, Player *, QString)), this, SLOT(logCreateArrow(Player *, Player *, QString, Player *, QString)));
|
||||||
connect(player, SIGNAL(logCreateToken(Player *, QString)), this, SLOT(logCreateToken(Player *, 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 *, QString, bool)), this, SLOT(logSetTapped(Player *, QString, bool)));
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ 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 logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||||
void logCreateToken(Player *player, QString cardName);
|
void logCreateToken(Player *player, QString cardName, QString pt);
|
||||||
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard);
|
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard);
|
||||||
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, QString cardName, bool tapped);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "protocol_items.h"
|
#include "protocol_items.h"
|
||||||
#include "gamescene.h"
|
#include "gamescene.h"
|
||||||
#include "settingscache.h"
|
#include "settingscache.h"
|
||||||
|
#include "dlg_create_token.h"
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
@@ -182,6 +183,10 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
|||||||
aCreateToken = new QAction(this);
|
aCreateToken = new QAction(this);
|
||||||
connect(aCreateToken, SIGNAL(triggered()), this, SLOT(actCreateToken()));
|
connect(aCreateToken, SIGNAL(triggered()), this, SLOT(actCreateToken()));
|
||||||
|
|
||||||
|
aCreateAnotherToken = new QAction(this);
|
||||||
|
connect(aCreateAnotherToken, SIGNAL(triggered()), this, SLOT(actCreateAnotherToken()));
|
||||||
|
aCreateAnotherToken->setEnabled(false);
|
||||||
|
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
countersMenu = playerMenu->addMenu(QString());
|
countersMenu = playerMenu->addMenu(QString());
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
@@ -190,6 +195,7 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
|||||||
playerMenu->addAction(aRollDie);
|
playerMenu->addAction(aRollDie);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
playerMenu->addAction(aCreateToken);
|
playerMenu->addAction(aCreateToken);
|
||||||
|
playerMenu->addAction(aCreateAnotherToken);
|
||||||
playerMenu->addSeparator();
|
playerMenu->addSeparator();
|
||||||
sayMenu = playerMenu->addMenu(QString());
|
sayMenu = playerMenu->addMenu(QString());
|
||||||
initSayMenu();
|
initSayMenu();
|
||||||
@@ -264,6 +270,7 @@ Player::Player(const QString &_name, int _id, bool _local, Client *_client, TabG
|
|||||||
countersMenu = 0;
|
countersMenu = 0;
|
||||||
sbMenu = 0;
|
sbMenu = 0;
|
||||||
cardMenu = 0;
|
cardMenu = 0;
|
||||||
|
aCreateAnotherToken = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rearrangeZones();
|
rearrangeZones();
|
||||||
@@ -376,6 +383,8 @@ void Player::retranslateUi()
|
|||||||
aRollDie->setShortcut(tr("Ctrl+I"));
|
aRollDie->setShortcut(tr("Ctrl+I"));
|
||||||
aCreateToken->setText(tr("&Create token..."));
|
aCreateToken->setText(tr("&Create token..."));
|
||||||
aCreateToken->setShortcut(tr("Ctrl+T"));
|
aCreateToken->setShortcut(tr("Ctrl+T"));
|
||||||
|
aCreateAnotherToken->setText(tr("C&reate another token"));
|
||||||
|
aCreateAnotherToken->setShortcut(tr("Ctrl+G"));
|
||||||
sayMenu->setTitle(tr("S&ay"));
|
sayMenu->setTitle(tr("S&ay"));
|
||||||
|
|
||||||
QMapIterator<int, Counter *> counterIterator(counters);
|
QMapIterator<int, Counter *> counterIterator(counters);
|
||||||
@@ -491,9 +500,22 @@ void Player::actRollDie()
|
|||||||
|
|
||||||
void Player::actCreateToken()
|
void Player::actCreateToken()
|
||||||
{
|
{
|
||||||
QString cardname = QInputDialog::getText(0, tr("Create token"), tr("Name:"));
|
DlgCreateToken dlg;
|
||||||
if (!cardname.isEmpty())
|
if (!dlg.exec())
|
||||||
sendGameCommand(new Command_CreateToken(-1, "table", cardname, QString(), -1, 0));
|
return;
|
||||||
|
|
||||||
|
lastTokenName = dlg.getName();
|
||||||
|
lastTokenColor = dlg.getColor();
|
||||||
|
lastTokenPT = dlg.getPT();
|
||||||
|
lastTokenAnnotation = dlg.getAnnotation();
|
||||||
|
aCreateAnotherToken->setEnabled(true);
|
||||||
|
|
||||||
|
sendGameCommand(new Command_CreateToken(-1, "table", dlg.getName(), dlg.getColor(), dlg.getPT(), dlg.getAnnotation(), -1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::actCreateAnotherToken()
|
||||||
|
{
|
||||||
|
sendGameCommand(new Command_CreateToken(-1, "table", lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation, -1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actSayMessage()
|
void Player::actSayMessage()
|
||||||
@@ -566,8 +588,11 @@ void Player::eventCreateToken(Event_CreateToken *event)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
CardItem *card = new CardItem(this, event->getCardName(), event->getCardId());
|
CardItem *card = new CardItem(this, event->getCardName(), event->getCardId());
|
||||||
|
card->setColor(event->getColor());
|
||||||
|
card->setPT(event->getPt());
|
||||||
|
card->setAnnotation(event->getAnnotation());
|
||||||
|
|
||||||
emit logCreateToken(this, card->getName());
|
emit logCreateToken(this, card->getName(), card->getPT());
|
||||||
zone->addCard(card, true, event->getX(), event->getY());
|
zone->addCard(card, true, event->getX(), event->getY());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ signals:
|
|||||||
void logShuffle(Player *player);
|
void logShuffle(Player *player);
|
||||||
void logRollDie(Player *player, int sides, int roll);
|
void logRollDie(Player *player, int sides, int roll);
|
||||||
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard);
|
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard);
|
||||||
void logCreateToken(Player *player, QString cardName);
|
void logCreateToken(Player *player, QString cardName, QString pt);
|
||||||
void logDrawCards(Player *player, int number);
|
void logDrawCards(Player *player, int number);
|
||||||
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
void logMoveCard(Player *player, QString cardName, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||||
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
||||||
@@ -66,6 +66,7 @@ public slots:
|
|||||||
void actUntapAll();
|
void actUntapAll();
|
||||||
void actRollDie();
|
void actRollDie();
|
||||||
void actCreateToken();
|
void actCreateToken();
|
||||||
|
void actCreateAnotherToken();
|
||||||
void actShuffle();
|
void actShuffle();
|
||||||
void actDrawCard();
|
void actDrawCard();
|
||||||
void actDrawCards();
|
void actDrawCards();
|
||||||
@@ -96,7 +97,7 @@ private:
|
|||||||
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
|
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
|
||||||
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard,
|
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard,
|
||||||
*aDrawCard, *aDrawCards, *aMulligan, *aShuffle,
|
*aDrawCard, *aDrawCards, *aMulligan, *aShuffle,
|
||||||
*aUntapAll, *aRollDie, *aCreateToken;
|
*aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken;
|
||||||
|
|
||||||
typedef void (Player::*CardMenuHandler)(CardItem *card);
|
typedef void (Player::*CardMenuHandler)(CardItem *card);
|
||||||
QHash<QAction *, CardMenuHandler> cardMenuHandlers;
|
QHash<QAction *, CardMenuHandler> cardMenuHandlers;
|
||||||
@@ -115,6 +116,7 @@ private:
|
|||||||
void actMoveToExile(CardItem *card);
|
void actMoveToExile(CardItem *card);
|
||||||
|
|
||||||
int defaultNumberTopCards;
|
int defaultNumberTopCards;
|
||||||
|
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
|
||||||
QString name;
|
QString name;
|
||||||
int id;
|
int id;
|
||||||
bool active;
|
bool active;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ ServerInfo_CardCounter::ServerInfo_CardCounter(int _id, int _value)
|
|||||||
insertItem(new SerializableItem_Int("value", _value));
|
insertItem(new SerializableItem_Int("value", _value));
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo_Card::ServerInfo_Card(int _id, const QString &_name, int _x, int _y, bool _tapped, bool _attacking, const QString &_pt, const QString &_annotation, const QList<ServerInfo_CardCounter *> &_counters)
|
ServerInfo_Card::ServerInfo_Card(int _id, const QString &_name, int _x, int _y, bool _tapped, bool _attacking, const QString &_color, const QString &_pt, const QString &_annotation, const QList<ServerInfo_CardCounter *> &_counters)
|
||||||
: SerializableItem_Map("card")
|
: SerializableItem_Map("card")
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_Int("id", _id));
|
insertItem(new SerializableItem_Int("id", _id));
|
||||||
@@ -48,6 +48,7 @@ ServerInfo_Card::ServerInfo_Card(int _id, const QString &_name, int _x, int _y,
|
|||||||
insertItem(new SerializableItem_Int("y", _y));
|
insertItem(new SerializableItem_Int("y", _y));
|
||||||
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
||||||
insertItem(new SerializableItem_Bool("attacking", _attacking));
|
insertItem(new SerializableItem_Bool("attacking", _attacking));
|
||||||
|
insertItem(new SerializableItem_String("color", _color));
|
||||||
insertItem(new SerializableItem_String("pt", _pt));
|
insertItem(new SerializableItem_String("pt", _pt));
|
||||||
insertItem(new SerializableItem_String("annotation", _annotation));
|
insertItem(new SerializableItem_String("annotation", _annotation));
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
|
|
||||||
class ServerInfo_Card : public SerializableItem_Map {
|
class ServerInfo_Card : public SerializableItem_Map {
|
||||||
public:
|
public:
|
||||||
ServerInfo_Card(int _id = -1, const QString &_name = QString(), int _x = -1, int _y = -1, bool _tapped = false, bool _attacking = false, const QString &_pt = QString(), const QString &_annotation = QString(), const QList<ServerInfo_CardCounter *> &_counterList = QList<ServerInfo_CardCounter *>());
|
ServerInfo_Card(int _id = -1, const QString &_name = QString(), int _x = -1, int _y = -1, bool _tapped = false, bool _attacking = false, const QString &_color = QString(), const QString &_pt = QString(), const QString &_annotation = QString(), const QList<ServerInfo_CardCounter *> &_counterList = QList<ServerInfo_CardCounter *>());
|
||||||
static SerializableItem *newItem() { return new ServerInfo_Card; }
|
static SerializableItem *newItem() { return new ServerInfo_Card; }
|
||||||
int getId() const { return static_cast<SerializableItem_Int *>(itemMap.value("id"))->getData(); }
|
int getId() const { return static_cast<SerializableItem_Int *>(itemMap.value("id"))->getData(); }
|
||||||
QString getName() const { return static_cast<SerializableItem_String *>(itemMap.value("name"))->getData(); }
|
QString getName() const { return static_cast<SerializableItem_String *>(itemMap.value("name"))->getData(); }
|
||||||
@@ -70,6 +70,7 @@ public:
|
|||||||
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 getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); }
|
bool getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); }
|
||||||
bool getAttacking() const { return static_cast<SerializableItem_Bool *>(itemMap.value("attacking"))->getData(); }
|
bool getAttacking() const { return static_cast<SerializableItem_Bool *>(itemMap.value("attacking"))->getData(); }
|
||||||
|
QString getColor() const { return static_cast<SerializableItem_String *>(itemMap.value("color"))->getData(); }
|
||||||
QString getPT() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); }
|
QString getPT() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); }
|
||||||
QString getAnnotation() const { return static_cast<SerializableItem_String *>(itemMap.value("annotation"))->getData(); }
|
QString getAnnotation() const { return static_cast<SerializableItem_String *>(itemMap.value("annotation"))->getData(); }
|
||||||
QList<ServerInfo_CardCounter *> getCounters() const { return typecastItemList<ServerInfo_CardCounter *>(); }
|
QList<ServerInfo_CardCounter *> getCounters() const { return typecastItemList<ServerInfo_CardCounter *>(); }
|
||||||
|
|||||||
@@ -114,12 +114,14 @@ Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, int _
|
|||||||
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
||||||
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
||||||
}
|
}
|
||||||
Command_CreateToken::Command_CreateToken(int _gameId, const QString &_zone, const QString &_cardName, const QString &_pt, int _x, int _y)
|
Command_CreateToken::Command_CreateToken(int _gameId, const QString &_zone, const QString &_cardName, const QString &_color, const QString &_pt, const QString &_annotation, int _x, int _y)
|
||||||
: GameCommand("create_token", _gameId)
|
: GameCommand("create_token", _gameId)
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_String("zone", _zone));
|
insertItem(new SerializableItem_String("zone", _zone));
|
||||||
insertItem(new SerializableItem_String("card_name", _cardName));
|
insertItem(new SerializableItem_String("card_name", _cardName));
|
||||||
|
insertItem(new SerializableItem_String("color", _color));
|
||||||
insertItem(new SerializableItem_String("pt", _pt));
|
insertItem(new SerializableItem_String("pt", _pt));
|
||||||
|
insertItem(new SerializableItem_String("annotation", _annotation));
|
||||||
insertItem(new SerializableItem_Int("x", _x));
|
insertItem(new SerializableItem_Int("x", _x));
|
||||||
insertItem(new SerializableItem_Int("y", _y));
|
insertItem(new SerializableItem_Int("y", _y));
|
||||||
}
|
}
|
||||||
@@ -255,13 +257,15 @@ Event_MoveCard::Event_MoveCard(int _playerId, int _cardId, const QString &_cardN
|
|||||||
insertItem(new SerializableItem_Int("new_card_id", _newCardId));
|
insertItem(new SerializableItem_Int("new_card_id", _newCardId));
|
||||||
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
||||||
}
|
}
|
||||||
Event_CreateToken::Event_CreateToken(int _playerId, const QString &_zone, int _cardId, const QString &_cardName, const QString &_pt, int _x, int _y)
|
Event_CreateToken::Event_CreateToken(int _playerId, const QString &_zone, int _cardId, const QString &_cardName, const QString &_color, const QString &_pt, const QString &_annotation, int _x, int _y)
|
||||||
: GameEvent("create_token", _playerId)
|
: GameEvent("create_token", _playerId)
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_String("zone", _zone));
|
insertItem(new SerializableItem_String("zone", _zone));
|
||||||
insertItem(new SerializableItem_Int("card_id", _cardId));
|
insertItem(new SerializableItem_Int("card_id", _cardId));
|
||||||
insertItem(new SerializableItem_String("card_name", _cardName));
|
insertItem(new SerializableItem_String("card_name", _cardName));
|
||||||
|
insertItem(new SerializableItem_String("color", _color));
|
||||||
insertItem(new SerializableItem_String("pt", _pt));
|
insertItem(new SerializableItem_String("pt", _pt));
|
||||||
|
insertItem(new SerializableItem_String("annotation", _annotation));
|
||||||
insertItem(new SerializableItem_Int("x", _x));
|
insertItem(new SerializableItem_Int("x", _x));
|
||||||
insertItem(new SerializableItem_Int("y", _y));
|
insertItem(new SerializableItem_Int("y", _y));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
2:roll_die:i,sides
|
2:roll_die:i,sides
|
||||||
2:draw_cards:i,number
|
2:draw_cards:i,number
|
||||||
2:move_card:s,start_zone:i,card_id:s,target_zone:i,x:i,y:b,face_down:b,tapped
|
2:move_card:s,start_zone:i,card_id:s,target_zone:i,x:i,y:b,face_down:b,tapped
|
||||||
2:create_token:s,zone:s,card_name:s,pt:i,x:i,y
|
2:create_token:s,zone:s,card_name:s,color:s,pt:s,annotation:i,x:i,y
|
||||||
2:create_arrow:i,start_player_id:s,start_zone:i,start_card_id:i,target_player_id:s,target_zone:i,target_card_id:c,color
|
2:create_arrow:i,start_player_id:s,start_zone:i,start_card_id:i,target_player_id:s,target_zone:i,target_card_id:c,color
|
||||||
2:delete_arrow:i,arrow_id
|
2:delete_arrow:i,arrow_id
|
||||||
2:set_card_attr:s,zone:i,card_id:s,attr_name:s,attr_value
|
2:set_card_attr:s,zone:i,card_id:s,attr_name:s,attr_value
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
3:shuffle
|
3:shuffle
|
||||||
3:roll_die:i,sides:i,value
|
3:roll_die:i,sides:i,value
|
||||||
3:move_card:i,card_id:s,card_name:s,start_zone:i,position:s,target_zone:i,x:i,y:i,new_card_id:b,face_down
|
3:move_card:i,card_id:s,card_name:s,start_zone:i,position:s,target_zone:i,x:i,y:i,new_card_id:b,face_down
|
||||||
3:create_token:s,zone:i,card_id:s,card_name:s,pt:i,x:i,y
|
3:create_token:s,zone:i,card_id:s,card_name:s,color:s,pt:s,annotation:i,x:i,y
|
||||||
3:delete_arrow:i,arrow_id
|
3:delete_arrow:i,arrow_id
|
||||||
3:set_card_attr:s,zone:i,card_id:s,attr_name:s,attr_value
|
3:set_card_attr:s,zone:i,card_id:s,attr_name:s,attr_value
|
||||||
3:set_card_counter:s,zone:i,card_id:i,counter_id:i,counter_value
|
3:set_card_counter:s,zone:i,card_id:i,counter_id:i,counter_value
|
||||||
|
|||||||
@@ -182,10 +182,12 @@ public:
|
|||||||
class Command_CreateToken : public GameCommand {
|
class Command_CreateToken : public GameCommand {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Command_CreateToken(int _gameId = -1, const QString &_zone = QString(), const QString &_cardName = QString(), const QString &_pt = QString(), int _x = -1, int _y = -1);
|
Command_CreateToken(int _gameId = -1, const QString &_zone = QString(), const QString &_cardName = QString(), const QString &_color = QString(), const QString &_pt = QString(), const QString &_annotation = QString(), int _x = -1, int _y = -1);
|
||||||
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
|
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
|
||||||
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); };
|
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); };
|
||||||
|
QString getColor() const { return static_cast<SerializableItem_String *>(itemMap.value("color"))->getData(); };
|
||||||
QString getPt() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); };
|
QString getPt() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); };
|
||||||
|
QString getAnnotation() const { return static_cast<SerializableItem_String *>(itemMap.value("annotation"))->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(); };
|
||||||
static SerializableItem *newItem() { return new Command_CreateToken; }
|
static SerializableItem *newItem() { return new Command_CreateToken; }
|
||||||
@@ -389,11 +391,13 @@ public:
|
|||||||
class Event_CreateToken : public GameEvent {
|
class Event_CreateToken : public GameEvent {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Event_CreateToken(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1, const QString &_cardName = QString(), const QString &_pt = QString(), int _x = -1, int _y = -1);
|
Event_CreateToken(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1, const QString &_cardName = QString(), const QString &_color = QString(), const QString &_pt = QString(), const QString &_annotation = QString(), int _x = -1, int _y = -1);
|
||||||
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
|
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
|
||||||
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
|
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
|
||||||
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); };
|
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); };
|
||||||
|
QString getColor() const { return static_cast<SerializableItem_String *>(itemMap.value("color"))->getData(); };
|
||||||
QString getPt() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); };
|
QString getPt() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); };
|
||||||
|
QString getAnnotation() const { return static_cast<SerializableItem_String *>(itemMap.value("annotation"))->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(); };
|
||||||
static SerializableItem *newItem() { return new Event_CreateToken; }
|
static SerializableItem *newItem() { return new Event_CreateToken; }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "server_card.h"
|
#include "server_card.h"
|
||||||
|
|
||||||
Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y)
|
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), pt(QString()), annotation(QString()), doesntUntap(false)
|
: id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false), facedown(false), color(QString()), pt(QString()), annotation(QString()), doesntUntap(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ void Server_Card::resetState()
|
|||||||
setTapped(false);
|
setTapped(false);
|
||||||
setAttacking(false);
|
setAttacking(false);
|
||||||
setFaceDown(false);
|
setFaceDown(false);
|
||||||
|
setColor(QString());
|
||||||
setPT(QString());
|
setPT(QString());
|
||||||
setAnnotation(QString());
|
setAnnotation(QString());
|
||||||
setDoesntUntap(false);
|
setDoesntUntap(false);
|
||||||
@@ -51,6 +52,8 @@ bool Server_Card::setAttribute(const QString &aname, const QString &avalue, bool
|
|||||||
setAttacking(avalue == "1");
|
setAttacking(avalue == "1");
|
||||||
} else if (aname == "facedown") {
|
} else if (aname == "facedown") {
|
||||||
setFaceDown(avalue == "1");
|
setFaceDown(avalue == "1");
|
||||||
|
} else if (aname == "color") {
|
||||||
|
setColor(avalue);
|
||||||
} else if (aname == "pt") {
|
} else if (aname == "pt") {
|
||||||
setPT(avalue);
|
setPT(avalue);
|
||||||
} else if (aname == "annotation") {
|
} else if (aname == "annotation") {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ private:
|
|||||||
bool tapped;
|
bool tapped;
|
||||||
bool attacking;
|
bool attacking;
|
||||||
bool facedown;
|
bool facedown;
|
||||||
|
QString color;
|
||||||
QString pt;
|
QString pt;
|
||||||
QString annotation;
|
QString annotation;
|
||||||
bool doesntUntap;
|
bool doesntUntap;
|
||||||
@@ -54,6 +55,7 @@ public:
|
|||||||
bool getTapped() const { return tapped; }
|
bool getTapped() const { return tapped; }
|
||||||
bool getAttacking() const { return attacking; }
|
bool getAttacking() const { return attacking; }
|
||||||
bool getFaceDown() const { return facedown; }
|
bool getFaceDown() const { return facedown; }
|
||||||
|
QString getColor() const { return color; }
|
||||||
QString getPT() const { return pt; }
|
QString getPT() const { return pt; }
|
||||||
QString getAnnotation() const { return annotation; }
|
QString getAnnotation() const { return annotation; }
|
||||||
bool getDoesntUntap() const { return doesntUntap; }
|
bool getDoesntUntap() const { return doesntUntap; }
|
||||||
@@ -65,6 +67,7 @@ public:
|
|||||||
void setTapped(bool _tapped) { tapped = _tapped; }
|
void setTapped(bool _tapped) { tapped = _tapped; }
|
||||||
void setAttacking(bool _attacking) { attacking = _attacking; }
|
void setAttacking(bool _attacking) { attacking = _attacking; }
|
||||||
void setFaceDown(bool _facedown) { facedown = _facedown; }
|
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) { pt = _pt; }
|
||||||
void setAnnotation(const QString &_annotation) { annotation = _annotation; }
|
void setAnnotation(const QString &_annotation) { annotation = _annotation; }
|
||||||
void setDoesntUntap(bool _doesntUntap) { doesntUntap = _doesntUntap; }
|
void setDoesntUntap(bool _doesntUntap) { doesntUntap = _doesntUntap; }
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ QList<ServerInfo_Player *> Server_Game::getGameState(Server_Player *playerWhosAs
|
|||||||
cardCounterList.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value()));
|
cardCounterList.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cardList.append(new ServerInfo_Card(card->getId(), displayedName, card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getPT(), card->getAnnotation(), cardCounterList));
|
cardList.append(new ServerInfo_Card(card->getId(), displayedName, card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), cardCounterList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zoneList.append(new ServerInfo_Zone(zone->getName(), zone->getType(), zone->hasCoords(), zone->cards.size(), cardList));
|
zoneList.append(new ServerInfo_Zone(zone->getName(), zone->getType(), zone->hasCoords(), zone->cards.size(), cardList));
|
||||||
|
|||||||
@@ -609,7 +609,6 @@ ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, Co
|
|||||||
if (!game->getGameStarted())
|
if (!game->getGameStarted())
|
||||||
return RespGameNotStarted;
|
return RespGameNotStarted;
|
||||||
|
|
||||||
// powtough wird erst mal ignoriert
|
|
||||||
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
||||||
if (!zone)
|
if (!zone)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
@@ -624,8 +623,12 @@ ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, Co
|
|||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
Server_Card *card = new Server_Card(cmd->getCardName(), player->newCardId(), x, y);
|
Server_Card *card = new Server_Card(cmd->getCardName(), player->newCardId(), x, y);
|
||||||
|
card->setPT(cmd->getPt());
|
||||||
|
card->setColor(cmd->getColor());
|
||||||
|
card->setAnnotation(cmd->getAnnotation());
|
||||||
|
|
||||||
zone->insertCard(card, x, y);
|
zone->insertCard(card, x, y);
|
||||||
game->sendGameEvent(new Event_CreateToken(player->getPlayerId(), zone->getName(), card->getId(), card->getName(), cmd->getPt(), x, y));
|
game->sendGameEvent(new Event_CreateToken(player->getPlayerId(), zone->getName(), card->getId(), card->getName(), cmd->getColor(), cmd->getPt(), cmd->getAnnotation(), x, y));
|
||||||
|
|
||||||
return RespOk;
|
return RespOk;
|
||||||
}
|
}
|
||||||
@@ -898,7 +901,7 @@ ResponseCode Server_ProtocolHandler::cmdDumpZone(Command_DumpZone *cmd, CommandC
|
|||||||
cardCounterIterator.next();
|
cardCounterIterator.next();
|
||||||
cardCounterList.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value()));
|
cardCounterList.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value()));
|
||||||
}
|
}
|
||||||
respCardList.append(new ServerInfo_Card(card->getId(), displayedName, card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getPT(), card->getAnnotation(), cardCounterList));
|
respCardList.append(new ServerInfo_Card(card->getId(), displayedName, card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), cardCounterList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zone->getType() == HiddenZone) {
|
if (zone->getType() == HiddenZone) {
|
||||||
|
|||||||
Reference in New Issue
Block a user