This closes feature request 0000020. Attention, this breaks protocol compatibility.

This commit is contained in:
Max-Wilhelm Bruker 2010-06-03 02:29:48 +02:00
parent cfd715cce9
commit 41c4603fe9
12 changed files with 87 additions and 13 deletions

View file

@ -47,7 +47,7 @@ class ProtocolItem : public SerializableItem_Map {
private:
static void initializeHashAuto();
public:
static const int protocolVersion = 6;
static const int protocolVersion = 7;
static void initializeHash();
virtual int getItemId() const = 0;
ProtocolItem(const QString &_itemType, const QString &_itemSubType);

View file

@ -147,9 +147,10 @@ Command_SetCardAttr::Command_SetCardAttr(int _gameId, const QString &_zone, int
insertItem(new SerializableItem_String("attr_name", _attrName));
insertItem(new SerializableItem_String("attr_value", _attrValue));
}
Command_ReadyStart::Command_ReadyStart(int _gameId)
Command_ReadyStart::Command_ReadyStart(int _gameId, bool _ready)
: GameCommand("ready_start", _gameId)
{
insertItem(new SerializableItem_Bool("ready", _ready));
}
Command_Concede::Command_Concede(int _gameId)
: GameCommand("concede", _gameId)

View file

@ -23,7 +23,7 @@
2:create_arrow:i,start_player_id:s,start_zone:i,start_card_id:i,target_player_id:s,target_zone:i,target_card_id:c,color
2:delete_arrow:i,arrow_id
2:set_card_attr:s,zone:i,card_id:s,attr_name:s,attr_value
2:ready_start
2:ready_start:b,ready
2:concede
2:inc_counter:i,counter_id:i,delta
2:create_counter:s,counter_name:c,color:i,radius:i,value

View file

@ -227,7 +227,8 @@ public:
class Command_ReadyStart : public GameCommand {
Q_OBJECT
public:
Command_ReadyStart(int _gameId = -1);
Command_ReadyStart(int _gameId = -1, bool _ready = false);
bool getReady() const { return static_cast<SerializableItem_Bool *>(itemMap.value("ready"))->getData(); };
static SerializableItem *newItem() { return new Command_ReadyStart; }
int getItemId() const { return ItemId_Command_ReadyStart; }
};

View file

@ -365,6 +365,8 @@ ResponseCode Server_ProtocolHandler::cmdSetSideboardPlan(Command_SetSideboardPla
{
if (player->getSpectator())
return RespFunctionNotAllowed;
if (player->getReadyStart())
return RespContextError;
DeckList *deck = player->getDeck();
if (!deck)
@ -385,7 +387,7 @@ ResponseCode Server_ProtocolHandler::cmdConcede(Command_Concede * /*cmd*/, Comma
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;
@ -393,7 +395,10 @@ ResponseCode Server_ProtocolHandler::cmdReadyStart(Command_ReadyStart * /*cmd*/,
if (!player->getDeck())
return RespContextError;
player->setReadyStart(true);
if (player->getReadyStart() == cmd->getReady())
return RespContextError;
player->setReadyStart(cmd->getReady());
game->sendGameEvent(new Event_PlayerPropertiesChanged(player->getProperties()), new Context_ReadyStart);
game->startGameIfReady();
return RespOk;