mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -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
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue