mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-21 23:00:24 -08:00
decklist transfer code
This commit is contained in:
@@ -67,6 +67,7 @@ void Server_ProtocolHandler::processCommand(Command *command)
|
||||
Server_Player *player = gamePair.second;
|
||||
|
||||
switch (command->getItemId()) {
|
||||
case ItemId_Command_DeckSelect: response = cmdDeckSelect(qobject_cast<Command_DeckSelect *>(command), game, player); break;
|
||||
case ItemId_Command_LeaveGame: response = cmdLeaveGame(qobject_cast<Command_LeaveGame *>(command), game, player); break;
|
||||
case ItemId_Command_Say: response = cmdSay(qobject_cast<Command_Say *>(command), game, player); break;
|
||||
case ItemId_Command_Shuffle: response = cmdShuffle(qobject_cast<Command_Shuffle *>(command), game, player); break;
|
||||
@@ -87,7 +88,6 @@ void Server_ProtocolHandler::processCommand(Command *command)
|
||||
case ItemId_Command_DumpZone: response = cmdDumpZone(qobject_cast<Command_DumpZone *>(command), game, player); break;
|
||||
case ItemId_Command_StopDumpZone: response = cmdStopDumpZone(qobject_cast<Command_StopDumpZone *>(command), game, player); break;
|
||||
case ItemId_Command_DumpAll: response = cmdDumpAll(qobject_cast<Command_DumpAll *>(command), game, player); break;
|
||||
case ItemId_Command_SubmitDeck: response = cmdSubmitDeck(qobject_cast<Command_SubmitDeck *>(command), game, player); break;
|
||||
}
|
||||
} else {
|
||||
qDebug() << "received generic Command";
|
||||
@@ -245,6 +245,27 @@ ResponseCode Server_ProtocolHandler::cmdLeaveGame(Command_LeaveGame * /*cmd*/, S
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
DeckList *deck;
|
||||
if (cmd->getDeckId() == -1) {
|
||||
if (!cmd->getDeck())
|
||||
return RespInvalidData;
|
||||
deck = cmd->getDeck();
|
||||
} else {
|
||||
try {
|
||||
deck = getDeckFromDatabase(cmd->getDeckId());
|
||||
} catch(ResponseCode r) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
player->setDeck(deck);
|
||||
|
||||
game->sendGameEvent(new Event_DeckSelect(-1, player->getPlayerId(), cmd->getDeckId()));
|
||||
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdSay(Command_Say *cmd, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
game->sendGameEvent(new Event_Say(-1, player->getPlayerId(), cmd->getMessage()));
|
||||
@@ -468,6 +489,9 @@ ResponseCode Server_ProtocolHandler::cmdSetCardAttr(Command_SetCardAttr *cmd, Se
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdReadyStart(Command_ReadyStart * /*cmd*/, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
if (!player->getDeck())
|
||||
return RespContextError;
|
||||
|
||||
player->setStatus(StatusReadyStart);
|
||||
game->sendGameEvent(new Event_ReadyStart(-1, player->getPlayerId()));
|
||||
game->startGameIfReady();
|
||||
@@ -570,8 +594,3 @@ ResponseCode Server_ProtocolHandler::cmdDumpAll(Command_DumpAll *cmd, Server_Gam
|
||||
{
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
ResponseCode Server_ProtocolHandler::cmdSubmitDeck(Command_SubmitDeck *cmd, Server_Game *game, Server_Player *player)
|
||||
{
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user