added responses + events

This commit is contained in:
Max-Wilhelm Bruker 2011-12-29 19:40:41 +01:00
parent 26f0f0df0e
commit ca9122b9fb
84 changed files with 815 additions and 1482 deletions

View file

@ -13,6 +13,7 @@ unix:!macx {
} else {
QT += multimedia
}
QT += multimedia
HEADERS += src/abstractcounter.h \
src/counter_general.h \

View file

@ -0,0 +1,7 @@
import "game_event_context.proto";
message Context_Concede {
extend GameEventContext {
optional Context_Concede ext = 1001;
}
}

View file

@ -0,0 +1,8 @@
import "game_event_context.proto";
message Context_DeckSelect {
extend GameEventContext {
optional Context_DeckSelect ext = 1002;
}
optional string deck_hash = 1;
}

View file

@ -0,0 +1,7 @@
import "game_event_context.proto";
message Context_MoveCard {
extend GameEventContext {
optional Context_MoveCard ext = 1004;
}
}

View file

@ -0,0 +1,8 @@
import "game_event_context.proto";
message Context_Mulligan {
extend GameEventContext {
optional Context_Mulligan ext = 1005;
}
optional uint32 number = 1;
}

View file

@ -0,0 +1,7 @@
import "game_event_context.proto";
message Context_ReadyStart {
extend GameEventContext {
optional Context_ReadyStart ext = 1000;
}
}

View file

@ -0,0 +1,7 @@
import "game_event_context.proto";
message Context_UndoDraw {
extend GameEventContext {
optional Context_UndoDraw ext = 1003;
}
}

View file

@ -0,0 +1,10 @@
import "session_event.proto";
import "serverinfo_user.proto";
message Event_AddToList {
extend SessionEvent {
optional Event_AddToList ext = 1005;
}
optional string list_name = 1;
optional ServerInfo_User user_info = 2;
}

View file

@ -0,0 +1,12 @@
import "game_event.proto";
message Event_AttachCard {
extend GameEvent {
optional Event_AttachCard ext = 2012;
}
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;
}

View file

