mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
protobuf client->server communication almost working
This commit is contained in:
parent
4eb9dfc5bf
commit
314f17091d
96 changed files with 1633 additions and 860 deletions
|
|
@ -6,6 +6,7 @@ MOC_DIR = build
|
|||
OBJECTS_DIR = build
|
||||
RESOURCES = cockatrice.qrc
|
||||
QT += network script svg
|
||||
LIBS += -lprotobuf
|
||||
unix:!macx {
|
||||
CONFIG += mobility
|
||||
MOBILITY = multimedia
|
||||
|
|
@ -81,6 +82,7 @@ HEADERS += src/abstractcounter.h \
|
|||
src/translation.h \
|
||||
src/priceupdater.h \
|
||||
src/soundengine.h \
|
||||
src/pending_command.h \
|
||||
../common/color.h \
|
||||
../common/serializable_item.h \
|
||||
../common/decklist.h \
|
||||
|
|
@ -167,6 +169,7 @@ SOURCES += src/abstractcounter.cpp \
|
|||
src/localclient.cpp \
|
||||
src/priceupdater.cpp \
|
||||
src/soundengine.cpp \
|
||||
src/pending_command.cpp \
|
||||
../common/serializable_item.cpp \
|
||||
../common/decklist.cpp \
|
||||
../common/protocol.cpp \
|
||||
|
|
@ -183,6 +186,9 @@ SOURCES += src/abstractcounter.cpp \
|
|||
../common/server_player.cpp \
|
||||
../common/server_protocolhandler.cpp
|
||||
|
||||
include ( ../pb_headers )
|
||||
include ( ../pb_sources )
|
||||
|
||||
TRANSLATIONS += \
|
||||
translations/cockatrice_de.ts \
|
||||
translations/cockatrice_en.ts \
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
#include "abstractclient.h"
|
||||
#include "protocol.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/commands.pb.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <QDebug>
|
||||
|
||||
AbstractClient::AbstractClient(QObject *parent)
|
||||
: QObject(parent), status(StatusDisconnected)
|
||||
: QObject(parent), nextCmdId(0), status(StatusDisconnected)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -16,15 +20,16 @@ void AbstractClient::processProtocolItem(ProtocolItem *item)
|
|||
{
|
||||
ProtocolResponse *response = qobject_cast<ProtocolResponse *>(item);
|
||||
if (response) {
|
||||
CommandContainer *cmdCont = pendingCommands.value(response->getCmdId(), 0);
|
||||
if (!cmdCont)
|
||||
const int cmdId = response->getCmdId();
|
||||
PendingCommand *pend = pendingCommands.value(cmdId, 0);
|
||||
if (!pend)
|
||||
return;
|
||||
|
||||
pendingCommands.remove(cmdCont->getCmdId());
|
||||
cmdCont->processResponse(response);
|
||||
pendingCommands.remove(cmdId);
|
||||
pend->processResponse(response);
|
||||
if (response->getReceiverMayDelete())
|
||||
delete response;
|
||||
cmdCont->deleteLater();
|
||||
pend->deleteLater();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -73,7 +78,39 @@ void AbstractClient::setStatus(const ClientStatus _status)
|
|||
}
|
||||
}
|
||||
|
||||
void AbstractClient::sendCommand(Command *cmd)
|
||||
void AbstractClient::sendCommand(const CommandContainer &cont)
|
||||
{
|
||||
sendCommandContainer(new CommandContainer(QList<Command *>() << cmd));
|
||||
sendCommand(new PendingCommand(cont));
|
||||
}
|
||||
|
||||
void AbstractClient::sendCommand(PendingCommand *pend)
|
||||
{
|
||||
const int cmdId = nextCmdId++;
|
||||
pendingCommands.insert(cmdId, pend);
|
||||
pend->getCommandContainer().set_cmd_id(cmdId);
|
||||
sendCommandContainer(pend->getCommandContainer());
|
||||
}
|
||||
|
||||
PendingCommand *AbstractClient::prepareSessionCommand(const ::google::protobuf::Message &cmd)
|
||||
{
|
||||
CommandContainer cont;
|
||||
SessionCommand *c = cont.add_session_command();
|
||||
c->GetReflection()->MutableMessage(c, cmd.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(cmd);
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
||||
PendingCommand *AbstractClient::prepareModeratorCommand(const ::google::protobuf::Message &cmd)
|
||||
{
|
||||
CommandContainer cont;
|
||||
ModeratorCommand *c = cont.add_moderator_command();
|
||||
c->GetReflection()->MutableMessage(c, cmd.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(cmd);
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
||||
PendingCommand *AbstractClient::prepareAdminCommand(const ::google::protobuf::Message &cmd)
|
||||
{
|
||||
CommandContainer cont;
|
||||
AdminCommand *c = cont.add_admin_command();
|
||||
c->GetReflection()->MutableMessage(c, cmd.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(cmd);
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
#define ABSTRACTCLIENT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
#include <google/protobuf/message.h>
|
||||
#include "protocol_datastructures.h"
|
||||
|
||||
class Command;
|
||||
class PendingCommand;
|
||||
class CommandContainer;
|
||||
class ProtocolItem;
|
||||
class ProtocolResponse;
|
||||
|
|
@ -56,20 +58,27 @@ signals:
|
|||
void userInfoChanged(ServerInfo_User *userInfo);
|
||||
void buddyListReceived(const QList<ServerInfo_User *> &buddyList);
|
||||
void ignoreListReceived(const QList<ServerInfo_User *> &ignoreList);
|
||||
private:
|
||||
int nextCmdId;
|
||||
protected slots:
|
||||
void processProtocolItem(ProtocolItem *item);
|
||||
protected:
|
||||
QMap<int, CommandContainer *> pendingCommands;
|
||||
QMap<int, PendingCommand *> pendingCommands;
|
||||
ClientStatus status;
|
||||
QString userName, password;
|
||||
void setStatus(ClientStatus _status);
|
||||
virtual void sendCommandContainer(const CommandContainer &cont) = 0;
|
||||
public:
|
||||
AbstractClient(QObject *parent = 0);
|
||||
~AbstractClient();
|
||||
|
||||
ClientStatus getStatus() const { return status; }
|
||||
virtual void sendCommand(Command *cmd);
|
||||
virtual void sendCommandContainer(CommandContainer *cont) = 0;
|
||||
void sendCommand(const CommandContainer &cont);
|
||||
void sendCommand(PendingCommand *pend);
|
||||
|
||||
PendingCommand *prepareSessionCommand(const ::google::protobuf::Message &cmd);
|
||||
PendingCommand *prepareModeratorCommand(const ::google::protobuf::Message &cmd);
|
||||
PendingCommand *prepareAdminCommand(const ::google::protobuf::Message &cmd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
#include "abstractcounter.h"
|
||||
#include "player.h"
|
||||
#include "protocol_items.h"
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsSceneHoverEvent>
|
||||
#include "pb/command_inc_counter.pb.h"
|
||||
#include "pb/command_set_counter.pb.h"
|
||||
|
||||
AbstractCounter::AbstractCounter(Player *_player, int _id, const QString &_name, bool _shownInCounterArea, int _value, QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent), player(_player), id(_id), name(_name), value(_value), hovered(false), aDec(0), aInc(0), dialogSemaphore(false), deleteAfterDialog(false), shownInCounterArea(_shownInCounterArea)
|
||||
|
|
@ -84,10 +85,16 @@ void AbstractCounter::setValue(int _value)
|
|||
void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
player->sendGameCommand(new Command_IncCounter(-1, id, 1));
|
||||
Command_IncCounter cmd;
|
||||
cmd.set_counter_id(id);
|
||||
cmd.set_delta(1);
|
||||
player->sendGameCommand(cmd);
|
||||
event->accept();
|
||||
} else if (event->button() == Qt::RightButton) {
|
||||
player->sendGameCommand(new Command_IncCounter(-1, id, -1));
|
||||
Command_IncCounter cmd;
|
||||
cmd.set_counter_id(id);
|
||||
cmd.set_delta(-1);
|
||||
player->sendGameCommand(cmd);
|
||||
event->accept();
|
||||
} else if (event->button() == Qt::MidButton) {
|
||||
if (menu)
|
||||
|
|
@ -111,8 +118,11 @@ void AbstractCounter::hoverLeaveEvent(QGraphicsSceneHoverEvent * /*event*/)
|
|||
|
||||
void AbstractCounter::incrementCounter()
|
||||
{
|
||||
int delta = static_cast<QAction *>(sender())->data().toInt();
|
||||
player->sendGameCommand(new Command_IncCounter(-1, id, delta));
|
||||
const int delta = static_cast<QAction *>(sender())->data().toInt();
|
||||
Command_IncCounter cmd;
|
||||
cmd.set_counter_id(id);
|
||||
cmd.set_delta(delta);
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void AbstractCounter::setCounter()
|
||||
|
|
@ -125,6 +135,11 @@ void AbstractCounter::setCounter()
|
|||
return;
|
||||
}
|
||||
dialogSemaphore = false;
|
||||
if (ok)
|
||||
player->sendGameCommand(new Command_SetCounter(-1, id, newValue));
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
Command_SetCounter cmd;
|
||||
cmd.set_counter_id(id);
|
||||
cmd.set_value(newValue);
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,17 @@
|
|||
#include "cardzone.h"
|
||||
#include "player.h"
|
||||
#include "math.h"
|
||||
#include "protocol_items.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QDebug>
|
||||
|
||||
#include "color.h"
|
||||
// XXX
|
||||
#include "pb/command_attach_card.pb.h"
|
||||
#include "pb/command_create_arrow.pb.h"
|
||||
#include "pb/command_delete_arrow.pb.h"
|
||||
|
||||
ArrowItem::ArrowItem(Player *_player, int _id, ArrowTarget *_startItem, ArrowTarget *_targetItem, const QColor &_color)
|
||||
: QGraphicsItem(), player(_player), id(_id), startItem(_startItem), targetItem(_targetItem), color(_color), fullColor(true)
|
||||
{
|
||||
|
|
@ -129,8 +134,11 @@ void ArrowItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
|
||||
event->accept();
|
||||
if (event->button() == Qt::RightButton)
|
||||
player->sendGameCommand(new Command_DeleteArrow(-1, id));
|
||||
if (event->button() == Qt::RightButton) {
|
||||
Command_DeleteArrow cmd;
|
||||
cmd.set_arrow_id(id);
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
ArrowDragItem::ArrowDragItem(Player *_owner, ArrowTarget *_startItem, const QColor &_color)
|
||||
|
|
@ -197,31 +205,23 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
// The target item can be a player as well.
|
||||
CardItem *startCard = qgraphicsitem_cast<CardItem *>(startItem);
|
||||
CardItem *targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
||||
|
||||
Command_CreateArrow cmd;
|
||||
cmd.mutable_arrow_color()->CopyFrom(Color(color).get_color()); // XXX
|
||||
cmd.set_start_player_id(startZone->getPlayer()->getId());
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_start_card_id(startCard->getId());
|
||||
|
||||
if (targetCard) {
|
||||
CardZone *targetZone = targetCard->getZone();
|
||||
player->sendGameCommand(new Command_CreateArrow(
|
||||
-1,
|
||||
startZone->getPlayer()->getId(),
|
||||
startZone->getName(),
|
||||
startCard->getId(),
|
||||
targetZone->getPlayer()->getId(),
|
||||
targetZone->getName(),
|
||||
targetCard->getId(),
|
||||
color
|
||||
));
|
||||
cmd.set_target_player_id(targetZone->getPlayer()->getId());
|
||||
cmd.set_target_zone(targetZone->getName().toStdString());
|
||||
cmd.set_target_card_id(targetCard->getId());
|
||||
} else {
|
||||
PlayerTarget *targetPlayer = qgraphicsitem_cast<PlayerTarget *>(targetItem);
|
||||
player->sendGameCommand(new Command_CreateArrow(
|
||||
-1,
|
||||
startZone->getPlayer()->getId(),
|
||||
startZone->getName(),
|
||||
startCard->getId(),
|
||||
targetPlayer->getOwner()->getId(),
|
||||
QString(),
|
||||
-1,
|
||||
color
|
||||
));
|
||||
cmd.set_target_player_id(targetPlayer->getOwner()->getId());
|
||||
}
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
delArrow();
|
||||
|
||||
|
|
@ -277,15 +277,15 @@ void ArrowAttachItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * /*event*/)
|
|||
CardZone *startZone = startCard->getZone();
|
||||
CardItem *targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
||||
CardZone *targetZone = targetCard->getZone();
|
||||
|
||||
Command_AttachCard cmd;
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_card_id(startCard->getId());
|
||||
cmd.set_target_player_id(targetZone->getPlayer()->getId());
|
||||
cmd.set_target_zone(targetZone->getName().toStdString());
|
||||
cmd.set_target_card_id(targetCard->getId());
|
||||
|
||||
player->sendGameCommand(new Command_AttachCard(
|
||||
-1,
|
||||
startZone->getName(),
|
||||
startCard->getId(),
|
||||
targetZone->getPlayer()->getId(),
|
||||
targetZone->getName(),
|
||||
targetCard->getId()
|
||||
));
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
delArrow();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
#include "carditem.h"
|
||||
#include "player.h"
|
||||
#include "zoneviewzone.h"
|
||||
#include "protocol_items.h"
|
||||
#include "protocol_datastructures.h"
|
||||
#include "pb/command_move_card.pb.h"
|
||||
|
||||
CardZone::CardZone(Player *_p, const QString &_name, bool _hasCardAttr, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent, bool isView)
|
||||
: AbstractGraphicsItem(parent), player(_p), name(_name), cards(_contentsKnown), view(NULL), menu(NULL), doubleClickAction(0), hasCardAttr(_hasCardAttr), isShufflable(_isShufflable)
|
||||
|
|
@ -179,12 +180,17 @@ void CardZone::moveAllToZone()
|
|||
QList<QVariant> data = static_cast<QAction *>(sender())->data().toList();
|
||||
QString targetZone = data[0].toString();
|
||||
int targetX = data[1].toInt();
|
||||
|
||||
QList<CardToMove *> idList;
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
idList.append(new CardToMove(cards[i]->getId()));
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, getName(), idList, player->getId(), targetZone, targetX));
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(getName().toStdString());
|
||||
cmd.set_target_player_id(player->getId());
|
||||
cmd.set_target_zone(targetZone.toStdString());
|
||||
cmd.set_x(targetX);
|
||||
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(cards[i]->getId());
|
||||
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
QPointF CardZone::closestGridPoint(const QPointF &point)
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@
|
|||
#include <QGroupBox>
|
||||
#include <QMessageBox>
|
||||
#include "dlg_creategame.h"
|
||||
#include "protocol_items.h"
|
||||
#include "tab_room.h"
|
||||
|
||||
DlgCreateGame::DlgCreateGame(AbstractClient *_client, int _roomId, const QMap<int, QString> &_gameTypes, QWidget *parent)
|
||||
: QDialog(parent), client(_client), roomId(_roomId), gameTypes(_gameTypes)
|
||||
#include "pending_command.h"
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
||||
DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameTypes, QWidget *parent)
|
||||
: QDialog(parent), room(_room), gameTypes(_gameTypes)
|
||||
{
|
||||
descriptionLabel = new QLabel(tr("&Description:"));
|
||||
descriptionEdit = new QLineEdit;
|
||||
|
|
@ -103,29 +106,27 @@ DlgCreateGame::DlgCreateGame(AbstractClient *_client, int _roomId, const QMap<in
|
|||
|
||||
void DlgCreateGame::actOK()
|
||||
{
|
||||
QList<GameTypeId *> gameTypeList;
|
||||
Command_CreateGame cmd;
|
||||
cmd.set_description(descriptionEdit->text().toStdString());
|
||||
cmd.set_password(passwordEdit->text().toStdString());
|
||||
cmd.set_max_players(maxPlayersEdit->value());
|
||||
cmd.set_only_buddies(onlyBuddiesCheckBox->isChecked());
|
||||
cmd.set_only_registered(onlyRegisteredCheckBox->isChecked());
|
||||
cmd.set_spectators_allowed(spectatorsAllowedCheckBox->isChecked());
|
||||
cmd.set_spectators_need_password(spectatorsNeedPasswordCheckBox->isChecked());
|
||||
cmd.set_spectators_can_talk(spectatorsCanTalkCheckBox->isChecked());
|
||||
cmd.set_spectators_see_everything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
|
||||
QMapIterator<int, QCheckBox *> gameTypeCheckBoxIterator(gameTypeCheckBoxes);
|
||||
while (gameTypeCheckBoxIterator.hasNext()) {
|
||||
gameTypeCheckBoxIterator.next();
|
||||
if (gameTypeCheckBoxIterator.value()->isChecked())
|
||||
gameTypeList.append(new GameTypeId(gameTypeCheckBoxIterator.key()));
|
||||
cmd.add_game_type_ids(gameTypeCheckBoxIterator.key());
|
||||
}
|
||||
|
||||
Command_CreateGame *createCommand = new Command_CreateGame(
|
||||
roomId,
|
||||
descriptionEdit->text(),
|
||||
passwordEdit->text(),
|
||||
maxPlayersEdit->value(),
|
||||
gameTypeList,
|
||||
onlyBuddiesCheckBox->isChecked(),
|
||||
onlyRegisteredCheckBox->isChecked(),
|
||||
spectatorsAllowedCheckBox->isChecked(),
|
||||
spectatorsNeedPasswordCheckBox->isChecked(),
|
||||
spectatorsCanTalkCheckBox->isChecked(),
|
||||
spectatorsSeeEverythingCheckBox->isChecked()
|
||||
);
|
||||
connect(createCommand, SIGNAL(finished(ResponseCode)), this, SLOT(checkResponse(ResponseCode)));
|
||||
client->sendCommand(createCommand);
|
||||
PendingCommand *pend = room->prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(checkResponse(ResponseCode)));
|
||||
room->sendRoomCommand(pend);
|
||||
|
||||
okButton->setEnabled(false);
|
||||
cancelButton->setEnabled(false);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define DLG_CREATEGAME_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "abstractclient.h"
|
||||
#include "protocol_datastructures.h"
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
|
|
@ -10,18 +10,18 @@ class QPushButton;
|
|||
class QCheckBox;
|
||||
class QGroupBox;
|
||||
class QSpinBox;
|
||||
class TabRoom;
|
||||
|
||||
class DlgCreateGame : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DlgCreateGame(AbstractClient *_client, int _roomId, const QMap<int, QString> &_gameTypes, QWidget *parent = 0);
|
||||
DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameTypes, QWidget *parent = 0);
|
||||
private slots:
|
||||
void actOK();
|
||||
void checkResponse(ResponseCode response);
|
||||
void spectatorsAllowedChanged(int state);
|
||||
private:
|
||||
AbstractClient *client;
|
||||
int roomId;
|
||||
TabRoom *room;
|
||||
QMap<int, QString> gameTypes;
|
||||
QMap<int, QCheckBox *> gameTypeCheckBoxes;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@
|
|||
#include <QInputDialog>
|
||||
#include "tab_supervisor.h"
|
||||
#include "dlg_creategame.h"
|
||||
#include "abstractclient.h"
|
||||
#include "protocol_items.h"
|
||||
#include "gameselector.h"
|
||||
#include "gamesmodel.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
||||
GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent)
|
||||
: QGroupBox(parent), client(_client), tabSupervisor(_tabSupervisor), room(_room)
|
||||
{
|
||||
|
|
@ -84,7 +85,7 @@ void GameSelector::showRunningGamesChanged(int state)
|
|||
|
||||
void GameSelector::actCreate()
|
||||
{
|
||||
DlgCreateGame dlg(client, room->getRoomId(), room->getGameTypes(), this);
|
||||
DlgCreateGame dlg(room, room->getGameTypes(), this);
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
|
|
@ -124,10 +125,16 @@ void GameSelector::actJoin()
|
|||
if (!ok)
|
||||
return;
|
||||
}
|
||||
|
||||
Command_JoinGame *commandJoinGame = new Command_JoinGame(game->getRoomId(), game->getGameId(), password, spectator, overrideRestrictions);
|
||||
connect(commandJoinGame, SIGNAL(finished(ResponseCode)), this, SLOT(checkResponse(ResponseCode)));
|
||||
client->sendCommand(commandJoinGame);
|
||||
|
||||
Command_JoinGame cmd;
|
||||
cmd.set_game_id(game->getGameId());
|
||||
cmd.set_password(password.toStdString());
|
||||
cmd.set_spectator(spectator);
|
||||
cmd.set_override_restrictions(overrideRestrictions);
|
||||
|
||||
PendingCommand *pend = room->prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(checkResponse(ResponseCode)));
|
||||
room->sendRoomCommand(pend);
|
||||
|
||||
if (createButton)
|
||||
createButton->setEnabled(false);
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
#include "handzone.h"
|
||||
#include "settingscache.h"
|
||||
#include "player.h"
|
||||
#include "protocol_items.h"
|
||||
#include "carddragitem.h"
|
||||
|
||||
#include "pb/command_move_card.pb.h"
|
||||
|
||||
HandZone::HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent)
|
||||
: SelectZone(_p, "hand", false, false, _contentsKnown, parent), zoneHeight(_zoneHeight)
|
||||
{
|
||||
|
|
@ -39,11 +40,17 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
|
||||
void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||
{
|
||||
QList<CardToMove *> idList;
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_target_player_id(player->getId());
|
||||
cmd.set_target_zone(getName().toStdString());
|
||||
cmd.set_x(cards.size());
|
||||
cmd.set_y(-1);
|
||||
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(dragItems[i]->getId());
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), cards.size(), -1));
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
QRectF HandZone::boundingRect() const
|
||||
|
|
|
|||
|
|
@ -2,23 +2,31 @@
|
|||
#include "localserverinterface.h"
|
||||
#include "protocol.h"
|
||||
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
LocalClient::LocalClient(LocalServerInterface *_lsi, const QString &_playerName, QObject *parent)
|
||||
: AbstractClient(parent), lsi(_lsi)
|
||||
{
|
||||
connect(lsi, SIGNAL(itemToClient(ProtocolItem *)), this, SLOT(itemFromServer(ProtocolItem *)));
|
||||
sendCommand(new Command_Login(_playerName, QString()));
|
||||
sendCommand(new Command_JoinRoom(0));
|
||||
|
||||
Command_Login loginCmd;
|
||||
loginCmd.set_user_name(_playerName.toStdString());
|
||||
sendCommand(prepareSessionCommand(loginCmd));
|
||||
|
||||
Command_JoinRoom joinCmd;
|
||||
joinCmd.set_room_id(0);
|
||||
sendCommand(prepareSessionCommand(joinCmd));
|
||||
}
|
||||
|
||||
LocalClient::~LocalClient()
|
||||
{
|
||||
}
|
||||
|
||||
void LocalClient::sendCommandContainer(CommandContainer *cont)
|
||||
void LocalClient::sendCommandContainer(const CommandContainer &cont)
|
||||
{
|
||||
cont->setReceiverMayDelete(false);
|
||||
pendingCommands.insert(cont->getCmdId(), cont);
|
||||
lsi->itemFromClient(cont);
|
||||
// cont->setReceiverMayDelete(false);
|
||||
// pendingCommands.insert(cont->getCmdId(), cont);
|
||||
// lsi->itemFromClient(cont);
|
||||
}
|
||||
|
||||
void LocalClient::itemFromServer(ProtocolItem *item)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
LocalClient(LocalServerInterface *_lsi, const QString &_playerName, QObject *parent = 0);
|
||||
~LocalClient();
|
||||
|
||||
void sendCommandContainer(CommandContainer *cont);
|
||||
void sendCommandContainer(const CommandContainer &cont);
|
||||
|
||||
private slots:
|
||||
void itemFromServer(ProtocolItem *item);
|
||||
|
|
|
|||
|
|
@ -22,5 +22,5 @@ void LocalServerInterface::sendProtocolItem(ProtocolItem *item, bool deleteItem)
|
|||
|
||||
void LocalServerInterface::itemFromClient(ProtocolItem *item)
|
||||
{
|
||||
processCommandContainer(static_cast<CommandContainer *>(item));
|
||||
//processCommandContainer(static_cast<CommandContainer *>(item));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,17 +10,17 @@ class LocalServerInterface : public Server_ProtocolHandler
|
|||
Q_OBJECT
|
||||
private:
|
||||
DeckList *getDeckFromDatabase(int /*deckId*/) { return 0; }
|
||||
ResponseCode cmdAddToList(Command_AddToList * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdRemoveFromList(Command_RemoveFromList * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckList(Command_DeckList * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckNewDir(Command_DeckNewDir * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDelDir(Command_DeckDelDir * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDel(Command_DeckDel * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckUpload(Command_DeckUpload * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDownload(Command_DeckDownload * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdBanFromServer(Command_BanFromServer * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdShutdownServer(Command_ShutdownServer * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdUpdateServerMessage(Command_UpdateServerMessage * /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdAddToList(const Command_AddToList & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdRemoveFromList(const Command_RemoveFromList & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckList(const Command_DeckList & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckNewDir(const Command_DeckNewDir & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDelDir(const Command_DeckDelDir & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDel(const Command_DeckDel & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckUpload(const Command_DeckUpload & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdDeckDownload(const Command_DeckDownload & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdBanFromServer(const Command_BanFromServer & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdShutdownServer(const Command_ShutdownServer & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
ResponseCode cmdUpdateServerMessage(const Command_UpdateServerMessage & /*cmd*/, CommandContainer * /*cont*/) { return RespFunctionNotAllowed; }
|
||||
protected:
|
||||
bool getCompressionSupport() const { return false; }
|
||||
public:
|
||||
|
|
|
|||
9
cockatrice/src/pending_command.cpp
Normal file
9
cockatrice/src/pending_command.cpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include "pending_command.h"
|
||||
#include "protocol.h"
|
||||
|
||||
void PendingCommand::processResponse(ProtocolResponse *response)
|
||||
{
|
||||
qDebug("processResponse");
|
||||
emit finished(response);
|
||||
emit finished(response->getResponseCode());
|
||||
}
|
||||
29
cockatrice/src/pending_command.h
Normal file
29
cockatrice/src/pending_command.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef PENDING_COMMAND_H
|
||||
#define PENDING_COMMAND_H
|
||||
|
||||
#include "protocol_datastructures.h"
|
||||
#include "pb/commands.pb.h"
|
||||
#include <QVariant>
|
||||
|
||||
class ProtocolResponse;
|
||||
|
||||
class PendingCommand : public QObject {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void finished(ProtocolResponse *response);
|
||||
void finished(ResponseCode response);
|
||||
private:
|
||||
CommandContainer commandContainer;
|
||||
QVariant extraData;
|
||||
int ticks;
|
||||
public:
|
||||
PendingCommand(const CommandContainer &_commandContainer, QVariant _extraData = QVariant())
|
||||
: commandContainer(_commandContainer), extraData(_extraData), ticks(0) { }
|
||||
CommandContainer &getCommandContainer() { return commandContainer; }
|
||||
void setExtraData(const QVariant &_extraData) { extraData = _extraData; }
|
||||
QVariant getExtraData() const { return extraData; }
|
||||
void processResponse(ProtocolResponse *response);
|
||||
int tick() { return ++ticks; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -5,9 +5,13 @@
|
|||
#include <QDebug>
|
||||
#include <math.h>
|
||||
#include "phasestoolbar.h"
|
||||
#include "protocol_items.h"
|
||||
#include "pixmapgenerator.h"
|
||||
|
||||
#include "pb/command_set_active_phase.pb.h"
|
||||
#include "pb/command_next_turn.pb.h"
|
||||
#include "pb/command_set_card_attr.pb.h"
|
||||
#include "pb/command_draw_cards.pb.h"
|
||||
|
||||
PhaseButton::PhaseButton(const QString &_name, QGraphicsItem *parent, QAction *_doubleClickAction, bool _highlightable)
|
||||
: QObject(), QGraphicsItem(parent), name(_name), active(false), highlightable(_highlightable), activeAnimationCounter(0), doubleClickAction(_doubleClickAction), width(50)
|
||||
{
|
||||
|
|
@ -222,20 +226,33 @@ void PhasesToolbar::phaseButtonClicked()
|
|||
PhaseButton *button = qobject_cast<PhaseButton *>(sender());
|
||||
if (button->getActive())
|
||||
button->triggerDoubleClickAction();
|
||||
emit sendGameCommand(new Command_SetActivePhase(-1, buttonList.indexOf(button)), -1);
|
||||
|
||||
Command_SetActivePhase cmd;
|
||||
cmd.set_phase(buttonList.indexOf(button));
|
||||
|
||||
emit sendGameCommand(cmd, -1);
|
||||
}
|
||||
|
||||
void PhasesToolbar::actNextTurn()
|
||||
{
|
||||
emit sendGameCommand(new Command_NextTurn, -1);
|
||||
emit sendGameCommand(Command_NextTurn(), -1);
|
||||
}
|
||||
|
||||
void PhasesToolbar::actUntapAll()
|
||||
{
|
||||
emit sendGameCommand(new Command_SetCardAttr(-1, "table", -1, "tapped", "0"), -1);
|
||||
Command_SetCardAttr cmd;
|
||||
cmd.set_zone("table");
|
||||
cmd.set_card_id(-1);
|
||||
cmd.set_attr_name("tapped");
|
||||
cmd.set_attr_value("0");
|
||||
|
||||
emit sendGameCommand(cmd, -1);
|
||||
}
|
||||
|
||||
void PhasesToolbar::actDrawCard()
|
||||
{
|
||||
emit sendGameCommand(new Command_DrawCards(-1, 1), -1);
|
||||
Command_DrawCards cmd;
|
||||
cmd.set_number(1);
|
||||
|
||||
emit sendGameCommand(cmd, -1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <QFrame>
|
||||
#include <QList>
|
||||
#include <QGraphicsObject>
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
class Player;
|
||||
class GameCommand;
|
||||
|
|
@ -62,7 +63,7 @@ private slots:
|
|||
void actUntapAll();
|
||||
void actDrawCard();
|
||||
signals:
|
||||
void sendGameCommand(GameCommand *command, int playerId);
|
||||
void sendGameCommand(const ::google::protobuf::Message &command, int playerId);
|
||||
protected:
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
#include "player.h"
|
||||
#include "carddragitem.h"
|
||||
#include "zoneviewzone.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pb/command_move_card.pb.h"
|
||||
|
||||
PileZone::PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent)
|
||||
: CardZone(_p, _name, false, _isShufflable, _contentsKnown, parent)
|
||||
|
|
@ -50,11 +51,17 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
|
||||
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||
{
|
||||
QList<CardToMove *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_target_player_id(player->getId());
|
||||
cmd.set_target_zone(getName().toStdString());
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0));
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(dragItems[i]->getId());
|
||||
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void PileZone::reorganizeCards()
|
||||
|
|
|
|||
|
|
@ -22,6 +22,21 @@
|
|||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pb/command_reveal_cards.pb.h"
|
||||
#include "pb/command_shuffle.pb.h"
|
||||
#include "pb/command_attach_card.pb.h"
|
||||
#include "pb/command_set_card_attr.pb.h"
|
||||
#include "pb/command_set_card_counter.pb.h"
|
||||
#include "pb/command_mulligan.pb.h"
|
||||
#include "pb/command_move_card.pb.h"
|
||||
#include "pb/command_draw_cards.pb.h"
|
||||
#include "pb/command_undo_draw.pb.h"
|
||||
#include "pb/command_roll_die.pb.h"
|
||||
#include "pb/command_create_token.pb.h"
|
||||
#include "pb/command_flip_card.pb.h"
|
||||
#include "pb/command_game_say.pb.h"
|
||||
|
||||
|
||||
PlayerArea::PlayerArea(QGraphicsItem *parentItem)
|
||||
: QObject(), QGraphicsItem(parentItem)
|
||||
{
|
||||
|
|
@ -345,13 +360,29 @@ void Player::playerListActionTriggered()
|
|||
int otherPlayerId = action->data().toInt();
|
||||
|
||||
if (menu == mRevealLibrary) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "deck", -1, otherPlayerId));
|
||||
Command_RevealCards cmd;
|
||||
cmd.set_zone_name("deck");
|
||||
cmd.set_card_id(-1);
|
||||
cmd.set_player_id(otherPlayerId);
|
||||
sendGameCommand(cmd);
|
||||
} else if (menu == mRevealTopCard) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "deck", 0, otherPlayerId));
|
||||
Command_RevealCards cmd;
|
||||
cmd.set_zone_name("deck");
|
||||
cmd.set_card_id(0);
|
||||
cmd.set_player_id(otherPlayerId);
|
||||
sendGameCommand(cmd);
|
||||
} else if (menu == mRevealHand) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "hand", -1, otherPlayerId));
|
||||
Command_RevealCards cmd;
|
||||
cmd.set_zone_name("hand");
|
||||
cmd.set_card_id(-1);
|
||||
cmd.set_player_id(otherPlayerId);
|
||||
sendGameCommand(cmd);
|
||||
} else if (menu == mRevealRandomHandCard) {
|
||||
sendGameCommand(new Command_RevealCards(-1, "hand", -2, otherPlayerId));
|
||||
Command_RevealCards cmd;
|
||||
cmd.set_zone_name("hand");
|
||||
cmd.set_card_id(-2);
|
||||
cmd.set_player_id(otherPlayerId);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -578,29 +609,34 @@ void Player::actViewSideboard()
|
|||
|
||||
void Player::actShuffle()
|
||||
{
|
||||
sendGameCommand(new Command_Shuffle);
|
||||
sendGameCommand(Command_Shuffle());
|
||||
}
|
||||
|
||||
void Player::actDrawCard()
|
||||
{
|
||||
sendGameCommand(new Command_DrawCards(-1, 1));
|
||||
Command_DrawCards cmd;
|
||||
cmd.set_number(1);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actMulligan()
|
||||
{
|
||||
sendGameCommand(new Command_Mulligan);
|
||||
sendGameCommand(Command_Mulligan());
|
||||
}
|
||||
|
||||
void Player::actDrawCards()
|
||||
{
|
||||
int number = QInputDialog::getInteger(0, tr("Draw cards"), tr("Number:"));
|
||||
if (number)
|
||||
sendGameCommand(new Command_DrawCards(-1, number));
|
||||
if (number) {
|
||||
Command_DrawCards cmd;
|
||||
cmd.set_number(number);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actUndoDraw()
|
||||
{
|
||||
sendGameCommand(new Command_UndoDraw);
|
||||
sendGameCommand(Command_UndoDraw());
|
||||
}
|
||||
|
||||
void Player::actMoveTopCardsToGrave()
|
||||
|
|
@ -609,14 +645,21 @@ void Player::actMoveTopCardsToGrave()
|
|||
if (!number)
|
||||
return;
|
||||
|
||||
QList<Command *> commandList;
|
||||
const int maxCards = zones.value("deck")->getCards().size();
|
||||
if (number > maxCards)
|
||||
number = maxCards;
|
||||
QList<CardToMove *> idList;
|
||||
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone("deck");
|
||||
cmd.set_target_player_id(getId());
|
||||
cmd.set_target_zone("grave");
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
|
||||
for (int i = 0; i < number; ++i)
|
||||
idList.append(new CardToMove(i));
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "grave", 0, 0));
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(i);
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actMoveTopCardsToExile()
|
||||
|
|
@ -625,32 +668,56 @@ void Player::actMoveTopCardsToExile()
|
|||
if (!number)
|
||||
return;
|
||||
|
||||
QList<Command *> commandList;
|
||||
const int maxCards = zones.value("deck")->getCards().size();
|
||||
if (number > maxCards)
|
||||
number = maxCards;
|
||||
QList<CardToMove *> idList;
|
||||
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone("deck");
|
||||
cmd.set_target_player_id(getId());
|
||||
cmd.set_target_zone("rfg");
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
|
||||
for (int i = 0; i < number; ++i)
|
||||
idList.append(new CardToMove(i));
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "rfg", 0, 0));
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(i);
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actMoveTopCardToBottom()
|
||||
{
|
||||
sendGameCommand(new Command_MoveCard(-1, "deck", QList<CardToMove *>() << new CardToMove(0), getId(), "deck", -1, 0));
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone("deck");
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(0);
|
||||
cmd.set_target_player_id(getId());
|
||||
cmd.set_target_zone("deck");
|
||||
cmd.set_x(-1);
|
||||
cmd.set_y(0);
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actUntapAll()
|
||||
{
|
||||
sendGameCommand(new Command_SetCardAttr(-1, "table", -1, "tapped", "0"));
|
||||
Command_SetCardAttr cmd;
|
||||
cmd.set_zone("table");
|
||||
cmd.set_card_id(-1);
|
||||
cmd.set_attr_name("tapped");
|
||||
cmd.set_attr_value("0");
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actRollDie()
|
||||
{
|
||||
bool ok;
|
||||
int sides = QInputDialog::getInteger(0, tr("Roll die"), tr("Number of sides:"), 20, 2, 1000, 1, &ok);
|
||||
if (ok)
|
||||
sendGameCommand(new Command_RollDie(-1, sides));
|
||||
if (ok) {
|
||||
Command_RollDie cmd;
|
||||
cmd.set_sides(sides);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actCreateToken()
|
||||
|
|
@ -666,18 +733,30 @@ void Player::actCreateToken()
|
|||
lastTokenDestroy = dlg.getDestroy();
|
||||
aCreateAnotherToken->setEnabled(true);
|
||||
|
||||
sendGameCommand(new Command_CreateToken(-1, "table", dlg.getName(), dlg.getColor(), dlg.getPT(), dlg.getAnnotation(), dlg.getDestroy(), -1, 0));
|
||||
actCreateAnotherToken();
|
||||
}
|
||||
|
||||
void Player::actCreateAnotherToken()
|
||||
{
|
||||
sendGameCommand(new Command_CreateToken(-1, "table", lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation, lastTokenDestroy, -1, 0));
|
||||
Command_CreateToken cmd;
|
||||
cmd.set_zone("table");
|
||||
cmd.set_card_name(lastTokenName.toStdString());
|
||||
cmd.set_color(lastTokenColor.toStdString());
|
||||
cmd.set_pt(lastTokenPT.toStdString());
|
||||
cmd.set_annotation(lastTokenAnnotation.toStdString());
|
||||
cmd.set_destroy_on_zone_change(lastTokenDestroy);
|
||||
cmd.set_x(-1);
|
||||
cmd.set_y(0);
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actSayMessage()
|
||||
{
|
||||
QAction *a = qobject_cast<QAction *>(sender());
|
||||
sendGameCommand(new Command_Say(-1, a->text()));
|
||||
Command_GameSay cmd;
|
||||
cmd.set_message(a->text().toStdString());
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::setCardAttrHelper(GameEventContext *context, CardItem *card, const QString &aname, const QString &avalue, bool allCards)
|
||||
|
|
@ -1154,13 +1233,27 @@ void Player::processCardAttachment(ServerInfo_Player *info)
|
|||
|
||||
void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
||||
{
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(c->getZone()->getName().toStdString());
|
||||
cmd.set_target_player_id(getId());
|
||||
CardToMove *cardToMove = cmd.mutable_cards_to_move()->add_card();
|
||||
cardToMove->set_card_id(c->getId());
|
||||
|
||||
CardInfo *ci = c->getInfo();
|
||||
if (ci->getTableRow() == 3)
|
||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId()), getId(), "stack", 0, 0));
|
||||
else {
|
||||
if (ci->getTableRow() == 3) {
|
||||
cmd.set_target_zone("stack");
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
} else {
|
||||
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId(), faceDown, ci->getPowTough(), tapped), getId(), "table", gridPoint.x(), gridPoint.y()));
|
||||
cardToMove->set_face_down(faceDown);
|
||||
cardToMove->set_pt(ci->getPowTough().toStdString());
|
||||
cardToMove->set_tapped(tapped);
|
||||
cmd.set_target_zone("table");
|
||||
cmd.set_x(gridPoint.x());
|
||||
cmd.set_y(gridPoint.y());
|
||||
}
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::addCard(CardItem *c)
|
||||
|
|
@ -1312,16 +1405,31 @@ void Player::rearrangeCounters()
|
|||
}
|
||||
}
|
||||
|
||||
void Player::sendGameCommand(GameCommand *command)
|
||||
PendingCommand * Player::prepareGameCommand(const google::protobuf::Message &cmd)
|
||||
{
|
||||
return static_cast<TabGame *>(parent())->prepareGameCommand(cmd);
|
||||
}
|
||||
|
||||
PendingCommand * Player::prepareGameCommand(const QList<const::google::protobuf::Message *> &cmdList)
|
||||
{
|
||||
return static_cast<TabGame *>(parent())->prepareGameCommand(cmdList);
|
||||
}
|
||||
|
||||
void Player::sendGameCommand(const google::protobuf::Message &command)
|
||||
{
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(command, id);
|
||||
}
|
||||
|
||||
void Player::sendCommandContainer(CommandContainer *cont)
|
||||
void Player::sendCommandContainer(CommandContainer &cont)
|
||||
{
|
||||
static_cast<TabGame *>(parent())->sendCommandContainer(cont, id);
|
||||
}
|
||||
|
||||
void Player::sendGameCommand(PendingCommand *pend)
|
||||
{
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(pend, id);
|
||||
}
|
||||
|
||||
bool Player::clearCardsToDelete()
|
||||
{
|
||||
if (cardsToDelete.isEmpty())
|
||||
|
|
@ -1341,55 +1449,118 @@ void Player::cardMenuAction(QAction *a)
|
|||
while (!sel.isEmpty())
|
||||
cardList.append(qgraphicsitem_cast<CardItem *>(sel.takeFirst()));
|
||||
|
||||
QList<Command *> commandList;
|
||||
QList< const ::google::protobuf::Message * > commandList;
|
||||
if (a->data().toInt() <= 4)
|
||||
for (int i = 0; i < cardList.size(); ++i) {
|
||||
CardItem *card = cardList[i];
|
||||
switch (a->data().toInt()) {
|
||||
case 0:
|
||||
if (!card->getTapped())
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "tapped", "1"));
|
||||
if (!card->getTapped()) {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_attr_name("tapped");
|
||||
cmd->set_attr_value("1");
|
||||
commandList.append(cmd);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (card->getTapped())
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "tapped", "0"));
|
||||
if (card->getTapped()) {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_attr_name("tapped");
|
||||
cmd->set_attr_value("0");
|
||||
commandList.append(cmd);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
commandList.append(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "doesnt_untap", QString::number(!card->getDoesntUntap())));
|
||||
break;
|
||||
case 3: {
|
||||
QString zone = card->getZone()->getName();
|
||||
commandList.append(new Command_FlipCard(-1, zone, card->getId(), !card->getFaceDown()));
|
||||
case 2: {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_attr_name("doesnt_untap");
|
||||
cmd->set_attr_value(card->getDoesntUntap() ? "1" : "0");
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
commandList.append(new Command_CreateToken(-1, card->getZone()->getName(), card->getName(), card->getColor(), card->getPT(), card->getAnnotation(), true, -1, card->getGridPoint().y()));
|
||||
case 3: {
|
||||
Command_FlipCard *cmd = new Command_FlipCard;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_face_down(!card->getFaceDown());
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
Command_CreateToken *cmd = new Command_CreateToken;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_name(card->getName().toStdString());
|
||||
cmd->set_color(card->getColor().toStdString());
|
||||
cmd->set_pt(card->getPT().toStdString());
|
||||
cmd->set_annotation(card->getAnnotation().toStdString());
|
||||
cmd->set_destroy_on_zone_change(true);
|
||||
cmd->set_x(-1);
|
||||
cmd->set_y(card->getGridPoint().y());
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QList<CardToMove *> idList;
|
||||
ListOfCardsToMove idList;
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
idList.append(new CardToMove(cardList[i]->getId()));
|
||||
idList.add_card()->set_card_id(cardList[i]->getId());
|
||||
QString startZone = cardList[0]->getZone()->getName();
|
||||
|
||||
switch (a->data().toInt()) {
|
||||
case 5:
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", 0, 0));
|
||||
case 5: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
cmd->mutable_cards_to_move()->CopyFrom(idList);
|
||||
cmd->set_target_player_id(getId());
|
||||
cmd->set_target_zone("deck");
|
||||
cmd->set_x(0);
|
||||
cmd->set_y(0);
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
case 6:
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", -1, 0));
|
||||
}
|
||||
case 6: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
cmd->mutable_cards_to_move()->CopyFrom(idList);
|
||||
cmd->set_target_player_id(getId());
|
||||
cmd->set_target_zone("deck");
|
||||
cmd->set_x(-1);
|
||||
cmd->set_y(0);
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
case 7:
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "grave", 0, 0));
|
||||
}
|
||||
case 7: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
cmd->mutable_cards_to_move()->CopyFrom(idList);
|
||||
cmd->set_target_player_id(getId());
|
||||
cmd->set_target_zone("grave");
|
||||
cmd->set_x(0);
|
||||
cmd->set_y(0);
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
case 8:
|
||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "rfg", 0, 0));
|
||||
}
|
||||
case 8: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
cmd->mutable_cards_to_move()->CopyFrom(idList);
|
||||
cmd->set_target_player_id(getId());
|
||||
cmd->set_target_zone("rfg");
|
||||
cmd->set_x(0);
|
||||
cmd->set_y(0);
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
sendCommandContainer(new CommandContainer(commandList));
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(prepareGameCommand(commandList));
|
||||
}
|
||||
|
||||
void Player::actIncPT(int deltaP, int deltaT)
|
||||
|
|
@ -1398,7 +1569,11 @@ void Player::actIncPT(int deltaP, int deltaT)
|
|||
QListIterator<QGraphicsItem *> j(scene()->selectedItems());
|
||||
while (j.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(j.next());
|
||||
sendGameCommand(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "pt", ptString));
|
||||
Command_SetCardAttr cmd;
|
||||
cmd.set_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
cmd.set_attr_name("pt");
|
||||
cmd.set_attr_value(ptString.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1423,7 +1598,11 @@ void Player::actSetPT(QAction * /*a*/)
|
|||
QListIterator<QGraphicsItem *> j(scene()->selectedItems());
|
||||
while (j.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(j.next());
|
||||
sendGameCommand(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "pt", pt));
|
||||
Command_SetCardAttr cmd;
|
||||
cmd.set_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
cmd.set_attr_name("pt");
|
||||
cmd.set_attr_value(pt.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1449,7 +1628,11 @@ void Player::actSetAnnotation(QAction * /*a*/)
|
|||
i.toFront();
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
sendGameCommand(new Command_SetCardAttr(-1, card->getZone()->getName(), card->getId(), "annotation", annotation));
|
||||
Command_SetCardAttr cmd;
|
||||
cmd.set_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
cmd.set_attr_name("annotation");
|
||||
cmd.set_attr_value(annotation.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1464,7 +1647,10 @@ void Player::actAttach(QAction *a)
|
|||
void Player::actUnattach(QAction *a)
|
||||
{
|
||||
CardItem *card = static_cast<CardItem *>(a->parent());
|
||||
sendGameCommand(new Command_AttachCard(-1, card->getZone()->getName(), card->getId(), -1, QString(), -1));
|
||||
Command_AttachCard cmd;
|
||||
cmd.set_start_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actCardCounterTrigger(QAction *a)
|
||||
|
|
@ -1476,8 +1662,14 @@ void Player::actCardCounterTrigger(QAction *a)
|
|||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
if (card->getCounters().value(counterId, 0) < MAX_COUNTERS_ON_CARD)
|
||||
sendGameCommand(new Command_SetCardCounter(-1, card->getZone()->getName(), card->getId(), counterId, card->getCounters().value(counterId, 0) + 1));
|
||||
if (card->getCounters().value(counterId, 0) < MAX_COUNTERS_ON_CARD) {
|
||||
Command_SetCardCounter cmd;
|
||||
cmd.set_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
cmd.set_counter_id(counterId);
|
||||
cmd.set_counter_value(card->getCounters().value(counterId, 0) + 1);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1485,8 +1677,14 @@ void Player::actCardCounterTrigger(QAction *a)
|
|||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
if (card->getCounters().value(counterId, 0))
|
||||
sendGameCommand(new Command_SetCardCounter(-1, card->getZone()->getName(), card->getId(), counterId, card->getCounters().value(counterId, 0) - 1));
|
||||
if (card->getCounters().value(counterId, 0)) {
|
||||
Command_SetCardCounter cmd;
|
||||
cmd.set_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
cmd.set_counter_id(counterId);
|
||||
cmd.set_counter_value(card->getCounters().value(counterId, 0) - 1);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1503,7 +1701,12 @@ void Player::actCardCounterTrigger(QAction *a)
|
|||
QListIterator<QGraphicsItem *> i(scene()->selectedItems());
|
||||
while (i.hasNext()) {
|
||||
CardItem *card = static_cast<CardItem *>(i.next());
|
||||
sendGameCommand(new Command_SetCardCounter(-1, card->getZone()->getName(), card->getId(), counterId, number));
|
||||
Command_SetCardCounter cmd;
|
||||
cmd.set_zone(card->getZone()->getName().toStdString());
|
||||
cmd.set_card_id(card->getId());
|
||||
cmd.set_counter_id(counterId);
|
||||
cmd.set_counter_value(number);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
#include <QPoint>
|
||||
#include <QMap>
|
||||
#include "carditem.h"
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
class CardDatabase;
|
||||
class QMenu;
|
||||
|
|
@ -46,6 +47,7 @@ class Event_DestroyCard;
|
|||
class Event_AttachCard;
|
||||
class Event_DrawCards;
|
||||
class Event_RevealCards;
|
||||
class PendingCommand;
|
||||
|
||||
class PlayerArea : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT
|
||||
|
|
@ -254,8 +256,12 @@ public:
|
|||
void processCardAttachment(ServerInfo_Player *info);
|
||||
|
||||
void processGameEvent(GameEvent *event, GameEventContext *context);
|
||||
void sendGameCommand(GameCommand *command);
|
||||
void sendCommandContainer(CommandContainer *cont);
|
||||
|
||||
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
|
||||
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
|
||||
void sendGameCommand(PendingCommand *pend);
|
||||
void sendGameCommand(const google::protobuf::Message &command);
|
||||
void sendCommandContainer(CommandContainer &cont);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
#include "pb/session_commands.pb.h"
|
||||
#include "pb/command_kick_from_game.pb.h"
|
||||
|
||||
PlayerListItemDelegate::PlayerListItemDelegate(QObject *const parent)
|
||||
: QStyledItemDelegate(parent)
|
||||
{
|
||||
|
|
@ -198,16 +201,35 @@ void PlayerListWidget::showContextMenu(const QPoint &pos, const QModelIndex &ind
|
|||
infoWidget->updateInfo(userName);
|
||||
} else if (actionClicked == aChat)
|
||||
emit openMessageDialog(userName, true);
|
||||
else if (actionClicked == aAddToBuddyList)
|
||||
client->sendCommand(new Command_AddToList("buddy", userName));
|
||||
else if (actionClicked == aRemoveFromBuddyList)
|
||||
client->sendCommand(new Command_RemoveFromList("buddy", userName));
|
||||
else if (actionClicked == aAddToIgnoreList)
|
||||
client->sendCommand(new Command_AddToList("ignore", userName));
|
||||
else if (actionClicked == aRemoveFromIgnoreList)
|
||||
client->sendCommand(new Command_RemoveFromList("ignore", userName));
|
||||
else if (actionClicked == aKick)
|
||||
game->sendGameCommand(new Command_KickFromGame(-1, playerId));
|
||||
else if (actionClicked == aAddToBuddyList) {
|
||||
Command_AddToList cmd;
|
||||
cmd.set_list("buddy");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aRemoveFromBuddyList) {
|
||||
Command_RemoveFromList cmd;
|
||||
cmd.set_list("buddy");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aAddToIgnoreList) {
|
||||
Command_AddToList cmd;
|
||||
cmd.set_list("ignore");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aRemoveFromIgnoreList) {
|
||||
Command_RemoveFromList cmd;
|
||||
cmd.set_list("ignore");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aKick) {
|
||||
Command_KickFromGame cmd;
|
||||
cmd.set_player_id(playerId);
|
||||
game->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
delete menu;
|
||||
delete aUserName;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@
|
|||
#include "protocol.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/commands.pb.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
RemoteClient::RemoteClient(QObject *parent)
|
||||
: AbstractClient(parent), timeRunning(0), lastDataReceived(0), topLevelItem(0)
|
||||
{
|
||||
|
|
@ -21,8 +25,6 @@ RemoteClient::RemoteClient(QObject *parent)
|
|||
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)));
|
||||
|
||||
xmlReader = new QXmlStreamReader;
|
||||
xmlWriter = new QXmlStreamWriter;
|
||||
xmlWriter->setDevice(socket);
|
||||
}
|
||||
|
||||
RemoteClient::~RemoteClient()
|
||||
|
|
@ -80,28 +82,41 @@ void RemoteClient::readData()
|
|||
disconnectFromServer();
|
||||
return;
|
||||
}
|
||||
xmlWriter->writeStartDocument();
|
||||
/* xmlWriter->writeStartDocument();
|
||||
xmlWriter->writeStartElement("cockatrice_client_stream");
|
||||
xmlWriter->writeAttribute("version", QString::number(ProtocolItem::protocolVersion));
|
||||
xmlWriter->writeAttribute("comp", "1");
|
||||
|
||||
*/
|
||||
topLevelItem = new TopLevelProtocolItem;
|
||||
connect(topLevelItem, SIGNAL(protocolItemReceived(ProtocolItem *)), this, SLOT(processProtocolItem(ProtocolItem *)));
|
||||
|
||||
setStatus(StatusLoggingIn);
|
||||
Command_Login *cmdLogin = new Command_Login(userName, password);
|
||||
connect(cmdLogin, SIGNAL(finished(ProtocolResponse *)), this, SLOT(loginResponse(ProtocolResponse *)));
|
||||
sendCommand(cmdLogin);
|
||||
|
||||
Command_Login cmdLogin;
|
||||
cmdLogin.set_user_name(userName.toStdString());
|
||||
cmdLogin.set_password(password.toStdString());
|
||||
|
||||
PendingCommand *pend = prepareSessionCommand(cmdLogin);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(loginResponse(ProtocolResponse *)));
|
||||
sendCommand(pend);
|
||||
}
|
||||
}
|
||||
if (status == StatusDisconnecting)
|
||||
disconnectFromServer();
|
||||
}
|
||||
|
||||
void RemoteClient::sendCommandContainer(CommandContainer *cont)
|
||||
void RemoteClient::sendCommandContainer(const CommandContainer &cont)
|
||||
{
|
||||
cont->write(xmlWriter);
|
||||
pendingCommands.insert(cont->getCmdId(), cont);
|
||||
QByteArray buf;
|
||||
unsigned int size = cont.ByteSize();
|
||||
buf.resize(size + 4);
|
||||
cont.SerializeToArray(buf.data() + 4, size);
|
||||
buf.data()[3] = (unsigned char) size;
|
||||
buf.data()[2] = (unsigned char) (size >> 8);
|
||||
buf.data()[1] = (unsigned char) (size >> 16);
|
||||
buf.data()[0] = (unsigned char) (size >> 24);
|
||||
|
||||
socket->write(buf);
|
||||
}
|
||||
|
||||
void RemoteClient::connectToServer(const QString &hostname, unsigned int port, const QString &_userName, const QString &_password)
|
||||
|
|
@ -123,7 +138,7 @@ void RemoteClient::disconnectFromServer()
|
|||
|
||||
timer->stop();
|
||||
|
||||
QList<CommandContainer *> pc = pendingCommands.values();
|
||||
QList<PendingCommand *> pc = pendingCommands.values();
|
||||
for (int i = 0; i < pc.size(); i++)
|
||||
delete pc[i];
|
||||
pendingCommands.clear();
|
||||
|
|
@ -134,21 +149,21 @@ void RemoteClient::disconnectFromServer()
|
|||
|
||||
void RemoteClient::ping()
|
||||
{
|
||||
QMutableMapIterator<int, CommandContainer *> i(pendingCommands);
|
||||
/* QMutableMapIterator<int, PendingCommand *> i(pendingCommands);
|
||||
while (i.hasNext())
|
||||
if (i.next().value()->tick() > maxTimeout) {
|
||||
CommandContainer *cont = i.value();
|
||||
i.remove();
|
||||
cont->deleteLater();
|
||||
}
|
||||
|
||||
*/
|
||||
int maxTime = timeRunning - lastDataReceived;
|
||||
emit maxPingTime(maxTime, maxTimeout);
|
||||
if (maxTime >= maxTimeout) {
|
||||
disconnectFromServer();
|
||||
emit serverTimeout();
|
||||
} else {
|
||||
sendCommand(new Command_Ping);
|
||||
sendCommand(prepareSessionCommand(Command_Ping()));
|
||||
++timeRunning;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ private:
|
|||
QTimer *timer;
|
||||
QTcpSocket *socket;
|
||||
QXmlStreamReader *xmlReader;
|
||||
QXmlStreamWriter *xmlWriter;
|
||||
TopLevelProtocolItem *topLevelItem;
|
||||
|
||||
void sendCommandContainer(const CommandContainer &cont);
|
||||
public:
|
||||
RemoteClient(QObject *parent = 0);
|
||||
~RemoteClient();
|
||||
|
|
@ -38,8 +39,6 @@ public:
|
|||
|
||||
void connectToServer(const QString &hostname, unsigned int port, const QString &_userName, const QString &_password);
|
||||
void disconnectFromServer();
|
||||
|
||||
void sendCommandContainer(CommandContainer *cont);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
#include "protocol_items.h"
|
||||
#include "abstractclient.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
RemoteDeckList_TreeModel::DirectoryNode::DirectoryNode(const QString &_name, RemoteDeckList_TreeModel::DirectoryNode *_parent)
|
||||
: RemoteDeckList_TreeModel::Node(_name, _parent)
|
||||
{
|
||||
|
|
@ -238,9 +241,10 @@ void RemoteDeckList_TreeModel::removeNode(RemoteDeckList_TreeModel::Node *node)
|
|||
|
||||
void RemoteDeckList_TreeModel::refreshTree()
|
||||
{
|
||||
Command_DeckList *command = new Command_DeckList;
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckListFinished(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
PendingCommand *pend = client->prepareSessionCommand(Command_DeckList());
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckListFinished(ProtocolResponse *)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void RemoteDeckList_TreeModel::deckListFinished(ProtocolResponse *r)
|
||||
|
|
|
|||
|
|
@ -4,9 +4,10 @@
|
|||
#include "stackzone.h"
|
||||
#include "settingscache.h"
|
||||
#include "player.h"
|
||||
#include "protocol_items.h"
|
||||
#include "carddragitem.h"
|
||||
|
||||
#include "pb/command_move_card.pb.h"
|
||||
|
||||
StackZone::StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent)
|
||||
: SelectZone(_p, "stack", false, false, true, parent), zoneHeight(_zoneHeight)
|
||||
{
|
||||
|
|
@ -57,11 +58,17 @@ void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
|
|||
if (startZone == this)
|
||||
return;
|
||||
|
||||
QList<CardToMove *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_target_player_id(player->getId());
|
||||
cmd.set_target_zone(getName().toStdString());
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0));
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(dragItems[i]->getId());
|
||||
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void StackZone::reorganizeCards()
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
#include <QLineEdit>
|
||||
#include "tab_admin.h"
|
||||
#include "abstractclient.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pb/admin_commands.pb.h"
|
||||
|
||||
ShutdownDialog::ShutdownDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
|
|
@ -100,14 +101,19 @@ void TabAdmin::retranslateUi()
|
|||
|
||||
void TabAdmin::actUpdateServerMessage()
|
||||
{
|
||||
client->sendCommand(new Command_UpdateServerMessage());
|
||||
client->sendCommand(client->prepareAdminCommand(Command_UpdateServerMessage()));
|
||||
}
|
||||
|
||||
void TabAdmin::actShutdownServer()
|
||||
{
|
||||
ShutdownDialog dlg;
|
||||
if (dlg.exec())
|
||||
client->sendCommand(new Command_ShutdownServer(dlg.getReason(), dlg.getMinutes()));
|
||||
if (dlg.exec()) {
|
||||
Command_ShutdownServer cmd;
|
||||
cmd.set_reason(dlg.getReason().toStdString());
|
||||
cmd.set_minutes(dlg.getMinutes());
|
||||
|
||||
client->sendCommand(client->prepareAdminCommand(cmd));
|
||||
}
|
||||
}
|
||||
|
||||
void TabAdmin::actUnlock()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,13 @@
|
|||
#include "window_deckeditor.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/command_deck_upload.pb.h"
|
||||
#include "pb/command_deck_download.pb.h"
|
||||
#include "pb/command_deck_new_dir.pb.h"
|
||||
#include "pb/command_deck_del_dir.pb.h"
|
||||
#include "pb/command_deck_del.pb.h"
|
||||
|
||||
TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_client)
|
||||
: Tab(_tabSupervisor), client(_client)
|
||||
{
|
||||
|
|
@ -157,9 +164,9 @@ void TabDeckStorage::actUpload()
|
|||
curRight = curRight->getParent();
|
||||
targetPath = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight)->getPath();
|
||||
|
||||
Command_DeckUpload *command = new Command_DeckUpload(deck, targetPath);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(uploadFinished(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
// Command_DeckUpload *command = new Command_DeckUpload(deck, targetPath);
|
||||
// connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(uploadFinished(ProtocolResponse *)));
|
||||
// client->sendCommand(command);
|
||||
}
|
||||
|
||||
void TabDeckStorage::uploadFinished(ProtocolResponse *r)
|
||||
|
|
@ -167,9 +174,9 @@ void TabDeckStorage::uploadFinished(ProtocolResponse *r)
|
|||
Response_DeckUpload *resp = qobject_cast<Response_DeckUpload *>(r);
|
||||
if (!resp)
|
||||
return;
|
||||
Command_DeckUpload *cmd = static_cast<Command_DeckUpload *>(sender());
|
||||
|
||||
serverDirView->addFileToTree(resp->getFile(), serverDirView->getNodeByPath(cmd->getPath()));
|
||||
// Command_DeckUpload *cmd = static_cast<Command_DeckUpload *>(sender());
|
||||
//
|
||||
// serverDirView->addFileToTree(resp->getFile(), serverDirView->getNodeByPath(cmd->getPath()));
|
||||
}
|
||||
|
||||
void TabDeckStorage::actOpenRemoteDeck()
|
||||
|
|
@ -178,9 +185,9 @@ void TabDeckStorage::actOpenRemoteDeck()
|
|||
if (!curRight)
|
||||
return;
|
||||
|
||||
Command_DeckDownload *command = new Command_DeckDownload(curRight->getId());
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(openRemoteDeckFinished(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
// Command_DeckDownload *command = new Command_DeckDownload(curRight->getId());
|
||||
// connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(openRemoteDeckFinished(ProtocolResponse *)));
|
||||
// client->sendCommand(command);
|
||||
}
|
||||
|
||||
void TabDeckStorage::openRemoteDeckFinished(ProtocolResponse *r)
|
||||
|
|
@ -211,10 +218,10 @@ void TabDeckStorage::actDownload()
|
|||
return;
|
||||
filePath += QString("/deck_%1.cod").arg(curRight->getId());
|
||||
|
||||
Command_DeckDownload *command = new Command_DeckDownload(curRight->getId());
|
||||
command->setExtraData(filePath);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(downloadFinished(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
// Command_DeckDownload *command = new Command_DeckDownload(curRight->getId());
|
||||
// command->setExtraData(filePath);
|
||||
// connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(downloadFinished(ProtocolResponse *)));
|
||||
// client->sendCommand(command);
|
||||
}
|
||||
|
||||
void TabDeckStorage::downloadFinished(ProtocolResponse *r)
|
||||
|
|
@ -222,10 +229,10 @@ void TabDeckStorage::downloadFinished(ProtocolResponse *r)
|
|||
Response_DeckDownload *resp = qobject_cast<Response_DeckDownload *>(r);
|
||||
if (!resp)
|
||||
return;
|
||||
Command_DeckDownload *cmd = static_cast<Command_DeckDownload *>(sender());
|
||||
|
||||
QString filePath = cmd->getExtraData().toString();
|
||||
resp->getDeck()->saveToFile(filePath, DeckList::CockatriceFormat);
|
||||
// Command_DeckDownload *cmd = static_cast<Command_DeckDownload *>(sender());
|
||||
//
|
||||
// QString filePath = cmd->getExtraData().toString();
|
||||
// resp->getDeck()->saveToFile(filePath, DeckList::CockatriceFormat);
|
||||
}
|
||||
|
||||
void TabDeckStorage::actNewFolder()
|
||||
|
|
@ -242,10 +249,14 @@ void TabDeckStorage::actNewFolder()
|
|||
curRight = curRight->getParent();
|
||||
RemoteDeckList_TreeModel::DirectoryNode *dir = dynamic_cast<RemoteDeckList_TreeModel::DirectoryNode *>(curRight);
|
||||
targetPath = dir->getPath();
|
||||
|
||||
Command_DeckNewDir *command = new Command_DeckNewDir(targetPath, folderName);
|
||||
connect(command, SIGNAL(finished(ResponseCode)), this, SLOT(newFolderFinished(ResponseCode)));
|
||||
client->sendCommand(command);
|
||||
|
||||
Command_DeckNewDir cmd;
|
||||
cmd.set_path(targetPath.toStdString());
|
||||
cmd.set_dir_name(folderName.toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(newFolderFinished(ResponseCode)));
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void TabDeckStorage::newFolderFinished(ResponseCode resp)
|
||||
|
|
@ -253,13 +264,13 @@ void TabDeckStorage::newFolderFinished(ResponseCode resp)
|
|||
if (resp != RespOk)
|
||||
return;
|
||||
|
||||
Command_DeckNewDir *cmd = static_cast<Command_DeckNewDir *>(sender());
|
||||
serverDirView->addFolderToTree(cmd->getDirName(), serverDirView->getNodeByPath(cmd->getPath()));
|
||||
// Command_DeckNewDir *cmd = static_cast<Command_DeckNewDir *>(sender());
|
||||
// serverDirView->addFolderToTree(cmd->getDirName(), serverDirView->getNodeByPath(cmd->getPath()));
|
||||
}
|
||||
|
||||
void TabDeckStorage::actDelete()
|
||||
{
|
||||
Command *command;
|
||||
PendingCommand *pend;
|
||||
RemoteDeckList_TreeModel::Node *curRight = serverDirView->getCurrentItem();
|
||||
if (!curRight)
|
||||
return;
|
||||
|
|
@ -268,11 +279,17 @@ void TabDeckStorage::actDelete()
|
|||
QString path = dir->getPath();
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
command = new Command_DeckDelDir(path);
|
||||
} else
|
||||
command = new Command_DeckDel(dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(curRight)->getId());
|
||||
connect(command, SIGNAL(finished(ResponseCode)), this, SLOT(deleteFinished(ResponseCode)));
|
||||
client->sendCommand(command);
|
||||
Command_DeckDelDir cmd;
|
||||
cmd.set_path(path.toStdString());
|
||||
pend = client->prepareSessionCommand(cmd);
|
||||
} else {
|
||||
Command_DeckDel cmd;
|
||||
cmd.set_deck_id(dynamic_cast<RemoteDeckList_TreeModel::FileNode *>(curRight)->getId());
|
||||
pend = client->prepareSessionCommand(cmd);
|
||||
}
|
||||
|
||||
connect(pend, SIGNAL(finished(ResponseCode)), this, SLOT(deleteFinished(ResponseCode)));
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void TabDeckStorage::deleteFinished(ResponseCode resp)
|
||||
|
|
@ -281,11 +298,11 @@ void TabDeckStorage::deleteFinished(ResponseCode resp)
|
|||
return;
|
||||
|
||||
RemoteDeckList_TreeModel::Node *toDelete = 0;
|
||||
Command_DeckDelDir *cmdDelDir = qobject_cast<Command_DeckDelDir *>(sender());
|
||||
if (cmdDelDir)
|
||||
toDelete = serverDirView->getNodeByPath(cmdDelDir->getPath());
|
||||
else
|
||||
toDelete = serverDirView->getNodeById(static_cast<Command_DeckDel *>(sender())->getDeckId());
|
||||
// Command_DeckDelDir *cmdDelDir = qobject_cast<Command_DeckDelDir *>(sender());
|
||||
// if (cmdDelDir)
|
||||
// toDelete = serverDirView->getNodeByPath(cmdDelDir->getPath());
|
||||
// else
|
||||
// toDelete = serverDirView->getNodeById(static_cast<Command_DeckDel *>(sender())->getDeckId());
|
||||
|
||||
if (toDelete)
|
||||
serverDirView->removeNode(toDelete);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,18 @@
|
|||
#include "settingscache.h"
|
||||
#include "carddatabase.h"
|
||||
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include "pending_command.h"
|
||||
#include "pb/command_concede.pb.h"
|
||||
#include "pb/command_deck_select.pb.h"
|
||||
#include "pb/command_ready_start.pb.h"
|
||||
#include "pb/command_set_sideboard_plan.pb.h"
|
||||
#include "pb/command_leave_game.pb.h"
|
||||
#include "pb/command_game_say.pb.h"
|
||||
#include "pb/command_set_active_phase.pb.h"
|
||||
#include "pb/command_next_turn.pb.h"
|
||||
#include "pb/command_delete_arrow.pb.h"
|
||||
|
||||
ReadyStartButton::ReadyStartButton(QWidget *parent)
|
||||
: QPushButton(parent), readyStart(false)
|
||||
{
|
||||
|
|
@ -50,8 +62,8 @@ void ReadyStartButton::setReadyStart(bool _readyStart)
|
|||
update();
|
||||
}
|
||||
|
||||
DeckViewContainer::DeckViewContainer(AbstractClient *_client, TabGame *parent)
|
||||
: QWidget(parent), client(_client)
|
||||
DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
|
||||
: QWidget(parent), playerId(_playerId)
|
||||
{
|
||||
loadLocalButton = new QPushButton;
|
||||
loadRemoteButton = new QPushButton;
|
||||
|
|
@ -110,18 +122,22 @@ void DeckViewContainer::loadLocalDeck()
|
|||
return;
|
||||
}
|
||||
|
||||
Command_DeckSelect *cmd = new Command_DeckSelect(static_cast<TabGame *>(parent())->getGameId(), deck, -1);
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckSelectFinished(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
Command_DeckSelect cmd;
|
||||
cmd.set_deck(""); // XXX
|
||||
PendingCommand *pend = static_cast<TabGame *>(parent())->prepareGameCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckSelectFinished(ProtocolResponse *)));
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(pend, playerId);
|
||||
}
|
||||
|
||||
void DeckViewContainer::loadRemoteDeck()
|
||||
{
|
||||
DlgLoadRemoteDeck dlg(client);
|
||||
DlgLoadRemoteDeck dlg(static_cast<TabGame *>(parent())->getClientForPlayer(playerId));
|
||||
if (dlg.exec()) {
|
||||
Command_DeckSelect *cmd = new Command_DeckSelect(static_cast<TabGame *>(parent())->getGameId(), 0, dlg.getDeckId());
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckSelectFinished(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
Command_DeckSelect cmd;
|
||||
cmd.set_deck_id(dlg.getDeckId());
|
||||
PendingCommand *pend = static_cast<TabGame *>(parent())->prepareGameCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(deckSelectFinished(ProtocolResponse *)));
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(pend, playerId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,13 +154,18 @@ void DeckViewContainer::deckSelectFinished(ProtocolResponse *r)
|
|||
|
||||
void DeckViewContainer::readyStart()
|
||||
{
|
||||
client->sendCommand(new Command_ReadyStart(static_cast<TabGame *>(parent())->getGameId(), !readyStartButton->getReadyStart()));
|
||||
Command_ReadyStart cmd;
|
||||
cmd.set_ready(!readyStartButton->getReadyStart());
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void DeckViewContainer::sideboardPlanChanged()
|
||||
{
|
||||
Command_SetSideboardPlan cmd;
|
||||
QList<MoveCardToZone *> newPlan = deckView->getSideboardPlan();
|
||||
client->sendCommand(new Command_SetSideboardPlan(static_cast<TabGame *>(parent())->getGameId(), newPlan));
|
||||
for (int i = 0; i < newPlan.size(); ++i)
|
||||
cmd.add_move_list()->CopyFrom(newPlan[i]->toPB());
|
||||
static_cast<TabGame *>(parent())->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void DeckViewContainer::setReadyStart(bool ready)
|
||||
|
|
@ -164,7 +185,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
{
|
||||
phasesToolbar = new PhasesToolbar;
|
||||
phasesToolbar->hide();
|
||||
connect(phasesToolbar, SIGNAL(sendGameCommand(GameCommand *, int)), this, SLOT(sendGameCommand(GameCommand *, int)));
|
||||
connect(phasesToolbar, SIGNAL(sendGameCommand(const ::google::protobuf::Message &, int)), this, SLOT(sendGameCommand(const ::google::protobuf::Message &, int)));
|
||||
|
||||
scene = new GameScene(phasesToolbar, this);
|
||||
gameView = new GameView(scene);
|
||||
|
|
@ -327,7 +348,7 @@ void TabGame::actConcede()
|
|||
if (QMessageBox::question(this, tr("Concede"), tr("Are you sure you want to concede this game?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
sendGameCommand(new Command_Concede);
|
||||
sendGameCommand(Command_Concede());
|
||||
}
|
||||
|
||||
void TabGame::actLeaveGame()
|
||||
|
|
@ -336,14 +357,16 @@ void TabGame::actLeaveGame()
|
|||
if (QMessageBox::question(this, tr("Leave game"), tr("Are you sure you want to leave this game?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
sendGameCommand(new Command_LeaveGame);
|
||||
sendGameCommand(Command_LeaveGame());
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void TabGame::actSay()
|
||||
{
|
||||
if (!sayEdit->text().isEmpty()) {
|
||||
sendGameCommand(new Command_Say(-1, sayEdit->text()));
|
||||
Command_GameSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
sendGameCommand(cmd);
|
||||
sayEdit->clear();
|
||||
}
|
||||
}
|
||||
|
|
@ -351,7 +374,9 @@ void TabGame::actSay()
|
|||
void TabGame::actPhaseAction()
|
||||
{
|
||||
int phase = phaseActions.indexOf(static_cast<QAction *>(sender()));
|
||||
emit sendGameCommand(new Command_SetActivePhase(-1, phase), -1);
|
||||
Command_SetActivePhase cmd;
|
||||
cmd.set_phase(phase);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void TabGame::actNextPhase()
|
||||
|
|
@ -359,12 +384,14 @@ void TabGame::actNextPhase()
|
|||
int phase = currentPhase;
|
||||
if (++phase >= phasesToolbar->phaseCount())
|
||||
phase = 0;
|
||||
sendGameCommand(new Command_SetActivePhase(-1, phase));
|
||||
Command_SetActivePhase cmd;
|
||||
cmd.set_phase(phase);
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void TabGame::actNextTurn()
|
||||
{
|
||||
sendGameCommand(new Command_NextTurn);
|
||||
sendGameCommand(Command_NextTurn());
|
||||
}
|
||||
|
||||
void TabGame::actRemoveLocalArrows()
|
||||
|
|
@ -377,7 +404,9 @@ void TabGame::actRemoveLocalArrows()
|
|||
QMapIterator<int, ArrowItem *> arrowIterator(player->getArrows());
|
||||
while (arrowIterator.hasNext()) {
|
||||
ArrowItem *a = arrowIterator.next().value();
|
||||
sendGameCommand(new Command_DeleteArrow(-1, a->getId()));
|
||||
Command_DeleteArrow cmd;
|
||||
cmd.set_arrow_id(a->getId());
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -392,14 +421,10 @@ Player *TabGame::addPlayer(int playerId, ServerInfo_User *info)
|
|||
messageLog->connectToPlayer(newPlayer);
|
||||
|
||||
if (local && !spectator) {
|
||||
AbstractClient *client;
|
||||
if (clients.size() > 1)
|
||||
client = clients.at(playerId);
|
||||
else {
|
||||
client = clients.first();
|
||||
if (clients.size() == 1)
|
||||
newPlayer->setShortcutsActive();
|
||||
}
|
||||
DeckViewContainer *deckView = new DeckViewContainer(client, this);
|
||||
|
||||
DeckViewContainer *deckView = new DeckViewContainer(playerId, this);
|
||||
connect(deckView, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
||||
deckViewContainers.insert(playerId, deckView);
|
||||
deckViewContainerLayout->addWidget(deckView);
|
||||
|
|
@ -462,37 +487,53 @@ void TabGame::processGameEventContainer(GameEventContainer *cont, AbstractClient
|
|||
messageLog->containerProcessingDone();
|
||||
}
|
||||
|
||||
void TabGame::sendGameCommand(GameCommand *command, int playerId)
|
||||
AbstractClient *TabGame::getClientForPlayer(int playerId) const
|
||||
{
|
||||
command->setGameId(gameId);
|
||||
AbstractClient *client;
|
||||
if (clients.size() > 1) {
|
||||
if (playerId == -1)
|
||||
playerId = getActiveLocalPlayer()->getId();
|
||||
|
||||
client = clients.at(playerId);
|
||||
return clients.at(playerId);
|
||||
} else
|
||||
client = clients.first();
|
||||
client->sendCommand(command);
|
||||
return clients.first();
|
||||
}
|
||||
|
||||
void TabGame::sendCommandContainer(CommandContainer *cont, int playerId)
|
||||
void TabGame::sendGameCommand(PendingCommand *pend, int playerId)
|
||||
{
|
||||
const QList<Command *> &cmdList = cont->getCommandList();
|
||||
for (int i = 0; i < cmdList.size(); ++i) {
|
||||
GameCommand *cmd = qobject_cast<GameCommand *>(cmdList[i]);
|
||||
if (cmd)
|
||||
cmd->setGameId(gameId);
|
||||
}
|
||||
getClientForPlayer(playerId)->sendCommand(pend);
|
||||
}
|
||||
|
||||
AbstractClient *client;
|
||||
if (clients.size() > 1) {
|
||||
if (playerId == -1)
|
||||
playerId = getActiveLocalPlayer()->getId();
|
||||
client = clients.at(playerId);
|
||||
} else
|
||||
client = clients.first();
|
||||
client->sendCommandContainer(cont);
|
||||
void TabGame::sendGameCommand(const google::protobuf::Message &command, int playerId)
|
||||
{
|
||||
AbstractClient *client = getClientForPlayer(playerId);
|
||||
client->sendCommand(prepareGameCommand(command));
|
||||
}
|
||||
|
||||
void TabGame::sendCommandContainer(CommandContainer &cont, int playerId)
|
||||
{
|
||||
cont.set_game_id(gameId);
|
||||
getClientForPlayer(playerId)->sendCommand(cont);
|
||||
}
|
||||
|
||||
PendingCommand *TabGame::prepareGameCommand(const ::google::protobuf::Message &cmd)
|
||||
{
|
||||
CommandContainer cont;
|
||||
cont.set_game_id(gameId);
|
||||
GameCommand *c = cont.add_game_command();
|
||||
c->GetReflection()->MutableMessage(c, cmd.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(cmd);
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
||||
PendingCommand *TabGame::prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList)
|
||||
{
|
||||
CommandContainer cont;
|
||||
cont.set_game_id(gameId);
|
||||
for (int i = 0; i < cmdList.size(); ++i) {
|
||||
GameCommand *c = cont.add_game_command();
|
||||
c->GetReflection()->MutableMessage(c, cmdList[i]->GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(*cmdList[i]);
|
||||
delete cmdList[i];
|
||||
}
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
||||
void TabGame::startGame(bool resuming)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <QMap>
|
||||
#include <QPushButton>
|
||||
#include "tab.h"
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
class AbstractClient;
|
||||
class CardDatabase;
|
||||
|
|
@ -47,6 +48,7 @@ class DeckList;
|
|||
class QVBoxLayout;
|
||||
class QHBoxLayout;
|
||||
class ServerInfo_User;
|
||||
class PendingCommand;
|
||||
|
||||
class ReadyStartButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
|
|
@ -66,7 +68,7 @@ private:
|
|||
QPushButton *loadLocalButton, *loadRemoteButton;
|
||||
ReadyStartButton *readyStartButton;
|
||||
DeckView *deckView;
|
||||
AbstractClient *client;
|
||||
int playerId;
|
||||
private slots:
|
||||
void loadLocalDeck();
|
||||
void loadRemoteDeck();
|
||||
|
|
@ -76,7 +78,7 @@ private slots:
|
|||
signals:
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
public:
|
||||
DeckViewContainer(AbstractClient *_client, TabGame *parent = 0);
|
||||
DeckViewContainer(int _playerId, TabGame *parent = 0);
|
||||
void retranslateUi();
|
||||
void setButtonsVisible(bool _visible);
|
||||
void setReadyStart(bool ready);
|
||||
|
|
@ -173,11 +175,15 @@ public:
|
|||
bool getSpectatorsCanTalk() const { return spectatorsCanTalk; }
|
||||
bool getSpectatorsSeeEverything() const { return spectatorsSeeEverything; }
|
||||
Player *getActiveLocalPlayer() const;
|
||||
AbstractClient *getClientForPlayer(int playerId) const;
|
||||
|
||||
void processGameEventContainer(GameEventContainer *cont, AbstractClient *client);
|
||||
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
|
||||
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
|
||||
public slots:
|
||||
void sendGameCommand(GameCommand *command, int playerId = -1);
|
||||
void sendCommandContainer(CommandContainer *cont, int playerId = -1);
|
||||
void sendGameCommand(PendingCommand *pend, int playerId = -1);
|
||||
void sendGameCommand(const ::google::protobuf::Message &command, int playerId = -1);
|
||||
void sendCommandContainer(CommandContainer &cont, int playerId = -1);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
#include "protocol_items.h"
|
||||
#include "chatview.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, const QString &_userName)
|
||||
: Tab(_tabSupervisor), client(_client), userName(_userName), userOnline(true)
|
||||
{
|
||||
|
|
@ -52,9 +55,14 @@ void TabMessage::sendMessage()
|
|||
if (sayEdit->text().isEmpty() || !userOnline)
|
||||
return;
|
||||
|
||||
Command_Message *cmd = new Command_Message(userName, sayEdit->text());
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(messageSent(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
Command_Message cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(messageSent(ProtocolResponse *)));
|
||||
client->sendCommand(pend);
|
||||
|
||||
sayEdit->clear();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,13 @@
|
|||
#include "tab_userlists.h"
|
||||
#include "userlist.h"
|
||||
#include "abstractclient.h"
|
||||
#include "protocol_items.h"
|
||||
#include "chatview.h"
|
||||
#include "gameselector.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
||||
TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, const QString &_ownName, ServerInfo_Room *info)
|
||||
: Tab(_tabSupervisor), client(_client), roomId(info->getRoomId()), roomName(info->getName()), ownName(_ownName)
|
||||
|
|
@ -108,9 +112,12 @@ void TabRoom::sendMessage()
|
|||
if (sayEdit->text().isEmpty())
|
||||
return;
|
||||
|
||||
Command_RoomSay *cmd = new Command_RoomSay(roomId, sayEdit->text());
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(sayFinished(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
Command_RoomSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
||||
PendingCommand *pend = prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(sayFinished(ProtocolResponse *)));
|
||||
sendRoomCommand(pend);
|
||||
sayEdit->clear();
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +129,7 @@ void TabRoom::sayFinished(ProtocolResponse *response)
|
|||
|
||||
void TabRoom::actLeaveRoom()
|
||||
{
|
||||
client->sendCommand(new Command_LeaveRoom(roomId));
|
||||
sendRoomCommand(prepareRoomCommand(Command_LeaveRoom()));
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
|
@ -161,3 +168,17 @@ void TabRoom::processSayEvent(Event_RoomSay *event)
|
|||
chatView->appendMessage(event->getPlayerName(), event->getMessage());
|
||||
emit userEvent(false);
|
||||
}
|
||||
|
||||
PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &cmd)
|
||||
{
|
||||
CommandContainer cont;
|
||||
RoomCommand *c = cont.add_room_command();
|
||||
cont.set_room_id(roomId);
|
||||
c->GetReflection()->MutableMessage(c, cmd.GetDescriptor()->FindExtensionByName("ext"))->CopyFrom(cmd);
|
||||
return new PendingCommand(cont);
|
||||
}
|
||||
|
||||
void TabRoom::sendRoomCommand(PendingCommand *pend)
|
||||
{
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "tab.h"
|
||||
#include <QGroupBox>
|
||||
#include <QMap>
|
||||
#include <google/protobuf/message.h>
|
||||
|
||||
class AbstractClient;
|
||||
class UserList;
|
||||
|
|
@ -21,6 +22,7 @@ class Event_LeaveRoom;
|
|||
class Event_RoomSay;
|
||||
class ProtocolResponse;
|
||||
class GameSelector;
|
||||
class PendingCommand;
|
||||
|
||||
class TabRoom : public Tab {
|
||||
Q_OBJECT
|
||||
|
|
@ -62,6 +64,9 @@ public:
|
|||
const QMap<int, QString> &getGameTypes() const { return gameTypes; }
|
||||
QString getChannelName() const { return roomName; }
|
||||
QString getTabText() const { return roomName; }
|
||||
|
||||
PendingCommand *prepareRoomCommand(const ::google::protobuf::Message &cmd);
|
||||
void sendRoomCommand(PendingCommand *pend);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
#include "userinfobox.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent)
|
||||
: QGroupBox(parent), client(_client)
|
||||
{
|
||||
|
|
@ -42,7 +45,7 @@ RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent)
|
|||
setLayout(vbox);
|
||||
|
||||
connect(client, SIGNAL(listRoomsEventReceived(Event_ListRooms *)), this, SLOT(processListRoomsEvent(Event_ListRooms *)));
|
||||
client->sendCommand(new Command_ListRooms);
|
||||
client->sendCommand(client->prepareSessionCommand(Command_ListRooms()));
|
||||
}
|
||||
|
||||
void RoomSelector::retranslateUi()
|
||||
|
|
@ -91,10 +94,14 @@ void RoomSelector::processListRoomsEvent(Event_ListRooms *event)
|
|||
|
||||
void RoomSelector::joinRoom(int id, bool setCurrent)
|
||||
{
|
||||
Command_JoinRoom *command = new Command_JoinRoom(id);
|
||||
command->setExtraData(setCurrent);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(joinFinished(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
Command_JoinRoom cmd;
|
||||
cmd.set_room_id(id);
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
pend->setExtraData(setCurrent);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(joinFinished(ProtocolResponse *)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void RoomSelector::joinClicked()
|
||||
|
|
@ -114,7 +121,7 @@ void RoomSelector::joinFinished(ProtocolResponse *r)
|
|||
if (!resp)
|
||||
return;
|
||||
|
||||
emit roomJoined(resp->getRoomInfo(), static_cast<Command *>(sender())->getExtraData().toBool());
|
||||
emit roomJoined(resp->getRoomInfo(), static_cast<PendingCommand *>(sender())->getExtraData().toBool());
|
||||
}
|
||||
|
||||
TabServer::TabServer(TabSupervisor *_tabSupervisor, AbstractClient *_client, QWidget *parent)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
||||
CloseButton::CloseButton(QWidget *parent)
|
||||
: QAbstractButton(parent)
|
||||
{
|
||||
|
|
@ -247,8 +249,9 @@ void TabSupervisor::localGameJoined(Event_GameJoined *event)
|
|||
setCurrentWidget(tab);
|
||||
|
||||
for (int i = 1; i < localClients.size(); ++i) {
|
||||
Command_JoinGame *cmd = new Command_JoinGame(0, event->getGameId());
|
||||
localClients[i]->sendCommand(cmd);
|
||||
// Command_JoinGame *cmd = new Command_JoinGame(0, event->getGameId());
|
||||
// localClients[i]->sendCommand(cmd);
|
||||
// XXX
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
#include "tab_userlists.h"
|
||||
#include "userlist.h"
|
||||
#include "userinfobox.h"
|
||||
#include "protocol_items.h"
|
||||
#include "abstractclient.h"
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *userInfo, QWidget *parent)
|
||||
: Tab(_tabSupervisor, parent), client(_client)
|
||||
|
|
@ -27,9 +30,9 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_clien
|
|||
connect(client, SIGNAL(addToListEventReceived(Event_AddToList *)), this, SLOT(processAddToListEvent(Event_AddToList *)));
|
||||
connect(client, SIGNAL(removeFromListEventReceived(Event_RemoveFromList *)), this, SLOT(processRemoveFromListEvent(Event_RemoveFromList *)));
|
||||
|
||||
Command_ListUsers *cmd = new Command_ListUsers;
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(processListUsersResponse(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
PendingCommand *pend = client->prepareSessionCommand(Command_ListUsers());
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(processListUsersResponse(ProtocolResponse *)));
|
||||
client->sendCommand(pend);
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(userInfoBox);
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@
|
|||
#include <math.h>
|
||||
#include "tablezone.h"
|
||||
#include "player.h"
|
||||
#include "protocol_items.h"
|
||||
#include "settingscache.h"
|
||||
#include "arrowitem.h"
|
||||
#include "carddragitem.h"
|
||||
#include "carddatabase.h"
|
||||
|
||||
#include "pb/command_move_card.pb.h"
|
||||
#include "pb/command_set_card_attr.pb.h"
|
||||
|
||||
TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
||||
: SelectZone(_p, "table", true, false, true, parent), active(false)
|
||||
{
|
||||
|
|
@ -93,11 +95,21 @@ void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
|
|||
|
||||
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint)
|
||||
{
|
||||
QList<CardToMove *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardToMove(dragItems[i]->getId(), dragItems[i]->getFaceDown(), startZone->getName() == name ? QString() : dragItems[i]->getItem()->getInfo()->getPowTough()));
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_target_player_id(player->getId());
|
||||
cmd.set_target_zone(getName().toStdString());
|
||||
cmd.set_x(gridPoint.x());
|
||||
cmd.set_y(gridPoint.y());
|
||||
|
||||
startZone->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), gridPoint.x(), gridPoint.y()));
|
||||
for (int i = 0; i < dragItems.size(); ++i) {
|
||||
CardToMove *ctm = cmd.mutable_cards_to_move()->add_card();
|
||||
ctm->set_card_id(dragItems[i]->getId());
|
||||
ctm->set_face_down(dragItems[i]->getFaceDown());
|
||||
ctm->set_pt(startZone->getName() == name ? std::string() : dragItems[i]->getItem()->getInfo()->getPowTough().toStdString());
|
||||
}
|
||||
|
||||
startZone->getPlayer()->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void TableZone::reorganizeCards()
|
||||
|
|
@ -181,13 +193,19 @@ void TableZone::toggleTapped()
|
|||
tapAll = true;
|
||||
break;
|
||||
}
|
||||
QList<Command *> cmdList;
|
||||
QList< const ::google::protobuf::Message * > cmdList;
|
||||
for (int i = 0; i < selectedItems.size(); i++) {
|
||||
CardItem *temp = qgraphicsitem_cast<CardItem *>(selectedItems[i]);
|
||||
if (temp->getTapped() != tapAll)
|
||||
cmdList.append(new Command_SetCardAttr(-1, name, temp->getId(), "tapped", tapAll ? "1" : "0"));
|
||||
if (temp->getTapped() != tapAll) {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(name.toStdString());
|
||||
cmd->set_card_id(temp->getId());
|
||||
cmd->set_attr_name("tapped");
|
||||
cmd->set_attr_value(tapAll ? "1" : "0");
|
||||
cmdList.append(cmd);
|
||||
}
|
||||
}
|
||||
player->sendCommandContainer(new CommandContainer(cmdList));
|
||||
player->sendGameCommand(player->prepareGameCommand(cmdList));
|
||||
}
|
||||
|
||||
CardItem *TableZone::takeCard(int position, int cardId, bool canResize)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
UserInfoBox::UserInfoBox(AbstractClient *_client, bool _fullInfo, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags), client(_client), fullInfo(_fullInfo)
|
||||
{
|
||||
|
|
@ -80,9 +83,13 @@ void UserInfoBox::updateInfo(ServerInfo_User *user)
|
|||
|
||||
void UserInfoBox::updateInfo(const QString &userName)
|
||||
{
|
||||
Command_GetUserInfo *command = new Command_GetUserInfo(userName);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(processResponse(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
Command_GetUserInfo cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(processResponse(ProtocolResponse *)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void UserInfoBox::processResponse(ProtocolResponse *r)
|
||||
|
|
@ -94,4 +101,4 @@ void UserInfoBox::processResponse(ProtocolResponse *r)
|
|||
updateInfo(response->getUserInfo());
|
||||
setFixedSize(sizeHint());
|
||||
show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@
|
|||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
#include "pb/moderator_commands.pb.h"
|
||||
|
||||
BanDialog::BanDialog(ServerInfo_User *info, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
|
|
@ -292,7 +296,7 @@ void UserList::userClicked(QTreeWidgetItem *item, int /*column*/)
|
|||
|
||||
void UserList::gamesOfUserReceived(ProtocolResponse *resp)
|
||||
{
|
||||
Command_GetGamesOfUser *command = static_cast<Command_GetGamesOfUser *>(sender());
|
||||
//Command_GetGamesOfUser *command = static_cast<Command_GetGamesOfUser *>(sender());
|
||||
Response_GetGamesOfUser *response = qobject_cast<Response_GetGamesOfUser *>(resp);
|
||||
if (!response)
|
||||
return;
|
||||
|
|
@ -314,7 +318,7 @@ void UserList::gamesOfUserReceived(ProtocolResponse *resp)
|
|||
for (int i = 0; i < gameList.size(); ++i)
|
||||
selector->processGameInfo(gameList[i]);
|
||||
|
||||
selector->setWindowTitle(tr("%1's games").arg(command->getUserName()));
|
||||
// selector->setWindowTitle(tr("%1's games").arg(command->getUserName()));
|
||||
selector->setAttribute(Qt::WA_DeleteOnClose);
|
||||
selector->show();
|
||||
}
|
||||
|
|
@ -334,7 +338,14 @@ void UserList::banUser_processUserInfoResponse(ProtocolResponse *r)
|
|||
void UserList::banUser_dialogFinished()
|
||||
{
|
||||
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
||||
client->sendCommand(new Command_BanFromServer(dlg->getBanName(), dlg->getBanIP(), dlg->getMinutes(), dlg->getReason()));
|
||||
|
||||
Command_BanFromServer cmd;
|
||||
cmd.set_user_name(dlg->getBanName().toStdString());
|
||||
cmd.set_address(dlg->getBanIP().toStdString());
|
||||
cmd.set_minutes(dlg->getMinutes());
|
||||
cmd.set_reason(dlg->getReason().toStdString());
|
||||
|
||||
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||
}
|
||||
|
||||
void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
||||
|
|
@ -390,22 +401,46 @@ void UserList::showContextMenu(const QPoint &pos, const QModelIndex &index)
|
|||
infoWidget->updateInfo(userName);
|
||||
} else if (actionClicked == aChat)
|
||||
emit openMessageDialog(userName, true);
|
||||
else if (actionClicked == aAddToBuddyList)
|
||||
client->sendCommand(new Command_AddToList("buddy", userName));
|
||||
else if (actionClicked == aRemoveFromBuddyList)
|
||||
client->sendCommand(new Command_RemoveFromList("buddy", userName));
|
||||
else if (actionClicked == aShowGames) {
|
||||
Command *cmd = new Command_GetGamesOfUser(userName);
|
||||
connect(cmd, SIGNAL(finished(ProtocolResponse *)), this, SLOT(gamesOfUserReceived(ProtocolResponse *)));
|
||||
client->sendCommand(cmd);
|
||||
} else if (actionClicked == aAddToIgnoreList)
|
||||
client->sendCommand(new Command_AddToList("ignore", userName));
|
||||
else if (actionClicked == aRemoveFromIgnoreList)
|
||||
client->sendCommand(new Command_RemoveFromList("ignore", userName));
|
||||
else if (actionClicked == aBan) {
|
||||
Command_GetUserInfo *command = new Command_GetUserInfo(userName);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(banUser_processUserInfoResponse(ProtocolResponse *)));
|
||||
client->sendCommand(command);
|
||||
else if (actionClicked == aAddToBuddyList) {
|
||||
Command_AddToList cmd;
|
||||
cmd.set_list("buddy");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aRemoveFromBuddyList) {
|
||||
Command_RemoveFromList cmd;
|
||||
cmd.set_list("buddy");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aShowGames) {
|
||||
Command_GetGamesOfUser cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(gamesOfUserReceived(ProtocolResponse *)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
} else if (actionClicked == aAddToIgnoreList) {
|
||||
Command_AddToList cmd;
|
||||
cmd.set_list("ignore");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aRemoveFromIgnoreList) {
|
||||
Command_RemoveFromList cmd;
|
||||
cmd.set_list("ignore");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aBan) {
|
||||
Command_GetUserInfo cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(banUser_processUserInfoResponse(ProtocolResponse *)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
delete menu;
|
||||
|
|
|
|||
|
|
@ -134,8 +134,8 @@ void MainWindow::actSinglePlayer()
|
|||
}
|
||||
tabSupervisor->startLocal(localClients);
|
||||
|
||||
Command_CreateGame *createCommand = new Command_CreateGame(0, QString(), QString(), numberPlayers, QList<GameTypeId *>(), false, false, false, false);
|
||||
mainClient->sendCommand(createCommand);
|
||||
// Command_CreateGame *createCommand = new Command_CreateGame(0, QString(), QString(), numberPlayers, QList<GameTypeId *>(), false, false, false, false);
|
||||
// mainClient->sendCommand(createCommand);
|
||||
}
|
||||
|
||||
void MainWindow::localGameEnded()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@
|
|||
#include "settingscache.h"
|
||||
#include "gamescene.h"
|
||||
|
||||
#include "pb/command_stop_dump_zone.pb.h"
|
||||
#include "pb/command_shuffle.pb.h"
|
||||
|
||||
TitleLabel::TitleLabel()
|
||||
: QGraphicsWidget(), text(" ")
|
||||
{
|
||||
|
|
@ -156,11 +159,15 @@ void ZoneViewWidget::resizeToZoneContents()
|
|||
void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
disconnect(zone, SIGNAL(beingDeleted()), this, 0);
|
||||
if (zone->getNumberCards() != -2)
|
||||
player->sendGameCommand(new Command_StopDumpZone(-1, player->getId(), zone->getName()));
|
||||
if (zone->getNumberCards() != -2) {
|
||||
Command_StopDumpZone cmd;
|
||||
cmd.set_player_id(player->getId());
|
||||
cmd.set_zone_name(zone->getName().toStdString());
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
if (shuffleCheckBox)
|
||||
if (shuffleCheckBox->isChecked())
|
||||
player->sendGameCommand(new Command_Shuffle);
|
||||
player->sendGameCommand(Command_Shuffle());
|
||||
emit closePressed(this);
|
||||
deleteLater();
|
||||
event->accept();
|
||||
|
|
|
|||
|
|
@ -2,8 +2,13 @@
|
|||
#include <QDebug>
|
||||
#include "zoneviewzone.h"
|
||||
#include "player.h"
|
||||
#include "protocol_items.h"
|
||||
#include "carddragitem.h"
|
||||
#include "protocol_items.h"
|
||||
|
||||
#include "protocol_datastructures.h"
|
||||
#include "pb/command_dump_zone.pb.h"
|
||||
#include "pb/command_move_card.pb.h"
|
||||
#include "pending_command.h"
|
||||
|
||||
ZoneViewZone::ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards, bool _revealZone, QGraphicsItem *parent)
|
||||
: SelectZone(_p, _origZone->getName(), false, false, true, parent, true), bRect(QRectF()), minRows(0), numberCards(_numberCards), origZone(_origZone), revealZone(_revealZone), sortByName(false), sortByType(false)
|
||||
|
|
@ -36,9 +41,14 @@ void ZoneViewZone::initializeCards(const QList<ServerInfo_Card *> &cardList)
|
|||
addCard(new CardItem(player, cardList[i]->getName(), cardList[i]->getId(), revealZone, this), false, i);
|
||||
reorganizeCards();
|
||||
} else if (!origZone->contentsKnown()) {
|
||||
Command_DumpZone *command = new Command_DumpZone(-1, player->getId(), name, numberCards);
|
||||
connect(command, SIGNAL(finished(ProtocolResponse *)), this, SLOT(zoneDumpReceived(ProtocolResponse *)));
|
||||
player->sendGameCommand(command);
|
||||
Command_DumpZone cmd;
|
||||
cmd.set_player_id(player->getId());
|
||||
cmd.set_zone_name(name.toStdString());
|
||||
cmd.set_number_cards(numberCards);
|
||||
|
||||
PendingCommand *pend = player->prepareGameCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(ProtocolResponse *)), this, SLOT(zoneDumpReceived(ProtocolResponse *)));
|
||||
player->sendGameCommand(pend);
|
||||
} else {
|
||||
const CardList &c = origZone->getCards();
|
||||
int number = numberCards == -1 ? c.size() : (numberCards < c.size() ? numberCards : c.size());
|
||||
|
|
@ -126,11 +136,17 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
|||
|
||||
void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||
{
|
||||
QList<CardToMove *> idList;
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||
Command_MoveCard cmd;
|
||||
cmd.set_start_zone(startZone->getName().toStdString());
|
||||
cmd.set_target_player_id(player->getId());
|
||||
cmd.set_target_zone(getName().toStdString());
|
||||
cmd.set_x(0);
|
||||
cmd.set_y(0);
|
||||
|
||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0));
|
||||
for (int i = 0; i < dragItems.size(); ++i)
|
||||
cmd.mutable_cards_to_move()->add_card()->set_card_id(dragItems[i]->getId());
|
||||
|
||||
player->sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void ZoneViewZone::removeCard(int position)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ public:
|
|||
{
|
||||
return QColor(value / 65536, (value % 65536) / 256, value % 256);
|
||||
}
|
||||
color get_color() const // HACK
|
||||
{
|
||||
color c;
|
||||
c.set_r(value / 65536);
|
||||
c.set_g((value % 65536) / 256);
|
||||
c.set_b(value % 256);
|
||||
return c;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#include <QSet>
|
||||
#include "serializable_item.h"
|
||||
|
||||
#include "pb/move_card_to_zone.pb.h"
|
||||
|
||||
class CardDatabase;
|
||||
class QIODevice;
|
||||
class QTextStream;
|
||||
|
|
@ -25,6 +27,7 @@ public:
|
|||
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); }
|
||||
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); }
|
||||
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); }
|
||||
MoveCard_ToZone toPB() { MoveCard_ToZone foo; foo.set_card_name(getCardName().toStdString()); foo.set_start_zone(getStartZone().toStdString()); foo.set_target_zone(getTargetZone().toStdString()); return foo; } // XXX
|
||||
};
|
||||
|
||||
class SideboardPlan : public SerializableItem_Map {
|
||||
|
|
|
|||
|
|
@ -1,237 +0,0 @@
|
|||
import "color.proto";
|
||||
import "move_card_to_zone.proto";
|
||||
|
||||
message Command_KickFromGame {
|
||||
optional sint32 player_id = 1;
|
||||
}
|
||||
|
||||
message Command_LeaveGame {
|
||||
}
|
||||
|
||||
message Command_GameSay {
|
||||
optional string message = 1;
|
||||
}
|
||||
|
||||
message Command_Shuffle {
|
||||
}
|
||||
|
||||
message Command_Mulligan {
|
||||
}
|
||||
|
||||
message Command_RollDie {
|
||||
optional uint32 sides = 1;
|
||||
}
|
||||
|
||||
message Command_DrawCards {
|
||||
optional uint32 number = 1;
|
||||
}
|
||||
|
||||
message Command_UndoDraw {
|
||||
}
|
||||
|
||||
message Command_FlipCard {
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional bool face_down = 3;
|
||||
}
|
||||
|
||||
message Command_AttachCard {
|
||||
optional string start_zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 target_player_id = 3;
|
||||
optional string target_zone = 4;
|
||||
optional sint32 target_card_id = 5;
|
||||
}
|
||||
|
||||
message Command_CreateToken {
|
||||
optional string zone = 1;
|
||||
optional string card_name = 2;
|
||||
optional string color = 3;
|
||||
optional string pt = 4;
|
||||
optional string annotation = 5;
|
||||
optional bool destroy_on_zone_change = 6;
|
||||
optional sint32 x = 7;
|
||||
optional sint32 y = 8;
|
||||
}
|
||||
|
||||
message Command_CreateArrow {
|
||||
optional sint32 start_player_id = 1;
|
||||
optional string start_zone = 2;
|
||||
optional sint32 start_card_id = 3;
|
||||
optional sint32 target_player_id = 4;
|
||||
optional string target_zone = 5;
|
||||
optional sint32 target_card_id = 6;
|
||||
optional color arrow_color = 7;
|
||||
}
|
||||
|
||||
message Command_DeleteArrow {
|
||||
optional sint32 arrow_id = 1;
|
||||
}
|
||||
|
||||
message Command_SetCardAttr {
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional string attr_name = 3;
|
||||
optional string attr_value = 4;
|
||||
}
|
||||
|
||||
message Command_SetCardCounter {
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 counter_id = 3;
|
||||
optional sint32 counter_value = 4;
|
||||
}
|
||||
|
||||
message Command_IncCardCounter {
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 counter_id = 3;
|
||||
optional sint32 counter_delta = 4;
|
||||
}
|
||||
|
||||
message Command_ReadyStart {
|
||||
optional bool ready = 1;
|
||||
}
|
||||
|
||||
message Command_Concede {
|
||||
}
|
||||
|
||||
message Command_IncCounter {
|
||||
optional sint32 counter_id = 1;
|
||||
optional sint32 delta = 2;
|
||||
}
|
||||
|
||||
message Command_CreateCounter {
|
||||
optional string counter_name = 1;
|
||||
optional color counter_color = 2;
|
||||
optional uint32 radius = 3;
|
||||
optional sint32 value = 4;
|
||||
}
|
||||
|
||||
message Command_SetCounter {
|
||||
optional sint32 counter_id = 1;
|
||||
optional sint32 value = 2;
|
||||
}
|
||||
|
||||
message Command_DelCounter {
|
||||
optional sint32 counter_id = 1;
|
||||
}
|
||||
|
||||
message Command_NextTurn {
|
||||
}
|
||||
|
||||
message Command_SetActivePhase {
|
||||
optional uint32 phase = 1;
|
||||
}
|
||||
|
||||
message Command_DumpZone {
|
||||
optional sint32 player_id = 1;
|
||||
optional string zone_name = 2;
|
||||
optional sint32 number_cards = 3;
|
||||
}
|
||||
|
||||
message Command_StopDumpZone {
|
||||
optional sint32 player_id = 1;
|
||||
optional string zone_name = 2;
|
||||
}
|
||||
|
||||
message Command_RevealCards {
|
||||
optional string zone_name = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 player_id = 3;
|
||||
}
|
||||
|
||||
message CardToMove {
|
||||
optional sint32 card_id = 1;
|
||||
optional bool face_down = 2;
|
||||
optional string pt = 3;
|
||||
optional bool tapped = 4;
|
||||
}
|
||||
|
||||
message Command_MoveCard {
|
||||
optional string start_zone = 1;
|
||||
repeated CardToMove cards_to_move = 2;
|
||||
optional sint32 target_player_id = 3;
|
||||
optional string target_zone = 4;
|
||||
optional sint32 x = 5;
|
||||
optional sint32 y = 6;
|
||||
}
|
||||
|
||||
message Command_SetSideboardPlan {
|
||||
repeated MoveCard_ToZone move_list = 1;
|
||||
}
|
||||
|
||||
message Command_DeckSelect {
|
||||
optional string deck = 1;
|
||||
optional sint32 deck_id = 2;
|
||||
}
|
||||
|
||||
message GameCommand {
|
||||
enum GameCommandType {
|
||||
KICK_FROM_GAME = 1000;
|
||||
LEAVE_GAME = 1001;
|
||||
GAME_SAY = 1002;
|
||||
SHUFFLE = 1003;
|
||||
MULLIGAN = 1004;
|
||||
ROLL_DIE = 1005;
|
||||
DRAW_CARDS = 1006;
|
||||
UNDO_DRAW = 1007;
|
||||
FLIP_CARD = 1008;
|
||||
ATTACH_CARD = 1009;
|
||||
CREATE_TOKEN = 1010;
|
||||
CREATE_ARROW = 1011;
|
||||
DELETE_ARROW = 1012;
|
||||
SET_CARD_ATTR = 1013;
|
||||
SET_CARD_COUNTER = 1014;
|
||||
INC_CARD_COUNTER = 1015;
|
||||
READY_START = 1016;
|
||||
CONCEDE = 1017;
|
||||
INC_COUNTER = 1018;
|
||||
CREATE_COUNTER = 1019;
|
||||
SET_COUNTER = 1020;
|
||||
DEL_COUNTER = 1021;
|
||||
NEXT_TURN = 1022;
|
||||
SET_ACTIVE_PHASE = 1023;
|
||||
DUMP_ZONE = 1024;
|
||||
STOP_DUMP_ZONE = 1025;
|
||||
REVEAL_CARDS = 1026;
|
||||
MOVE_CARD = 1027;
|
||||
SET_SIDEBOARD_PLAN = 1028;
|
||||
DECK_SELECT = 1029;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
extend GameCommand {
|
||||
optional Command_KickFromGame command_kick_from_game = 1000;
|
||||
optional Command_LeaveGame command_leave_game = 1001;
|
||||
optional Command_GameSay command_game_say = 1002;
|
||||
optional Command_Shuffle command_shuffle = 1003;
|
||||
optional Command_Mulligan command_mulligan = 1004;
|
||||
optional Command_RollDie command_roll_die = 1005;
|
||||
optional Command_DrawCards command_draw_cards = 1006;
|
||||
optional Command_UndoDraw command_undo_draw = 1007;
|
||||
optional Command_FlipCard command_flip_card = 1008;
|
||||
optional Command_AttachCard command_attach_card = 1009;
|
||||
optional Command_CreateToken command_create_token = 1010;
|
||||
optional Command_CreateArrow command_create_arrow = 1011;
|
||||
optional Command_DeleteArrow command_delete_arrow = 1012;
|
||||
optional Command_SetCardAttr command_set_card_attr = 1013;
|
||||
optional Command_SetCardCounter command_set_card_counter = 1014;
|
||||
optional Command_IncCardCounter command_inc_card_counter = 1015;
|
||||
optional Command_ReadyStart command_ready_start = 1016;
|
||||
optional Command_Concede command_concede = 1017;
|
||||
optional Command_IncCounter command_inc_counter = 1018;
|
||||
optional Command_CreateCounter command_create_counter = 1019;
|
||||
optional Command_SetCounter command_set_counter = 1020;
|
||||
optional Command_DelCounter command_del_counter = 1021;
|
||||
optional Command_NextTurn command_next_turn = 1022;
|
||||
optional Command_SetActivePhase command_set_active_phase = 1023;
|
||||
optional Command_DumpZone command_dump_zone = 1024;
|
||||
optional Command_StopDumpZone command_stop_dump_zone = 1025;
|
||||
optional Command_RevealCards command_reveal_cards = 1026;
|
||||
optional Command_MoveCard command_move_card = 1027;
|
||||
optional Command_SetSideboardPlan command_set_sideboard_plan = 1028;
|
||||
optional Command_DeckSelect command_deck_select = 1029;
|
||||
}
|
||||
|
||||
5
common/pb/proto/.directory
Normal file
5
common/pb/proto/.directory
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[Dolphin]
|
||||
AdditionalInfoV2=Details_Size,Details_Date,CustomizedDetails
|
||||
Timestamp=2011,12,18,12,16,39
|
||||
Version=2
|
||||
ViewMode=1
|
||||
|
|
@ -1,11 +1,3 @@
|
|||
message Command_UpdateServerMessage {
|
||||
}
|
||||
|
||||
message Command_ShutdownServer {
|
||||
optional string reason = 1;
|
||||
optional uint32 minutes = 2;
|
||||
}
|
||||
|
||||
message AdminCommand {
|
||||
enum AdminCommandType {
|
||||
UPDATE_SERVER_MESSAGE = 1000;
|
||||
|
|
@ -14,8 +6,16 @@ message AdminCommand {
|
|||
extensions 100 to max;
|
||||
}
|
||||
|
||||
extend AdminCommand {
|
||||
optional Command_UpdateServerMessage command_update_server_message = 1000;
|
||||
optional Command_ShutdownServer command_shutdown_server = 1001;
|
||||
message Command_UpdateServerMessage {
|
||||
extend AdminCommand {
|
||||
optional Command_UpdateServerMessage ext = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_ShutdownServer {
|
||||
extend AdminCommand {
|
||||
optional Command_ShutdownServer ext = 1001;
|
||||
}
|
||||
optional string reason = 1;
|
||||
optional uint32 minutes = 2;
|
||||
}
|
||||
|
||||
13
common/pb/proto/command_attach_card.proto
Normal file
13
common/pb/proto/command_attach_card.proto
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import "game_commands.proto";
|
||||
message Command_AttachCard {
|
||||
extend GameCommand {
|
||||
optional Command_AttachCard ext = 1009;
|
||||
}
|
||||
optional string start_zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 target_player_id = 3;
|
||||
optional string target_zone = 4;
|
||||
optional sint32 target_card_id = 5;
|
||||
}
|
||||
|
||||
|
||||
6
common/pb/proto/command_concede.proto
Normal file
6
common/pb/proto/command_concede.proto
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import "game_commands.proto";
|
||||
message Command_Concede {
|
||||
extend GameCommand {
|
||||
optional Command_Concede ext = 1017;
|
||||
}
|
||||
}
|
||||
17
common/pb/proto/command_create_arrow.proto
Normal file
17
common/pb/proto/command_create_arrow.proto
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import "game_commands.proto";
|
||||
import "color.proto";
|
||||
|
||||
message Command_CreateArrow {
|
||||
extend GameCommand {
|
||||
optional Command_CreateArrow ext = 1011;
|
||||
}
|
||||
optional sint32 start_player_id = 1;
|
||||
optional string start_zone = 2;
|
||||
optional sint32 start_card_id = 3;
|
||||
optional sint32 target_player_id = 4;
|
||||
optional string target_zone = 5;
|
||||
optional sint32 target_card_id = 6;
|
||||
optional color arrow_color = 7;
|
||||
}
|
||||
|
||||
|
||||
12
common/pb/proto/command_create_counter.proto
Normal file
12
common/pb/proto/command_create_counter.proto
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import "game_commands.proto";
|
||||
import "color.proto";
|
||||
|
||||
message Command_CreateCounter {
|
||||
extend GameCommand {
|
||||
optional Command_CreateCounter ext = 1019;
|
||||
}
|
||||
optional string counter_name = 1;
|
||||
optional color counter_color = 2;
|
||||
optional uint32 radius = 3;
|
||||
optional sint32 value = 4;
|
||||
}
|
||||
16
common/pb/proto/command_create_token.proto
Normal file
16
common/pb/proto/command_create_token.proto
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import "game_commands.proto";
|
||||
message Command_CreateToken {
|
||||
extend GameCommand {
|
||||
optional Command_CreateToken ext = 1010;
|
||||
}
|
||||
optional string zone = 1;
|
||||
optional string card_name = 2;
|
||||
optional string color = 3;
|
||||
optional string pt = 4;
|
||||
optional string annotation = 5;
|
||||
optional bool destroy_on_zone_change = 6;
|
||||
optional sint32 x = 7;
|
||||
optional sint32 y = 8;
|
||||
}
|
||||
|
||||
|
||||
8
common/pb/proto/command_deck_del.proto
Normal file
8
common/pb/proto/command_deck_del.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_DeckDel {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckDel ext = 1011;
|
||||
}
|
||||
optional uint32 deck_id = 1;
|
||||
}
|
||||
9
common/pb/proto/command_deck_del_dir.proto
Normal file
9
common/pb/proto/command_deck_del_dir.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_DeckDelDir {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckDelDir ext = 1010;
|
||||
}
|
||||
optional string path = 1;
|
||||
}
|
||||
|
||||
9
common/pb/proto/command_deck_download.proto
Normal file
9
common/pb/proto/command_deck_download.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_DeckDownload {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckDownload ext = 1012;
|
||||
}
|
||||
optional uint32 deck_id = 1;
|
||||
}
|
||||
|
||||
10
common/pb/proto/command_deck_new_dir.proto
Normal file
10
common/pb/proto/command_deck_new_dir.proto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_DeckNewDir {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckNewDir ext = 1009;
|
||||
}
|
||||
optional string path = 1;
|
||||
optional string dir_name = 2;
|
||||
}
|
||||
|
||||
8
common/pb/proto/command_deck_select.proto
Normal file
8
common/pb/proto/command_deck_select.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_DeckSelect {
|
||||
extend GameCommand {
|
||||
optional Command_DeckSelect ext = 1029;
|
||||
}
|
||||
optional string deck = 1;
|
||||
optional sint32 deck_id = 2;
|
||||
}
|
||||
10
common/pb/proto/command_deck_upload.proto
Normal file
10
common/pb/proto/command_deck_upload.proto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_DeckUpload {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckUpload ext = 1013;
|
||||
}
|
||||
optional string path = 1;
|
||||
optional string deck_list = 2;
|
||||
}
|
||||
|
||||
7
common/pb/proto/command_del_counter.proto
Normal file
7
common/pb/proto/command_del_counter.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_DelCounter {
|
||||
extend GameCommand {
|
||||
optional Command_DelCounter ext = 1021;
|
||||
}
|
||||
optional sint32 counter_id = 1;
|
||||
}
|
||||
7
common/pb/proto/command_delete_arrow.proto
Normal file
7
common/pb/proto/command_delete_arrow.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_DeleteArrow {
|
||||
extend GameCommand {
|
||||
optional Command_DeleteArrow ext = 1012;
|
||||
}
|
||||
optional sint32 arrow_id = 1;
|
||||
}
|
||||
8
common/pb/proto/command_draw_cards.proto
Normal file
8
common/pb/proto/command_draw_cards.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_DrawCards {
|
||||
extend GameCommand {
|
||||
optional Command_DrawCards ext = 1006;
|
||||
}
|
||||
optional uint32 number = 1;
|
||||
}
|
||||
|
||||
9
common/pb/proto/command_dump_zone.proto
Normal file
9
common/pb/proto/command_dump_zone.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "game_commands.proto";
|
||||
message Command_DumpZone {
|
||||
extend GameCommand {
|
||||
optional Command_DumpZone ext = 1024;
|
||||
}
|
||||
optional sint32 player_id = 1;
|
||||
optional string zone_name = 2;
|
||||
optional sint32 number_cards = 3;
|
||||
}
|
||||
11
common/pb/proto/command_flip_card.proto
Normal file
11
common/pb/proto/command_flip_card.proto
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import "game_commands.proto";
|
||||
message Command_FlipCard {
|
||||
extend GameCommand {
|
||||
optional Command_FlipCard ext = 1008;
|
||||
}
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional bool face_down = 3;
|
||||
}
|
||||
|
||||
|
||||
9
common/pb/proto/command_game_say.proto
Normal file
9
common/pb/proto/command_game_say.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "game_commands.proto";
|
||||
message Command_GameSay {
|
||||
extend GameCommand {
|
||||
optional Command_GameSay ext = 1002;
|
||||
}
|
||||
optional string message = 1;
|
||||
}
|
||||
|
||||
|
||||
10
common/pb/proto/command_inc_card_counter.proto
Normal file
10
common/pb/proto/command_inc_card_counter.proto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "game_commands.proto";
|
||||
message Command_IncCardCounter {
|
||||
extend GameCommand {
|
||||
optional Command_IncCardCounter ext = 1015;
|
||||
}
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 counter_id = 3;
|
||||
optional sint32 counter_delta = 4;
|
||||
}
|
||||
8
common/pb/proto/command_inc_counter.proto
Normal file
8
common/pb/proto/command_inc_counter.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_IncCounter {
|
||||
extend GameCommand {
|
||||
optional Command_IncCounter ext = 1018;
|
||||
}
|
||||
optional sint32 counter_id = 1;
|
||||
optional sint32 delta = 2;
|
||||
}
|
||||
8
common/pb/proto/command_kick_from_game.proto
Normal file
8
common/pb/proto/command_kick_from_game.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_KickFromGame {
|
||||
extend GameCommand {
|
||||
optional Command_KickFromGame ext = 1000;
|
||||
}
|
||||
optional sint32 player_id = 1;
|
||||
}
|
||||
|
||||
7
common/pb/proto/command_leave_game.proto
Normal file
7
common/pb/proto/command_leave_game.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_LeaveGame {
|
||||
extend GameCommand {
|
||||
optional Command_LeaveGame ext = 1001;
|
||||
}
|
||||
}
|
||||
|
||||
24
common/pb/proto/command_move_card.proto
Normal file
24
common/pb/proto/command_move_card.proto
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import "game_commands.proto";
|
||||
message CardToMove {
|
||||
optional sint32 card_id = 1;
|
||||
optional bool face_down = 2;
|
||||
optional string pt = 3;
|
||||
optional bool tapped = 4;
|
||||
}
|
||||
|
||||
message ListOfCardsToMove {
|
||||
repeated CardToMove card = 1;
|
||||
}
|
||||
|
||||
message Command_MoveCard {
|
||||
extend GameCommand {
|
||||
optional Command_MoveCard ext = 1027;
|
||||
}
|
||||
optional string start_zone = 1;
|
||||
optional ListOfCardsToMove cards_to_move = 2;
|
||||
optional sint32 target_player_id = 3;
|
||||
optional string target_zone = 4;
|
||||
optional sint32 x = 5;
|
||||
optional sint32 y = 6;
|
||||
}
|
||||
|
||||
8
common/pb/proto/command_mulligan.proto
Normal file
8
common/pb/proto/command_mulligan.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_Mulligan {
|
||||
extend GameCommand {
|
||||
optional Command_Mulligan ext = 1004;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
common/pb/proto/command_next_turn.proto
Normal file
6
common/pb/proto/command_next_turn.proto
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import "game_commands.proto";
|
||||
message Command_NextTurn {
|
||||
extend GameCommand {
|
||||
optional Command_NextTurn ext = 1022;
|
||||
}
|
||||
}
|
||||
7
common/pb/proto/command_ready_start.proto
Normal file
7
common/pb/proto/command_ready_start.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_ReadyStart {
|
||||
extend GameCommand {
|
||||
optional Command_ReadyStart ext = 1016;
|
||||
}
|
||||
optional bool ready = 1;
|
||||
}
|
||||
9
common/pb/proto/command_reveal_cards.proto
Normal file
9
common/pb/proto/command_reveal_cards.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "game_commands.proto";
|
||||
message Command_RevealCards {
|
||||
extend GameCommand {
|
||||
optional Command_RevealCards ext = 1026;
|
||||
}
|
||||
optional string zone_name = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 player_id = 3;
|
||||
}
|
||||
8
common/pb/proto/command_roll_die.proto
Normal file
8
common/pb/proto/command_roll_die.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_RollDie {
|
||||
extend GameCommand {
|
||||
optional Command_RollDie ext = 1005;
|
||||
}
|
||||
optional uint32 sides = 1;
|
||||
}
|
||||
|
||||
7
common/pb/proto/command_set_active_phase.proto
Normal file
7
common/pb/proto/command_set_active_phase.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_SetActivePhase {
|
||||
extend GameCommand {
|
||||
optional Command_SetActivePhase ext = 1023;
|
||||
}
|
||||
optional uint32 phase = 1;
|
||||
}
|
||||
10
common/pb/proto/command_set_card_attr.proto
Normal file
10
common/pb/proto/command_set_card_attr.proto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "game_commands.proto";
|
||||
message Command_SetCardAttr {
|
||||
extend GameCommand {
|
||||
optional Command_SetCardAttr ext = 1013;
|
||||
}
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional string attr_name = 3;
|
||||
optional string attr_value = 4;
|
||||
}
|
||||
10
common/pb/proto/command_set_card_counter.proto
Normal file
10
common/pb/proto/command_set_card_counter.proto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "game_commands.proto";
|
||||
message Command_SetCardCounter {
|
||||
extend GameCommand {
|
||||
optional Command_SetCardCounter ext = 1014;
|
||||
}
|
||||
optional string zone = 1;
|
||||
optional sint32 card_id = 2;
|
||||
optional sint32 counter_id = 3;
|
||||
optional sint32 counter_value = 4;
|
||||
}
|
||||
8
common/pb/proto/command_set_counter.proto
Normal file
8
common/pb/proto/command_set_counter.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_SetCounter {
|
||||
extend GameCommand {
|
||||
optional Command_SetCounter ext = 1020;
|
||||
}
|
||||
optional sint32 counter_id = 1;
|
||||
optional sint32 value = 2;
|
||||
}
|
||||
10
common/pb/proto/command_set_sideboard_plan.proto
Normal file
10
common/pb/proto/command_set_sideboard_plan.proto
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import "game_commands.proto";
|
||||
import "move_card_to_zone.proto";
|
||||
|
||||
message Command_SetSideboardPlan {
|
||||
extend GameCommand {
|
||||
optional Command_SetSideboardPlan ext = 1028;
|
||||
}
|
||||
repeated MoveCard_ToZone move_list = 1;
|
||||
}
|
||||
|
||||
7
common/pb/proto/command_shuffle.proto
Normal file
7
common/pb/proto/command_shuffle.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "game_commands.proto";
|
||||
message Command_Shuffle {
|
||||
extend GameCommand {
|
||||
optional Command_Shuffle ext = 1003;
|
||||
}
|
||||
}
|
||||
|
||||
8
common/pb/proto/command_stop_dump_zone.proto
Normal file
8
common/pb/proto/command_stop_dump_zone.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "game_commands.proto";
|
||||
message Command_StopDumpZone {
|
||||
extend GameCommand {
|
||||
optional Command_StopDumpZone ext = 1025;
|
||||
}
|
||||
optional sint32 player_id = 1;
|
||||
optional string zone_name = 2;
|
||||
}
|
||||
6
common/pb/proto/command_undo_draw.proto
Normal file
6
common/pb/proto/command_undo_draw.proto
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import "game_commands.proto";
|
||||
message Command_UndoDraw {
|
||||
extend GameCommand {
|
||||
optional Command_UndoDraw ext = 1007;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,13 +5,6 @@ import "moderator_commands.proto";
|
|||
import "admin_commands.proto";
|
||||
|
||||
message CommandContainer {
|
||||
enum CommandType {
|
||||
SESSION = 0;
|
||||
GAME = 1;
|
||||
ROOM = 2;
|
||||
MODERATOR = 3;
|
||||
ADMIN = 4;
|
||||
}
|
||||
required uint64 cmd_id = 1;
|
||||
|
||||
optional uint32 game_id = 10;
|
||||
35
common/pb/proto/game_commands.proto
Normal file
35
common/pb/proto/game_commands.proto
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
message GameCommand {
|
||||
enum GameCommandType {
|
||||
KICK_FROM_GAME = 1000;
|
||||
LEAVE_GAME = 1001;
|
||||
GAME_SAY = 1002;
|
||||
SHUFFLE = 1003;
|
||||
MULLIGAN = 1004;
|
||||
ROLL_DIE = 1005;
|
||||
DRAW_CARDS = 1006;
|
||||
UNDO_DRAW = 1007;
|
||||
FLIP_CARD = 1008;
|
||||
ATTACH_CARD = 1009;
|
||||
CREATE_TOKEN = 1010;
|
||||
CREATE_ARROW = 1011;
|
||||
DELETE_ARROW = 1012;
|
||||
SET_CARD_ATTR = 1013;
|
||||
SET_CARD_COUNTER = 1014;
|
||||
INC_CARD_COUNTER = 1015;
|
||||
READY_START = 1016;
|
||||
CONCEDE = 1017;
|
||||
INC_COUNTER = 1018;
|
||||
CREATE_COUNTER = 1019;
|
||||
SET_COUNTER = 1020;
|
||||
DEL_COUNTER = 1021;
|
||||
NEXT_TURN = 1022;
|
||||
SET_ACTIVE_PHASE = 1023;
|
||||
DUMP_ZONE = 1024;
|
||||
STOP_DUMP_ZONE = 1025;
|
||||
REVEAL_CARDS = 1026;
|
||||
MOVE_CARD = 1027;
|
||||
SET_SIDEBOARD_PLAN = 1028;
|
||||
DECK_SELECT = 1029;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
|
@ -1,12 +1,3 @@
|
|||
|
||||
|
||||
message Command_BanFromServer {
|
||||
optional string user_name = 1;
|
||||
optional string address = 2;
|
||||
optional uint32 minutes = 3;
|
||||
optional string reason = 4;
|
||||
}
|
||||
|
||||
message ModeratorCommand {
|
||||
enum ModeratorCommandType {
|
||||
BAN_FROM_SERVER = 1000;
|
||||
|
|
@ -14,7 +5,12 @@ message ModeratorCommand {
|
|||
extensions 100 to max;
|
||||
}
|
||||
|
||||
extend ModeratorCommand {
|
||||
optional Command_BanFromServer command_ban_from_server = 1000;
|
||||
message Command_BanFromServer {
|
||||
extend ModeratorCommand {
|
||||
optional Command_BanFromServer ext = 1000;
|
||||
}
|
||||
optional string user_name = 1;
|
||||
optional string address = 2;
|
||||
optional uint32 minutes = 3;
|
||||
optional string reason = 4;
|
||||
}
|
||||
|
||||
|
|
@ -1,12 +1,30 @@
|
|||
message RoomCommand {
|
||||
enum RoomCommandType {
|
||||
LEAVE_ROOM = 1000;
|
||||
ROOM_SAY = 1001;
|
||||
CREATE_GAME = 1002;
|
||||
JOIN_GAME = 1003;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
message Command_LeaveRoom {
|
||||
extend RoomCommand {
|
||||
optional Command_LeaveRoom ext = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_RoomSay {
|
||||
extend RoomCommand {
|
||||
optional Command_RoomSay ext = 1001;
|
||||
}
|
||||
optional string message = 1;
|
||||
}
|
||||
|
||||
message Command_CreateGame {
|
||||
extend RoomCommand {
|
||||
optional Command_CreateGame ext = 1002;
|
||||
}
|
||||
optional string description = 1;
|
||||
optional string password = 2;
|
||||
optional uint32 max_players = 3;
|
||||
|
|
@ -20,27 +38,11 @@ message Command_CreateGame {
|
|||
}
|
||||
|
||||
message Command_JoinGame {
|
||||
extend RoomCommand {
|
||||
optional Command_JoinGame ext = 1003;
|
||||
}
|
||||
optional uint32 game_id = 1;
|
||||
optional string password = 2;
|
||||
optional bool spectator = 3;
|
||||
optional bool override_restrictions = 4;
|
||||
}
|
||||
|
||||
message RoomCommand {
|
||||
enum RoomCommandType {
|
||||
LEAVE_ROOM = 1000;
|
||||
ROOM_SAY = 1001;
|
||||
CREATE_GAME = 1002;
|
||||
JOIN_GAME = 1003;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
extend RoomCommand {
|
||||
optional Command_LeaveRoom command_leave_room = 1000;
|
||||
optional Command_RoomSay command_room_say = 1001;
|
||||
optional Command_CreateGame command_create_game = 1002;
|
||||
optional Command_JoinGame command_join_game = 1003;
|
||||
}
|
||||
|
||||
|
||||
98
common/pb/proto/session_commands.proto
Normal file
98
common/pb/proto/session_commands.proto
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
message SessionCommand {
|
||||
enum SessionCommandType {
|
||||
PING = 1000;
|
||||
LOGIN = 1001;
|
||||
MESSAGE = 1002;
|
||||
LIST_USERS = 1003;
|
||||
GET_GAMES_OF_USER = 1004;
|
||||
GET_USER_INFO = 1005;
|
||||
ADD_TO_LIST = 1006;
|
||||
REMOVE_FROM_LIST = 1007;
|
||||
DECK_LIST = 1008;
|
||||
DECK_NEW_DIR = 1009;
|
||||
DECK_DEL_DIR = 1010;
|
||||
DECK_DEL = 1011;
|
||||
DECK_DOWNLOAD = 1012;
|
||||
DECK_UPLOAD = 1013;
|
||||
LIST_ROOMS = 1014;
|
||||
JOIN_ROOM = 1015;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
message Command_Ping {
|
||||
extend SessionCommand {
|
||||
optional Command_Ping ext = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_Login {
|
||||
extend SessionCommand {
|
||||
optional Command_Login ext = 1001;
|
||||
}
|
||||
optional string user_name = 1;
|
||||
optional string password = 2;
|
||||
}
|
||||
|
||||
message Command_Message {
|
||||
extend SessionCommand {
|
||||
optional Command_Message ext = 1002;
|
||||
}
|
||||
optional string user_name = 1;
|
||||
optional string message = 2;
|
||||
}
|
||||
|
||||
message Command_ListUsers {
|
||||
extend SessionCommand {
|
||||
optional Command_ListUsers ext = 1003;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_GetGamesOfUser {
|
||||
extend SessionCommand {
|
||||
optional Command_GetGamesOfUser ext = 1004;
|
||||
}
|
||||
optional string user_name = 1;
|
||||
}
|
||||
|
||||
message Command_GetUserInfo {
|
||||
extend SessionCommand {
|
||||
optional Command_GetUserInfo ext = 1005;
|
||||
}
|
||||
optional string user_name = 1;
|
||||
}
|
||||
|
||||
message Command_AddToList {
|
||||
extend SessionCommand {
|
||||
optional Command_AddToList ext = 1006;
|
||||
}
|
||||
optional string list = 1;
|
||||
optional string user_name = 2;
|
||||
}
|
||||
|
||||
message Command_RemoveFromList {
|
||||
extend SessionCommand {
|
||||
optional Command_RemoveFromList ext = 1007;
|
||||
}
|
||||
optional string list = 1;
|
||||
optional string user_name = 2;
|
||||
}
|
||||
|
||||
message Command_DeckList {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckList ext = 1008;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_ListRooms {
|
||||
extend SessionCommand {
|
||||
optional Command_ListRooms ext = 1014;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_JoinRoom {
|
||||
extend SessionCommand {
|
||||
optional Command_JoinRoom ext = 1015;
|
||||
}
|
||||
optional uint32 room_id = 1;
|
||||
}
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
message Command_Ping {
|
||||
}
|
||||
|
||||
message Command_Login {
|
||||
optional string user_name = 1;
|
||||
optional string password = 2;
|
||||
}
|
||||
|
||||
message Command_Message {
|
||||
optional string user_name = 1;
|
||||
optional string message = 2;
|
||||
}
|
||||
|
||||
message Command_ListUsers {
|
||||
}
|
||||
|
||||
message Command_GetGamesOfUser {
|
||||
optional string user_name = 1;
|
||||
}
|
||||
|
||||
message Command_GetUserInfo {
|
||||
optional string user_name = 1;
|
||||
}
|
||||
|
||||
message Command_AddToList {
|
||||
optional string list = 1;
|
||||
optional string user_name = 2;
|
||||
}
|
||||
|
||||
message Command_RemoveFromList {
|
||||
optional string list = 1;
|
||||
optional string user_name = 2;
|
||||
}
|
||||
|
||||
message Command_DeckList {
|
||||
}
|
||||
|
||||
message Command_DeckNewDir {
|
||||
optional string path = 1;
|
||||
optional string dir_name = 2;
|
||||
}
|
||||
|
||||
message Command_DeckDelDir {
|
||||
optional string path = 1;
|
||||
}
|
||||
|
||||
message Command_DeckDel {
|
||||
optional uint32 deck_id = 1;
|
||||
}
|
||||
|
||||
message Command_DeckDownload {
|
||||
optional uint32 deck_id = 1;
|
||||
}
|
||||
|
||||
message Command_DeckUpload {
|
||||
optional string path = 1;
|
||||
optional string deck_list = 2;
|
||||
}
|
||||
|
||||
message Command_ListRooms {
|
||||
}
|
||||
|
||||
message Command_JoinRoom {
|
||||
optional uint32 room_id = 1;
|
||||
}
|
||||
|
||||
message SessionCommand {
|
||||
enum SessionCommandType {
|
||||
PING = 1000;
|
||||
LOGIN = 1001;
|
||||
MESSAGE = 1002;
|
||||
LIST_USERS = 1003;
|
||||
GET_GAMES_OF_USER = 1004;
|
||||
GET_USER_INFO = 1005;
|
||||
ADD_TO_LIST = 1006;
|
||||
REMOVE_FROM_LIST = 1007;
|
||||
DECK_LIST = 1008;
|
||||
DECK_NEW_DIR = 1009;
|
||||
DECK_DEL_DIR = 1010;
|
||||
DECK_DEL = 1011;
|
||||
DECK_DOWNLOAD = 1012;
|
||||
DECK_UPLOAD = 1013;
|
||||
LIST_ROOMS = 1014;
|
||||
JOIN_ROOM = 1015;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
||||
extend SessionCommand {
|
||||
optional Command_Ping command_ping = 1000;
|
||||
optional Command_Login command_login = 1001;
|
||||
optional Command_Message command_message = 1002;
|
||||
optional Command_ListUsers command_list_users = 1003;
|
||||
optional Command_GetGamesOfUser command_get_games_of_user = 1004;
|
||||
optional Command_GetUserInfo command_get_user_info = 1005;
|
||||
optional Command_AddToList command_add_to_list = 1006;
|
||||
optional Command_RemoveFromList command_remove_from_list = 1007;
|
||||
optional Command_DeckList command_deck_list = 1008;
|
||||
optional Command_DeckNewDir command_deck_new_dir = 1009;
|
||||
optional Command_DeckDelDir command_deck_del_dir = 1010;
|
||||
optional Command_DeckDel command_deck_del = 1011;
|
||||
optional Command_DeckDownload command_deck_download = 1012;
|
||||
optional Command_DeckUpload command_deck_upload = 1013;
|
||||
optional Command_ListRooms command_list_rooms = 1014;
|
||||
optional Command_JoinRoom command_join_room = 1015;
|
||||
}
|
||||
|
||||
|
|
@ -30,10 +30,10 @@ void ProtocolItem::initializeHash()
|
|||
registerSerializableItem("directory", DeckList_Directory::newItem);
|
||||
// registerSerializableItem("card_to_move", CardToMove::newItem);
|
||||
registerSerializableItem("game_type_id", GameTypeId::newItem);
|
||||
/*
|
||||
registerSerializableItem("containercmd", CommandContainer::newItem);
|
||||
registerSerializableItem("containergame_event", GameEventContainer::newItem);
|
||||
|
||||
// registerSerializableItem("containercmd", CommandContainer::newItem);
|
||||
registerSerializableItem("containergame_event", GameEventContainer::newItem);
|
||||
/*
|
||||
registerSerializableItem("cmdcreate_game", Command_CreateGame::newItem);
|
||||
registerSerializableItem("cmddeck_upload", Command_DeckUpload::newItem);
|
||||
registerSerializableItem("cmddeck_select", Command_DeckSelect::newItem);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#include <QSet>
|
||||
#include <QDebug>
|
||||
#include "server_game.h"
|
||||
#include "pb/game_commands.pb.h"
|
||||
#include "pb/command_move_card.pb.h"
|
||||
|
||||
Server_CardZone::Server_CardZone(Server_Player *_player, const QString &_name, bool _has_coords, ZoneType _type)
|
||||
: player(_player), name(_name), has_coords(_has_coords), type(_type), cardsBeingLookedAt(0)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "protocol.h"
|
||||
#include "protocol_items.h"
|
||||
#include "decklist.h"
|
||||
#include "pb/game_commands.pb.h"
|
||||
#include "pb/command_move_card.pb.h"
|
||||
#include <QDebug>
|
||||
|
||||
Server_Player::Server_Player(Server_Game *_game, int _playerId, ServerInfo_User *_userInfo, bool _spectator, Server_ProtocolHandler *_handler)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,41 @@
|
|||
#include "decklist.h"
|
||||
#include <QDateTime>
|
||||
#include "pb/commands.pb.h"
|
||||
#include "pb/command_attach_card.pb.h"
|
||||
#include "pb/command_concede.pb.h"
|
||||
#include "pb/command_create_arrow.pb.h"
|
||||
#include "pb/command_create_counter.pb.h"
|
||||
#include "pb/command_create_token.pb.h"
|
||||
#include "pb/command_deck_select.pb.h"
|
||||
#include "pb/command_del_counter.pb.h"
|
||||
#include "pb/command_delete_arrow.pb.h"
|
||||
#include "pb/command_draw_cards.pb.h"
|
||||
#include "pb/command_dump_zone.pb.h"
|
||||
#include "pb/command_flip_card.pb.h"
|
||||
#include "pb/command_game_say.pb.h"
|
||||
#include "pb/command_inc_card_counter.pb.h"
|
||||
#include "pb/command_inc_counter.pb.h"
|
||||
#include "pb/command_kick_from_game.pb.h"
|
||||
#include "pb/command_leave_game.pb.h"
|
||||
#include "pb/command_move_card.pb.h"
|
||||
#include "pb/command_mulligan.pb.h"
|
||||
#include "pb/command_next_turn.pb.h"
|
||||
#include "pb/command_ready_start.pb.h"
|
||||
#include "pb/command_reveal_cards.pb.h"
|
||||
#include "pb/command_roll_die.pb.h"
|
||||
#include "pb/command_set_active_phase.pb.h"
|
||||
#include "pb/command_set_card_attr.pb.h"
|
||||
#include "pb/command_set_card_counter.pb.h"
|
||||
#include "pb/command_set_counter.pb.h"
|
||||
#include "pb/command_set_sideboard_plan.pb.h"
|
||||
#include "pb/command_shuffle.pb.h"
|
||||
#include "pb/command_stop_dump_zone.pb.h"
|
||||
#include "pb/command_undo_draw.pb.h"
|
||||
#include "pb/command_deck_upload.pb.h"
|
||||
#include "pb/command_deck_download.pb.h"
|
||||
#include "pb/command_deck_new_dir.pb.h"
|
||||
#include "pb/command_deck_del_dir.pb.h"
|
||||
#include "pb/command_deck_del.pb.h"
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
Server_ProtocolHandler::Server_ProtocolHandler(Server *_server, QObject *parent)
|
||||
|
|
@ -76,33 +111,33 @@ ResponseCode Server_ProtocolHandler::processSessionCommandContainer(CommandConta
|
|||
{
|
||||
ResponseCode finalResponseCode = RespOk;
|
||||
for (int i = cont->session_command_size() - 1; i >= 0; --i) {
|
||||
ResponseCode resp;
|
||||
ResponseCode resp = RespInvalidCommand;
|
||||
const SessionCommand &sc = cont->session_command(i);
|
||||
std::vector< const ::google::protobuf::FieldDescriptor * > fieldList;
|
||||
sc.GetReflection()->ListFields(sc, &fieldList);
|
||||
int num = 0;
|
||||
for (unsigned int j = 0; j < fieldList.size(); ++j)
|
||||
if (fieldList[j]->number() >= 100) {
|
||||
if (fieldList[j]->is_extension()) {
|
||||
num = fieldList[j]->number();
|
||||
break;
|
||||
}
|
||||
switch ((SessionCommand::SessionCommandType) num) {
|
||||
case SessionCommand::PING: resp = cmdPing(sc.GetExtension(command_ping), cont); break;
|
||||
case SessionCommand::LOGIN: resp = cmdLogin(sc.GetExtension(command_login), cont, bla); break;
|
||||
case SessionCommand::MESSAGE: resp = cmdMessage(sc.GetExtension(command_message), cont, bla); break;
|
||||
case SessionCommand::ADD_TO_LIST: resp = cmdAddToList(sc.GetExtension(command_add_to_list), cont); break;
|
||||
case SessionCommand::REMOVE_FROM_LIST: resp = cmdRemoveFromList(sc.GetExtension(command_remove_from_list), cont); break;
|
||||
case SessionCommand::DECK_LIST: resp = cmdDeckList(sc.GetExtension(command_deck_list), cont); break;
|
||||
case SessionCommand::DECK_NEW_DIR: resp = cmdDeckNewDir(sc.GetExtension(command_deck_new_dir), cont); break;
|
||||
case SessionCommand::DECK_DEL_DIR: resp = cmdDeckDelDir(sc.GetExtension(command_deck_del_dir), cont); break;
|
||||
case SessionCommand::DECK_DEL: resp = cmdDeckDel(sc.GetExtension(command_deck_del), cont); break;
|
||||
case SessionCommand::DECK_UPLOAD: resp = cmdDeckUpload(sc.GetExtension(command_deck_upload), cont); break;
|
||||
case SessionCommand::DECK_DOWNLOAD: resp = cmdDeckDownload(sc.GetExtension(command_deck_download), cont); break;
|
||||
case SessionCommand::GET_GAMES_OF_USER: resp = cmdGetGamesOfUser(sc.GetExtension(command_get_games_of_user), cont, bla); break;
|
||||
case SessionCommand::GET_USER_INFO: resp = cmdGetUserInfo(sc.GetExtension(command_get_user_info), cont, bla); break;
|
||||
case SessionCommand::LIST_ROOMS: resp = cmdListRooms(sc.GetExtension(command_list_rooms), cont, bla); break;
|
||||
case SessionCommand::JOIN_ROOM: resp = cmdJoinRoom(sc.GetExtension(command_join_room), cont, bla); break;
|
||||
case SessionCommand::LIST_USERS: resp = cmdListUsers(sc.GetExtension(command_list_users), cont, bla); break;
|
||||
case SessionCommand::PING: resp = cmdPing(sc.GetExtension(Command_Ping::ext), cont); break;
|
||||
case SessionCommand::LOGIN: resp = cmdLogin(sc.GetExtension(Command_Login::ext), cont, bla); break;
|
||||
case SessionCommand::MESSAGE: resp = cmdMessage(sc.GetExtension(Command_Message::ext), cont, bla); break;
|
||||
case SessionCommand::ADD_TO_LIST: resp = cmdAddToList(sc.GetExtension(Command_AddToList::ext), cont); break;
|
||||
case SessionCommand::REMOVE_FROM_LIST: resp = cmdRemoveFromList(sc.GetExtension(Command_RemoveFromList::ext), cont); break;
|
||||
case SessionCommand::DECK_LIST: resp = cmdDeckList(sc.GetExtension(Command_DeckList::ext), cont); break;
|
||||
case SessionCommand::DECK_NEW_DIR: resp = cmdDeckNewDir(sc.GetExtension(Command_DeckNewDir::ext), cont); break;
|
||||
case SessionCommand::DECK_DEL_DIR: resp = cmdDeckDelDir(sc.GetExtension(Command_DeckDelDir::ext), cont); break;
|
||||
case SessionCommand::DECK_DEL: resp = cmdDeckDel(sc.GetExtension(Command_DeckDel::ext), cont); break;
|
||||
case SessionCommand::DECK_UPLOAD: resp = cmdDeckUpload(sc.GetExtension(Command_DeckUpload::ext), cont); break;
|
||||
case SessionCommand::DECK_DOWNLOAD: resp = cmdDeckDownload(sc.GetExtension(Command_DeckDownload::ext), cont); break;
|
||||
case SessionCommand::GET_GAMES_OF_USER: resp = cmdGetGamesOfUser(sc.GetExtension(Command_GetGamesOfUser::ext), cont, bla); break;
|
||||
case SessionCommand::GET_USER_INFO: resp = cmdGetUserInfo(sc.GetExtension(Command_GetUserInfo::ext), cont, bla); break;
|
||||
case SessionCommand::LIST_ROOMS: resp = cmdListRooms(sc.GetExtension(Command_ListRooms::ext), cont, bla); break;
|
||||
case SessionCommand::JOIN_ROOM: resp = cmdJoinRoom(sc.GetExtension(Command_JoinRoom::ext), cont, bla); break;
|
||||
case SessionCommand::LIST_USERS: resp = cmdListUsers(sc.GetExtension(Command_ListUsers::ext), cont, bla); break;
|
||||
}
|
||||
if ((resp != RespOk) && (resp != RespNothing))
|
||||
finalResponseCode = resp;
|
||||
|
|
@ -123,21 +158,21 @@ ResponseCode Server_ProtocolHandler::processRoomCommandContainer(CommandContaine
|
|||
|
||||
ResponseCode finalResponseCode = RespOk;
|
||||
for (int i = cont->room_command_size() - 1; i >= 0; --i) {
|
||||
ResponseCode resp;
|
||||
ResponseCode resp = RespInvalidCommand;
|
||||
const RoomCommand &sc = cont->room_command(i);
|
||||
std::vector< const ::google::protobuf::FieldDescriptor * > fieldList;
|
||||
sc.GetReflection()->ListFields(sc, &fieldList);
|
||||
int num = 0;
|
||||
for (unsigned int j = 0; j < fieldList.size(); ++j)
|
||||
if (fieldList[j]->number() >= 100) {
|
||||
if (fieldList[j]->is_extension()) {
|
||||
num = fieldList[j]->number();
|
||||
break;
|
||||
}
|
||||
switch ((RoomCommand::RoomCommandType) num) {
|
||||
case RoomCommand::LEAVE_ROOM: resp = cmdLeaveRoom(sc.GetExtension(command_leave_room), cont, room); break;
|
||||
case RoomCommand::ROOM_SAY: resp = cmdRoomSay(sc.GetExtension(command_room_say), cont, room); break;
|
||||
case RoomCommand::CREATE_GAME: resp = cmdCreateGame(sc.GetExtension(command_create_game), cont, room); break;
|
||||
case RoomCommand::JOIN_GAME: resp = cmdJoinGame(sc.GetExtension(command_join_game), cont, room); break;
|
||||
case RoomCommand::LEAVE_ROOM: resp = cmdLeaveRoom(sc.GetExtension(Command_LeaveRoom::ext), cont, room); break;
|
||||
case RoomCommand::ROOM_SAY: resp = cmdRoomSay(sc.GetExtension(Command_RoomSay::ext), cont, room); break;
|
||||
case RoomCommand::CREATE_GAME: resp = cmdCreateGame(sc.GetExtension(Command_CreateGame::ext), cont, room); break;
|
||||
case RoomCommand::JOIN_GAME: resp = cmdJoinGame(sc.GetExtension(Command_JoinGame::ext), cont, room); break;
|
||||
}
|
||||
if ((resp != RespOk) && (resp != RespNothing))
|
||||
finalResponseCode = resp;
|
||||
|
|
@ -164,47 +199,47 @@ ResponseCode Server_ProtocolHandler::processGameCommandContainer(CommandContaine
|
|||
|
||||
ResponseCode finalResponseCode = RespOk;
|
||||
for (int i = cont->game_command_size() - 1; i >= 0; --i) {
|
||||
ResponseCode resp;
|
||||
ResponseCode resp = RespInvalidCommand;
|
||||
const GameCommand &sc = cont->game_command(i);
|
||||
std::vector< const ::google::protobuf::FieldDescriptor * > fieldList;
|
||||
sc.GetReflection()->ListFields(sc, &fieldList);
|
||||
int num = 0;
|
||||
for (unsigned int j = 0; j < fieldList.size(); ++j)
|
||||
if (fieldList[j]->number() >= 100) {
|
||||
if (fieldList[j]->is_extension()) {
|
||||
num = fieldList[j]->number();
|
||||
break;
|
||||
}
|
||||
switch ((GameCommand::GameCommandType) num) {
|
||||
case GameCommand::KICK_FROM_GAME: resp = cmdKickFromGame(sc.GetExtension(command_kick_from_game), cont, game, player, bla); break;
|
||||
case GameCommand::LEAVE_GAME: resp = cmdLeaveGame(sc.GetExtension(command_leave_game), cont, game, player, bla); break;
|
||||
case GameCommand::GAME_SAY: resp = cmdGameSay(sc.GetExtension(command_game_say), cont, game, player, bla); break;
|
||||
case GameCommand::SHUFFLE: resp = cmdShuffle(sc.GetExtension(command_shuffle), cont, game, player, bla); break;
|
||||
case GameCommand::MULLIGAN: resp = cmdMulligan(sc.GetExtension(command_mulligan), cont, game, player, bla); break;
|
||||
case GameCommand::ROLL_DIE: resp = cmdRollDie(sc.GetExtension(command_roll_die), cont, game, player, bla); break;
|
||||
case GameCommand::DRAW_CARDS: resp = cmdDrawCards(sc.GetExtension(command_draw_cards), cont, game, player, bla); break;
|
||||
case GameCommand::UNDO_DRAW: resp = cmdUndoDraw(sc.GetExtension(command_undo_draw), cont, game, player, bla); break;
|
||||
case GameCommand::FLIP_CARD: resp = cmdFlipCard(sc.GetExtension(command_flip_card), cont, game, player, bla); break;
|
||||
case GameCommand::ATTACH_CARD: resp = cmdAttachCard(sc.GetExtension(command_attach_card), cont, game, player, bla); break;
|
||||
case GameCommand::CREATE_TOKEN: resp = cmdCreateToken(sc.GetExtension(command_create_token), cont, game, player, bla); break;
|
||||
case GameCommand::CREATE_ARROW: resp = cmdCreateArrow(sc.GetExtension(command_create_arrow), cont, game, player, bla); break;
|
||||
case GameCommand::DELETE_ARROW: resp = cmdDeleteArrow(sc.GetExtension(command_delete_arrow), cont, game, player, bla); break;
|
||||
case GameCommand::SET_CARD_ATTR: resp = cmdSetCardAttr(sc.GetExtension(command_set_card_attr), cont, game, player, bla); break;
|
||||
case GameCommand::SET_CARD_COUNTER: resp = cmdSetCardCounter(sc.GetExtension(command_set_card_counter), cont, game, player, bla); break;
|
||||
case GameCommand::INC_CARD_COUNTER: resp = cmdIncCardCounter(sc.GetExtension(command_inc_card_counter), cont, game, player, bla); break;
|
||||
case GameCommand::READY_START: resp = cmdReadyStart(sc.GetExtension(command_ready_start), cont, game, player, bla); break;
|
||||
case GameCommand::CONCEDE: resp = cmdConcede(sc.GetExtension(command_concede), cont, game, player, bla); break;
|
||||
case GameCommand::INC_COUNTER: resp = cmdIncCounter(sc.GetExtension(command_inc_counter), cont, game, player, bla); break;
|
||||
case GameCommand::CREATE_COUNTER: resp = cmdCreateCounter(sc.GetExtension(command_create_counter), cont, game, player, bla); break;
|
||||
case GameCommand::SET_COUNTER: resp = cmdSetCounter(sc.GetExtension(command_set_counter), cont, game, player, bla); break;
|
||||
case GameCommand::DEL_COUNTER: resp = cmdDelCounter(sc.GetExtension(command_del_counter), cont, game, player, bla); break;
|
||||
case GameCommand::NEXT_TURN: resp = cmdNextTurn(sc.GetExtension(command_next_turn), cont, game, player, bla); break;
|
||||
case GameCommand::SET_ACTIVE_PHASE: resp = cmdSetActivePhase(sc.GetExtension(command_set_active_phase), cont, game, player, bla); break;
|
||||
case GameCommand::DUMP_ZONE: resp = cmdDumpZone(sc.GetExtension(command_dump_zone), cont, game, player, bla); break;
|
||||
case GameCommand::STOP_DUMP_ZONE: resp = cmdStopDumpZone(sc.GetExtension(command_stop_dump_zone), cont, game, player, bla); break;
|
||||
case GameCommand::REVEAL_CARDS: resp = cmdRevealCards(sc.GetExtension(command_reveal_cards), cont, game, player, bla); break;
|
||||
case GameCommand::MOVE_CARD: resp = cmdMoveCard(sc.GetExtension(command_move_card), cont, game, player, bla); break;
|
||||
case GameCommand::SET_SIDEBOARD_PLAN: resp = cmdSetSideboardPlan(sc.GetExtension(command_set_sideboard_plan), cont, game, player, bla); break;
|
||||
case GameCommand::DECK_SELECT: resp = cmdDeckSelect(sc.GetExtension(command_deck_select), cont, game, player, bla); break;
|
||||
case GameCommand::KICK_FROM_GAME: resp = cmdKickFromGame(sc.GetExtension(Command_KickFromGame::ext), cont, game, player, bla); break;
|
||||
case GameCommand::LEAVE_GAME: resp = cmdLeaveGame(sc.GetExtension(Command_LeaveGame::ext), cont, game, player, bla); break;
|
||||
case GameCommand::GAME_SAY: resp = cmdGameSay(sc.GetExtension(Command_GameSay::ext), cont, game, player, bla); break;
|
||||
case GameCommand::SHUFFLE: resp = cmdShuffle(sc.GetExtension(Command_Shuffle::ext), cont, game, player, bla); break;
|
||||
case GameCommand::MULLIGAN: resp = cmdMulligan(sc.GetExtension(Command_Mulligan::ext), cont, game, player, bla); break;
|
||||
case GameCommand::ROLL_DIE: resp = cmdRollDie(sc.GetExtension(Command_RollDie::ext), cont, game, player, bla); break;
|
||||
case GameCommand::DRAW_CARDS: resp = cmdDrawCards(sc.GetExtension(Command_DrawCards::ext), cont, game, player, bla); break;
|
||||
case GameCommand::UNDO_DRAW: resp = cmdUndoDraw(sc.GetExtension(Command_UndoDraw::ext), cont, game, player, bla); break;
|
||||
case GameCommand::FLIP_CARD: resp = cmdFlipCard(sc.GetExtension(Command_FlipCard::ext), cont, game, player, bla); break;
|
||||
case GameCommand::ATTACH_CARD: resp = cmdAttachCard(sc.GetExtension(Command_AttachCard::ext), cont, game, player, bla); break;
|
||||
case GameCommand::CREATE_TOKEN: resp = cmdCreateToken(sc.GetExtension(Command_CreateToken::ext), cont, game, player, bla); break;
|
||||
case GameCommand::CREATE_ARROW: resp = cmdCreateArrow(sc.GetExtension(Command_CreateArrow::ext), cont, game, player, bla); break;
|
||||
case GameCommand::DELETE_ARROW: resp = cmdDeleteArrow(sc.GetExtension(Command_DeleteArrow::ext), cont, game, player, bla); break;
|
||||
case GameCommand::SET_CARD_ATTR: resp = cmdSetCardAttr(sc.GetExtension(Command_SetCardAttr::ext), cont, game, player, bla); break;
|
||||
case GameCommand::SET_CARD_COUNTER: resp = cmdSetCardCounter(sc.GetExtension(Command_SetCardCounter::ext), cont, game, player, bla); break;
|
||||
case GameCommand::INC_CARD_COUNTER: resp = cmdIncCardCounter(sc.GetExtension(Command_IncCardCounter::ext), cont, game, player, bla); break;
|
||||
case GameCommand::READY_START: resp = cmdReadyStart(sc.GetExtension(Command_ReadyStart::ext), cont, game, player, bla); break;
|
||||
case GameCommand::CONCEDE: resp = cmdConcede(sc.GetExtension(Command_Concede::ext), cont, game, player, bla); break;
|
||||
case GameCommand::INC_COUNTER: resp = cmdIncCounter(sc.GetExtension(Command_IncCounter::ext), cont, game, player, bla); break;
|
||||
case GameCommand::CREATE_COUNTER: resp = cmdCreateCounter(sc.GetExtension(Command_CreateCounter::ext), cont, game, player, bla); break;
|
||||
case GameCommand::SET_COUNTER: resp = cmdSetCounter(sc.GetExtension(Command_SetCounter::ext), cont, game, player, bla); break;
|
||||
case GameCommand::DEL_COUNTER: resp = cmdDelCounter(sc.GetExtension(Command_DelCounter::ext), cont, game, player, bla); break;
|
||||
case GameCommand::NEXT_TURN: resp = cmdNextTurn(sc.GetExtension(Command_NextTurn::ext), cont, game, player, bla); break;
|
||||
case GameCommand::SET_ACTIVE_PHASE: resp = cmdSetActivePhase(sc.GetExtension(Command_SetActivePhase::ext), cont, game, player, bla); break;
|
||||
case GameCommand::DUMP_ZONE: resp = cmdDumpZone(sc.GetExtension(Command_DumpZone::ext), cont, game, player, bla); break;
|
||||
case GameCommand::STOP_DUMP_ZONE: resp = cmdStopDumpZone(sc.GetExtension(Command_StopDumpZone::ext), cont, game, player, bla); break;
|
||||
case GameCommand::REVEAL_CARDS: resp = cmdRevealCards(sc.GetExtension(Command_RevealCards::ext), cont, game, player, bla); break;
|
||||
case GameCommand::MOVE_CARD: resp = cmdMoveCard(sc.GetExtension(Command_MoveCard::ext), cont, game, player, bla); break;
|
||||
case GameCommand::SET_SIDEBOARD_PLAN: resp = cmdSetSideboardPlan(sc.GetExtension(Command_SetSideboardPlan::ext), cont, game, player, bla); break;
|
||||
case GameCommand::DECK_SELECT: resp = cmdDeckSelect(sc.GetExtension(Command_DeckSelect::ext), cont, game, player, bla); break;
|
||||
}
|
||||
if ((resp != RespOk) && (resp != RespNothing))
|
||||
finalResponseCode = resp;
|
||||
|
|
@ -214,23 +249,25 @@ ResponseCode Server_ProtocolHandler::processGameCommandContainer(CommandContaine
|
|||
|
||||
ResponseCode Server_ProtocolHandler::processModeratorCommandContainer(CommandContainer *cont, BlaContainer *bla)
|
||||
{
|
||||
if (!userInfo)
|
||||
return RespLoginNeeded;
|
||||
if (!(userInfo->getUserLevel() & ServerInfo_User::IsModerator))
|
||||
return RespLoginNeeded;
|
||||
|
||||
ResponseCode finalResponseCode = RespOk;
|
||||
for (int i = cont->moderator_command_size() - 1; i >= 0; --i) {
|
||||
ResponseCode resp;
|
||||
ResponseCode resp = RespInvalidCommand;
|
||||
const ModeratorCommand &sc = cont->moderator_command(i);
|
||||
std::vector< const ::google::protobuf::FieldDescriptor * > fieldList;
|
||||
sc.GetReflection()->ListFields(sc, &fieldList);
|
||||
int num = 0;
|
||||
for (unsigned int j = 0; j < fieldList.size(); ++j)
|
||||
if (fieldList[j]->number() >= 100) {
|
||||
if (fieldList[j]->is_extension()) {
|
||||
num = fieldList[j]->number();
|
||||
break;
|
||||
}
|
||||
switch ((ModeratorCommand::ModeratorCommandType) num) {
|
||||
case ModeratorCommand::BAN_FROM_SERVER: resp = cmdBanFromServer(sc.GetExtension(command_ban_from_server), cont); break;
|
||||
case ModeratorCommand::BAN_FROM_SERVER: resp = cmdBanFromServer(sc.GetExtension(Command_BanFromServer::ext), cont); break;
|
||||
}
|
||||
if ((resp != RespOk) && (resp != RespNothing))
|
||||
finalResponseCode = resp;
|
||||
|
|
@ -240,24 +277,26 @@ ResponseCode Server_ProtocolHandler::processModeratorCommandContainer(CommandCon
|
|||
|
||||
ResponseCode Server_ProtocolHandler::processAdminCommandContainer(CommandContainer *cont, BlaContainer *bla)
|
||||
{
|
||||
if (!userInfo)
|
||||
return RespLoginNeeded;
|
||||
if (!(userInfo->getUserLevel() & ServerInfo_User::IsAdmin))
|
||||
return RespLoginNeeded;
|
||||
|
||||
ResponseCode finalResponseCode = RespOk;
|
||||
for (int i = cont->admin_command_size() - 1; i >= 0; --i) {
|
||||
ResponseCode resp;
|
||||
ResponseCode resp = RespInvalidCommand;
|
||||
const AdminCommand &sc = cont->admin_command(i);
|
||||
std::vector< const ::google::protobuf::FieldDescriptor * > fieldList;
|
||||
sc.GetReflection()->ListFields(sc, &fieldList);
|
||||
int num = 0;
|
||||
for (unsigned int j = 0; j < fieldList.size(); ++j)
|
||||
if (fieldList[j]->number() >= 100) {
|
||||
if (fieldList[j]->is_extension()) {
|
||||
num = fieldList[j]->number();
|
||||
break;
|
||||
}
|
||||
switch ((AdminCommand::AdminCommandType) num) {
|
||||
case AdminCommand::SHUTDOWN_SERVER: resp = cmdShutdownServer(sc.GetExtension(command_shutdown_server), cont); break;
|
||||
case AdminCommand::UPDATE_SERVER_MESSAGE: resp = cmdUpdateServerMessage(sc.GetExtension(command_update_server_message), cont); break;
|
||||
case AdminCommand::SHUTDOWN_SERVER: resp = cmdShutdownServer(sc.GetExtension(Command_ShutdownServer::ext), cont); break;
|
||||
case AdminCommand::UPDATE_SERVER_MESSAGE: resp = cmdUpdateServerMessage(sc.GetExtension(Command_UpdateServerMessage::ext), cont); break;
|
||||
}
|
||||
if ((resp != RespOk) && (resp != RespNothing))
|
||||
finalResponseCode = resp;
|
||||
|
|
@ -857,8 +896,8 @@ ResponseCode Server_ProtocolHandler::cmdMoveCard(const Command_MoveCard &cmd, Co
|
|||
return RespContextError;
|
||||
|
||||
QList<const CardToMove *> cardsToMove;
|
||||
for (int i = 0; i < cmd.cards_to_move_size(); ++i)
|
||||
cardsToMove.append(&cmd.cards_to_move(i));
|
||||
for (int i = 0; i < cmd.cards_to_move().card_size(); ++i)
|
||||
cardsToMove.append(&cmd.cards_to_move().card(i));
|
||||
|
||||
return player->moveCard(bla, QString::fromStdString(cmd.start_zone()), cardsToMove, cmd.target_player_id(), QString::fromStdString(cmd.target_zone()), cmd.x(), cmd.y());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,15 +37,7 @@ HEADERS += src/main.h \
|
|||
../common/server_game.h \
|
||||
../common/server_player.h \
|
||||
../common/server_protocolhandler.h \
|
||||
../common/server_arrowtarget.h \
|
||||
../common/pb/commands.pb.h \
|
||||
../common/pb/color.pb.h \
|
||||
../common/pb/move_card_to_zone.pb.h \
|
||||
../common/pb/game_commands.pb.h \
|
||||
../common/pb/room_commands.pb.h \
|
||||
../common/pb/session_commands.pb.h \
|
||||
../common/pb/moderator_commands.pb.h \
|
||||
../common/pb/admin_commands.pb.h
|
||||
../common/server_arrowtarget.h
|
||||
|
||||
|
||||
SOURCES += src/main.cpp \
|
||||
|
|
@ -68,13 +60,7 @@ SOURCES += src/main.cpp \
|
|||
../common/server_room.cpp \
|
||||
../common/server_game.cpp \
|
||||
../common/server_player.cpp \
|
||||
../common/server_protocolhandler.cpp \
|
||||
../common/pb/commands.pb.cc \
|
||||
../common/pb/color.pb.cc \
|
||||
../common/pb/move_card_to_zone.pb.cc \
|
||||
../common/pb/game_commands.pb.cc \
|
||||
../common/pb/room_commands.pb.cc \
|
||||
../common/pb/session_commands.pb.cc \
|
||||
../common/pb/moderator_commands.pb.cc \
|
||||
../common/pb/admin_commands.pb.cc
|
||||
|
||||
../common/server_protocolhandler.cpp
|
||||
|
||||
include ( ../pb_headers )
|
||||
include ( ../pb_sources )
|
||||
|
|
|
|||
|
|
@ -33,11 +33,17 @@
|
|||
#include "server_logger.h"
|
||||
|
||||
#include "pb/commands.pb.h"
|
||||
#include "pb/command_deck_upload.pb.h"
|
||||
#include "pb/command_deck_download.pb.h"
|
||||
#include "pb/command_deck_new_dir.pb.h"
|
||||
#include "pb/command_deck_del_dir.pb.h"
|
||||
#include "pb/command_deck_del.pb.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
ServerSocketInterface::ServerSocketInterface(Servatrice *_server, QTcpSocket *_socket, QObject *parent)
|
||||
: Server_ProtocolHandler(_server, parent), servatrice(_server), socket(_socket), topLevelItem(0), compressionSupport(false)
|
||||
: Server_ProtocolHandler(_server, parent), servatrice(_server), socket(_socket), topLevelItem(0), compressionSupport(false), messageInProgress(false)
|
||||
{
|
||||
xmlWriter = new QXmlStreamWriter(&xmlBuffer);
|
||||
xmlReader = new QXmlStreamReader;
|
||||
|
|
@ -107,6 +113,7 @@ void ServerSocketInterface::readClient()
|
|||
|
||||
CommandContainer *newCommandContainer = new CommandContainer;
|
||||
newCommandContainer->ParseFromArray(inputBuffer.data(), messageLength);
|
||||
logger->logMessage(QString::fromStdString(newCommandContainer->ShortDebugString()), this);
|
||||
inputBuffer.remove(0, messageLength);
|
||||
messageInProgress = false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue