minor visual change, server crash fix, multiplayer leave/concede fixes
This commit is contained in:
parent
6bdc8914a9
commit
d4f600393f
10 changed files with 169 additions and 58 deletions
|
@ -69,12 +69,13 @@ void AbstractCardItem::transformPainter(QPainter *painter, const QSizeF &transla
|
|||
painter->setTransform(pixmapTransform);
|
||||
|
||||
QFont f;
|
||||
int fontSize = translatedSize.height() / 8;
|
||||
int fontSize = round(translatedSize.height() / 8);
|
||||
if (fontSize < 9)
|
||||
fontSize = 9;
|
||||
if (fontSize > 12)
|
||||
fontSize = 12;
|
||||
if (fontSize > 10)
|
||||
fontSize = 10;
|
||||
f.setPixelSize(fontSize);
|
||||
|
||||
painter->setFont(f);
|
||||
}
|
||||
|
||||
|
|
|
@ -330,7 +330,6 @@ void CardInfo::imageLoaded(const QImage &image)
|
|||
|
||||
QPixmap *CardInfo::getPixmap(QSize size)
|
||||
{
|
||||
qDebug() << "CardInfo::getPixmap(" << size.width() << size.height() << ") for" << getName();
|
||||
QPixmap *cachedPixmap = scaledPixmapCache.value(size.width());
|
||||
if (cachedPixmap)
|
||||
return cachedPixmap;
|
||||
|
|
|
@ -26,6 +26,7 @@ void GameScene::addPlayer(Player *player)
|
|||
addItem(player);
|
||||
rearrange();
|
||||
connect(player, SIGNAL(sizeChanged()), this, SLOT(rearrange()));
|
||||
connect(player, SIGNAL(gameConceded()), this, SLOT(rearrange()));
|
||||
}
|
||||
|
||||
void GameScene::removePlayer(Player *player)
|
||||
|
@ -41,6 +42,9 @@ void GameScene::rearrange()
|
|||
struct PlayerProcessor {
|
||||
static void processPlayer(Player *p, qreal &w, QPointF &b, bool singlePlayer)
|
||||
{
|
||||
if (p->getConceded())
|
||||
return;
|
||||
|
||||
const QRectF br = p->boundingRect();
|
||||
if (br.width() > w)
|
||||
w = br.width();
|
||||
|
@ -52,7 +56,8 @@ void GameScene::rearrange()
|
|||
|
||||
qreal sceneHeight = -playerAreaSpacing;
|
||||
for (int i = 0; i < players.size(); ++i)
|
||||
sceneHeight += players[i]->boundingRect().height() + playerAreaSpacing;
|
||||
if (!players[i]->getConceded())
|
||||
sceneHeight += players[i]->boundingRect().height() + playerAreaSpacing;
|
||||
phasesToolbar->setHeight(sceneHeight);
|
||||
qreal phasesWidth = phasesToolbar->getWidth();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
Player::Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent)
|
||||
: QObject(_parent), shortcutsActive(false), defaultNumberTopCards(3), lastTokenDestroy(true), userInfo(new ServerInfo_User(info)), id(_id), active(false), local(_local), mirrored(false), dialogSemaphore(false)
|
||||
: QObject(_parent), shortcutsActive(false), defaultNumberTopCards(3), lastTokenDestroy(true), userInfo(new ServerInfo_User(info)), id(_id), active(false), local(_local), mirrored(false), conceded(false), dialogSemaphore(false)
|
||||
{
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
|
||||
|
@ -264,15 +264,25 @@ Player::~Player()
|
|||
|
||||
static_cast<GameScene *>(scene())->removePlayer(this);
|
||||
|
||||
clear();
|
||||
QMapIterator<QString, CardZone *> i(zones);
|
||||
while (i.hasNext())
|
||||
delete i.next().value();
|
||||
zones.clear();
|
||||
|
||||
delete playerMenu;
|
||||
delete userInfo;
|
||||
}
|
||||
|
||||
void Player::clear()
|
||||
{
|
||||
clearArrows();
|
||||
|
||||
QMapIterator<QString, CardZone *> i(zones);
|
||||
while (i.hasNext())
|
||||
delete i.next().value();
|
||||
i.next().value()->clearContents();
|
||||
|
||||
clearCounters();
|
||||
delete playerMenu;
|
||||
delete userInfo;
|
||||
}
|
||||
|
||||
void Player::addPlayer(Player *player)
|
||||
|
@ -362,6 +372,11 @@ void Player::rearrangeZones()
|
|||
rearrangeCounters();
|
||||
}
|
||||
|
||||
void Player::updateZones()
|
||||
{
|
||||
table->reorganizeCards();
|
||||
}
|
||||
|
||||
void Player::updateBgPixmap()
|
||||
{
|
||||
QString bgPath = settingsCache->getPlayerBgPath();
|
||||
|
@ -1485,6 +1500,16 @@ qreal Player::getMinimumWidth() const
|
|||
return result;
|
||||
}
|
||||
|
||||
void Player::setConceded(bool _conceded)
|
||||
{
|
||||
conceded = _conceded;
|
||||
setVisible(!conceded);
|
||||
if (conceded) {
|
||||
clear();
|
||||
emit gameConceded();
|
||||
}
|
||||
}
|
||||
|
||||
void Player::setMirrored(bool _mirrored)
|
||||
{
|
||||
if (mirrored != _mirrored) {
|
||||
|
|
|
@ -74,6 +74,7 @@ signals:
|
|||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||
|
||||
void sizeChanged();
|
||||
void gameConceded();
|
||||
public slots:
|
||||
void actUntapAll();
|
||||
void actRollDie();
|
||||
|
@ -102,7 +103,6 @@ public slots:
|
|||
void actSetAnnotation(QAction *action);
|
||||
void cardMenuAction(QAction *action);
|
||||
void actCardCounterTrigger(QAction *action);
|
||||
|
||||
private slots:
|
||||
void addPlayer(Player *player);
|
||||
void removePlayer(Player *player);
|
||||
|
@ -134,6 +134,7 @@ private:
|
|||
bool active;
|
||||
bool local;
|
||||
bool mirrored;
|
||||
bool conceded;
|
||||
|
||||
bool dialogSemaphore;
|
||||
bool clearCardsToDelete();
|
||||
|
@ -203,6 +204,7 @@ public:
|
|||
Player(ServerInfo_User *info, int _id, bool _local, TabGame *_parent);
|
||||
~Player();
|
||||
void retranslateUi();
|
||||
void clear();
|
||||
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||
int getId() const { return id; }
|
||||
QString getName() const;
|
||||
|
@ -211,13 +213,16 @@ public:
|
|||
bool getMirrored() const { return mirrored; }
|
||||
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
||||
const QMap<int, ArrowItem *> &getArrows() const { return arrows; }
|
||||
TableZone *getTable() const { return table; }
|
||||
void setCardMenu(QMenu *menu);
|
||||
QMenu *getCardMenu() const;
|
||||
bool getActive() const { return active; }
|
||||
void setActive(bool _active);
|
||||
void setShortcutsActive();
|
||||
void setShortcutsInactive();
|
||||
void updateZones();
|
||||
|
||||
void setConceded(bool _conceded);
|
||||
bool getConceded() const { return conceded; }
|
||||
|
||||
qreal getMinimumWidth() const;
|
||||
void setMirrored(bool _mirrored);
|
||||
|
|
|
@ -477,6 +477,10 @@ void TabGame::startGame()
|
|||
}
|
||||
mainLayout->removeItem(deckViewContainerLayout);
|
||||
|
||||
QMapIterator<int, Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->setConceded(false);
|
||||
|
||||
playerListWidget->setGameStarted(true);
|
||||
started = true;
|
||||
gameView->show();
|
||||
|
@ -581,7 +585,16 @@ void TabGame::eventPlayerPropertiesChanged(Event_PlayerPropertiesChanged *event,
|
|||
messageLog->logNotReadyStart(player);
|
||||
break;
|
||||
}
|
||||
case ItemId_Context_Concede: messageLog->logConcede(player); break;
|
||||
case ItemId_Context_Concede: {
|
||||
messageLog->logConcede(player);
|
||||
player->setConceded(true);
|
||||
|
||||
QMapIterator<int, Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->updateZones();
|
||||
|
||||
break;
|
||||
}
|
||||
case ItemId_Context_DeckSelect: messageLog->logDeckSelect(player, static_cast<Context_DeckSelect *>(context)->getDeckId()); break;
|
||||
default: ;
|
||||
}
|
||||
|
@ -609,13 +622,21 @@ void TabGame::eventLeave(Event_Leave *event, GameEventContext * /*context*/)
|
|||
int playerId = event->getPlayerId();
|
||||
|
||||
Player *player = players.value(playerId, 0);
|
||||
if (player) {
|
||||
messageLog->logLeave(player);
|
||||
playerListWidget->removePlayer(playerId);
|
||||
players.remove(playerId);
|
||||
emit playerRemoved(player);
|
||||
player->deleteLater();
|
||||
}
|
||||
if (!player)
|
||||
return;
|
||||
|
||||
messageLog->logLeave(player);
|
||||
playerListWidget->removePlayer(playerId);
|
||||
players.remove(playerId);
|
||||
emit playerRemoved(player);
|
||||
player->clear();
|
||||
player->deleteLater();
|
||||
|
||||
// Rearrange all remaining zones so that attachment relationship updates take place
|
||||
QMapIterator<int, Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->updateZones();
|
||||
|
||||
emit userEvent();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
Server_Card::~Server_Card()
|
||||
{
|
||||
// setParentCard(0) leads to the item being removed from our list, so we can't iterate properly
|
||||
|
|
|
@ -227,13 +227,17 @@ void Server_Game::removePlayer(Server_Player *player)
|
|||
}
|
||||
|
||||
sendGameEvent(new Event_Leave(player->getPlayerId()));
|
||||
bool playerActive = activePlayer == player->getPlayerId();
|
||||
bool spectator = player->getSpectator();
|
||||
delete player;
|
||||
|
||||
if (!getPlayerCount())
|
||||
deleteLater();
|
||||
else if (!spectator)
|
||||
else if (!spectator) {
|
||||
stopGameIfFinished();
|
||||
if (gameStarted && playerActive)
|
||||
nextTurn();
|
||||
}
|
||||
qobject_cast<Server_Room *>(parent())->broadcastGameListUpdate(this);
|
||||
}
|
||||
|
||||
|
@ -271,7 +275,7 @@ void Server_Game::nextTurn()
|
|||
++listPos;
|
||||
if (listPos == keys.size())
|
||||
listPos = 0;
|
||||
} while (players.value(keys[listPos])->getSpectator());
|
||||
} while (players.value(keys[listPos])->getSpectator() || players.value(keys[listPos])->getConceded());
|
||||
|
||||
setActivePlayer(keys[listPos]);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ Server_Player::~Server_Player()
|
|||
if (handler)
|
||||
handler->playerRemovedFromGame(game);
|
||||
delete userInfo;
|
||||
|
||||
clearZones();
|
||||
}
|
||||
|
||||
int Server_Player::newCardId()
|
||||
|
|
|
@ -322,14 +322,14 @@ ResponseCode Server_ProtocolHandler::cmdJoinRoom(Command_JoinRoom *cmd, CommandC
|
|||
return RespNothing;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdLeaveRoom(Command_LeaveRoom * /*cmd*/, CommandContainer *cont, Server_Room *room)
|
||||
ResponseCode Server_ProtocolHandler::cmdLeaveRoom(Command_LeaveRoom * /*cmd*/, CommandContainer * /*cont*/, Server_Room *room)
|
||||
{
|
||||
rooms.remove(room->getId());
|
||||
room->removeClient(this);
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdRoomSay(Command_RoomSay *cmd, CommandContainer *cont, Server_Room *room)
|
||||
ResponseCode Server_ProtocolHandler::cmdRoomSay(Command_RoomSay *cmd, CommandContainer * /*cont*/, Server_Room *room)
|
||||
{
|
||||
room->say(this, cmd->getMessage());
|
||||
return RespOk;
|
||||
|
@ -351,7 +351,7 @@ ResponseCode Server_ProtocolHandler::cmdListUsers(Command_ListUsers * /*cmd*/, C
|
|||
return RespNothing;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateGame(Command_CreateGame *cmd, CommandContainer *cont, Server_Room *room)
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateGame(Command_CreateGame *cmd, CommandContainer * /*cont*/, Server_Room *room)
|
||||
{
|
||||
if (authState == PasswordWrong)
|
||||
return RespLoginNeeded;
|
||||
|
@ -370,7 +370,7 @@ ResponseCode Server_ProtocolHandler::cmdCreateGame(Command_CreateGame *cmd, Comm
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd, CommandContainer *cont, Server_Room *room)
|
||||
ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd, CommandContainer * /*cont*/, Server_Room *room)
|
||||
{
|
||||
if (authState == PasswordWrong)
|
||||
return RespLoginNeeded;
|
||||
|
@ -392,7 +392,7 @@ ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd, CommandC
|
|||
return result;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdLeaveGame(Command_LeaveGame * /*cmd*/, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdLeaveGame(Command_LeaveGame * /*cmd*/, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
game->removePlayer(player);
|
||||
return RespOk;
|
||||
|
@ -423,7 +423,7 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Comm
|
|||
return RespNothing;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdSetSideboardPlan(Command_SetSideboardPlan *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdSetSideboardPlan(Command_SetSideboardPlan *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
@ -438,18 +438,24 @@ ResponseCode Server_ProtocolHandler::cmdSetSideboardPlan(Command_SetSideboardPla
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdConcede(Command_Concede * /*cmd*/, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdConcede(Command_Concede * /*cmd*/, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
player->setConceded(true);
|
||||
player->clearZones();
|
||||
game->sendGameEvent(new Event_PlayerPropertiesChanged(player->getPlayerId(), player->getProperties()), new Context_Concede);
|
||||
game->stopGameIfFinished();
|
||||
if (game->getGameStarted() && (game->getActivePlayer() == player->getPlayerId()))
|
||||
game->nextTurn();
|
||||
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdReadyStart(Command_ReadyStart *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdReadyStart(Command_ReadyStart *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
@ -466,7 +472,7 @@ ResponseCode Server_ProtocolHandler::cmdReadyStart(Command_ReadyStart *cmd, Comm
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdSay(Command_Say *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdSay(Command_Say *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator() && !game->getSpectatorsCanTalk())
|
||||
return RespFunctionNotAllowed;
|
||||
|
@ -475,13 +481,15 @@ ResponseCode Server_ProtocolHandler::cmdSay(Command_Say *cmd, CommandContainer *
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdShuffle(Command_Shuffle * /*cmd*/, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdShuffle(Command_Shuffle * /*cmd*/, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
player->getZones().value("deck")->shuffle();
|
||||
game->sendGameEvent(new Event_Shuffle(player->getPlayerId()));
|
||||
|
@ -495,6 +503,8 @@ ResponseCode Server_ProtocolHandler::cmdMulligan(Command_Mulligan * /*cmd*/, Com
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_CardZone *hand = player->getZones().value("hand");
|
||||
int number = (hand->cards.size() <= 1) ? player->getInitialCards() : hand->cards.size() - 1;
|
||||
|
@ -512,10 +522,12 @@ ResponseCode Server_ProtocolHandler::cmdMulligan(Command_Mulligan * /*cmd*/, Com
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdRollDie(Command_RollDie *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdRollDie(Command_RollDie *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
game->sendGameEvent(new Event_RollDie(player->getPlayerId(), cmd->getSides(), rng->getNumber(1, cmd->getSides())));
|
||||
return RespOk;
|
||||
|
@ -528,17 +540,21 @@ ResponseCode Server_ProtocolHandler::cmdDrawCards(Command_DrawCards *cmd, Comman
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
return player->drawCards(cont, cmd->getNumber());
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdUndoDraw(Command_UndoDraw *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdUndoDraw(Command_UndoDraw * /*cmd*/, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
return player->undoDraw(cont);
|
||||
}
|
||||
|
@ -550,6 +566,8 @@ ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, CommandC
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
QList<int> cardIds;
|
||||
const QList<CardId *> &temp = cmd->getCardIds();
|
||||
|
@ -566,6 +584,8 @@ ResponseCode Server_ProtocolHandler::cmdFlipCard(Command_FlipCard *cmd, CommandC
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
||||
if (!zone)
|
||||
|
@ -595,6 +615,8 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_CardZone *startzone = player->getZones().value(cmd->getStartZone());
|
||||
if (!startzone)
|
||||
|
@ -670,13 +692,15 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
||||
if (!zone)
|
||||
|
@ -703,13 +727,15 @@ ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, Co
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateArrow(Command_CreateArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateArrow(Command_CreateArrow *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_Player *startPlayer = game->getPlayer(cmd->getStartPlayerId());
|
||||
Server_Player *targetPlayer = game->getPlayer(cmd->getTargetPlayerId());
|
||||
|
@ -764,13 +790,15 @@ ResponseCode Server_ProtocolHandler::cmdCreateArrow(Command_CreateArrow *cmd, Co
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdDeleteArrow(Command_DeleteArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdDeleteArrow(Command_DeleteArrow *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
if (!player->deleteArrow(cmd->getArrowId()))
|
||||
return RespNameNotFound;
|
||||
|
@ -786,6 +814,8 @@ ResponseCode Server_ProtocolHandler::cmdSetCardAttr(Command_SetCardAttr *cmd, Co
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
return player->setCardAttrHelper(cont, cmd->getZone(), cmd->getCardId(), cmd->getAttrName(), cmd->getAttrValue());
|
||||
}
|
||||
|
@ -797,6 +827,8 @@ ResponseCode Server_ProtocolHandler::cmdSetCardCounter(Command_SetCardCounter *c
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
||||
if (!zone)
|
||||
|
@ -822,6 +854,8 @@ ResponseCode Server_ProtocolHandler::cmdIncCardCounter(Command_IncCardCounter *c
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
||||
if (!zone)
|
||||
|
@ -841,13 +875,15 @@ ResponseCode Server_ProtocolHandler::cmdIncCardCounter(Command_IncCardCounter *c
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdIncCounter(Command_IncCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdIncCounter(Command_IncCounter *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
const QMap<int, Server_Counter *> counters = player->getCounters();
|
||||
Server_Counter *c = counters.value(cmd->getCounterId(), 0);
|
||||
|
@ -859,13 +895,15 @@ ResponseCode Server_ProtocolHandler::cmdIncCounter(Command_IncCounter *cmd, Comm
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateCounter(Command_CreateCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdCreateCounter(Command_CreateCounter *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_Counter *c = new Server_Counter(player->newCounterId(), cmd->getCounterName(), cmd->getColor(), cmd->getRadius(), cmd->getValue());
|
||||
player->addCounter(c);
|
||||
|
@ -874,13 +912,15 @@ ResponseCode Server_ProtocolHandler::cmdCreateCounter(Command_CreateCounter *cmd
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdSetCounter(Command_SetCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdSetCounter(Command_SetCounter *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_Counter *c = player->getCounters().value(cmd->getCounterId(), 0);;
|
||||
if (!c)
|
||||
|
@ -891,13 +931,15 @@ ResponseCode Server_ProtocolHandler::cmdSetCounter(Command_SetCounter *cmd, Comm
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdDelCounter(Command_DelCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdDelCounter(Command_DelCounter *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
if (!player->deleteCounter(cmd->getCounterId()))
|
||||
return RespNameNotFound;
|
||||
|
@ -905,25 +947,29 @@ ResponseCode Server_ProtocolHandler::cmdDelCounter(Command_DelCounter *cmd, Comm
|
|||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdNextTurn(Command_NextTurn * /*cmd*/, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdNextTurn(Command_NextTurn * /*cmd*/, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
game->nextTurn();
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdSetActivePhase(Command_SetActivePhase *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdSetActivePhase(Command_SetActivePhase *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (player->getSpectator())
|
||||
return RespFunctionNotAllowed;
|
||||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
if (game->getActivePlayer() != player->getPlayerId())
|
||||
return RespContextError;
|
||||
|
@ -981,10 +1027,12 @@ ResponseCode Server_ProtocolHandler::cmdDumpZone(Command_DumpZone *cmd, CommandC
|
|||
return RespNothing;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdStopDumpZone(Command_StopDumpZone *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||
ResponseCode Server_ProtocolHandler::cmdStopDumpZone(Command_StopDumpZone *cmd, CommandContainer * /*cont*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_Player *otherPlayer = game->getPlayer(cmd->getPlayerId());
|
||||
if (!otherPlayer)
|
||||
|
@ -1007,6 +1055,8 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(Command_RevealCards *cmd, Co
|
|||
|
||||
if (!game->getGameStarted())
|
||||
return RespGameNotStarted;
|
||||
if (player->getConceded())
|
||||
return RespContextError;
|
||||
|
||||
Server_Player *otherPlayer = 0;
|
||||
if (cmd->getPlayerId() != -1) {
|
||||
|
|
Loading…
Reference in a new issue