@ -0,0 +1,8 @@
import "session_event.proto";
message Event_ConnectionClosed {
extend SessionEvent {
optional Event_ConnectionClosed ext = 1002;
}
optional string reason = 1;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_ConnectionStateChanged {
extend GameEvent {
optional Event_ConnectionStateChanged ext = 1006;
}
optional bool connected = 1;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
import "serverinfo_arrow.proto";
message Event_CreateArrows {
extend GameEvent {
optional Event_CreateArrows ext = 2000;
}
repeated ServerInfo_Arrow arrow_list = 1;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
import "serverinfo_counter.proto";
message Event_CreateCounters {
extend GameEvent {
optional Event_CreateCounters ext = 2002;
}
repeated ServerInfo_Counter counter_list = 1;
}

View file

@ -0,0 +1,16 @@
import "game_event.proto";
message Event_CreateToken {
extend GameEvent {
optional Event_CreateToken ext = 2013;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional string card_name = 3;
optional string color = 4;
optional string pt = 5;
optional string annotation = 6;
optional bool destroy_on_zone_change = 7;
optional sint32 x = 8;
optional sint32 y = 9;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_DelCounter {
extend GameEvent {
optional Event_DelCounter ext = 2004;
}
optional sint32 counter_id = 1;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_DeleteArrow {
extend GameEvent {
optional Event_DeleteArrow ext = 2001;
}
optional sint32 arrow_id = 1;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
message Event_DestroyCard {
extend GameEvent {
optional Event_DestroyCard ext = 2011;
}
optional string zone_name = 1;
optional uint32 card_id = 2;
}

View file

@ -0,0 +1,10 @@
import "game_event.proto";
import "serverinfo_card.proto";
message Event_DrawCards {
extend GameEvent {
optional Event_DrawCards ext = 2005;
}
optional sint32 number = 1;
repeated ServerInfo_Card cards = 2;
}

View file

@ -0,0 +1,10 @@
import "game_event.proto";
message Event_DumpZone {
extend GameEvent {
optional Event_DumpZone ext = 2018;
}
optional sint32 zone_owner_id = 1;
optional string zone_name = 2;
optional sint32 number_cards = 3;
}

View file

@ -0,0 +1,11 @@
import "game_event.proto";
message Event_FlipCard {
extend GameEvent {
optional Event_FlipCard ext = 2010;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional string card_name = 3;
optional bool face_down = 4;
}

View file

@ -0,0 +1,7 @@
import "game_event.proto";
message Event_GameClosed {
extend GameEvent {
optional Event_GameClosed ext = 1002;
}
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_GameHostChanged {
extend GameEvent {
optional Event_GameHostChanged ext = 1003;
}
}

View file

@ -0,0 +1,15 @@
import "session_event.proto";
message Event_GameJoined {
extend SessionEvent {
optional Event_GameJoined ext = 1009;
}
optional sint32 game_id = 1;
optional string game_description = 2;
optional sint32 host_id = 3;
optional sint32 player_id = 4;
optional bool spectator = 5;
optional bool spectators_can_talk = 6;
optional bool spectators_see_everything = 7;
optional bool resuming = 8;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_GameSay {
extend GameEvent {
optional Event_GameSay ext = 1009;
}
optional string message = 1;
}

View file

@ -0,0 +1,12 @@
import "game_event.proto";
import "serverinfo_player.proto";
message Event_GameStateChanged {
extend GameEvent {
optional Event_GameStateChanged ext = 1005;
}
repeated ServerInfo_Player player_list = 1;
optional bool game_started = 2;
optional sint32 active_player_id = 3;
optional sint32 active_phase = 4;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
import "serverinfo_playerproperties.proto";
message Event_Join {
extend GameEvent {
optional Event_Join ext = 1000;
}
optional ServerInfo_PlayerProperties player_properties = 1;
}

View file

@ -0,0 +1,9 @@
import "room_event.proto";
import "serverinfo_user.proto";
message Event_JoinRoom {
extend RoomEvent {
optional Event_JoinRoom ext = 1001;
}
optional ServerInfo_User user_info = 1;
}

View file

@ -0,0 +1,7 @@
import "game_event.proto";
message Event_Kicked {
extend GameEvent {
optional Event_Kicked ext = 1004;
}
}

View file

@ -0,0 +1,7 @@
import "game_event.proto";
message Event_Leave {
extend GameEvent {
optional Event_Leave ext = 1001;
}
}

View file

@ -0,0 +1,11 @@
import "room_event.proto";
message Event_LeaveRoom {
extend RoomEvent {
optional Event_LeaveRoom ext = 1000;
}
optional string name = 1;
}

View file

@ -0,0 +1,9 @@
import "room_event.proto";
import "serverinfo_game.proto";
message Event_ListGames {
extend RoomEvent {
optional Event_ListGames ext = 1003;
}
repeated ServerInfo_Game game_list = 1;
}

View file

@ -0,0 +1,9 @@
import "session_event.proto";
import "serverinfo_room.proto";
message Event_ListRooms {
extend SessionEvent {
optional Event_ListRooms ext = 1004;
}
repeated ServerInfo_Room room_list = 1;
}

View file

@ -0,0 +1,17 @@
import "game_event.proto";
message Event_MoveCard {
extend GameEvent {
optional Event_MoveCard ext = 2009;
}
optional sint32 card_id = 1;
optional string card_name = 2;
optional string start_zone = 3;
optional sint32 position = 4;
optional sint32 target_player_id = 5;
optional string target_zone = 6;
optional sint32 x = 7;
optional sint32 y = 8;
optional sint32 new_card_id = 9;
optional bool face_down = 10;
}

View file

@ -0,0 +1,10 @@
import "game_event.proto";
import "serverinfo_playerping.proto";
message Event_Ping {
extend GameEvent {
optional Event_Ping ext = 1008;
}
optional uint32 seconds_elapsed = 1;
repeated ServerInfo_PlayerPing ping_list = 2;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
import "serverinfo_playerproperties.proto";
message Event_PlayerPropertiesChanged {
extend GameEvent {
optional Event_PlayerPropertiesChanged ext = 1007;
}
optional ServerInfo_PlayerProperties player_properties = 1;
}

View file

@ -0,0 +1,9 @@
import "session_event.proto";
message Event_RemoveFromList {
extend SessionEvent {
optional Event_RemoveFromList ext = 1006;
}
optional string list_name = 1;
optional string user_name = 2;
}

View file

@ -0,0 +1,12 @@
import "game_event.proto";
import "serverinfo_card.proto";
message Event_RevealCards {
extend GameEvent {
optional Event_RevealCards ext = 2006;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional sint32 other_player_id = 3;
repeated ServerInfo_Card cards = 4;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
message Event_RollDie {
extend GameEvent {
optional Event_RollDie ext = 2008;
}
optional uint32 sides = 1;
optional uint32 value = 2;
}

View file

@ -0,0 +1,9 @@
import "room_event.proto";
message Event_RoomSay {
extend RoomEvent {
optional Event_RoomSay ext = 1002;
}
optional string name = 1;
optional string message = 2;
}

View file

@ -0,0 +1,8 @@
import "session_event.proto";
message Event_ServerMessage {
extend SessionEvent {
optional Event_ServerMessage ext = 1000;
}
optional string message = 1;
}

View file

@ -0,0 +1,9 @@
import "session_event.proto";
message Event_ServerShutdown {
extend SessionEvent {
optional Event_ServerShutdown ext = 1001;
}
optional string reason = 1;
optional uint32 minutes = 2;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_SetActivePhase {
extend GameEvent {
optional Event_SetActivePhase ext = 2017;
}
optional sint32 phase = 1;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
message Event_SetActivePlayer {
extend GameEvent {
optional Event_SetActivePlayer ext = 2016;
}
optional sint32 active_player_id = 1;
}

View file

@ -0,0 +1,11 @@
import "game_event.proto";
message Event_SetCardAttr {
extend GameEvent {
optional Event_SetCardAttr ext = 2014;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional string attr_name = 3;
optional string attr_value = 4;
}

View file

@ -0,0 +1,11 @@
import "game_event.proto";
message Event_SetCardCounter {
extend GameEvent {
optional Event_SetCardCounter ext = 2015;
}
optional string zone_name = 1;
optional sint32 card_id = 2;
optional sint32 counter_id = 3;
optional sint32 counter_value = 4;
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
message Event_SetCounter {
extend GameEvent {
optional Event_SetCounter ext = 2003;
}
optional sint32 counter_id = 1;
optional sint32 value = 2;
}

View file

@ -0,0 +1,7 @@
import "game_event.proto";
message Event_Shuffle {
extend GameEvent {
optional Event_Shuffle ext = 2007;
}
}

View file

@ -0,0 +1,9 @@
import "game_event.proto";
message Event_StopDumpZone {
extend GameEvent {
optional Event_StopDumpZone ext = 2019;
}
optional sint32 zone_owner_id = 1;
optional string zone_name = 2;
}

View file

@ -0,0 +1,9 @@
import "session_event.proto";
import "serverinfo_user.proto";
message Event_UserJoined {
extend SessionEvent {
optional Event_UserJoined ext = 1007;
}
optional ServerInfo_User user_info = 1;
}

View file

@ -0,0 +1,8 @@
import "session_event.proto";
message Event_UserLeft {
extend SessionEvent {
optional Event_UserLeft ext = 1008;
}
optional string name = 1;
}

View file

@ -0,0 +1,10 @@
import "session_event.proto";
message Event_UserMessage {
extend SessionEvent {
optional Event_UserMessage ext = 1003;
}
optional string sender_name = 1;
optional string receiver_name = 2;
optional string message = 3;
}

View file

@ -0,0 +1,36 @@
message GameEvent {
enum GameEventType {
JOIN = 1000;
LEAVE = 1001;
GAME_CLOSED = 1002;
GAME_HOST_CHANGED = 1003;
KICKED = 1004;
GAME_STATE_CHANGED = 1005;
CONNECTION_STATE_CHANGED = 1006;
PLAYER_PROPERTIES_CHANGED = 1007;
PING = 1008;
GAME_SAY = 1009;
CREATE_ARROWS = 2000;
DELETE_ARROW = 2001;
CREATE_COUNTERS = 2002;
SET_COUNTER = 2003;
DEL_COUNTER = 2004;
DRAW_CARDS = 2005;
REVEAL_CARDS = 2006;
SHUFFLE = 2007;
ROLL_DIE = 2008;
MOVE_CARD = 2009;
FLIP_CARD = 2010;
DESTROY_CARD = 2011;
ATTACH_CARD = 2012;
CREATE_TOKEN = 2013;
SET_CARD_ATTR = 2014;
SET_CARD_COUNTER = 2015;
SET_ACTIVE_PLAYER = 2016;
SET_ACTIVE_PHASE = 2017;
DUMP_ZONE = 2018;
STOP_DUMP_ZONE = 2019;
}
optional sint32 player_id = 1;
extensions 100 to max;
}

View file

@ -0,0 +1,8 @@
import "game_event.proto";
import "game_event_context.proto";
message GameEventContainer {
optional uint32 game_id = 1;
repeated GameEvent event_list = 2;
optional GameEventContext context = 3;
}

View file

@ -0,0 +1,11 @@
message GameEventContext {
enum ContextType {
READY_START = 1000;
CONCEDE = 1001;
DECK_SELECT = 1002;
UNDO_DRAW = 1003;
MOVE_CARD = 1004;
MULLIGAN = 1005;
}
extensions 100 to max;
}

View file

@ -0,0 +1,38 @@
message Response {
enum ResponseCode {
RespNothing = 0;
RespOk = 1;
RespNotInRoom = 2;
RespInternalError = 3;
RespInvalidCommand = 4;
RespInvalidData = 5;
RespNameNotFound = 6;
RespLoginNeeded = 7;
RespFunctionNotAllowed = 8;
RespGameNotStarted = 9;
RespGameFull = 10;
RespContextError = 11;
RespWrongPassword = 12;
RespSpectatorsNotAllowed = 13;
RespOnlyBuddies = 14;
RespUserLevelTooLow = 15;
RespInIgnoreList = 16;
RespWouldOverwriteOldSession = 17;
RespChatFlood = 18;
}
enum ResponseType {
JOIN_ROOM = 1000;
LIST_USERS = 1001;
GET_GAMES_OF_USER = 1002;
GET_USER_INFO = 1003;
DUMP_ZONE = 1004;
LOGIN = 1005;
DECK_LIST = 1006;
DECK_DOWNLOAD = 1007;
DECK_UPLOAD = 1008;
}
required uint64 cmd_id = 1;
optional ResponseCode response_code = 2;
extensions 100 to max;
}

View file

@ -0,0 +1,9 @@
import "response.proto";
import "serverinfo_zone.proto";
message Response_DumpZone {
extend Response {
optional Response_DumpZone ext = 1004;
}
optional ServerInfo_Zone zone_info = 1;
}

View file

@ -0,0 +1,12 @@
import "response.proto";
import "serverinfo_game.proto";
import "serverinfo_room.proto";
message Response_GetGamesOfUser {
extend Response {
optional Response_GetGamesOfUser ext = 1002;
}
repeated ServerInfo_Room room_list = 1;
repeated ServerInfo_Game game_list = 2;
}

View file

@ -0,0 +1,11 @@
import "response.proto";
import "serverinfo_user.proto";
message Response_GetUserInfo {
extend Response {
optional Response_GetUserInfo ext = 1003;
}
optional ServerInfo_User user_info = 1;
}

View file

@ -0,0 +1,9 @@
import "response.proto";
import "serverinfo_room.proto";
message Response_JoinRoom {
extend Response {
optional Response_JoinRoom ext = 1000;
}
optional ServerInfo_Room room_info = 1;
}

View file

@ -0,0 +1,10 @@
import "response.proto";
import "serverinfo_user.proto";
message Response_ListUsers {
extend Response {
optional Response_ListUsers ext = 1001;
}
repeated ServerInfo_User user_list = 1;
}

View file

@ -0,0 +1,11 @@
import "response.proto";
import "serverinfo_user.proto";
message Response_Login {
extend Response {
optional Response_Login ext = 1005;
}
optional ServerInfo_User user_info = 1;
repeated ServerInfo_User buddy_list = 2;
repeated ServerInfo_User ignore_list = 3;
}

View file

@ -0,0 +1,10 @@
message RoomEvent {
enum RoomEventType {
LEAVE_ROOM = 1000;
JOIN_ROOM = 1001;
ROOM_SAY = 1002;
LIST_GAMES = 1003;
}
optional sint32 room_id = 1;
extensions 100 to max;
}

View file

@ -0,0 +1,17 @@
import "response.proto";
import "session_event.proto";
import "game_event_container.proto";
import "room_event.proto";
message ServerMessage {
enum MessageType {
RESPONSE = 0;
SESSION_EVENT = 1;
GAME_EVENT_CONTAINER = 2;
ROOM_EVENT = 3;
}
optional Response response = 1;
optional SessionEvent session_event = 2;
optional GameEventContainer game_event_container = 3;
optional RoomEvent room_event = 4;
}

View file

@ -0,0 +1,12 @@
import "color.proto";
message ServerInfo_Arrow {
optional sint32 id = 1;
optional sint32 start_player_id = 2;
optional string start_zone = 3;
optional sint32 start_card_id = 4;
optional sint32 target_player_id = 5;
optional string target_zone = 6;
optional sint32 target_card_id = 7;
optional color arrow_color = 8;
}

View file

@ -0,0 +1,20 @@
import "serverinfo_cardcounter.proto";
message ServerInfo_Card {
optional sint32 id = 1;
optional string name = 2;
optional sint32 x = 3;
optional sint32 y = 4;
optional bool face_down = 5;
optional bool tapped = 6;
optional bool attacking = 7;
optional string color = 8;
optional string pt = 9;
optional string annotation = 10;
optional bool destroy_on_zone_change = 11;
optional bool doesnt_untap = 12;
repeated ServerInfo_CardCounter counter_list = 13;
optional sint32 attach_player_id = 14;
optional string attach_zone = 15;
optional sint32 attach_card_id = 16;
}

View file

@ -0,0 +1,4 @@
message ServerInfo_CardCounter {
optional sint32 id = 1;
optional sint32 value = 2;
}

View file

@ -0,0 +1,9 @@
import "color.proto";
message ServerInfo_Counter {
optional sint32 id = 1;
optional string name = 2;
optional color counter_color = 3;
optional sint32 radius = 4;
optional sint32 count = 5;
}

View file

@ -0,0 +1,18 @@
import "serverinfo_user.proto";
message ServerInfo_Game {
optional sint32 room_id = 1;
optional sint32 game_id = 2;
optional string description = 3;
optional bool with_password = 4;
optional uint32 player_count = 5;
optional uint32 max_players = 6;
optional bool started = 7;
repeated sint32 game_types = 8;
optional ServerInfo_User creator_info = 9;
optional bool only_buddies = 10;
optional bool only_registered = 11;
optional bool spectators_allowed = 12;
optional bool spectators_need_password = 13;
optional uint32 spectators_count = 14;
}

View file

@ -0,0 +1,5 @@
message ServerInfo_GameType {
optional sint32 game_type_id = 1;
optional string description = 2;
};

View file

@ -0,0 +1,12 @@
import "serverinfo_zone.proto";
import "serverinfo_counter.proto";
import "serverinfo_arrow.proto";
import "serverinfo_playerproperties.proto";
message ServerInfo_Player {
optional ServerInfo_PlayerProperties properties = 1;
optional string deck_list = 2;
repeated ServerInfo_Zone zone_list = 3;
repeated ServerInfo_Counter counter_list = 4;
repeated ServerInfo_Arrow arrow_list = 5;
}

View file

@ -0,0 +1,4 @@
message ServerInfo_PlayerPing {
optional sint32 player_id = 1;
optional sint32 ping_time = 2;
}

View file

@ -0,0 +1,10 @@
import "serverinfo_user.proto";
message ServerInfo_PlayerProperties {
optional sint32 player_id = 1;
optional ServerInfo_User user_info = 2;
optional bool spectator = 3;
optional bool conceded = 4;
optional bool ready_start = 5;
optional string deck_hash = 6;
}

View file

@ -0,0 +1,15 @@
import "serverinfo_game.proto";
import "serverinfo_user.proto";
import "serverinfo_gametype.proto";
message ServerInfo_Room {
optional sint32 room_id = 1;
optional string name = 2;
optional string description = 3;
optional uint32 game_count = 4;
optional uint32 player_count = 5;
optional bool auto_join = 6;
repeated ServerInfo_Game game_list = 7;
repeated ServerInfo_User user_list = 8;
repeated ServerInfo_GameType gametype_list = 9;
}

View file

@ -0,0 +1,21 @@
message ServerInfo_User {
enum UserLevelFlags {
IsNothing = 0;
IsUser = 1;
IsRegistered = 2;
IsModerator = 4;
IsAdmin = 8;
};
enum Gender {
GenderUnknown = -1;
Male = 0;
Female = 1;
};
optional string name = 1;
optional uint32 user_level = 2;
optional string address = 3;
optional string real_name = 4;
optional Gender gender = 5;
optional string country = 6;
optional bytes avatar_bmp = 7;
}

View file

@ -0,0 +1,14 @@
import "serverinfo_card.proto";
message ServerInfo_Zone {
enum ZoneType {
PrivateZone = 0;
PublicZone = 1;
HiddenZone = 2;
}
optional string name = 1;
optional ZoneType type = 2;
optional bool with_coords = 3;
optional sint32 card_count = 4;
repeated ServerInfo_Card card_list = 5;
}

View file

@ -0,0 +1,15 @@
message SessionEvent {
enum SessionEventType {
SERVER_MESSAGE = 1000;
SERVER_SHUTDOWN = 1001;
CONNECTION_CLOSED = 1002;
USER_MESSAGE = 1003;
LIST_ROOMS = 1004;
ADD_TO_LIST = 1005;
REMOVE_FROM_LIST = 1006;
USER_JOINED = 1007;
USER_LEFT = 1008;
GAME_JOINED = 1009;
}
extensions 100 to max;
}

View file

@ -1,8 +1,6 @@
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include "protocol.h"
#include "protocol_items.h"
#include "decklist.h"
ProtocolItem::ProtocolItem(const QString &_itemType, const QString &_itemSubType)
: SerializableItem_Map(_itemType, _itemSubType), receiverMayDelete(true)
@ -10,90 +8,6 @@ ProtocolItem::ProtocolItem(const QString &_itemType, const QString &_itemSubType
}
void ProtocolItem::initializeHash()
{
initializeHashAuto();
registerSerializableItem("move_card_to_zone", MoveCardToZone::newItem);
registerSerializableItem("room", ServerInfo_Room::newItem);
registerSerializableItem("user", ServerInfo_User::newItem);
registerSerializableItem("game", ServerInfo_Game::newItem);
registerSerializableItem("game_type", ServerInfo_GameType::newItem);
registerSerializableItem("card_counter", ServerInfo_CardCounter::newItem);
registerSerializableItem("card", ServerInfo_Card::newItem);
registerSerializableItem("zone", ServerInfo_Zone::newItem);
registerSerializableItem("counter", ServerInfo_Counter::newItem);
registerSerializableItem("arrow", ServerInfo_Arrow::newItem);
registerSerializableItem("player_properties", ServerInfo_PlayerProperties::newItem);
registerSerializableItem("player", ServerInfo_Player::newItem);
registerSerializableItem("player_ping", ServerInfo_PlayerPing::newItem);
registerSerializableItem("file", DeckList_File::newItem);
registerSerializableItem("directory", DeckList_Directory::newItem);
registerSerializableItem("game_type_id", GameTypeId::newItem);
registerSerializableItem("containergame_event", GameEventContainer::newItem);
registerSerializableItem("resp", ProtocolResponse::newItem);
ProtocolResponse::initializeHash();
registerSerializableItem("respjoin_room", Response_JoinRoom::newItem);
registerSerializableItem("resplist_users", Response_ListUsers::newItem);
registerSerializableItem("respget_games_of_user", Response_GetGamesOfUser::newItem);
registerSerializableItem("respget_user_info", Response_GetUserInfo::newItem);
registerSerializableItem("respdeck_list", Response_DeckList::newItem);
registerSerializableItem("respdeck_download", Response_DeckDownload::newItem);
registerSerializableItem("respdeck_upload", Response_DeckUpload::newItem);
registerSerializableItem("respdump_zone", Response_DumpZone::newItem);
registerSerializableItem("resplogin", Response_Login::newItem);
registerSerializableItem("room_eventlist_games", Event_ListGames::newItem);
registerSerializableItem("room_eventjoin_room", Event_JoinRoom::newItem);
registerSerializableItem("generic_eventadd_to_list", Event_AddToList::newItem);
registerSerializableItem("generic_eventuser_joined", Event_UserJoined::newItem);
registerSerializableItem("generic_eventlist_rooms", Event_ListRooms::newItem);
registerSerializableItem("game_eventjoin", Event_Join::newItem);
registerSerializableItem("game_eventgame_state_changed", Event_GameStateChanged::newItem);
registerSerializableItem("game_eventplayer_properties_changed", Event_PlayerPropertiesChanged::newItem);
registerSerializableItem("game_eventcreate_arrows", Event_CreateArrows::newItem);
registerSerializableItem("game_eventcreate_counters", Event_CreateCounters::newItem);
registerSerializableItem("game_eventdraw_cards", Event_DrawCards::newItem);
registerSerializableItem("game_eventreveal_cards", Event_RevealCards::newItem);
registerSerializableItem("game_eventping", Event_Ping::newItem);
}
TopLevelProtocolItem::TopLevelProtocolItem()
: SerializableItem(QString()), currentItem(0)
{
}
bool TopLevelProtocolItem::readCurrentItem(QXmlStreamReader *xml)
{
if (currentItem) {
if (currentItem->read(xml)) {
emit protocolItemReceived(currentItem);
currentItem = 0;
}
return true;
} else
return false;
}
bool TopLevelProtocolItem::readElement(QXmlStreamReader *xml)
{
if (!readCurrentItem(xml) && (xml->isStartElement())) {
QString childName = xml->name().toString();
QString childSubType = xml->attributes().value("type").toString();
currentItem = dynamic_cast<ProtocolItem *>(getNewItem(childName + childSubType));
if (!currentItem)
currentItem = new ProtocolItem_Invalid;
if (xml->attributes().value("comp").toString().toInt() == 1)
currentItem->setCompressed(true);
readCurrentItem(xml);
}
return SerializableItem::readElement(xml);
}
void TopLevelProtocolItem::writeElement(QXmlStreamWriter * /*xml*/)
{
}
@ -136,96 +50,7 @@ void BlaContainer::enqueueGameEventPrivate(GameEvent *event, int gameId, int pla
gameEventQueuePrivate->setContext(context);
}
QHash<QString, ResponseCode> ProtocolResponse::responseHash;
ProtocolResponse::ProtocolResponse(int _cmdId, ResponseCode _responseCode, const QString &_itemName)
: ProtocolItem("resp", _itemName)
{
insertItem(new SerializableItem_Int("cmd_id", _cmdId));
insertItem(new SerializableItem_String("response_code", responseHash.key(_responseCode)));
}
void ProtocolResponse::initializeHash()
{
responseHash.insert(QString(), RespNothing);
responseHash.insert("ok", RespOk);
responseHash.insert("not_in_room", RespNotInRoom);
responseHash.insert("internal_error", RespInternalError);
responseHash.insert("invalid_command", RespInvalidCommand);
responseHash.insert("name_not_found", RespNameNotFound);
responseHash.insert("login_needed", RespLoginNeeded);
responseHash.insert("function_not_allowed", RespFunctionNotAllowed);
responseHash.insert("game_not_started", RespGameNotStarted);
responseHash.insert("game_full", RespGameFull);
responseHash.insert("context_error", RespContextError);
responseHash.insert("wrong_password", RespWrongPassword);
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
responseHash.insert("only_buddies", RespOnlyBuddies);
responseHash.insert("user_level_too_low", RespUserLevelTooLow);
responseHash.insert("in_ignore_list", RespInIgnoreList);
responseHash.insert("would_overwrite_old_session", RespWouldOverwriteOldSession);
responseHash.insert("chat_flood", RespChatFlood);
}
Response_JoinRoom::Response_JoinRoom(int _cmdId, ResponseCode _responseCode, ServerInfo_Room *_roomInfo)
: ProtocolResponse(_cmdId, _responseCode, "join_room")
{
if (!_roomInfo)
_roomInfo = new ServerInfo_Room;
insertItem(_roomInfo);
}
Response_ListUsers::Response_ListUsers(int _cmdId, ResponseCode _responseCode, const QList<ServerInfo_User *> &_userList)
: ProtocolResponse(_cmdId, _responseCode, "list_users")
{
for (int i = 0; i < _userList.size(); ++i)
itemList.append(_userList[i]);
}
Response_DeckList::Response_DeckList(int _cmdId, ResponseCode _responseCode, DeckList_Directory *_root)
: ProtocolResponse(_cmdId, _responseCode, "deck_list")
{
if (!_root)
_root = new DeckList_Directory;
insertItem(_root);
}
Response_GetGamesOfUser::Response_GetGamesOfUser(int _cmdId, ResponseCode _responseCode, const QList<ServerInfo_Room *> &_roomList, const QList<ServerInfo_Game *> &_gameList)
: ProtocolResponse(_cmdId, _responseCode, "get_games_of_user")
{
roomList = _roomList;
for (int i = 0; i < _roomList.size(); ++i)
itemList.append(_roomList[i]);
gameList = _gameList;
for (int i = 0; i < _gameList.size(); ++i)
itemList.append(_gameList[i]);
}
void Response_GetGamesOfUser::extractData()
{
for (int i = 0; i < itemList.size(); ++i) {
ServerInfo_Room *room = dynamic_cast<ServerInfo_Room *>(itemList[i]);
if (room) {
roomList.append(room);
continue;
}
ServerInfo_Game *game = dynamic_cast<ServerInfo_Game *>(itemList[i]);
if (game) {
gameList.append(game);
continue;
}
}
}
Response_GetUserInfo::Response_GetUserInfo(int _cmdId, ResponseCode _responseCode, ServerInfo_User *_user)
: ProtocolResponse(_cmdId, _responseCode, "get_user_info")
{
if (!_user)
_user = new ServerInfo_User;
insertItem(_user);
}
/*
Response_DeckDownload::Response_DeckDownload(int _cmdId, ResponseCode _responseCode, DeckList *_deck)
: ProtocolResponse(_cmdId, _responseCode, "deck_download")
{
@ -246,90 +71,8 @@ Response_DeckUpload::Response_DeckUpload(int _cmdId, ResponseCode _responseCode,
_file = new DeckList_File;
insertItem(_file);
}
Response_DumpZone::Response_DumpZone(int _cmdId, ResponseCode _responseCode, ServerInfo_Zone *_zone)
: ProtocolResponse(_cmdId, _responseCode, "dump_zone")
{
if (!_zone)
_zone = new ServerInfo_Zone;
insertItem(_zone);
}
Response_Login::Response_Login(int _cmdId, ResponseCode _responseCode, ServerInfo_User *_userInfo, const QList<ServerInfo_User *> &_buddyList, const QList<ServerInfo_User *> &_ignoreList)
: ProtocolResponse(_cmdId, _responseCode, "login")
{
if (!_userInfo)
_userInfo = new ServerInfo_User;
insertItem(_userInfo);
insertItem(new ServerInfo_UserList("buddy_list", _buddyList));
insertItem(new ServerInfo_UserList("ignore_list", _ignoreList));
}
GameEvent::GameEvent(const QString &_eventName, int _playerId)
: ProtocolItem("game_event", _eventName)
{
insertItem(new SerializableItem_Int("player_id", _playerId));
}
GameEventContext::GameEventContext(const QString &_contextName)
: ProtocolItem("game_event_context", _contextName)
{
}
RoomEvent::RoomEvent(const QString &_eventName, int _roomId)
: ProtocolItem("room_event", _eventName)
{
insertItem(new SerializableItem_Int("room_id", _roomId));
}
Event_ListRooms::Event_ListRooms(const QList<ServerInfo_Room *> &_roomList)
: GenericEvent("list_rooms")
{
for (int i = 0; i < _roomList.size(); ++i)
itemList.append(_roomList[i]);
}
Event_JoinRoom::Event_JoinRoom(int _roomId, ServerInfo_User *_info)
: RoomEvent("join_room", _roomId)
{
if (!_info)
_info = new ServerInfo_User;
insertItem(_info);
}
Event_ListGames::Event_ListGames(int _roomId, const QList<ServerInfo_Game *> &_gameList)
: RoomEvent("list_games", _roomId)
{
for (int i = 0; i < _gameList.size(); ++i)
itemList.append(_gameList[i]);
}
Event_AddToList::Event_AddToList(const QString &_list, ServerInfo_User *_userInfo)
: GenericEvent("add_to_list")
{
if (!_userInfo)
_userInfo = new ServerInfo_User;
insertItem(_userInfo);
insertItem(new SerializableItem_String("list", _list));
}
Event_UserJoined::Event_UserJoined(ServerInfo_User *_userInfo)
: GenericEvent("user_joined")
{
if (!_userInfo)
_userInfo = new ServerInfo_User;
insertItem(_userInfo);
}
Event_Join::Event_Join(ServerInfo_PlayerProperties *player)
: GameEvent("join", -1)
{
if (!player)
player = new ServerInfo_PlayerProperties;
insertItem(player);
}
*/
/*
GameEventContainer::GameEventContainer(const QList<GameEvent *> &_eventList, int _gameId, GameEventContext *_context)
: ProtocolItem("container", "game_event")
{
@ -380,61 +123,4 @@ GameEventContainer *GameEventContainer::makeNew(GameEvent *event, int _gameId)
{
return new GameEventContainer(QList<GameEvent *>() << event, _gameId);
}
Event_GameStateChanged::Event_GameStateChanged(bool _gameStarted, int _activePlayer, int _activePhase, const QList<ServerInfo_Player *> &_playerList)
: GameEvent("game_state_changed", -1)
{
insertItem(new SerializableItem_Bool("game_started", _gameStarted));
insertItem(new SerializableItem_Int("active_player", _activePlayer));
insertItem(new SerializableItem_Int("active_phase", _activePhase));
for (int i = 0; i < _playerList.size(); ++i)
itemList.append(_playerList[i]);
}
Event_PlayerPropertiesChanged::Event_PlayerPropertiesChanged(int _playerId, ServerInfo_PlayerProperties *_properties)
: GameEvent("player_properties_changed", _playerId)
{
if (!_properties)
_properties = new ServerInfo_PlayerProperties;
insertItem(_properties);
}
Event_Ping::Event_Ping(int _secondsElapsed, const QList<ServerInfo_PlayerPing *> &_pingList)
: GameEvent("ping", -1)
{
insertItem(new SerializableItem_Int("seconds_elapsed", _secondsElapsed));
for (int i = 0; i < _pingList.size(); ++i)
itemList.append(_pingList[i]);
}
Event_CreateArrows::Event_CreateArrows(int _playerId, const QList<ServerInfo_Arrow *> &_arrowList)
: GameEvent("create_arrows", _playerId)
{
for (int i = 0; i < _arrowList.size(); ++i)
itemList.append(_arrowList[i]);
}
Event_CreateCounters::Event_CreateCounters(int _playerId, const QList<ServerInfo_Counter *> &_counterList)
: GameEvent("create_counters", _playerId)
{
for (int i = 0; i < _counterList.size(); ++i)
itemList.append(_counterList[i]);
}
Event_DrawCards::Event_DrawCards(int _playerId, int _numberCards, const QList<ServerInfo_Card *> &_cardList)
: GameEvent("draw_cards", _playerId)
{
insertItem(new SerializableItem_Int("number_cards", _numberCards));
for (int i = 0; i < _cardList.size(); ++i)
itemList.append(_cardList[i]);
}
Event_RevealCards::Event_RevealCards(int _playerId, const QString &_zoneName, int _cardId, int _otherPlayerId, const QList<ServerInfo_Card *> &_cardList)
: GameEvent("reveal_cards", _playerId)
{
insertItem(new SerializableItem_String("zone_name", _zoneName));
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_Int("other_player_id", _otherPlayerId));
for (int i = 0; i < _cardList.size(); ++i)
itemList.append(_cardList[i]);
}
*/

View file

@ -6,7 +6,6 @@
#include <QHash>
#include <QObject>
#include <QVariant>
#include "protocol_item_ids.h"
#include "protocol_datastructures.h"
class QXmlStreamReader;
@ -20,39 +19,6 @@ class GameEventContainer;
class GameEventContext;
class MoveCardToZone;
enum ItemId {
ItemId_CommandContainer = ItemId_Other + 50,
ItemId_GameEventContainer = ItemId_Other + 51,
ItemId_Command_CreateGame = ItemId_Other + 99,
ItemId_Command_DeckUpload = ItemId_Other + 100,
ItemId_Command_DeckSelect = ItemId_Other + 101,
ItemId_Command_SetSideboardPlan = ItemId_Other + 102,
ItemId_Command_MoveCard = ItemId_Other + 103,
ItemId_Event_ListRooms = ItemId_Other + 200,
ItemId_Event_JoinRoom = ItemId_Other + 201,
ItemId_Event_ListGames = ItemId_Other + 203,
ItemId_Event_UserJoined = ItemId_Other + 204,
ItemId_Event_GameStateChanged = ItemId_Other + 205,
ItemId_Event_PlayerPropertiesChanged = ItemId_Other + 206,
ItemId_Event_CreateArrows = ItemId_Other + 207,
ItemId_Event_CreateCounters = ItemId_Other + 208,
ItemId_Event_DrawCards = ItemId_Other + 209,
ItemId_Event_RevealCards = ItemId_Other + 210,
ItemId_Event_Join = ItemId_Other + 211,
ItemId_Event_Ping = ItemId_Other + 212,
ItemId_Event_AddToList = ItemId_Other + 213,
ItemId_Response_ListUsers = ItemId_Other + 300,
ItemId_Response_GetGamesOfUser = ItemId_Other + 301,
ItemId_Response_GetUserInfo = ItemId_Other + 302,
ItemId_Response_DeckList = ItemId_Other + 303,
ItemId_Response_DeckDownload = ItemId_Other + 304,
ItemId_Response_DeckUpload = ItemId_Other + 305,
ItemId_Response_DumpZone = ItemId_Other + 306,
ItemId_Response_JoinRoom = ItemId_Other + 307,
ItemId_Response_Login = ItemId_Other + 308,
ItemId_Invalid = ItemId_Other + 1000
};
class ProtocolItem : public SerializableItem_Map {
Q_OBJECT
private:
@ -68,26 +34,6 @@ public:
bool isEmpty() const { return false; }
};
class ProtocolItem_Invalid : public ProtocolItem {
public:
ProtocolItem_Invalid() : ProtocolItem(QString(), QString()) { }
int getItemId() const { return ItemId_Invalid; }
};
class TopLevelProtocolItem : public SerializableItem {
Q_OBJECT
signals:
void protocolItemReceived(ProtocolItem *item);
private:
ProtocolItem *currentItem;
bool readCurrentItem(QXmlStreamReader *xml);
public:
TopLevelProtocolItem();
bool readElement(QXmlStreamReader *xml);
void writeElement(QXmlStreamWriter *xml);
bool isEmpty() const { return false; }
};
// ----------------
// --- COMMANDS ---
// ----------------
@ -118,67 +64,9 @@ public:
void enqueueGameEventPrivate(GameEvent *event, int gameId, int playerId = -1, GameEventContext *context = 0);
int getPrivatePlayerId() const { return privatePlayerId; }
};
// -----------------
// --- RESPONSES ---
// -----------------
class ProtocolResponse : public ProtocolItem {
Q_OBJECT
private:
static QHash<QString, ResponseCode> responseHash;
public:
ProtocolResponse(int _cmdId = -1, ResponseCode _responseCode = RespNothing, const QString &_itemName = QString());
int getItemId() const { return ItemId_Other; }
static void initializeHash();
static SerializableItem *newItem() { return new ProtocolResponse; }
int getCmdId() const { return static_cast<SerializableItem_Int *>(itemMap.value("cmd_id"))->getData(); }
void setCmdId(int _cmdId) { static_cast<SerializableItem_Int *>(itemMap.value("cmd_id"))->setData(_cmdId); }
ResponseCode getResponseCode() const { return responseHash.value(static_cast<SerializableItem_String *>(itemMap.value("response_code"))->getData(), RespOk); }
};
class Response_JoinRoom : public ProtocolResponse {
Q_OBJECT
public:
Response_JoinRoom(int _cmdId = -1, ResponseCode _responseCode = RespOk, ServerInfo_Room *_roomInfo = 0);
int getItemId() const { return ItemId_Response_JoinRoom; }
static SerializableItem *newItem() { return new Response_JoinRoom; }
ServerInfo_Room *getRoomInfo() const { return static_cast<ServerInfo_Room *>(itemMap.value("room")); }
};
class Response_ListUsers : public ProtocolResponse {
Q_OBJECT
public:
Response_ListUsers(int _cmdId = -1, ResponseCode _responseCode = RespOk, const QList<ServerInfo_User *> &_userList = QList<ServerInfo_User *>());
int getItemId() const { return ItemId_Response_ListUsers; }
static SerializableItem *newItem() { return new Response_ListUsers; }
QList<ServerInfo_User *> getUserList() const { return typecastItemList<ServerInfo_User *>(); }
};
class Response_GetGamesOfUser : public ProtocolResponse {
Q_OBJECT
private:
QList<ServerInfo_Game *> gameList;
QList<ServerInfo_Room *> roomList;
protected:
void extractData();
public:
Response_GetGamesOfUser(int _cmdId = -1, ResponseCode _responseCode = RespOk, const QList<ServerInfo_Room *> &_roomList = QList<ServerInfo_Room *>(), const QList<ServerInfo_Game *> &_gameList = QList<ServerInfo_Game *>());
int getItemId() const { return ItemId_Response_GetGamesOfUser; }
static SerializableItem *newItem() { return new Response_GetGamesOfUser; }
QList<ServerInfo_Room *> getRoomList() const { return roomList; }
QList<ServerInfo_Game *> getGameList() const { return gameList; }
};
class Response_GetUserInfo : public ProtocolResponse {
Q_OBJECT
public:
Response_GetUserInfo(int _cmdId = -1, ResponseCode _responseCode = RespOk, ServerInfo_User *_userInfo = 0);
int getItemId() const { return ItemId_Response_GetUserInfo; }
static SerializableItem *newItem() { return new Response_GetUserInfo; }
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
};
/*
* XXX
*
class Response_DeckList : public ProtocolResponse {
Q_OBJECT
public:
@ -205,203 +93,5 @@ public:
static SerializableItem *newItem() { return new Response_DeckUpload; }
DeckList_File *getFile() const { return static_cast<DeckList_File *>(itemMap.value("file")); }
};
class Response_DumpZone : public ProtocolResponse {
Q_OBJECT
public:
Response_DumpZone(int _cmdId = -1, ResponseCode _responseCode = RespOk, ServerInfo_Zone *zone = 0);
int getItemId() const { return ItemId_Response_DumpZone; }
static SerializableItem *newItem() { return new Response_DumpZone; }
ServerInfo_Zone *getZone() const { return static_cast<ServerInfo_Zone *>(itemMap.value("zone")); }
};
class Response_Login : public ProtocolResponse {
Q_OBJECT
public:
Response_Login(int _cmdId = -1, ResponseCode _responseCode = RespOk, ServerInfo_User *_userInfo = 0, const QList<ServerInfo_User *> &_buddyList = QList<ServerInfo_User *>(), const QList<ServerInfo_User *> &_ignoreList = QList<ServerInfo_User *>());
int getItemId() const { return ItemId_Response_Login; }
static SerializableItem *newItem() { return new Response_Login; }
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
QList<ServerInfo_User *> getBuddyList() const { return static_cast<ServerInfo_UserList *>(itemMap.value("buddy_list"))->getUserList(); }
QList<ServerInfo_User *> getIgnoreList() const { return static_cast<ServerInfo_UserList *>(itemMap.value("ignore_list"))->getUserList(); }
};
// --------------
// --- EVENTS ---
// --------------
class GenericEvent : public ProtocolItem {
Q_OBJECT
public:
GenericEvent(const QString &_eventName)
: ProtocolItem("generic_event", _eventName) { }
};
class GameEvent : public ProtocolItem {
Q_OBJECT
public:
GameEvent(const QString &_eventName, int _playerId);
int getPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("player_id"))->getData(); }
};
class GameEventContext : public ProtocolItem {
Q_OBJECT
public:
GameEventContext(const QString &_contextName);
};
class GameEventContainer : public ProtocolItem {
Q_OBJECT
private:
QList<GameEvent *> eventList;
GameEventContext *context;
protected:
void extractData();
public:
GameEventContainer(const QList<GameEvent *> &_eventList = QList<GameEvent *>(), int _gameId = -1, GameEventContext *_context = 0);
static SerializableItem *newItem() { return new GameEventContainer; }
int getItemId() const { return ItemId_GameEventContainer; }
QList<GameEvent *> getEventList() const { return eventList; }
GameEventContext *getContext() const { return context; }
void setContext(GameEventContext *_context);
void addGameEvent(GameEvent *event);
static GameEventContainer *makeNew(GameEvent *event, int _gameId);
int getGameId() const { return static_cast<SerializableItem_Int *>(itemMap.value("game_id"))->getData(); }
void setGameId(int _gameId) { static_cast<SerializableItem_Int *>(itemMap.value("game_id"))->setData(_gameId); }
};
class RoomEvent : public ProtocolItem {
Q_OBJECT
public:
RoomEvent(const QString &_eventName, int _roomId);
int getRoomId() const { return static_cast<SerializableItem_Int *>(itemMap.value("room_id"))->getData(); }
};
class Event_ListRooms : public GenericEvent {
Q_OBJECT
public:
Event_ListRooms(const QList<ServerInfo_Room *> &_roomList = QList<ServerInfo_Room *>());
int getItemId() const { return ItemId_Event_ListRooms; }
static SerializableItem *newItem() { return new Event_ListRooms; }
QList<ServerInfo_Room *> getRoomList() const { return typecastItemList<ServerInfo_Room *>(); }
};
class Event_JoinRoom : public RoomEvent {
Q_OBJECT
public:
Event_JoinRoom(int _roomId = -1, ServerInfo_User *_info = 0);
int getItemId() const { return ItemId_Event_JoinRoom; }
static SerializableItem *newItem() { return new Event_JoinRoom; }
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
};
class Event_ListGames : public RoomEvent {
Q_OBJECT
public:
Event_ListGames(int _roomId = -1, const QList<ServerInfo_Game *> &_gameList = QList<ServerInfo_Game *>());
int getItemId() const { return ItemId_Event_ListGames; }
static SerializableItem *newItem() { return new Event_ListGames; }
QList<ServerInfo_Game *> getGameList() const { return typecastItemList<ServerInfo_Game *>(); }
};
class Event_AddToList : public GenericEvent {
Q_OBJECT
public:
Event_AddToList(const QString &_list = QString(), ServerInfo_User *_userInfo = 0);
int getItemId() const { return ItemId_Event_AddToList; }
static SerializableItem *newItem() { return new Event_AddToList; }
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
QString getList() const { return static_cast<SerializableItem_String *>(itemMap.value("list"))->getData(); }
};
class Event_UserJoined : public GenericEvent {
Q_OBJECT
public:
Event_UserJoined(ServerInfo_User *_userInfo = 0);
int getItemId() const { return ItemId_Event_UserJoined; }
static SerializableItem *newItem() { return new Event_UserJoined; }
ServerInfo_User *getUserInfo() const { return static_cast<ServerInfo_User *>(itemMap.value("user")); }
};
class Event_Join : public GameEvent {
Q_OBJECT
public:
Event_Join(ServerInfo_PlayerProperties *player = 0);
static SerializableItem *newItem() { return new Event_Join; }
int getItemId() const { return ItemId_Event_Join; }
ServerInfo_PlayerProperties *getPlayer() const { return static_cast<ServerInfo_PlayerProperties *>(itemMap.value("player_properties")); }
};
class Event_GameStateChanged : public GameEvent {
Q_OBJECT
public:
Event_GameStateChanged(bool _gameStarted = false, int _activePlayer = -1, int _activePhase = -1, const QList<ServerInfo_Player *> &_playerList = QList<ServerInfo_Player *>());
static SerializableItem *newItem() { return new Event_GameStateChanged; }
int getItemId() const { return ItemId_Event_GameStateChanged; }
QList<ServerInfo_Player *> getPlayerList() const { return typecastItemList<ServerInfo_Player *>(); }
bool getGameStarted() const { return static_cast<SerializableItem_Bool *>(itemMap.value("game_started"))->getData(); }
int getActivePlayer() const { return static_cast<SerializableItem_Int *>(itemMap.value("active_player"))->getData(); }
int getActivePhase() const { return static_cast<SerializableItem_Int *>(itemMap.value("active_phase"))->getData(); }
};
class Event_PlayerPropertiesChanged : public GameEvent {
Q_OBJECT
public:
Event_PlayerPropertiesChanged(int _playerId = -1, ServerInfo_PlayerProperties *_properties = 0);
static SerializableItem *newItem() { return new Event_PlayerPropertiesChanged; }
int getItemId() const { return ItemId_Event_PlayerPropertiesChanged; }
ServerInfo_PlayerProperties *getProperties() const { return static_cast<ServerInfo_PlayerProperties *>(itemMap.value("player_properties")); }
};
class Event_Ping : public GameEvent {
Q_OBJECT
public:
Event_Ping(int _secondsElapsed = -1, const QList<ServerInfo_PlayerPing *> &_pingList = QList<ServerInfo_PlayerPing *>());
static SerializableItem *newItem() { return new Event_Ping; }
int getItemId() const { return ItemId_Event_Ping; }
int getSecondsElapsed() const { return static_cast<SerializableItem_Int *>(itemMap.value("seconds_elapsed"))->getData(); }
QList<ServerInfo_PlayerPing *> getPingList() const { return typecastItemList<ServerInfo_PlayerPing *>(); }
};
class Event_CreateArrows : public GameEvent {
Q_OBJECT
public:
Event_CreateArrows(int _playerId = -1, const QList<ServerInfo_Arrow *> &_arrowList = QList<ServerInfo_Arrow *>());
int getItemId() const { return ItemId_Event_CreateArrows; }
static SerializableItem *newItem() { return new Event_CreateArrows; }
QList<ServerInfo_Arrow *> getArrowList() const { return typecastItemList<ServerInfo_Arrow *>(); }
};
class Event_CreateCounters : public GameEvent {
Q_OBJECT
public:
Event_CreateCounters(int _playerId = -1, const QList<ServerInfo_Counter *> &_counterList = QList<ServerInfo_Counter *>());
int getItemId() const { return ItemId_Event_CreateCounters; }
static SerializableItem *newItem() { return new Event_CreateCounters; }
QList<ServerInfo_Counter *> getCounterList() const { return typecastItemList<ServerInfo_Counter *>(); }
};
class Event_DrawCards : public GameEvent {
Q_OBJECT
public:
Event_DrawCards(int _playerId = -1, int numberCards = -1, const QList<ServerInfo_Card *> &_cardList = QList<ServerInfo_Card *>());
int getItemId() const { return ItemId_Event_DrawCards; }
static SerializableItem *newItem() { return new Event_DrawCards; }
int getNumberCards() const { return static_cast<SerializableItem_Int *>(itemMap.value("number_cards"))->getData(); }
QList<ServerInfo_Card *> getCardList() const { return typecastItemList<ServerInfo_Card *>(); }
};
class Event_RevealCards : public GameEvent {
Q_OBJECT
public:
Event_RevealCards(int _playerId = -1, const QString &_zoneName = QString(), int cardId = -1, int _otherPlayerId = -1, const QList<ServerInfo_Card *> &_cardList = QList<ServerInfo_Card *>());
int getItemId() const { return ItemId_Event_RevealCards; }
static SerializableItem *newItem() { return new Event_RevealCards; }
QString getZoneName() const { return static_cast<SerializableItem_String *>(itemMap.value("zone_name"))->getData(); }
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); }
int getOtherPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("other_player_id"))->getData(); }
QList<ServerInfo_Card *> getCardList() const { return typecastItemList<ServerInfo_Card *>(); }
};
*/
#endif

View file

@ -1,40 +0,0 @@
enum AutoItemId {
ItemId_Event_ConnectionStateChanged = 1001,
ItemId_Event_Say = 1002,
ItemId_Event_Leave = 1003,
ItemId_Event_GameClosed = 1004,
ItemId_Event_GameHostChanged = 1005,
ItemId_Event_Kicked = 1006,
ItemId_Event_Shuffle = 1007,
ItemId_Event_RollDie = 1008,
ItemId_Event_MoveCard = 1009,
ItemId_Event_FlipCard = 1010,
ItemId_Event_DestroyCard = 1011,
ItemId_Event_AttachCard = 1012,
ItemId_Event_CreateToken = 1013,
ItemId_Event_DeleteArrow = 1014,
ItemId_Event_SetCardAttr = 1015,
ItemId_Event_SetCardCounter = 1016,
ItemId_Event_SetCounter = 1017,
ItemId_Event_DelCounter = 1018,
ItemId_Event_SetActivePlayer = 1019,
ItemId_Event_SetActivePhase = 1020,
ItemId_Event_DumpZone = 1021,
ItemId_Event_StopDumpZone = 1022,
ItemId_Event_RemoveFromList = 1023,
ItemId_Event_ServerMessage = 1024,
ItemId_Event_ServerShutdown = 1025,
ItemId_Event_ConnectionClosed = 1026,
ItemId_Event_Message = 1027,
ItemId_Event_GameJoined = 1028,
ItemId_Event_UserLeft = 1029,
ItemId_Event_LeaveRoom = 1030,
ItemId_Event_RoomSay = 1031,
ItemId_Context_ReadyStart = 1032,
ItemId_Context_Concede = 1033,
ItemId_Context_DeckSelect = 1034,
ItemId_Context_UndoDraw = 1035,
ItemId_Context_MoveCard = 1036,
ItemId_Context_Mulligan = 1037,
ItemId_Other = 1038
};

View file

@ -1,267 +0,0 @@
#include "protocol.h"
#include "protocol_items.h"
Event_ConnectionStateChanged::Event_ConnectionStateChanged(int _playerId, bool _connected)
: GameEvent("connection_state_changed", _playerId)
{
insertItem(new SerializableItem_Bool("connected", _connected));
}
Event_Say::Event_Say(int _playerId, const QString &_message)
: GameEvent("say", _playerId)
{
insertItem(new SerializableItem_String("message", _message));
}
Event_Leave::Event_Leave(int _playerId)
: GameEvent("leave", _playerId)
{
}
Event_GameClosed::Event_GameClosed(int _playerId)
: GameEvent("game_closed", _playerId)
{
}
Event_GameHostChanged::Event_GameHostChanged(int _playerId)
: GameEvent("game_host_changed", _playerId)
{
}
Event_Kicked::Event_Kicked(int _playerId)
: GameEvent("kicked", _playerId)
{
}
Event_Shuffle::Event_Shuffle(int _playerId)
: GameEvent("shuffle", _playerId)
{
}
Event_RollDie::Event_RollDie(int _playerId, int _sides, int _value)
: GameEvent("roll_die", _playerId)
{
insertItem(new SerializableItem_Int("sides", _sides));
insertItem(new SerializableItem_Int("value", _value));
}
Event_MoveCard::Event_MoveCard(int _playerId, int _cardId, const QString &_cardName, const QString &_startZone, int _position, int _targetPlayerId, const QString &_targetZone, int _x, int _y, int _newCardId, bool _faceDown)
: GameEvent("move_card", _playerId)
{
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_String("card_name", _cardName));
insertItem(new SerializableItem_String("start_zone", _startZone));
insertItem(new SerializableItem_Int("position", _position));
insertItem(new SerializableItem_Int("target_player_id", _targetPlayerId));
insertItem(new SerializableItem_String("target_zone", _targetZone));
insertItem(new SerializableItem_Int("x", _x));
insertItem(new SerializableItem_Int("y", _y));
insertItem(new SerializableItem_Int("new_card_id", _newCardId));
insertItem(new SerializableItem_Bool("face_down", _faceDown));
}
Event_FlipCard::Event_FlipCard(int _playerId, const QString &_zone, int _cardId, const QString &_cardName, bool _faceDown)
: GameEvent("flip_card", _playerId)
{
insertItem(new SerializableItem_String("zone", _zone));
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_String("card_name", _cardName));
insertItem(new SerializableItem_Bool("face_down", _faceDown));
}
Event_DestroyCard::Event_DestroyCard(int _playerId, const QString &_zone, int _cardId)
: GameEvent("destroy_card", _playerId)
{
insertItem(new SerializableItem_String("zone", _zone));
insertItem(new SerializableItem_Int("card_id", _cardId));
}
Event_AttachCard::Event_AttachCard(int _playerId, const QString &_startZone, int _cardId, int _targetPlayerId, const QString &_targetZone, int _targetCardId)
: GameEvent("attach_card", _playerId)
{
insertItem(new SerializableItem_String("start_zone", _startZone));
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_Int("target_player_id", _targetPlayerId));
insertItem(new SerializableItem_String("target_zone", _targetZone));
insertItem(new SerializableItem_Int("target_card_id", _targetCardId));
}
Event_CreateToken::Event_CreateToken(int _playerId, const QString &_zone, int _cardId, const QString &_cardName, const QString &_color, const QString &_pt, const QString &_annotation, bool _destroyOnZoneChange, int _x, int _y)
: GameEvent("create_token", _playerId)
{
insertItem(new SerializableItem_String("zone", _zone));
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_String("card_name", _cardName));
insertItem(new SerializableItem_String("color", _color));
insertItem(new SerializableItem_String("pt", _pt));
insertItem(new SerializableItem_String("annotation", _annotation));
insertItem(new SerializableItem_Bool("destroy_on_zone_change", _destroyOnZoneChange));
insertItem(new SerializableItem_Int("x", _x));
insertItem(new SerializableItem_Int("y", _y));
}
Event_DeleteArrow::Event_DeleteArrow(int _playerId, int _arrowId)
: GameEvent("delete_arrow", _playerId)
{
insertItem(new SerializableItem_Int("arrow_id", _arrowId));
}
Event_SetCardAttr::Event_SetCardAttr(int _playerId, const QString &_zone, int _cardId, const QString &_attrName, const QString &_attrValue)
: GameEvent("set_card_attr", _playerId)
{
insertItem(new SerializableItem_String("zone", _zone));
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_String("attr_name", _attrName));
insertItem(new SerializableItem_String("attr_value", _attrValue));
}
Event_SetCardCounter::Event_SetCardCounter(int _playerId, const QString &_zone, int _cardId, int _counterId, int _counterValue)
: GameEvent("set_card_counter", _playerId)
{
insertItem(new SerializableItem_String("zone", _zone));
insertItem(new SerializableItem_Int("card_id", _cardId));
insertItem(new SerializableItem_Int("counter_id", _counterId));
insertItem(new SerializableItem_Int("counter_value", _counterValue));
}
Event_SetCounter::Event_SetCounter(int _playerId, int _counterId, int _value)
: GameEvent("set_counter", _playerId)
{
insertItem(new SerializableItem_Int("counter_id", _counterId));
insertItem(new SerializableItem_Int("value", _value));
}
Event_DelCounter::Event_DelCounter(int _playerId, int _counterId)
: GameEvent("del_counter", _playerId)
{
insertItem(new SerializableItem_Int("counter_id", _counterId));
}
Event_SetActivePlayer::Event_SetActivePlayer(int _playerId, int _activePlayerId)
: GameEvent("set_active_player", _playerId)
{
insertItem(new SerializableItem_Int("active_player_id", _activePlayerId));
}
Event_SetActivePhase::Event_SetActivePhase(int _playerId, int _phase)
: GameEvent("set_active_phase", _playerId)
{
insertItem(new SerializableItem_Int("phase", _phase));
}
Event_DumpZone::Event_DumpZone(int _playerId, int _zoneOwnerId, const QString &_zone, int _numberCards)
: GameEvent("dump_zone", _playerId)
{
insertItem(new SerializableItem_Int("zone_owner_id", _zoneOwnerId));
insertItem(new SerializableItem_String("zone", _zone));
insertItem(new SerializableItem_Int("number_cards", _numberCards));
}
Event_StopDumpZone::Event_StopDumpZone(int _playerId, int _zoneOwnerId, const QString &_zone)
: GameEvent("stop_dump_zone", _playerId)
{
insertItem(new SerializableItem_Int("zone_owner_id", _zoneOwnerId));
insertItem(new SerializableItem_String("zone", _zone));
}
Event_RemoveFromList::Event_RemoveFromList(const QString &_list, const QString &_userName)
: GenericEvent("remove_from_list")
{
insertItem(new SerializableItem_String("list", _list));
insertItem(new SerializableItem_String("user_name", _userName));
}
Event_ServerMessage::Event_ServerMessage(const QString &_message)
: GenericEvent("server_message")
{
insertItem(new SerializableItem_String("message", _message));
}
Event_ServerShutdown::Event_ServerShutdown(const QString &_reason, int _minutes)
: GenericEvent("server_shutdown")
{
insertItem(new SerializableItem_String("reason", _reason));
insertItem(new SerializableItem_Int("minutes", _minutes));
}
Event_ConnectionClosed::Event_ConnectionClosed(const QString &_reason)
: GenericEvent("connection_closed")
{
insertItem(new SerializableItem_String("reason", _reason));
}
Event_Message::Event_Message(const QString &_senderName, const QString &_receiverName, const QString &_text)
: GenericEvent("message")
{
insertItem(new SerializableItem_String("sender_name", _senderName));
insertItem(new SerializableItem_String("receiver_name", _receiverName));
insertItem(new SerializableItem_String("text", _text));
}
Event_GameJoined::Event_GameJoined(int _gameId, const QString &_gameDescription, int _hostId, int _playerId, bool _spectator, bool _spectatorsCanTalk, bool _spectatorsSeeEverything, bool _resuming)
: GenericEvent("game_joined")
{
insertItem(new SerializableItem_Int("game_id", _gameId));
insertItem(new SerializableItem_String("game_description", _gameDescription));
insertItem(new SerializableItem_Int("host_id", _hostId));
insertItem(new SerializableItem_Int("player_id", _playerId));
insertItem(new SerializableItem_Bool("spectator", _spectator));
insertItem(new SerializableItem_Bool("spectators_can_talk", _spectatorsCanTalk));
insertItem(new SerializableItem_Bool("spectators_see_everything", _spectatorsSeeEverything));
insertItem(new SerializableItem_Bool("resuming", _resuming));
}
Event_UserLeft::Event_UserLeft(const QString &_userName)
: GenericEvent("user_left")
{
insertItem(new SerializableItem_String("user_name", _userName));
}
Event_LeaveRoom::Event_LeaveRoom(int _roomId, const QString &_playerName)
: RoomEvent("leave_room", _roomId)
{
insertItem(new SerializableItem_String("player_name", _playerName));
}
Event_RoomSay::Event_RoomSay(int _roomId, const QString &_playerName, const QString &_message)
: RoomEvent("room_say", _roomId)
{
insertItem(new SerializableItem_String("player_name", _playerName));
insertItem(new SerializableItem_String("message", _message));
}
Context_ReadyStart::Context_ReadyStart()
: GameEventContext("ready_start")
{
}
Context_Concede::Context_Concede()
: GameEventContext("concede")
{
}
Context_DeckSelect::Context_DeckSelect(const QString &_deckHash)
: GameEventContext("deck_select")
{
insertItem(new SerializableItem_String("deck_hash", _deckHash));
}
Context_UndoDraw::Context_UndoDraw()
: GameEventContext("undo_draw")
{
}
Context_MoveCard::Context_MoveCard()
: GameEventContext("move_card")
{
}
Context_Mulligan::Context_Mulligan(int _number)
: GameEventContext("mulligan")
{
insertItem(new SerializableItem_Int("number", _number));
}
void ProtocolItem::initializeHashAuto()
{
itemNameHash.insert("game_eventconnection_state_changed", Event_ConnectionStateChanged::newItem);
itemNameHash.insert("game_eventsay", Event_Say::newItem);
itemNameHash.insert("game_eventleave", Event_Leave::newItem);
itemNameHash.insert("game_eventgame_closed", Event_GameClosed::newItem);
itemNameHash.insert("game_eventgame_host_changed", Event_GameHostChanged::newItem);
itemNameHash.insert("game_eventkicked", Event_Kicked::newItem);
itemNameHash.insert("game_eventshuffle", Event_Shuffle::newItem);
itemNameHash.insert("game_eventroll_die", Event_RollDie::newItem);
itemNameHash.insert("game_eventmove_card", Event_MoveCard::newItem);
itemNameHash.insert("game_eventflip_card", Event_FlipCard::newItem);
itemNameHash.insert("game_eventdestroy_card", Event_DestroyCard::newItem);
itemNameHash.insert("game_eventattach_card", Event_AttachCard::newItem);
itemNameHash.insert("game_eventcreate_token", Event_CreateToken::newItem);
itemNameHash.insert("game_eventdelete_arrow", Event_DeleteArrow::newItem);
itemNameHash.insert("game_eventset_card_attr", Event_SetCardAttr::newItem);
itemNameHash.insert("game_eventset_card_counter", Event_SetCardCounter::newItem);
itemNameHash.insert("game_eventset_counter", Event_SetCounter::newItem);
itemNameHash.insert("game_eventdel_counter", Event_DelCounter::newItem);
itemNameHash.insert("game_eventset_active_player", Event_SetActivePlayer::newItem);
itemNameHash.insert("game_eventset_active_phase", Event_SetActivePhase::newItem);
itemNameHash.insert("game_eventdump_zone", Event_DumpZone::newItem);
itemNameHash.insert("game_eventstop_dump_zone", Event_StopDumpZone::newItem);
itemNameHash.insert("generic_eventremove_from_list", Event_RemoveFromList::newItem);
itemNameHash.insert("generic_eventserver_message", Event_ServerMessage::newItem);
itemNameHash.insert("generic_eventserver_shutdown", Event_ServerShutdown::newItem);
itemNameHash.insert("generic_eventconnection_closed", Event_ConnectionClosed::newItem);
itemNameHash.insert("generic_eventmessage", Event_Message::newItem);
itemNameHash.insert("generic_eventgame_joined", Event_GameJoined::newItem);
itemNameHash.insert("generic_eventuser_left", Event_UserLeft::newItem);
itemNameHash.insert("room_eventleave_room", Event_LeaveRoom::newItem);
itemNameHash.insert("room_eventroom_say", Event_RoomSay::newItem);
itemNameHash.insert("game_event_contextready_start", Context_ReadyStart::newItem);
itemNameHash.insert("game_event_contextconcede", Context_Concede::newItem);
itemNameHash.insert("game_event_contextdeck_select", Context_DeckSelect::newItem);
itemNameHash.insert("game_event_contextundo_draw", Context_UndoDraw::newItem);
itemNameHash.insert("game_event_contextmove_card", Context_MoveCard::newItem);
itemNameHash.insert("game_event_contextmulligan", Context_Mulligan::newItem);
}

View file

@ -1,37 +0,0 @@
3:connection_state_changed:b,connected
3:say:s,message
3:leave
3:game_closed
3:game_host_changed
3:kicked
3:shuffle
3:roll_die:i,sides:i,value
3:move_card:i,card_id:s,card_name:s,start_zone:i,position:i,target_player_id:s,target_zone:i,x:i,y:i,new_card_id:b,face_down
3:flip_card:s,zone:i,card_id:s,card_name:b,face_down
3:destroy_card:s,zone:i,card_id
3:attach_card:s,start_zone:i,card_id:i,target_player_id:s,target_zone:i,target_card_id
3:create_token:s,zone:i,card_id:s,card_name:s,color:s,pt:s,annotation:b,destroy_on_zone_change:i,x:i,y
3:delete_arrow:i,arrow_id
3:set_card_attr:s,zone:i,card_id:s,attr_name:s,attr_value
3:set_card_counter:s,zone:i,card_id:i,counter_id:i,counter_value
3:set_counter:i,counter_id:i,value
3:del_counter:i,counter_id
3:set_active_player:i,active_player_id
3:set_active_phase:i,phase
3:dump_zone:i,zone_owner_id:s,zone:i,number_cards
3:stop_dump_zone:i,zone_owner_id:s,zone
4:remove_from_list:s,list:s,user_name
4:server_message:s,message
4:server_shutdown:s,reason:i,minutes
4:connection_closed:s,reason
4:message:s,sender_name:s,receiver_name:s,text
4:game_joined:i,game_id:s,game_description:i,host_id:i,player_id:b,spectator:b,spectators_can_talk:b,spectators_see_everything:b,resuming
4:user_left:s,user_name
5:leave_room:s,player_name
5:room_say:s,player_name:s,message
6:ready_start
6:concede
6:deck_select:s,deck_hash
6:undo_draw
6:move_card
6:mulligan:i,number

View file

@ -1,342 +0,0 @@
#ifndef PROTOCOL_ITEMS_H
#define PROTOCOL_ITEMS_H
#include "protocol.h"
class Event_ConnectionStateChanged : public GameEvent {
Q_OBJECT
public:
Event_ConnectionStateChanged(int _playerId = -1, bool _connected = false);
bool getConnected() const { return static_cast<SerializableItem_Bool *>(itemMap.value("connected"))->getData(); };
static SerializableItem *newItem() { return new Event_ConnectionStateChanged; }
int getItemId() const { return ItemId_Event_ConnectionStateChanged; }
};
class Event_Say : public GameEvent {
Q_OBJECT
public:
Event_Say(int _playerId = -1, const QString &_message = QString());
QString getMessage() const { return static_cast<SerializableItem_String *>(itemMap.value("message"))->getData(); };
static SerializableItem *newItem() { return new Event_Say; }
int getItemId() const { return ItemId_Event_Say; }
};
class Event_Leave : public GameEvent {
Q_OBJECT
public:
Event_Leave(int _playerId = -1);
static SerializableItem *newItem() { return new Event_Leave; }
int getItemId() const { return ItemId_Event_Leave; }
};
class Event_GameClosed : public GameEvent {
Q_OBJECT
public:
Event_GameClosed(int _playerId = -1);
static SerializableItem *newItem() { return new Event_GameClosed; }
int getItemId() const { return ItemId_Event_GameClosed; }
};
class Event_GameHostChanged : public GameEvent {
Q_OBJECT
public:
Event_GameHostChanged(int _playerId = -1);
static SerializableItem *newItem() { return new Event_GameHostChanged; }
int getItemId() const { return ItemId_Event_GameHostChanged; }
};
class Event_Kicked : public GameEvent {
Q_OBJECT
public:
Event_Kicked(int _playerId = -1);
static SerializableItem *newItem() { return new Event_Kicked; }
int getItemId() const { return ItemId_Event_Kicked; }
};
class Event_Shuffle : public GameEvent {
Q_OBJECT
public:
Event_Shuffle(int _playerId = -1);
static SerializableItem *newItem() { return new Event_Shuffle; }
int getItemId() const { return ItemId_Event_Shuffle; }
};
class Event_RollDie : public GameEvent {
Q_OBJECT
public:
Event_RollDie(int _playerId = -1, int _sides = -1, int _value = -1);
int getSides() const { return static_cast<SerializableItem_Int *>(itemMap.value("sides"))->getData(); };
int getValue() const { return static_cast<SerializableItem_Int *>(itemMap.value("value"))->getData(); };
static SerializableItem *newItem() { return new Event_RollDie; }
int getItemId() const { return ItemId_Event_RollDie; }
};
class Event_MoveCard : public GameEvent {
Q_OBJECT
public:
Event_MoveCard(int _playerId = -1, int _cardId = -1, const QString &_cardName = QString(), const QString &_startZone = QString(), int _position = -1, int _targetPlayerId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1, int _newCardId = -1, bool _faceDown = false);
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
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(); };
int getPosition() const { return static_cast<SerializableItem_Int *>(itemMap.value("position"))->getData(); };
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_id"))->getData(); };
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); };
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); };
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); };
int getNewCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("new_card_id"))->getData(); };
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("face_down"))->getData(); };
static SerializableItem *newItem() { return new Event_MoveCard; }
int getItemId() const { return ItemId_Event_MoveCard; }
};
class Event_FlipCard : public GameEvent {
Q_OBJECT
public:
Event_FlipCard(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1, const QString &_cardName = QString(), bool _faceDown = false);
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); };
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("face_down"))->getData(); };
static SerializableItem *newItem() { return new Event_FlipCard; }
int getItemId() const { return ItemId_Event_FlipCard; }
};
class Event_DestroyCard : public GameEvent {
Q_OBJECT
public:
Event_DestroyCard(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1);
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
static SerializableItem *newItem() { return new Event_DestroyCard; }
int getItemId() const { return ItemId_Event_DestroyCard; }
};
class Event_AttachCard : public GameEvent {
Q_OBJECT
public:
Event_AttachCard(int _playerId = -1, const QString &_startZone = QString(), int _cardId = -1, int _targetPlayerId = -1, const QString &_targetZone = QString(), int _targetCardId = -1);
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); };
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_id"))->getData(); };
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); };
int getTargetCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_card_id"))->getData(); };
static SerializableItem *newItem() { return new Event_AttachCard; }
int getItemId() const { return ItemId_Event_AttachCard; }
};
class Event_CreateToken : public GameEvent {
Q_OBJECT
public:
Event_CreateToken(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1, const QString &_cardName = QString(), const QString &_color = QString(), const QString &_pt = QString(), const QString &_annotation = QString(), bool _destroyOnZoneChange = false, int _x = -1, int _y = -1);
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
QString getCardName() const { return static_cast<SerializableItem_String *>(itemMap.value("card_name"))->getData(); };
QString getColor() const { return static_cast<SerializableItem_String *>(itemMap.value("color"))->getData(); };
QString getPt() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); };
QString getAnnotation() const { return static_cast<SerializableItem_String *>(itemMap.value("annotation"))->getData(); };
bool getDestroyOnZoneChange() const { return static_cast<SerializableItem_Bool *>(itemMap.value("destroy_on_zone_change"))->getData(); };
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); };
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); };
static SerializableItem *newItem() { return new Event_CreateToken; }
int getItemId() const { return ItemId_Event_CreateToken; }
};
class Event_DeleteArrow : public GameEvent {
Q_OBJECT
public:
Event_DeleteArrow(int _playerId = -1, int _arrowId = -1);
int getArrowId() const { return static_cast<SerializableItem_Int *>(itemMap.value("arrow_id"))->getData(); };
static SerializableItem *newItem() { return new Event_DeleteArrow; }
int getItemId() const { return ItemId_Event_DeleteArrow; }
};
class Event_SetCardAttr : public GameEvent {
Q_OBJECT
public:
Event_SetCardAttr(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1, const QString &_attrName = QString(), const QString &_attrValue = QString());
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
QString getAttrName() const { return static_cast<SerializableItem_String *>(itemMap.value("attr_name"))->getData(); };
QString getAttrValue() const { return static_cast<SerializableItem_String *>(itemMap.value("attr_value"))->getData(); };
static SerializableItem *newItem() { return new Event_SetCardAttr; }
int getItemId() const { return ItemId_Event_SetCardAttr; }
};
class Event_SetCardCounter : public GameEvent {
Q_OBJECT
public:
Event_SetCardCounter(int _playerId = -1, const QString &_zone = QString(), int _cardId = -1, int _counterId = -1, int _counterValue = -1);
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
int getCounterId() const { return static_cast<SerializableItem_Int *>(itemMap.value("counter_id"))->getData(); };
int getCounterValue() const { return static_cast<SerializableItem_Int *>(itemMap.value("counter_value"))->getData(); };
static SerializableItem *newItem() { return new Event_SetCardCounter; }
int getItemId() const { return ItemId_Event_SetCardCounter; }
};
class Event_SetCounter : public GameEvent {
Q_OBJECT
public:
Event_SetCounter(int _playerId = -1, int _counterId = -1, int _value = -1);
int getCounterId() const { return static_cast<SerializableItem_Int *>(itemMap.value("counter_id"))->getData(); };
int getValue() const { return static_cast<SerializableItem_Int *>(itemMap.value("value"))->getData(); };
static SerializableItem *newItem() { return new Event_SetCounter; }
int getItemId() const { return ItemId_Event_SetCounter; }
};
class Event_DelCounter : public GameEvent {
Q_OBJECT
public:
Event_DelCounter(int _playerId = -1, int _counterId = -1);
int getCounterId() const { return static_cast<SerializableItem_Int *>(itemMap.value("counter_id"))->getData(); };
static SerializableItem *newItem() { return new Event_DelCounter; }
int getItemId() const { return ItemId_Event_DelCounter; }
};
class Event_SetActivePlayer : public GameEvent {
Q_OBJECT
public:
Event_SetActivePlayer(int _playerId = -1, int _activePlayerId = -1);
int getActivePlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("active_player_id"))->getData(); };
static SerializableItem *newItem() { return new Event_SetActivePlayer; }
int getItemId() const { return ItemId_Event_SetActivePlayer; }
};
class Event_SetActivePhase : public GameEvent {
Q_OBJECT
public:
Event_SetActivePhase(int _playerId = -1, int _phase = -1);
int getPhase() const { return static_cast<SerializableItem_Int *>(itemMap.value("phase"))->getData(); };
static SerializableItem *newItem() { return new Event_SetActivePhase; }
int getItemId() const { return ItemId_Event_SetActivePhase; }
};
class Event_DumpZone : public GameEvent {
Q_OBJECT
public:
Event_DumpZone(int _playerId = -1, int _zoneOwnerId = -1, const QString &_zone = QString(), int _numberCards = -1);
int getZoneOwnerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("zone_owner_id"))->getData(); };
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
int getNumberCards() const { return static_cast<SerializableItem_Int *>(itemMap.value("number_cards"))->getData(); };
static SerializableItem *newItem() { return new Event_DumpZone; }
int getItemId() const { return ItemId_Event_DumpZone; }
};
class Event_StopDumpZone : public GameEvent {
Q_OBJECT
public:
Event_StopDumpZone(int _playerId = -1, int _zoneOwnerId = -1, const QString &_zone = QString());
int getZoneOwnerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("zone_owner_id"))->getData(); };
QString getZone() const { return static_cast<SerializableItem_String *>(itemMap.value("zone"))->getData(); };
static SerializableItem *newItem() { return new Event_StopDumpZone; }
int getItemId() const { return ItemId_Event_StopDumpZone; }
};
class Event_RemoveFromList : public GenericEvent {
Q_OBJECT
public:
Event_RemoveFromList(const QString &_list = QString(), const QString &_userName = QString());
QString getList() const { return static_cast<SerializableItem_String *>(itemMap.value("list"))->getData(); };
QString getUserName() const { return static_cast<SerializableItem_String *>(itemMap.value("user_name"))->getData(); };
static SerializableItem *newItem() { return new Event_RemoveFromList; }
int getItemId() const { return ItemId_Event_RemoveFromList; }
};
class Event_ServerMessage : public GenericEvent {
Q_OBJECT
public:
Event_ServerMessage(const QString &_message = QString());
QString getMessage() const { return static_cast<SerializableItem_String *>(itemMap.value("message"))->getData(); };
static SerializableItem *newItem() { return new Event_ServerMessage; }
int getItemId() const { return ItemId_Event_ServerMessage; }
};
class Event_ServerShutdown : public GenericEvent {
Q_OBJECT
public:
Event_ServerShutdown(const QString &_reason = QString(), int _minutes = -1);
QString getReason() const { return static_cast<SerializableItem_String *>(itemMap.value("reason"))->getData(); };
int getMinutes() const { return static_cast<SerializableItem_Int *>(itemMap.value("minutes"))->getData(); };
static SerializableItem *newItem() { return new Event_ServerShutdown; }
int getItemId() const { return ItemId_Event_ServerShutdown; }
};
class Event_ConnectionClosed : public GenericEvent {
Q_OBJECT
public:
Event_ConnectionClosed(const QString &_reason = QString());
QString getReason() const { return static_cast<SerializableItem_String *>(itemMap.value("reason"))->getData(); };
static SerializableItem *newItem() { return new Event_ConnectionClosed; }
int getItemId() const { return ItemId_Event_ConnectionClosed; }
};
class Event_Message : public GenericEvent {
Q_OBJECT
public:
Event_Message(const QString &_senderName = QString(), const QString &_receiverName = QString(), const QString &_text = QString());
QString getSenderName() const { return static_cast<SerializableItem_String *>(itemMap.value("sender_name"))->getData(); };
QString getReceiverName() const { return static_cast<SerializableItem_String *>(itemMap.value("receiver_name"))->getData(); };
QString getText() const { return static_cast<SerializableItem_String *>(itemMap.value("text"))->getData(); };
static SerializableItem *newItem() { return new Event_Message; }
int getItemId() const { return ItemId_Event_Message; }
};
class Event_GameJoined : public GenericEvent {
Q_OBJECT
public:
Event_GameJoined(int _gameId = -1, const QString &_gameDescription = QString(), int _hostId = -1, int _playerId = -1, bool _spectator = false, bool _spectatorsCanTalk = false, bool _spectatorsSeeEverything = false, bool _resuming = false);
int getGameId() const { return static_cast<SerializableItem_Int *>(itemMap.value("game_id"))->getData(); };
QString getGameDescription() const { return static_cast<SerializableItem_String *>(itemMap.value("game_description"))->getData(); };
int getHostId() const { return static_cast<SerializableItem_Int *>(itemMap.value("host_id"))->getData(); };
int getPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("player_id"))->getData(); };
bool getSpectator() const { return static_cast<SerializableItem_Bool *>(itemMap.value("spectator"))->getData(); };
bool getSpectatorsCanTalk() const { return static_cast<SerializableItem_Bool *>(itemMap.value("spectators_can_talk"))->getData(); };
bool getSpectatorsSeeEverything() const { return static_cast<SerializableItem_Bool *>(itemMap.value("spectators_see_everything"))->getData(); };
bool getResuming() const { return static_cast<SerializableItem_Bool *>(itemMap.value("resuming"))->getData(); };
static SerializableItem *newItem() { return new Event_GameJoined; }
int getItemId() const { return ItemId_Event_GameJoined; }
};
class Event_UserLeft : public GenericEvent {
Q_OBJECT
public:
Event_UserLeft(const QString &_userName = QString());
QString getUserName() const { return static_cast<SerializableItem_String *>(itemMap.value("user_name"))->getData(); };
static SerializableItem *newItem() { return new Event_UserLeft; }
int getItemId() const { return ItemId_Event_UserLeft; }
};
class Event_LeaveRoom : public RoomEvent {
Q_OBJECT
public:
Event_LeaveRoom(int _roomId = -1, const QString &_playerName = QString());
QString getPlayerName() const { return static_cast<SerializableItem_String *>(itemMap.value("player_name"))->getData(); };
static SerializableItem *newItem() { return new Event_LeaveRoom; }
int getItemId() const { return ItemId_Event_LeaveRoom; }
};
class Event_RoomSay : public RoomEvent {
Q_OBJECT
public:
Event_RoomSay(int _roomId = -1, const QString &_playerName = QString(), const QString &_message = QString());
QString getPlayerName() const { return static_cast<SerializableItem_String *>(itemMap.value("player_name"))->getData(); };
QString getMessage() const { return static_cast<SerializableItem_String *>(itemMap.value("message"))->getData(); };
static SerializableItem *newItem() { return new Event_RoomSay; }
int getItemId() const { return ItemId_Event_RoomSay; }
};
class Context_ReadyStart : public GameEventContext {
Q_OBJECT
public:
Context_ReadyStart();
static SerializableItem *newItem() { return new Context_ReadyStart; }
int getItemId() const { return ItemId_Context_ReadyStart; }
};
class Context_Concede : public GameEventContext {
Q_OBJECT
public:
Context_Concede();
static SerializableItem *newItem() { return new Context_Concede; }
int getItemId() const { return ItemId_Context_Concede; }
};
class Context_DeckSelect : public GameEventContext {
Q_OBJECT
public:
Context_DeckSelect(const QString &_deckHash = QString());
QString getDeckHash() const { return static_cast<SerializableItem_String *>(itemMap.value("deck_hash"))->getData(); };
static SerializableItem *newItem() { return new Context_DeckSelect; }
int getItemId() const { return ItemId_Context_DeckSelect; }
};
class Context_UndoDraw : public GameEventContext {
Q_OBJECT
public:
Context_UndoDraw();
static SerializableItem *newItem() { return new Context_UndoDraw; }
int getItemId() const { return ItemId_Context_UndoDraw; }
};
class Context_MoveCard : public GameEventContext {
Q_OBJECT
public:
Context_MoveCard();
static SerializableItem *newItem() { return new Context_MoveCard; }
int getItemId() const { return ItemId_Context_MoveCard; }
};
class Context_Mulligan : public GameEventContext {
Q_OBJECT
public:
Context_Mulligan(int _number = -1);
int getNumber() const { return static_cast<SerializableItem_Int *>(itemMap.value("number"))->getData(); };
static SerializableItem *newItem() { return new Context_Mulligan; }
int getItemId() const { return ItemId_Context_Mulligan; }
};
#endif

