removed some unneeded code, counter appearance changed
This commit is contained in:
parent
a543c9b90c
commit
29699418d2
20 changed files with 293 additions and 242 deletions
|
@ -13,14 +13,12 @@ HEADERS += src/counter.h \
|
||||||
src/gamesmodel.h \
|
src/gamesmodel.h \
|
||||||
src/client.h \
|
src/client.h \
|
||||||
src/window_main.h \
|
src/window_main.h \
|
||||||
src/zonelist.h \
|
|
||||||
src/cardzone.h \
|
src/cardzone.h \
|
||||||
src/player.h \
|
src/player.h \
|
||||||
src/cardlist.h \
|
src/cardlist.h \
|
||||||
src/carditem.h \
|
src/carditem.h \
|
||||||
src/tablezone.h \
|
src/tablezone.h \
|
||||||
src/handzone.h \
|
src/handzone.h \
|
||||||
src/playerlist.h \
|
|
||||||
src/game.h \
|
src/game.h \
|
||||||
src/carddatabase.h \
|
src/carddatabase.h \
|
||||||
src/gameview.h \
|
src/gameview.h \
|
||||||
|
@ -53,12 +51,10 @@ SOURCES += src/counter.cpp \
|
||||||
src/gamesmodel.cpp \
|
src/gamesmodel.cpp \
|
||||||
src/player.cpp \
|
src/player.cpp \
|
||||||
src/cardzone.cpp \
|
src/cardzone.cpp \
|
||||||
src/zonelist.cpp \
|
|
||||||
src/cardlist.cpp \
|
src/cardlist.cpp \
|
||||||
src/carditem.cpp \
|
src/carditem.cpp \
|
||||||
src/tablezone.cpp \
|
src/tablezone.cpp \
|
||||||
src/handzone.cpp \
|
src/handzone.cpp \
|
||||||
src/playerlist.cpp \
|
|
||||||
src/game.cpp \
|
src/game.cpp \
|
||||||
src/carddatabase.cpp \
|
src/carddatabase.cpp \
|
||||||
src/gameview.cpp \
|
src/gameview.cpp \
|
||||||
|
|
|
@ -245,10 +245,11 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (!zone->getPlayer()->getLocal())
|
if (!zone->getPlayer()->getLocal())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (zone->getName() == "table")
|
TableZone *tz = qobject_cast<TableZone *>(zone);
|
||||||
((TableZone *) zone)->toggleTapped();
|
if (tz)
|
||||||
|
tz->toggleTapped();
|
||||||
else {
|
else {
|
||||||
TableZone *table = (TableZone *) zone->getPlayer()->getZones().findZone("table");
|
TableZone *table = zone->getPlayer()->getTable();
|
||||||
QPoint gridPoint = table->getFreeGridPoint(info->getTableRow());
|
QPoint gridPoint = table->getFreeGridPoint(info->getTableRow());
|
||||||
table->handleDropEventByGrid(id, zone, gridPoint, false);
|
table->handleDropEventByGrid(id, zone, gridPoint, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,13 +132,12 @@ void CardZone::setCardAttr(int cardId, const QString &aname, const QString &aval
|
||||||
player->client->setCardAttr(name, cardId, aname, avalue);
|
player->client->setCardAttr(name, cardId, aname, avalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardZone::setView(ZoneViewZone *_view)
|
void CardZone::moveAllToZone()
|
||||||
{
|
{
|
||||||
view = _view;
|
QList<QVariant> data = static_cast<QAction *>(sender())->data().toList();
|
||||||
}
|
QString targetZone = data[0].toString();
|
||||||
|
int targetX = data[1].toInt();
|
||||||
|
|
||||||
void CardZone::moveAllToZone(const QString &targetZone, int targetX)
|
|
||||||
{
|
|
||||||
// Cards need to be moved in reverse order so that the other
|
// Cards need to be moved in reverse order so that the other
|
||||||
// cards' list index doesn't change
|
// cards' list index doesn't change
|
||||||
for (int i = cards.size() - 1; i >= 0; i--)
|
for (int i = cards.size() - 1; i >= 0; i--)
|
||||||
|
|
|
@ -29,6 +29,8 @@ protected:
|
||||||
virtual void addCardImpl(CardItem *card, int x, int y) = 0;
|
virtual void addCardImpl(CardItem *card, int x, int y) = 0;
|
||||||
signals:
|
signals:
|
||||||
void contentsChanged();
|
void contentsChanged();
|
||||||
|
public slots:
|
||||||
|
void moveAllToZone();
|
||||||
public:
|
public:
|
||||||
enum { Type = typeZone };
|
enum { Type = typeZone };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
|
@ -52,9 +54,8 @@ public:
|
||||||
virtual CardItem *takeCard(int position, int cardId, const QString &cardName, bool canResize = true);
|
virtual CardItem *takeCard(int position, int cardId, const QString &cardName, bool canResize = true);
|
||||||
void setCardAttr(int cardId, const QString &aname, const QString &avalue);
|
void setCardAttr(int cardId, const QString &aname, const QString &avalue);
|
||||||
ZoneViewZone *getView() const { return view; }
|
ZoneViewZone *getView() const { return view; }
|
||||||
void setView(ZoneViewZone *_view);
|
void setView(ZoneViewZone *_view) { view = _view; }
|
||||||
virtual void reorganizeCards() = 0;
|
virtual void reorganizeCards() = 0;
|
||||||
void moveAllToZone(const QString &targetZone, int targetX);
|
|
||||||
virtual QPointF closestGridPoint(const QPointF &point);
|
virtual QPointF closestGridPoint(const QPointF &point);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -314,14 +314,14 @@ void Client::readLine()
|
||||||
emit protocolError();
|
emit protocolError();
|
||||||
}
|
}
|
||||||
} else if (prefix == "list_counters") {
|
} else if (prefix == "list_counters") {
|
||||||
if (values.size() != 5) {
|
if (values.size() != 6) {
|
||||||
emit protocolError();
|
emit protocolError();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int cmdid = values.takeFirst().toInt();
|
int cmdid = values.takeFirst().toInt();
|
||||||
PendingCommand *pc = pendingCommands.value(cmdid, 0);
|
PendingCommand *pc = pendingCommands.value(cmdid, 0);
|
||||||
int colorValue = values[2].toInt();
|
int colorValue = values[3].toInt();
|
||||||
ServerCounter sc(values[0].toInt(), values[1], QColor(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256), values[3].toInt());
|
ServerCounter sc(values[0].toInt(), values[1].toInt(), values[2], QColor(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256), values[4].toInt(), values[5].toInt());
|
||||||
|
|
||||||
PendingCommand_ListCounters *pcLC = qobject_cast<PendingCommand_ListCounters *>(pc);
|
PendingCommand_ListCounters *pcLC = qobject_cast<PendingCommand_ListCounters *>(pc);
|
||||||
if (pcLC)
|
if (pcLC)
|
||||||
|
@ -508,24 +508,24 @@ PendingCommand *Client::readyStart()
|
||||||
return cmd("ready_start");
|
return cmd("ready_start");
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCommand *Client::incCounter(const QString &counter, int delta)
|
PendingCommand *Client::incCounter(int counterId, int delta)
|
||||||
{
|
{
|
||||||
return cmd(QString("inc_counter|%1|%2").arg(counter).arg(delta));
|
return cmd(QString("inc_counter|%1|%2").arg(counterId).arg(delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCommand *Client::addCounter(const QString &counter, QColor color, int value)
|
PendingCommand *Client::addCounter(const QString &counterName, QColor color, int radius, int value)
|
||||||
{
|
{
|
||||||
return cmd(QString("add_counter|%1|%2|%3").arg(counter).arg(color.red() * 65536 + color.green() * 256 + color.blue()).arg(value));
|
return cmd(QString("add_counter|%1|%2|%3|%4").arg(counterName).arg(color.red() * 65536 + color.green() * 256 + color.blue()).arg(radius).arg(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCommand *Client::setCounter(const QString &counter, int value)
|
PendingCommand *Client::setCounter(int counterId, int value)
|
||||||
{
|
{
|
||||||
return cmd(QString("set_counter|%1|%2").arg(counter).arg(value));
|
return cmd(QString("set_counter|%1|%2").arg(counterId).arg(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCommand *Client::delCounter(const QString &counter)
|
PendingCommand *Client::delCounter(int counterId)
|
||||||
{
|
{
|
||||||
return cmd(QString("del_counter|%1").arg(counter));
|
return cmd(QString("del_counter|%1").arg(counterId));
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingCommand_ListCounters *Client::listCounters(int playerId)
|
PendingCommand_ListCounters *Client::listCounters(int playerId)
|
||||||
|
|
|
@ -173,15 +173,19 @@ public:
|
||||||
class ServerCounter {
|
class ServerCounter {
|
||||||
private:
|
private:
|
||||||
int playerId;
|
int playerId;
|
||||||
|
int id;
|
||||||
QString name;
|
QString name;
|
||||||
QColor color;
|
QColor color;
|
||||||
|
int radius;
|
||||||
int count;
|
int count;
|
||||||
public:
|
public:
|
||||||
ServerCounter(int _playerId, const QString &_name, QColor _color, int _count)
|
ServerCounter(int _playerId, int _id, const QString &_name, QColor _color, int _radius, int _count)
|
||||||
: playerId(_playerId), name(_name), color(_color), count(_count) { }
|
: playerId(_playerId), id(_id), name(_name), color(_color), radius(_radius), count(_count) { }
|
||||||
int getPlayerId() const { return playerId; }
|
int getPlayerId() const { return playerId; }
|
||||||
|
int getId() const { return id; }
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
QColor getColor() const { return color; }
|
QColor getColor() const { return color; }
|
||||||
|
int getRadius() const { return radius; }
|
||||||
int getCount() const { return count; }
|
int getCount() const { return count; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -355,10 +359,10 @@ public slots:
|
||||||
PendingCommand *createToken(const QString &zone, const QString &name, const QString &powtough, int x, int y);
|
PendingCommand *createToken(const QString &zone, const QString &name, const QString &powtough, int x, int y);
|
||||||
PendingCommand *setCardAttr(const QString &zone, int cardid, const QString &aname, const QString &avalue);
|
PendingCommand *setCardAttr(const QString &zone, int cardid, const QString &aname, const QString &avalue);
|
||||||
PendingCommand *readyStart();
|
PendingCommand *readyStart();
|
||||||
PendingCommand *incCounter(const QString &counter, int delta);
|
PendingCommand *incCounter(int counterId, int delta);
|
||||||
PendingCommand *addCounter(const QString &counter, QColor color, int value);
|
PendingCommand *addCounter(const QString &counterName, QColor color, int radius, int value);
|
||||||
PendingCommand *setCounter(const QString &counter, int value);
|
PendingCommand *setCounter(int counterId, int value);
|
||||||
PendingCommand *delCounter(const QString &counter);
|
PendingCommand *delCounter(int counterId);
|
||||||
PendingCommand_ListCounters *listCounters(int playerId);
|
PendingCommand_ListCounters *listCounters(int playerId);
|
||||||
PendingCommand *nextTurn();
|
PendingCommand *nextTurn();
|
||||||
PendingCommand *setActivePhase(int phase);
|
PendingCommand *setActivePhase(int phase);
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
Counter::Counter(Player *_player, const QString &_name, QColor _color, int _value, QGraphicsItem *parent)
|
Counter::Counter(Player *_player, int _id, const QString &_name, QColor _color, int _radius, int _value, QGraphicsItem *parent)
|
||||||
: QGraphicsItem(parent), name(_name), color(_color), value(_value), player(_player)
|
: QGraphicsItem(parent), id(_id), name(_name), color(_color), radius(_radius), value(_value), player(_player)
|
||||||
{
|
{
|
||||||
|
if (radius > Player::counterAreaWidth / 2)
|
||||||
|
radius = Player::counterAreaWidth / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF Counter::boundingRect() const
|
QRectF Counter::boundingRect() const
|
||||||
{
|
{
|
||||||
return QRectF(0, 0, 40, 40);
|
return QRectF(0, 0, radius * 2, radius * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Counter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
void Counter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||||
|
@ -18,8 +20,8 @@ void Counter::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*
|
||||||
painter->setBrush(QBrush(color));
|
painter->setBrush(QBrush(color));
|
||||||
painter->drawEllipse(boundingRect());
|
painter->drawEllipse(boundingRect());
|
||||||
if (value) {
|
if (value) {
|
||||||
QFont f("Times");
|
QFont f("Serif");
|
||||||
f.setPixelSize(20);
|
f.setPixelSize(radius * 0.8);
|
||||||
f.setWeight(QFont::Bold);
|
f.setWeight(QFont::Bold);
|
||||||
painter->setFont(f);
|
painter->setFont(f);
|
||||||
painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(value));
|
painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(value));
|
||||||
|
@ -35,7 +37,7 @@ void Counter::setValue(int _value)
|
||||||
void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void Counter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
player->client->incCounter(name, 1);
|
player->client->incCounter(id, 1);
|
||||||
else if (event->button() == Qt::RightButton)
|
else if (event->button() == Qt::RightButton)
|
||||||
player->client->incCounter(name, -1);
|
player->client->incCounter(id, -1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,20 @@ class Player;
|
||||||
|
|
||||||
class Counter : public QGraphicsItem {
|
class Counter : public QGraphicsItem {
|
||||||
private:
|
private:
|
||||||
|
int id;
|
||||||
QString name;
|
QString name;
|
||||||
QColor color;
|
QColor color;
|
||||||
|
int radius;
|
||||||
int value;
|
int value;
|
||||||
protected:
|
protected:
|
||||||
Player *player;
|
Player *player;
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
public:
|
public:
|
||||||
Counter(Player *_player, const QString &_name, QColor _color, int _value, QGraphicsItem *parent = 0);
|
Counter(Player *_player, int _id, const QString &_name, QColor _color, int _radius, int _value, QGraphicsItem *parent = 0);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
|
int getId() const { return id; }
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
int getValue() const { return value; }
|
int getValue() const { return value; }
|
||||||
void setValue(int _value);
|
void setValue(int _value);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "dlg_startgame.h"
|
#include "dlg_startgame.h"
|
||||||
#include "counter.h"
|
#include "counter.h"
|
||||||
#include "gamescene.h"
|
#include "gamescene.h"
|
||||||
|
#include "player.h"
|
||||||
|
|
||||||
Game::Game(CardDatabase *_db, Client *_client, GameScene *_scene, QMenuBar *menuBar, QObject *parent)
|
Game::Game(CardDatabase *_db, Client *_client, GameScene *_scene, QMenuBar *menuBar, QObject *parent)
|
||||||
: QObject(parent), db(_db), client(_client), scene(_scene), started(false), currentPhase(-1)
|
: QObject(parent), db(_db), client(_client), scene(_scene), started(false), currentPhase(-1)
|
||||||
|
@ -83,10 +84,14 @@ Game::Game(CardDatabase *_db, Client *_client, GameScene *_scene, QMenuBar *menu
|
||||||
Game::~Game()
|
Game::~Game()
|
||||||
{
|
{
|
||||||
qDebug("Game destructor");
|
qDebug("Game destructor");
|
||||||
for (int i = 0; i < players.size(); i++) {
|
|
||||||
emit playerRemoved(players.at(i));
|
QMapIterator<int, Player *> i(players);
|
||||||
delete players.at(i);
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
emit playerRemoved(i.value());
|
||||||
|
delete i.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete gameMenu;
|
delete gameMenu;
|
||||||
delete cardMenu;
|
delete cardMenu;
|
||||||
}
|
}
|
||||||
|
@ -115,8 +120,9 @@ void Game::retranslateUi()
|
||||||
|
|
||||||
moveMenu->setTitle(tr("&Move to"));
|
moveMenu->setTitle(tr("&Move to"));
|
||||||
|
|
||||||
for (int i = 0; i < players.size(); ++i)
|
QMapIterator<int, Player *> i(players);
|
||||||
players[i]->retranslateUi();
|
while (i.hasNext())
|
||||||
|
i.next().value()->retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
Player *Game::addPlayer(int playerId, const QString &playerName, bool local)
|
Player *Game::addPlayer(int playerId, const QString &playerName, bool local)
|
||||||
|
@ -132,7 +138,7 @@ Player *Game::addPlayer(int playerId, const QString &playerName, bool local)
|
||||||
connect(newPlayer, SIGNAL(logSetCounter(Player *, QString, int, int)), this, SIGNAL(logSetCounter(Player *, QString, int, int)));
|
connect(newPlayer, SIGNAL(logSetCounter(Player *, QString, int, int)), this, SIGNAL(logSetCounter(Player *, QString, int, int)));
|
||||||
connect(newPlayer, SIGNAL(logSetDoesntUntap(Player *, QString, bool)), this, SIGNAL(logSetDoesntUntap(Player *, QString, bool)));
|
connect(newPlayer, SIGNAL(logSetDoesntUntap(Player *, QString, bool)), this, SIGNAL(logSetDoesntUntap(Player *, QString, bool)));
|
||||||
|
|
||||||
players << newPlayer;
|
players.insert(playerId, newPlayer);
|
||||||
emit playerAdded(newPlayer);
|
emit playerAdded(newPlayer);
|
||||||
|
|
||||||
return newPlayer;
|
return newPlayer;
|
||||||
|
@ -141,10 +147,11 @@ Player *Game::addPlayer(int playerId, const QString &playerName, bool local)
|
||||||
void Game::cardListReceived(QList<ServerZoneCard> list)
|
void Game::cardListReceived(QList<ServerZoneCard> list)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
Player *p = players.findPlayer(list[i].getPlayerId());
|
Player *p = players.value(list[i].getPlayerId(), 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
CardZone *zone = p->getZones().findZone(list[i].getZoneName());
|
|
||||||
|
CardZone *zone = p->getZones().value(list[i].getZoneName(), 0);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -161,12 +168,14 @@ void Game::cardListReceived(QList<ServerZoneCard> list)
|
||||||
void Game::zoneListReceived(QList<ServerZone> list)
|
void Game::zoneListReceived(QList<ServerZone> list)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
Player *p = players.findPlayer(list[i].getPlayerId());
|
Player *p = players.value(list[i].getPlayerId(), 0);
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
CardZone *zone = p->getZones().findZone(list[i].getName());
|
|
||||||
|
CardZone *zone = p->getZones().value(list[i].getName(), 0);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
zone->clearContents();
|
zone->clearContents();
|
||||||
if (
|
if (
|
||||||
(list[i].getType() != ServerZone::PublicZone)
|
(list[i].getType() != ServerZone::PublicZone)
|
||||||
|
@ -181,13 +190,15 @@ void Game::zoneListReceived(QList<ServerZone> list)
|
||||||
|
|
||||||
void Game::counterListReceived(QList<ServerCounter> list)
|
void Game::counterListReceived(QList<ServerCounter> list)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < players.size(); ++i)
|
QMapIterator<int, Player *> i(players);
|
||||||
players[i]->clearCounters();
|
while (i.hasNext())
|
||||||
|
i.next().value()->clearCounters();
|
||||||
|
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
Player *p = players.findPlayer(list[i].getPlayerId());
|
Player *p = players.value(list[i].getPlayerId(), 0);
|
||||||
if (p)
|
if (!p)
|
||||||
p->addCounter(list[i].getName(), list[i].getColor(), list[i].getCount());
|
continue;
|
||||||
|
p->addCounter(list[i].getId(), list[i].getName(), list[i].getColor(), list[i].getRadius(), list[i].getCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +226,7 @@ void Game::restartGameDialog()
|
||||||
void Game::gameEvent(const ServerEventData &msg)
|
void Game::gameEvent(const ServerEventData &msg)
|
||||||
{
|
{
|
||||||
qDebug(QString("game::gameEvent: public=%1, player=%2, name=%3, type=%4, data=%5").arg(msg.getPublic()).arg(msg.getPlayerId()).arg(msg.getPlayerName()).arg(msg.getEventType()).arg(msg.getEventData().join("/")).toLatin1());
|
qDebug(QString("game::gameEvent: public=%1, player=%2, name=%3, type=%4, data=%5").arg(msg.getPublic()).arg(msg.getPlayerId()).arg(msg.getPlayerName()).arg(msg.getEventType()).arg(msg.getEventData().join("/")).toLatin1());
|
||||||
Player *p = players.findPlayer(msg.getPlayerId());
|
Player *p = players.value(msg.getPlayerId(), 0);
|
||||||
if (!msg.getPublic()) {
|
if (!msg.getPublic()) {
|
||||||
if (!p)
|
if (!p)
|
||||||
return;
|
return;
|
||||||
|
@ -287,13 +298,16 @@ void Game::gameEvent(const ServerEventData &msg)
|
||||||
case eventSetActivePlayer: {
|
case eventSetActivePlayer: {
|
||||||
QStringList data = msg.getEventData();
|
QStringList data = msg.getEventData();
|
||||||
int playerId = data[0].toInt();
|
int playerId = data[0].toInt();
|
||||||
Player *player = players.findPlayer(playerId);
|
Player *player = players.value(playerId, 0);
|
||||||
if (!player) {
|
if (!player) {
|
||||||
qDebug(QString("setActivePlayer: invalid player: %1").arg(playerId).toLatin1());
|
qDebug(QString("setActivePlayer: invalid player: %1").arg(playerId).toLatin1());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < players.size(); ++i)
|
QMapIterator<int, Player *> i(players);
|
||||||
players[i]->setActive(players[i] == player);
|
while (i.hasNext()) {
|
||||||
|
i.next();
|
||||||
|
i.value()->setActive(i.value() == player);
|
||||||
|
}
|
||||||
emit logSetActivePlayer(player);
|
emit logSetActivePlayer(player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -319,10 +333,10 @@ void Game::gameEvent(const ServerEventData &msg)
|
||||||
}
|
}
|
||||||
case eventDumpZone: {
|
case eventDumpZone: {
|
||||||
QStringList data = msg.getEventData();
|
QStringList data = msg.getEventData();
|
||||||
Player *zoneOwner = players.findPlayer(data[0].toInt());
|
Player *zoneOwner = players.value(data[0].toInt(), 0);
|
||||||
if (!zoneOwner)
|
if (!zoneOwner)
|
||||||
break;
|
break;
|
||||||
CardZone *zone = zoneOwner->getZones().findZone(data[1]);
|
CardZone *zone = zoneOwner->getZones().value(data[1], 0);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
break;
|
break;
|
||||||
emit logDumpZone(p, zone, data[2].toInt());
|
emit logDumpZone(p, zone, data[2].toInt());
|
||||||
|
@ -330,10 +344,10 @@ void Game::gameEvent(const ServerEventData &msg)
|
||||||
}
|
}
|
||||||
case eventStopDumpZone: {
|
case eventStopDumpZone: {
|
||||||
QStringList data = msg.getEventData();
|
QStringList data = msg.getEventData();
|
||||||
Player *zoneOwner = players.findPlayer(data[0].toInt());
|
Player *zoneOwner = players.value(data[0].toInt(), 0);
|
||||||
if (!zoneOwner)
|
if (!zoneOwner)
|
||||||
break;
|
break;
|
||||||
CardZone *zone = zoneOwner->getZones().findZone(data[1]);
|
CardZone *zone = zoneOwner->getZones().value(data[1], 0);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
break;
|
break;
|
||||||
emit logStopDumpZone(p, zone);
|
emit logStopDumpZone(p, zone);
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
#define GAME_H
|
#define GAME_H
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QMap>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "playerlist.h"
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
class GameScene;
|
class GameScene;
|
||||||
|
@ -13,6 +15,7 @@ class CardDatabase;
|
||||||
class DlgStartGame;
|
class DlgStartGame;
|
||||||
class CardItem;
|
class CardItem;
|
||||||
class QMenuBar;
|
class QMenuBar;
|
||||||
|
class CardZone;
|
||||||
|
|
||||||
class Game : public QObject {
|
class Game : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -32,7 +35,7 @@ private:
|
||||||
Client *client;
|
Client *client;
|
||||||
GameScene *scene;
|
GameScene *scene;
|
||||||
QStringList spectatorList;
|
QStringList spectatorList;
|
||||||
PlayerList players;
|
QMap<int, Player *> players;
|
||||||
bool started;
|
bool started;
|
||||||
int currentPhase;
|
int currentPhase;
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -21,7 +21,7 @@ Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Cl
|
||||||
bgPixmap.load(bgPath);
|
bgPixmap.load(bgPath);
|
||||||
setCacheMode(DeviceCoordinateCache);
|
setCacheMode(DeviceCoordinateCache);
|
||||||
|
|
||||||
QPointF base = QPointF(55, 50);
|
QPointF base = QPointF(counterAreaWidth, 50);
|
||||||
|
|
||||||
PileZone *deck = new PileZone(this, "deck", true, false, this);
|
PileZone *deck = new PileZone(this, "deck", true, false, this);
|
||||||
deck->setPos(base);
|
deck->setPos(base);
|
||||||
|
@ -41,7 +41,7 @@ Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Cl
|
||||||
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
|
connect(table, SIGNAL(sizeChanged()), this, SLOT(updateBoundingRect()));
|
||||||
hand = new HandZone(this, (int) table->boundingRect().height(), this);
|
hand = new HandZone(this, (int) table->boundingRect().height(), this);
|
||||||
|
|
||||||
base = QPointF(deck->boundingRect().width() + 60, 0);
|
base = QPointF(deck->boundingRect().width() + counterAreaWidth + 5, 0);
|
||||||
hand->setPos(base);
|
hand->setPos(base);
|
||||||
base += QPointF(hand->boundingRect().width(), 0);
|
base += QPointF(hand->boundingRect().width(), 0);
|
||||||
table->setPos(base);
|
table->setPos(base);
|
||||||
|
@ -49,10 +49,31 @@ Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Cl
|
||||||
updateBoundingRect();
|
updateBoundingRect();
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
aMoveHandToTopLibrary = new QAction(this);
|
aMoveToTopLibrary = new QAction(this);
|
||||||
connect(aMoveHandToTopLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToTopLibrary()));
|
aMoveToTopLibrary->setData(QList<QVariant>() << "deck" << 0);
|
||||||
aMoveHandToBottomLibrary = new QAction(this);
|
aMoveToBottomLibrary = new QAction(this);
|
||||||
connect(aMoveHandToBottomLibrary, SIGNAL(triggered()), this, SLOT(actMoveHandToBottomLibrary()));
|
aMoveToBottomLibrary->setData(QList<QVariant>() << "deck" << -1);
|
||||||
|
aMoveToHand = new QAction(this);
|
||||||
|
aMoveToHand->setData(QList<QVariant>() << "hand" << 0);
|
||||||
|
aMoveToGraveyard = new QAction(this);
|
||||||
|
aMoveToGraveyard->setData(QList<QVariant>() << "grave" << 0);
|
||||||
|
aMoveToRfg = new QAction(this);
|
||||||
|
aMoveToRfg->setData(QList<QVariant>() << "rfg" << 0);
|
||||||
|
|
||||||
|
connect(aMoveToTopLibrary, SIGNAL(triggered()), hand, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToBottomLibrary, SIGNAL(triggered()), hand, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToGraveyard, SIGNAL(triggered()), hand, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToRfg, SIGNAL(triggered()), hand, SLOT(moveAllToZone()));
|
||||||
|
|
||||||
|
connect(aMoveToTopLibrary, SIGNAL(triggered()), grave, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToBottomLibrary, SIGNAL(triggered()), grave, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToHand, SIGNAL(triggered()), grave, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToRfg, SIGNAL(triggered()), grave, SLOT(moveAllToZone()));
|
||||||
|
|
||||||
|
connect(aMoveToTopLibrary, SIGNAL(triggered()), rfg, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToBottomLibrary, SIGNAL(triggered()), rfg, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToHand, SIGNAL(triggered()), rfg, SLOT(moveAllToZone()));
|
||||||
|
connect(aMoveToGraveyard, SIGNAL(triggered()), rfg, SLOT(moveAllToZone()));
|
||||||
|
|
||||||
aViewLibrary = new QAction(this);
|
aViewLibrary = new QAction(this);
|
||||||
connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary()));
|
connect(aViewLibrary, SIGNAL(triggered()), this, SLOT(actViewLibrary()));
|
||||||
|
@ -82,8 +103,10 @@ Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Cl
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
handMenu = playerMenu->addMenu(QString());
|
handMenu = playerMenu->addMenu(QString());
|
||||||
handMenu->addAction(aMoveHandToTopLibrary);
|
handMenu->addAction(aMoveToTopLibrary);
|
||||||
handMenu->addAction(aMoveHandToBottomLibrary);
|
handMenu->addAction(aMoveToBottomLibrary);
|
||||||
|
handMenu->addAction(aMoveToGraveyard);
|
||||||
|
handMenu->addAction(aMoveToRfg);
|
||||||
hand->setMenu(handMenu);
|
hand->setMenu(handMenu);
|
||||||
|
|
||||||
libraryMenu = playerMenu->addMenu(QString());
|
libraryMenu = playerMenu->addMenu(QString());
|
||||||
|
@ -109,6 +132,18 @@ Player::Player(const QString &_name, int _id, bool _local, CardDatabase *_db, Cl
|
||||||
rfg->setMenu(rfgMenu, aViewRfg);
|
rfg->setMenu(rfgMenu, aViewRfg);
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
|
graveMenu->addSeparator();
|
||||||
|
graveMenu->addAction(aMoveToTopLibrary);
|
||||||
|
graveMenu->addAction(aMoveToBottomLibrary);
|
||||||
|
graveMenu->addAction(aMoveToHand);
|
||||||
|
graveMenu->addAction(aMoveToRfg);
|
||||||
|
|
||||||
|
rfgMenu->addSeparator();
|
||||||
|
rfgMenu->addAction(aMoveToTopLibrary);
|
||||||
|
rfgMenu->addAction(aMoveToBottomLibrary);
|
||||||
|
rfgMenu->addAction(aMoveToHand);
|
||||||
|
rfgMenu->addAction(aMoveToGraveyard);
|
||||||
|
|
||||||
sbMenu = playerMenu->addMenu(QString());
|
sbMenu = playerMenu->addMenu(QString());
|
||||||
sbMenu->addAction(aViewSideboard);
|
sbMenu->addAction(aViewSideboard);
|
||||||
sb->setMenu(sbMenu, aViewSideboard);
|
sb->setMenu(sbMenu, aViewSideboard);
|
||||||
|
@ -153,8 +188,9 @@ Player::~Player()
|
||||||
{
|
{
|
||||||
qDebug("Player destructor");
|
qDebug("Player destructor");
|
||||||
|
|
||||||
for (int i = 0; i < zones.size(); i++)
|
QMapIterator<QString, CardZone *> i(zones);
|
||||||
delete zones.at(i);
|
while (i.hasNext())
|
||||||
|
delete i.next().value();
|
||||||
|
|
||||||
clearCounters();
|
clearCounters();
|
||||||
delete playerMenu;
|
delete playerMenu;
|
||||||
|
@ -175,8 +211,11 @@ void Player::retranslateUi()
|
||||||
rfgMenu->setTitle(tr("&Exile"));
|
rfgMenu->setTitle(tr("&Exile"));
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
aMoveHandToTopLibrary->setText(tr("Move to &top of library"));
|
aMoveToTopLibrary->setText(tr("Move to &top of library"));
|
||||||
aMoveHandToBottomLibrary->setText(tr("Move to &bottom of library"));
|
aMoveToBottomLibrary->setText(tr("Move to &bottom of library"));
|
||||||
|
aMoveToHand->setText(tr("Move to &hand"));
|
||||||
|
aMoveToGraveyard->setText(tr("Move to g&raveyard"));
|
||||||
|
aMoveToRfg->setText(tr("Move to &exile"));
|
||||||
aViewLibrary->setText(tr("&View library"));
|
aViewLibrary->setText(tr("&View library"));
|
||||||
aViewLibrary->setShortcut(tr("F3"));
|
aViewLibrary->setShortcut(tr("F3"));
|
||||||
aViewTopCards->setText(tr("View &top cards of library..."));
|
aViewTopCards->setText(tr("View &top cards of library..."));
|
||||||
|
@ -233,16 +272,6 @@ void Player::initSayMenu()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actMoveHandToTopLibrary()
|
|
||||||
{
|
|
||||||
zones.findZone("hand")->moveAllToZone("deck", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::actMoveHandToBottomLibrary()
|
|
||||||
{
|
|
||||||
zones.findZone("hand")->moveAllToZone("deck", -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::actViewLibrary()
|
void Player::actViewLibrary()
|
||||||
{
|
{
|
||||||
emit toggleZoneView(this, "deck", -1);
|
emit toggleZoneView(this, "deck", -1);
|
||||||
|
@ -297,20 +326,22 @@ void Player::actUntapAll()
|
||||||
|
|
||||||
void Player::actIncLife()
|
void Player::actIncLife()
|
||||||
{
|
{
|
||||||
client->incCounter("life", 1);
|
// XXX
|
||||||
|
client->incCounter(lifeCounter->getId(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actDecLife()
|
void Player::actDecLife()
|
||||||
{
|
{
|
||||||
client->incCounter("life", -1);
|
// XXX
|
||||||
|
client->incCounter(lifeCounter->getId(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actSetLife()
|
void Player::actSetLife()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
int life = QInputDialog::getInteger(0, tr("Set life"), tr("New life total:"), getCounter("life")->getValue(), 0, 2000000000, 1, &ok);
|
int life = QInputDialog::getInteger(0, tr("Set life"), tr("New life total:"), lifeCounter->getValue(), 0, 2000000000, 1, &ok);
|
||||||
if (ok)
|
if (ok)
|
||||||
client->setCounter("life", life);
|
client->setCounter(lifeCounter->getId(), life);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actRollDie()
|
void Player::actRollDie()
|
||||||
|
@ -336,7 +367,7 @@ void Player::actSayMessage()
|
||||||
|
|
||||||
void Player::addZone(CardZone *z)
|
void Player::addZone(CardZone *z)
|
||||||
{
|
{
|
||||||
zones << z;
|
zones.insert(z->getName(), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QString &avalue, bool allCards)
|
void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QString &avalue, bool allCards)
|
||||||
|
@ -376,41 +407,44 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
// XXX Fehlerbehandlung
|
// XXX Fehlerbehandlung
|
||||||
|
|
||||||
// Clean up existing zones first
|
// Clean up existing zones first
|
||||||
for (int i = 0; i < zones.size(); i++) {
|
QMapIterator<QString, CardZone *> zoneIterator(zones);
|
||||||
if (ZoneViewZone *view = zones.at(i)->getView())
|
while (zoneIterator.hasNext()) {
|
||||||
|
zoneIterator.next();
|
||||||
|
if (ZoneViewZone *view = zoneIterator.value()->getView())
|
||||||
((ZoneViewWidget *) view->parentItem())->close();
|
((ZoneViewWidget *) view->parentItem())->close();
|
||||||
zones.at(i)->clearContents();
|
zoneIterator.value()->clearContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCounters();
|
clearCounters();
|
||||||
|
|
||||||
CardZone *deck = zones.findZone("deck");
|
CardZone *deck = zones.value("deck");
|
||||||
for (; deck_cards; deck_cards--)
|
for (; deck_cards; deck_cards--)
|
||||||
deck->addCard(new CardItem(db), false, -1);
|
deck->addCard(new CardItem(db), false, -1);
|
||||||
|
|
||||||
CardZone *sb = zones.findZone("sb");
|
CardZone *sb = zones.value("sb");
|
||||||
for (; sb_cards; sb_cards--)
|
for (; sb_cards; sb_cards--)
|
||||||
sb->addCard(new CardItem(db), false, -1);
|
sb->addCard(new CardItem(db), false, -1);
|
||||||
|
|
||||||
for (int i = 0; i < zones.size(); i++)
|
zoneIterator.toFront();
|
||||||
zones.at(i)->reorganizeCards();
|
while (zoneIterator.hasNext())
|
||||||
|
zoneIterator.next().value()->reorganizeCards();
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
client->addCounter("life", Qt::white, 20);
|
client->addCounter("life", Qt::white, 25, 20);
|
||||||
client->addCounter("w", QColor(255, 255, 150), 0);
|
client->addCounter("w", QColor(255, 255, 150), 20, 0);
|
||||||
client->addCounter("u", QColor(150, 150, 255), 0);
|
client->addCounter("u", QColor(150, 150, 255), 20, 0);
|
||||||
client->addCounter("b", QColor(150, 150, 150), 0);
|
client->addCounter("b", QColor(150, 150, 150), 20, 0);
|
||||||
client->addCounter("r", QColor(250, 150, 150), 0);
|
client->addCounter("r", QColor(250, 150, 150), 20, 0);
|
||||||
client->addCounter("g", QColor(150, 255, 150), 0);
|
client->addCounter("g", QColor(150, 255, 150), 20, 0);
|
||||||
client->addCounter("x", QColor(255, 255, 255), 0);
|
client->addCounter("x", QColor(255, 255, 255), 20, 0);
|
||||||
client->addCounter("storm", QColor(255, 255, 255), 0);
|
client->addCounter("storm", QColor(255, 255, 255), 20, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eventDraw: {
|
case eventDraw: {
|
||||||
CardZone *deck = zones.findZone("deck");
|
CardZone *deck = zones.value("deck");
|
||||||
CardZone *hand = zones.findZone("hand");
|
CardZone *hand = zones.value("hand");
|
||||||
if (!event.getPublic()) {
|
if (!event.getPublic()) {
|
||||||
hand->addCard(deck->takeCard(0, data[0].toInt(), data[1]), true, -1);
|
hand->addCard(deck->takeCard(0, data[0].toInt(), data[1]), true, -1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -428,13 +462,17 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
}
|
}
|
||||||
int cardId = data[0].toInt();
|
int cardId = data[0].toInt();
|
||||||
QString cardName = data[1];
|
QString cardName = data[1];
|
||||||
CardZone *startZone = zones.findZone(data[2]);
|
CardZone *startZone = zones.value(data[2], 0);
|
||||||
if (!startZone)
|
if (!startZone) {
|
||||||
qDebug(QString("start zone invalid: %1").arg(data[2]).toLatin1());
|
qDebug(QString("start zone invalid: %1").arg(data[2]).toLatin1());
|
||||||
|
break;
|
||||||
|
}
|
||||||
int position = data[3].toInt();
|
int position = data[3].toInt();
|
||||||
CardZone *targetZone = zones.findZone(data[4]);
|
CardZone *targetZone = zones.value(data[4], 0);
|
||||||
if (!targetZone)
|
if (!targetZone) {
|
||||||
qDebug(QString("target zone invalid: %1").arg(data[4]).toLatin1());
|
qDebug(QString("target zone invalid: %1").arg(data[4]).toLatin1());
|
||||||
|
break;
|
||||||
|
}
|
||||||
int x = data[5].toInt();
|
int x = data[5].toInt();
|
||||||
int y = data[6].toInt();
|
int y = data[6].toInt();
|
||||||
bool facedown = data[7].toInt();
|
bool facedown = data[7].toInt();
|
||||||
|
@ -467,7 +505,9 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
if (data.size() != 6) {
|
if (data.size() != 6) {
|
||||||
qDebug("error");
|
qDebug("error");
|
||||||
}
|
}
|
||||||
CardZone *zone = zones.findZone(data[0]);
|
CardZone *zone = zones.value(data[0], 0);
|
||||||
|
if (!zone)
|
||||||
|
break;
|
||||||
int cardid = data[1].toInt();
|
int cardid = data[1].toInt();
|
||||||
QString cardname = data[2];
|
QString cardname = data[2];
|
||||||
QString powtough = data[3];
|
QString powtough = data[3];
|
||||||
|
@ -485,7 +525,9 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
if (data.size() != 4) {
|
if (data.size() != 4) {
|
||||||
// XXX
|
// XXX
|
||||||
}
|
}
|
||||||
CardZone *zone = zones.findZone(data[0]);
|
CardZone *zone = zones.value(data[0], 0);
|
||||||
|
if (!zone)
|
||||||
|
break;
|
||||||
int cardId = data[1].toInt();
|
int cardId = data[1].toInt();
|
||||||
QString aname = data[2];
|
QString aname = data[2];
|
||||||
QString avalue = data[3];
|
QString avalue = data[3];
|
||||||
|
@ -504,23 +546,27 @@ void Player::gameEvent(const ServerEventData &event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eventAddCounter: {
|
case eventAddCounter: {
|
||||||
if (data.size() != 3) {
|
if (data.size() != 4) {
|
||||||
// XXX
|
// XXX
|
||||||
}
|
}
|
||||||
QString counterName = data[0];
|
int counterId = data[0].toInt();
|
||||||
int colorValue = data[1].toInt();
|
QString counterName = data[1];
|
||||||
int value = data[2].toInt();
|
int colorValue = data[2].toInt();
|
||||||
|
int radius = data[3].toInt();
|
||||||
|
int value = data[4].toInt();
|
||||||
QColor color(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
|
QColor color(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
|
||||||
addCounter(counterName, color, value);
|
addCounter(counterId, counterName, color, radius, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eventSetCounter: {
|
case eventSetCounter: {
|
||||||
if (data.size() != 2) {
|
if (data.size() != 2) {
|
||||||
// XXX
|
// XXX
|
||||||
}
|
}
|
||||||
|
int counterId = data[0].toInt();
|
||||||
int value = data[1].toInt();
|
int value = data[1].toInt();
|
||||||
QString counterName = data[0];
|
Counter *c = counters.value(counterId, 0);
|
||||||
Counter *c = getCounter(counterName);
|
if (!c)
|
||||||
|
break;
|
||||||
int oldValue = c->getValue();
|
int oldValue = c->getValue();
|
||||||
c->setValue(value);
|
c->setValue(value);
|
||||||
emit logSetCounter(this, c->getName(), value, oldValue);
|
emit logSetCounter(this, c->getName(), value, oldValue);
|
||||||
|
@ -583,46 +629,62 @@ void Player::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/
|
||||||
painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr);
|
painter->drawText(QRectF(0, 0, totalWidth, 40), Qt::AlignCenter, nameStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter *Player::getCounter(const QString &name, bool remove)
|
void Player::addCounter(int counterId, const QString &name, QColor color, int radius, int value)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < counterList.size(); i++) {
|
Counter *c = new Counter(this, counterId, name, color, radius, value, this);
|
||||||
Counter *temp = counterList.at(i);
|
counters.insert(counterId, c);
|
||||||
if (temp->getName() == name) {
|
if (name == "life")
|
||||||
if (remove)
|
lifeCounter = c;
|
||||||
counterList.removeAt(i);
|
// XXX
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::addCounter(const QString &name, QColor color, int value)
|
|
||||||
{
|
|
||||||
counterList.append(new Counter(this, name, color, value, this));
|
|
||||||
rearrangeCounters();
|
rearrangeCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::delCounter(const QString &name)
|
void Player::delCounter(int counterId)
|
||||||
{
|
{
|
||||||
delete getCounter(name, true);
|
Counter *c = counters.value(counterId, 0);
|
||||||
|
if (!c)
|
||||||
|
return;
|
||||||
|
counters.remove(counterId);
|
||||||
|
delete c;
|
||||||
rearrangeCounters();
|
rearrangeCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::clearCounters()
|
void Player::clearCounters()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < counterList.size(); i++)
|
QMapIterator<int, Counter *> counterIterator(counters);
|
||||||
delete counterList.at(i);
|
while (counterIterator.hasNext())
|
||||||
counterList.clear();
|
delete counterIterator.next().value();
|
||||||
|
counters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::rearrangeCounters()
|
void Player::rearrangeCounters()
|
||||||
{
|
{
|
||||||
const int counterAreaWidth = 55;
|
qreal marginTop = 50;
|
||||||
qreal y = 50;
|
qreal marginBottom = 15;
|
||||||
for (int i = 0; i < counterList.size(); i++) {
|
|
||||||
Counter *temp = counterList.at(i);
|
// Determine total height of bounding rectangles
|
||||||
QRectF br = temp->boundingRect();
|
qreal totalHeight = 0;
|
||||||
temp->setPos((counterAreaWidth - br.width()) / 2, y);
|
QMapIterator<int, Counter *> counterIterator(counters);
|
||||||
y += br.height() + 10;
|
while (counterIterator.hasNext()) {
|
||||||
|
counterIterator.next();
|
||||||
|
totalHeight += counterIterator.value()->boundingRect().height();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine free space between objects
|
||||||
|
qreal padding = (boundingRect().height() - marginTop - marginBottom - totalHeight) / (counters.size() - 1);
|
||||||
|
qreal y = boundingRect().y() + marginTop;
|
||||||
|
|
||||||
|
if (counters.size() == 1) {
|
||||||
|
padding = 0;
|
||||||
|
y += (boundingRect().height() - marginTop - marginBottom) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Place objects
|
||||||
|
for (counterIterator.toFront(); counterIterator.hasNext(); ) {
|
||||||
|
Counter *c = counterIterator.next().value();
|
||||||
|
|
||||||
|
QRectF br = c->boundingRect();
|
||||||
|
c->setPos((counterAreaWidth - br.width()) / 2, y);
|
||||||
|
y += br.height() + padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QPoint>
|
#include <QPoint>
|
||||||
#include "zonelist.h"
|
#include <QMap>
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
#include "carditem.h"
|
||||||
|
|
||||||
class Client;
|
class Client;
|
||||||
class CardDatabase;
|
class CardDatabase;
|
||||||
|
@ -13,6 +14,7 @@ class QAction;
|
||||||
class ZoneViewZone;
|
class ZoneViewZone;
|
||||||
class Game;
|
class Game;
|
||||||
class Counter;
|
class Counter;
|
||||||
|
class CardZone;
|
||||||
class TableZone;
|
class TableZone;
|
||||||
class HandZone;
|
class HandZone;
|
||||||
|
|
||||||
|
@ -45,9 +47,6 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void updateBoundingRect();
|
void updateBoundingRect();
|
||||||
|
|
||||||
void actMoveHandToTopLibrary();
|
|
||||||
void actMoveHandToBottomLibrary();
|
|
||||||
|
|
||||||
void actShuffle();
|
void actShuffle();
|
||||||
void actDrawCard();
|
void actDrawCard();
|
||||||
void actDrawCards();
|
void actDrawCards();
|
||||||
|
@ -59,7 +58,7 @@ private slots:
|
||||||
void actViewSideboard();
|
void actViewSideboard();
|
||||||
private:
|
private:
|
||||||
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *sayMenu;
|
QMenu *playerMenu, *handMenu, *graveMenu, *rfgMenu, *libraryMenu, *sbMenu, *sayMenu;
|
||||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary,
|
QAction *aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToRfg,
|
||||||
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard,
|
*aViewLibrary, *aViewTopCards, *aViewGraveyard, *aViewRfg, *aViewSideboard,
|
||||||
*aDrawCard, *aDrawCards, *aShuffle,
|
*aDrawCard, *aDrawCards, *aShuffle,
|
||||||
*aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aRollDie, *aCreateToken;
|
*aUntapAll, *aDecLife, *aIncLife, *aSetLife, *aRollDie, *aCreateToken;
|
||||||
|
@ -70,7 +69,7 @@ private:
|
||||||
bool active;
|
bool active;
|
||||||
bool local;
|
bool local;
|
||||||
|
|
||||||
ZoneList zones;
|
QMap<QString, CardZone *> zones;
|
||||||
TableZone *table;
|
TableZone *table;
|
||||||
HandZone *hand;
|
HandZone *hand;
|
||||||
|
|
||||||
|
@ -80,18 +79,21 @@ private:
|
||||||
QPixmap bgPixmap;
|
QPixmap bgPixmap;
|
||||||
QRectF bRect;
|
QRectF bRect;
|
||||||
|
|
||||||
QList<Counter *> counterList;
|
QMap<int, Counter *> counters;
|
||||||
|
Counter *lifeCounter;
|
||||||
|
|
||||||
void rearrangeCounters();
|
void rearrangeCounters();
|
||||||
void initSayMenu();
|
void initSayMenu();
|
||||||
public:
|
public:
|
||||||
|
static const int counterAreaWidth = 65;
|
||||||
|
|
||||||
enum { Type = typeOther };
|
enum { Type = typeOther };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
|
||||||
Counter *getCounter(const QString &name, bool remove = false);
|
void addCounter(int counterId, const QString &name, QColor color, int radius, int value);
|
||||||
void addCounter(const QString &name, QColor color, int value);
|
void delCounter(int counterId);
|
||||||
void delCounter(const QString &name);
|
|
||||||
void clearCounters();
|
void clearCounters();
|
||||||
|
|
||||||
Client *client;
|
Client *client;
|
||||||
|
@ -103,7 +105,8 @@ public:
|
||||||
int getId() const { return id; }
|
int getId() const { return id; }
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
bool getLocal() const { return local; }
|
bool getLocal() const { return local; }
|
||||||
const ZoneList &getZones() const { return zones; }
|
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
||||||
|
TableZone *getTable() const { return table; }
|
||||||
void gameEvent(const ServerEventData &event);
|
void gameEvent(const ServerEventData &event);
|
||||||
CardDatabase *getDb() const { return db; }
|
CardDatabase *getDb() const { return db; }
|
||||||
void showCardMenu(const QPoint &p);
|
void showCardMenu(const QPoint &p);
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
#include "playerlist.h"
|
|
||||||
|
|
||||||
Player *PlayerList::findPlayer(int id) const
|
|
||||||
{
|
|
||||||
for (int i = 0; i < size(); i++) {
|
|
||||||
Player *temp = at(i);
|
|
||||||
if (temp->getId() == id)
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef PLAYERLIST_H
|
|
||||||
#define PLAYERLIST_H
|
|
||||||
|
|
||||||
#include "player.h"
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
class PlayerList : public QList<Player *> {
|
|
||||||
public:
|
|
||||||
Player *findPlayer(int id) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,11 +0,0 @@
|
||||||
#include "zonelist.h"
|
|
||||||
|
|
||||||
CardZone *ZoneList::findZone(const QString &name) const
|
|
||||||
{
|
|
||||||
for (int i = 0; i < size(); i++) {
|
|
||||||
CardZone *temp = at(i);
|
|
||||||
if (!temp->getName().compare(name))
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef ZONELIST_H
|
|
||||||
#define ZONELIST_H
|
|
||||||
|
|
||||||
#include "cardzone.h"
|
|
||||||
#include <QList>
|
|
||||||
|
|
||||||
class ZoneList : public QList<CardZone *> {
|
|
||||||
public:
|
|
||||||
CardZone *findZone(const QString &name) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -45,7 +45,7 @@ void ZoneViewLayout::toggleZoneView(Player *player, const QString &zoneName, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZoneViewWidget *item = new ZoneViewWidget(db, player, player->getZones().findZone(zoneName), numberCards, this);
|
ZoneViewWidget *item = new ZoneViewWidget(db, player, player->getZones().value(zoneName), numberCards, this);
|
||||||
views.append(item);
|
views.append(item);
|
||||||
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeItem(ZoneViewWidget *)));
|
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeItem(ZoneViewWidget *)));
|
||||||
connect(item, SIGNAL(sizeChanged()), this, SLOT(reorganize()));
|
connect(item, SIGNAL(sizeChanged()), this, SLOT(reorganize()));
|
||||||
|
|
|
@ -24,14 +24,18 @@
|
||||||
|
|
||||||
class Counter {
|
class Counter {
|
||||||
protected:
|
protected:
|
||||||
|
int id;
|
||||||
QString name;
|
QString name;
|
||||||
int color;
|
int color;
|
||||||
|
int radius;
|
||||||
int count;
|
int count;
|
||||||
public:
|
public:
|
||||||
Counter(QString _name, int _color, int _count = 0) : name(_name), color(_color), count(_count) { }
|
Counter(int _id, const QString &_name, int _color, int _radius, int _count = 0) : id(_id), name(_name), color(_color), radius(_radius), count(_count) { }
|
||||||
~Counter() { }
|
~Counter() { }
|
||||||
|
int getId() const { return id; }
|
||||||
QString getName() const { return name; }
|
QString getName() const { return name; }
|
||||||
int getColor() const { return color; }
|
int getColor() const { return color; }
|
||||||
|
int getRadius() const { return radius; }
|
||||||
int getCount() const { return count; }
|
int getCount() const { return count; }
|
||||||
void setCount(int _count) { count = _count; }
|
void setCount(int _count) { count = _count; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
QHash<QString, ServerSocket::CommandProperties> ServerSocket::commandHash;
|
QHash<QString, ServerSocket::CommandProperties> ServerSocket::commandHash;
|
||||||
|
|
||||||
ServerSocket::ServerSocket(Server *_server, QObject *parent)
|
ServerSocket::ServerSocket(Server *_server, QObject *parent)
|
||||||
: QTcpSocket(parent), server(_server), game(0), spectator(false), PlayerStatus(StatusNormal), authState(PasswordWrong), acceptsGameListChanges(false)
|
: QTcpSocket(parent), server(_server), game(0), spectator(false), nextCardId(0), PlayerStatus(StatusNormal), authState(PasswordWrong), acceptsGameListChanges(false)
|
||||||
{
|
{
|
||||||
if (commandHash.isEmpty()) {
|
if (commandHash.isEmpty()) {
|
||||||
commandHash.insert("ping", CommandProperties(false, false, false, true, QList<QVariant::Type>(), &ServerSocket::cmdPing));
|
commandHash.insert("ping", CommandProperties(false, false, false, true, QList<QVariant::Type>(), &ServerSocket::cmdPing));
|
||||||
|
@ -94,12 +94,13 @@ ServerSocket::ServerSocket(Server *_server, QObject *parent)
|
||||||
commandHash.insert("add_counter", CommandProperties(true, true, true, false, QList<QVariant::Type>()
|
commandHash.insert("add_counter", CommandProperties(true, true, true, false, QList<QVariant::Type>()
|
||||||
<< QVariant::String
|
<< QVariant::String
|
||||||
<< QVariant::Int
|
<< QVariant::Int
|
||||||
|
<< QVariant::Int
|
||||||
<< QVariant::Int, &ServerSocket::cmdAddCounter));
|
<< QVariant::Int, &ServerSocket::cmdAddCounter));
|
||||||
commandHash.insert("set_counter", CommandProperties(true, true, true, false, QList<QVariant::Type>()
|
commandHash.insert("set_counter", CommandProperties(true, true, true, false, QList<QVariant::Type>()
|
||||||
<< QVariant::String
|
<< QVariant::Int
|
||||||
<< QVariant::Int, &ServerSocket::cmdSetCounter));
|
<< QVariant::Int, &ServerSocket::cmdSetCounter));
|
||||||
commandHash.insert("del_counter", CommandProperties(true, true, true, false, QList<QVariant::Type>()
|
commandHash.insert("del_counter", CommandProperties(true, true, true, false, QList<QVariant::Type>()
|
||||||
<< QVariant::String, &ServerSocket::cmdDelCounter));
|
<< QVariant::Int, &ServerSocket::cmdDelCounter));
|
||||||
commandHash.insert("list_counters", CommandProperties(true, true, true, true, QList<QVariant::Type>()
|
commandHash.insert("list_counters", CommandProperties(true, true, true, true, QList<QVariant::Type>()
|
||||||
<< QVariant::Int, &ServerSocket::cmdListCounters));
|
<< QVariant::Int, &ServerSocket::cmdListCounters));
|
||||||
commandHash.insert("list_zones", CommandProperties(true, true, true, true, QList<QVariant::Type>()
|
commandHash.insert("list_zones", CommandProperties(true, true, true, true, QList<QVariant::Type>()
|
||||||
|
@ -143,6 +144,18 @@ int ServerSocket::newCardId()
|
||||||
return nextCardId++;
|
return nextCardId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ServerSocket::newCounterId() const
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
QMapIterator<int, Counter *> i(counters);
|
||||||
|
while (i.hasNext()) {
|
||||||
|
Counter *c = i.next().value();
|
||||||
|
if (c->getId() > id)
|
||||||
|
id = c->getId();
|
||||||
|
}
|
||||||
|
return id + 1;
|
||||||
|
}
|
||||||
|
|
||||||
PlayerZone *ServerSocket::getZone(const QString &name) const
|
PlayerZone *ServerSocket::getZone(const QString &name) const
|
||||||
{
|
{
|
||||||
QListIterator<PlayerZone *> ZoneIterator(zones);
|
QListIterator<PlayerZone *> ZoneIterator(zones);
|
||||||
|
@ -154,17 +167,6 @@ PlayerZone *ServerSocket::getZone(const QString &name) const
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Counter *ServerSocket::getCounter(const QString &name) const
|
|
||||||
{
|
|
||||||
QListIterator<Counter *> CounterIterator(counters);
|
|
||||||
while (CounterIterator.hasNext()) {
|
|
||||||
Counter *temp = CounterIterator.next();
|
|
||||||
if (temp->getName() == name)
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerSocket::setupZones()
|
void ServerSocket::setupZones()
|
||||||
{
|
{
|
||||||
// Delete existing zones and counters
|
// Delete existing zones and counters
|
||||||
|
@ -209,8 +211,9 @@ void ServerSocket::clearZones()
|
||||||
delete zones.at(i);
|
delete zones.at(i);
|
||||||
zones.clear();
|
zones.clear();
|
||||||
|
|
||||||
for (int i = 0; i < counters.size(); i++)
|
QMapIterator<int, Counter *> counterIterator(counters);
|
||||||
delete counters.at(i);
|
while (counterIterator.hasNext())
|
||||||
|
delete counterIterator.next().value();
|
||||||
counters.clear();
|
counters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,60 +591,62 @@ ReturnMessage::ReturnCode ServerSocket::cmdSetCardAttr(const QList<QVariant> &pa
|
||||||
|
|
||||||
ReturnMessage::ReturnCode ServerSocket::cmdIncCounter(const QList<QVariant> ¶ms)
|
ReturnMessage::ReturnCode ServerSocket::cmdIncCounter(const QList<QVariant> ¶ms)
|
||||||
{
|
{
|
||||||
Counter *c = getCounter(params[0].toString());
|
Counter *c = counters.value(params[0].toInt(), 0);
|
||||||
if (!c)
|
if (!c)
|
||||||
return ReturnMessage::ReturnContextError;
|
return ReturnMessage::ReturnContextError;
|
||||||
int delta = params[1].toInt();
|
int delta = params[1].toInt();
|
||||||
|
|
||||||
c->setCount(c->getCount() + delta);
|
c->setCount(c->getCount() + delta);
|
||||||
emit broadcastEvent(QString("set_counter|%1|%2").arg(c->getName()).arg(c->getCount()), this);
|
emit broadcastEvent(QString("set_counter|%1|%2").arg(c->getId()).arg(c->getCount()), this);
|
||||||
return ReturnMessage::ReturnOk;
|
return ReturnMessage::ReturnOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnMessage::ReturnCode ServerSocket::cmdAddCounter(const QList<QVariant> ¶ms)
|
ReturnMessage::ReturnCode ServerSocket::cmdAddCounter(const QList<QVariant> ¶ms)
|
||||||
{
|
{
|
||||||
QString name = params[0].toString();
|
QString name = params[0].toString();
|
||||||
if (getCounter(name))
|
|
||||||
return ReturnMessage::ReturnContextError;
|
|
||||||
int color = params[1].toInt();
|
int color = params[1].toInt();
|
||||||
int count = params[2].toInt();
|
int radius = params[2].toInt();
|
||||||
|
int count = params[3].toInt();
|
||||||
|
|
||||||
Counter *c = new Counter(name, color, count);
|
Counter *c = new Counter(newCounterId(), name, color, radius, count);
|
||||||
counters << c;
|
counters.insert(c->getId(), c);
|
||||||
emit broadcastEvent(QString("add_counter|%1|%2|%3").arg(c->getName()).arg(color).arg(count), this);
|
emit broadcastEvent(QString("add_counter|%1|%2|%3|%4|%5").arg(c->getId()).arg(c->getName()).arg(color).arg(radius).arg(count), this);
|
||||||
|
|
||||||
return ReturnMessage::ReturnOk;
|
return ReturnMessage::ReturnOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnMessage::ReturnCode ServerSocket::cmdSetCounter(const QList<QVariant> ¶ms)
|
ReturnMessage::ReturnCode ServerSocket::cmdSetCounter(const QList<QVariant> ¶ms)
|
||||||
{
|
{
|
||||||
Counter *c = getCounter(params[0].toString());
|
Counter *c = counters.value(params[0].toInt(), 0);
|
||||||
if (!c)
|
if (!c)
|
||||||
return ReturnMessage::ReturnContextError;
|
return ReturnMessage::ReturnContextError;
|
||||||
int count = params[1].toInt();
|
int count = params[1].toInt();
|
||||||
|
|
||||||
c->setCount(count);
|
c->setCount(count);
|
||||||
emit broadcastEvent(QString("set_counter|%1|%2").arg(c->getName()).arg(count), this);
|
emit broadcastEvent(QString("set_counter|%1|%2").arg(c->getId()).arg(count), this);
|
||||||
return ReturnMessage::ReturnOk;
|
return ReturnMessage::ReturnOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnMessage::ReturnCode ServerSocket::cmdDelCounter(const QList<QVariant> ¶ms)
|
ReturnMessage::ReturnCode ServerSocket::cmdDelCounter(const QList<QVariant> ¶ms)
|
||||||
{
|
{
|
||||||
Counter *c = getCounter(params[0].toString());
|
int counterId = params[0].toInt();
|
||||||
|
Counter *c = counters.value(counterId, 0);
|
||||||
if (!c)
|
if (!c)
|
||||||
return ReturnMessage::ReturnContextError;
|
return ReturnMessage::ReturnContextError;
|
||||||
|
counters.remove(counterId);
|
||||||
delete c;
|
delete c;
|
||||||
counters.removeAt(counters.indexOf(c));
|
emit broadcastEvent(QString("del_counter|%1").arg(counterId), this);
|
||||||
emit broadcastEvent(QString("del_counter|%1").arg(params[0].toString()), this);
|
|
||||||
return ReturnMessage::ReturnOk;
|
return ReturnMessage::ReturnOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ServerSocket::listCountersHelper(ServerSocket *player)
|
QStringList ServerSocket::listCountersHelper(ServerSocket *player)
|
||||||
{
|
{
|
||||||
QStringList result;
|
QStringList result;
|
||||||
const QList<Counter *> &counterList = player->getCounters();
|
QMapIterator<int, Counter *> i(player->getCounters());
|
||||||
for (int i = 0; i < counterList.size(); ++i)
|
while (i.hasNext()) {
|
||||||
result << QString("%1|%2|%3|%4").arg(player->getPlayerId()).arg(counterList[i]->getName()).arg(counterList[i]->getColor()).arg(counterList[i]->getCount());
|
Counter *c = i.next().value();
|
||||||
|
result << QString("%1|%2|%3|%4|%5|%6").arg(player->getPlayerId()).arg(c->getId()).arg(c->getName()).arg(c->getColor()).arg(c->getRadius()).arg(c->getCount());
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,14 +110,14 @@ private:
|
||||||
QList<QString> DeckList;
|
QList<QString> DeckList;
|
||||||
QList<QString> SideboardList;
|
QList<QString> SideboardList;
|
||||||
QList<PlayerZone *> zones;
|
QList<PlayerZone *> zones;
|
||||||
QList<Counter *> counters;
|
QMap<int, Counter *> counters;
|
||||||
int playerId;
|
int playerId;
|
||||||
QString playerName;
|
QString playerName;
|
||||||
bool spectator;
|
bool spectator;
|
||||||
int nextCardId;
|
int nextCardId;
|
||||||
int newCardId();
|
int newCardId();
|
||||||
|
int newCounterId() const;
|
||||||
PlayerZone *getZone(const QString &name) const;
|
PlayerZone *getZone(const QString &name) const;
|
||||||
Counter *getCounter(const QString &name) const;
|
|
||||||
void clearZones();
|
void clearZones();
|
||||||
bool parseCommand(QString line);
|
bool parseCommand(QString line);
|
||||||
PlayerStatusEnum PlayerStatus;
|
PlayerStatusEnum PlayerStatus;
|
||||||
|
@ -143,7 +143,7 @@ public:
|
||||||
bool getAcceptsGameListChanges() const { return acceptsGameListChanges; }
|
bool getAcceptsGameListChanges() const { return acceptsGameListChanges; }
|
||||||
bool getAcceptsChatChannelListChanges() const { return acceptsChatChannelListChanges; }
|
bool getAcceptsChatChannelListChanges() const { return acceptsChatChannelListChanges; }
|
||||||
const QList<PlayerZone *> &getZones() const { return zones; }
|
const QList<PlayerZone *> &getZones() const { return zones; }
|
||||||
const QList<Counter *> &getCounters() const { return counters; }
|
const QMap<int, Counter *> &getCounters() const { return counters; }
|
||||||
void setupZones();
|
void setupZones();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue