new protocol code

This commit is contained in:
Max-Wilhelm Bruker 2010-02-26 17:28:02 +01:00
parent ba8d40211c
commit 888a64b0fd
25 changed files with 487 additions and 333 deletions

View file

@ -32,48 +32,48 @@ private:
virtual DeckList *getDeckFromDatabase(int deckId) = 0;
ResponseCode cmdPing(Command_Ping *cmd);
ResponseCode cmdLogin(Command_Login *cmd);
virtual ResponseCode cmdDeckList(Command_DeckList *cmd) = 0;
virtual ResponseCode cmdDeckNewDir(Command_DeckNewDir *cmd) = 0;
virtual ResponseCode cmdDeckDelDir(Command_DeckDelDir *cmd) = 0;
virtual ResponseCode cmdDeckDel(Command_DeckDel *cmd) = 0;
virtual ResponseCode cmdDeckUpload(Command_DeckUpload *cmd) = 0;
virtual ResponseCode cmdDeckDownload(Command_DeckDownload *cmd) = 0;
ResponseCode cmdListChatChannels(Command_ListChatChannels *cmd);
ResponseCode cmdChatJoinChannel(Command_ChatJoinChannel *cmd);
ResponseCode cmdChatLeaveChannel(Command_ChatLeaveChannel *cmd, Server_ChatChannel *channel);
ResponseCode cmdChatSay(Command_ChatSay *cmd, Server_ChatChannel *channel);
ResponseCode cmdListGames(Command_ListGames *cmd);
ResponseCode cmdCreateGame(Command_CreateGame *cmd);
ResponseCode cmdJoinGame(Command_JoinGame *cmd);
ResponseCode cmdLeaveGame(Command_LeaveGame *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdConcede(Command_Concede *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdReadyStart(Command_ReadyStart *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdDeckSelect(Command_DeckSelect *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdSay(Command_Say *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdShuffle(Command_Shuffle *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdMulligan(Command_Mulligan *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdRollDie(Command_RollDie *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdPing(Command_Ping *cmd, CommandContainer *cont);
ResponseCode cmdLogin(Command_Login *cmd, CommandContainer *cont);
virtual ResponseCode cmdDeckList(Command_DeckList *cmd, CommandContainer *cont) = 0;
virtual ResponseCode cmdDeckNewDir(Command_DeckNewDir *cmd, CommandContainer *cont) = 0;
virtual ResponseCode cmdDeckDelDir(Command_DeckDelDir *cmd, CommandContainer *cont) = 0;
virtual ResponseCode cmdDeckDel(Command_DeckDel *cmd, CommandContainer *cont) = 0;
virtual ResponseCode cmdDeckUpload(Command_DeckUpload *cmd, CommandContainer *cont) = 0;
virtual ResponseCode cmdDeckDownload(Command_DeckDownload *cmd, CommandContainer *cont) = 0;
ResponseCode cmdListChatChannels(Command_ListChatChannels *cmd, CommandContainer *cont);
ResponseCode cmdChatJoinChannel(Command_ChatJoinChannel *cmd, CommandContainer *cont);
ResponseCode cmdChatLeaveChannel(Command_ChatLeaveChannel *cmd, CommandContainer *cont, Server_ChatChannel *channel);
ResponseCode cmdChatSay(Command_ChatSay *cmd, CommandContainer *cont, Server_ChatChannel *channel);
ResponseCode cmdListGames(Command_ListGames *cmd, CommandContainer *cont);
ResponseCode cmdCreateGame(Command_CreateGame *cmd, CommandContainer *cont);
ResponseCode cmdJoinGame(Command_JoinGame *cmd, CommandContainer *cont);
ResponseCode cmdLeaveGame(Command_LeaveGame *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdConcede(Command_Concede *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdReadyStart(Command_ReadyStart *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdDeckSelect(Command_DeckSelect *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdSay(Command_Say *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdShuffle(Command_Shuffle *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdMulligan(Command_Mulligan *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdRollDie(Command_RollDie *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
// XXX Maybe the following function and others belong into Server_Player
ResponseCode drawCards(Server_Game *game, Server_Player *player, int number);
ResponseCode cmdDrawCards(Command_DrawCards *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdDrawCards(Command_DrawCards *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode moveCard(Server_Game *game, Server_Player *player, const QString &_startZone, int _cardId, const QString &_targetZone, int _x, int _y, bool _faceDown);
ResponseCode cmdMoveCard(Command_MoveCard *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdCreateToken(Command_CreateToken *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdCreateArrow(Command_CreateArrow *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdDeleteArrow(Command_DeleteArrow *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdSetCardAttr(Command_SetCardAttr *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdIncCounter(Command_IncCounter *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdCreateCounter(Command_CreateCounter *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdSetCounter(Command_SetCounter *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdDelCounter(Command_DelCounter *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdNextTurn(Command_NextTurn *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdSetActivePhase(Command_SetActivePhase *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdDumpZone(Command_DumpZone *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdStopDumpZone(Command_StopDumpZone *cmd, Server_Game *game, Server_Player *player);
ResponseCode cmdMoveCard(Command_MoveCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdCreateToken(Command_CreateToken *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdCreateArrow(Command_CreateArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdDeleteArrow(Command_DeleteArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdSetCardAttr(Command_SetCardAttr *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdIncCounter(Command_IncCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdCreateCounter(Command_CreateCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdSetCounter(Command_SetCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdDelCounter(Command_DelCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdNextTurn(Command_NextTurn *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdSetActivePhase(Command_SetActivePhase *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdDumpZone(Command_DumpZone *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
ResponseCode cmdStopDumpZone(Command_StopDumpZone *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
void processCommandHelper(Command *command);
ResponseCode processCommandHelper(Command *command, CommandContainer *cont);
private slots:
void pingClockTimeout();
public:
@ -86,7 +86,7 @@ public:
const QString &getPlayerName() const { return playerName; }
const QDateTime &getLastCommandTime() const { return lastCommandTime; }
void processCommand(Command *command);
void processCommandContainer(CommandContainer *cont);
virtual void sendProtocolItem(ProtocolItem *item, bool deleteItem = true) = 0;
void enqueueProtocolItem(ProtocolItem *item);
};