View file

@ -1,162 +0,0 @@
#!/usr/bin/perl
$initializeHash = '';
$itemId = 1000;
$headerfileBuffer = '';
open(idfile, ">protocol_item_ids.h");
open(headerfile, ">protocol_items.h");
print headerfile "#ifndef PROTOCOL_ITEMS_H\n"
. "#define PROTOCOL_ITEMS_H\n\n"
. "#include \"protocol.h\"\n\n";
open(cppfile, ">protocol_items.cpp");
print cppfile "#include \"protocol.h\"\n"
. "#include \"protocol_items.h\"\n\n";
open(file, "protocol_items.dat");
while (<file>) {
s/\s+$//;
@line = split(/:/);
$type = shift(@line);
$name1 = shift(@line);
($name2 = $name1) =~ s/_(.)/\U$1\E/g;
$name2 =~ s/^(.)/\U$1\E/;
if ($type == 0) {
$type = 'cmd';
$namePrefix = 'Command';
$baseClass = 'Command';
$parentConstructorCall = "$baseClass(\"$name1\")";
$constructorParamsH = "";
$constructorParamsCpp = "";
} elsif ($type == 1) {
$type = 'cmd';
$namePrefix = 'Command';
$baseClass = 'RoomCommand';
$parentConstructorCall = "$baseClass(\"$name1\", _roomId)";
$constructorParamsH = "int _roomId = -1";
$constructorParamsCpp = "int _roomId";
} elsif ($type == 2) {
$type = 'cmd';
$namePrefix = 'Command';
$baseClass = 'GameCommand';
$parentConstructorCall = "$baseClass(\"$name1\", _gameId)";
$constructorParamsH = "int _gameId = -1";
$constructorParamsCpp = "int _gameId";
} elsif ($type == 3) {
$type = 'game_event';
$namePrefix = 'Event';
$baseClass = 'GameEvent';
$parentConstructorCall = "$baseClass(\"$name1\", _playerId)";
$constructorParamsH = "int _playerId = -1";
$constructorParamsCpp = "int _playerId";
} elsif ($type == 4) {
$type = 'generic_event';
$namePrefix = 'Event';
$baseClass = 'GenericEvent';
$parentConstructorCall = "$baseClass(\"$name1\")";
$constructorParamsH = "";
$constructorParamsCpp = "";
} elsif ($type == 5) {
$type = 'room_event';
$namePrefix = 'Event';
$baseClass = 'RoomEvent';
$parentConstructorCall = "$baseClass(\"$name1\", _roomId)";
$constructorParamsH = "int _roomId = -1";
$constructorParamsCpp = "int _roomId";
} elsif ($type == 6) {
$type = 'game_event_context';
$namePrefix = 'Context';
$baseClass = 'GameEventContext';
$parentConstructorCall = "$baseClass(\"$name1\")";
$constructorParamsH = "";
$constructorParamsCpp = "";
} elsif ($type == 7) {
$type = 'cmd';
$namePrefix = 'Command';
$baseClass = 'AdminCommand';
$parentConstructorCall = "$baseClass(\"$name1\")";
$constructorParamsH = "";
$constructorParamsCpp = "";
} elsif ($type == 8) {
$type = 'cmd';
$namePrefix = 'Command';
$baseClass = 'ModeratorCommand';
$parentConstructorCall = "$baseClass(\"$name1\")";
$constructorParamsH = "";
$constructorParamsCpp = "";
}
$className = $namePrefix . '_' . $name2;
$itemEnum .= "ItemId_$className = " . ++$itemId . ",\n";
$headerfileBuffer .= "class $className : public $baseClass {\n"
. "\tQ_OBJECT\n";
$constructorCode = '';
$getFunctionCode = '';
while ($param = shift(@line)) {
($key, $value) = split(/,/, $param);
($prettyVarName = $value) =~ s/_(.)/\U$1\E/g;
if (!($constructorParamsH eq '')) {
$constructorParamsH .= ', ';
}
if (!($constructorParamsCpp eq '')) {
$constructorParamsCpp .= ', ';
}
($prettyVarName2 = $prettyVarName) =~ s/^(.)/\U$1\E/;
if ($key eq 'b') {
$dataType = 'bool';
$constructorParamsH .= "bool _$prettyVarName = false";
$constructorParamsCpp .= "bool _$prettyVarName";
$constructorCode .= "\tinsertItem(new SerializableItem_Bool(\"$value\", _$prettyVarName));\n";
$getFunctionCode .= "\t$dataType get$prettyVarName2() const { return static_cast<SerializableItem_Bool *>(itemMap.value(\"$value\"))->getData(); };\n";
} elsif ($key eq 's') {
$dataType = 'QString';
$constructorParamsH .= "const QString &_$prettyVarName = QString()";
$constructorParamsCpp .= "const QString &_$prettyVarName";
$constructorCode .= "\tinsertItem(new SerializableItem_String(\"$value\", _$prettyVarName));\n";
$getFunctionCode .= "\t$dataType get$prettyVarName2() const { return static_cast<SerializableItem_String *>(itemMap.value(\"$value\"))->getData(); };\n";
} elsif ($key eq 'i') {
$dataType = 'int';
$constructorParamsH .= "int _$prettyVarName = -1";
$constructorParamsCpp .= "int _$prettyVarName";
$constructorCode .= "\tinsertItem(new SerializableItem_Int(\"$value\", _$prettyVarName));\n";
$getFunctionCode .= "\t$dataType get$prettyVarName2() const { return static_cast<SerializableItem_Int *>(itemMap.value(\"$value\"))->getData(); };\n";
} elsif ($key eq 'c') {
$dataType = 'Color';
$constructorParamsH .= "const Color &_$prettyVarName = Color()";
$constructorParamsCpp .= "const Color &_$prettyVarName";
$constructorCode .= "\tinsertItem(new SerializableItem_Color(\"$value\", _$prettyVarName));\n";
$getFunctionCode .= "\t$dataType get$prettyVarName2() const { return static_cast<SerializableItem_Color *>(itemMap.value(\"$value\"))->getData(); };\n";
}
}
$headerfileBuffer .= "public:\n"
. "\t$className($constructorParamsH);\n"
. $getFunctionCode
. "\tstatic SerializableItem *newItem() { return new $className; }\n"
. "\tint getItemId() const { return ItemId_$className; }\n"
. "};\n";
print cppfile $className . "::$className($constructorParamsCpp)\n"
. "\t: $parentConstructorCall\n"
. "{\n"
. $constructorCode
. "}\n";
$initializeHash .= "\titemNameHash.insert(\"$type$name1\", $className" . "::newItem);\n";
}
close(file);
print idfile "enum AutoItemId {\n"
. $itemEnum
. "ItemId_Other = " . ++$itemId . "\n"
. "};\n";
close(idfile);
print headerfile $headerfileBuffer
. "\n#endif\n";
close(headerfile);
print cppfile "void ProtocolItem::initializeHashAuto()\n"
. "{\n"
. $initializeHash
. "}\n";
close(cppfile);

View file

@ -24,7 +24,6 @@ HEADERS += src/main.h \
../common/serializable_item.h \
../common/decklist.h \
../common/protocol.h \
../common/protocol_items.h \
../common/protocol_datastructures.h \
../common/rng_abstract.h \
../common/rng_sfmt.h \
@ -49,7 +48,6 @@ SOURCES += src/main.cpp \
../common/serializable_item.cpp \
../common/decklist.cpp \
../common/protocol.cpp \
../common/protocol_items.cpp \
../common/protocol_datastructures.cpp \
../common/rng_abstract.cpp \
../common/rng_sfmt.cpp \