Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
69407072
Commit
69407072
authored
Nov 29, 2009
by
Max-Wilhelm Bruker
Browse files
restructured protocol code
parent
122f8ea9
Changes
32
Hide whitespace changes
Inline
Side-by-side
common/protocol_datastructures.h
View file @
69407072
...
@@ -4,9 +4,7 @@
...
@@ -4,9 +4,7 @@
#include
<QString>
#include
<QString>
#include
<QColor>
#include
<QColor>
#include
<QDateTime>
#include
<QDateTime>
#include
"serializable_item.h"
class
QXmlStreamReader
;
class
QXmlStreamWriter
;
enum
ResponseCode
{
RespNothing
,
RespOk
,
RespInvalidCommand
,
RespInvalidData
,
RespNameNotFound
,
RespLoginNeeded
,
RespContextError
,
RespWrongPassword
,
RespSpectatorsNotAllowed
};
enum
ResponseCode
{
RespNothing
,
RespOk
,
RespInvalidCommand
,
RespInvalidData
,
RespNameNotFound
,
RespLoginNeeded
,
RespContextError
,
RespWrongPassword
,
RespSpectatorsNotAllowed
};
...
@@ -20,210 +18,124 @@ enum ResponseCode { RespNothing, RespOk, RespInvalidCommand, RespInvalidData, Re
...
@@ -20,210 +18,124 @@ enum ResponseCode { RespNothing, RespOk, RespInvalidCommand, RespInvalidData, Re
// list index, whereas cards in any other zone are referenced by their ids.
// list index, whereas cards in any other zone are referenced by their ids.
enum
ZoneType
{
PrivateZone
,
PublicZone
,
HiddenZone
};
enum
ZoneType
{
PrivateZone
,
PublicZone
,
HiddenZone
};
class
ColorConverter
{
class
ServerInfo_ChatChannel
:
public
SerializableItem_Map
{
public:
public:
static
int
colorToInt
(
const
QColor
&
color
)
ServerInfo_ChatChannel
(
const
QString
&
_name
=
QString
(),
const
QString
&
_description
=
QString
(),
int
_playerCount
=
-
1
,
bool
_autoJoin
=
false
);
{
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_ChatChannel
;
}
return
color
.
red
()
*
65536
+
color
.
green
()
*
256
+
color
.
blue
();
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
}
QString
getDescription
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"description"
))
->
getData
();
}
static
QColor
colorFromInt
(
int
colorValue
)
int
getPlayerCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_count"
))
->
getData
();
}
{
bool
getAutoJoin
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"auto_join"
))
->
getData
();
}
return
QColor
(
colorValue
/
65536
,
(
colorValue
%
65536
)
/
256
,
colorValue
%
256
);
}
};
};
class
SerializableItem
{
class
ServerInfo_ChatUser
:
public
SerializableItem_Map
{
protected:
SerializableItem
*
currentItem
;
public:
public:
Ser
ializableItem
()
:
currentItem
(
0
)
{
}
Ser
verInfo_ChatUser
(
const
QString
&
_name
=
QString
());
virtual
bool
readElement
(
QXmlStreamReader
*
xml
)
=
0
;
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_ChatUser
;
}
virtual
void
writeElement
(
QXmlStreamWriter
*
xml
)
=
0
;
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
};
};
class
ServerChatChannelInfo
{
class
ServerInfo_Game
:
public
SerializableItem_Map
{
private:
QString
name
;
QString
description
;
int
playerCount
;
bool
autoJoin
;
public:
public:
ServerChatChannelInfo
(
const
QString
&
_name
,
const
QString
&
_description
,
int
_playerCount
,
bool
_autoJoin
)
ServerInfo_Game
(
int
_gameId
=
-
1
,
const
QString
&
_description
=
QString
(),
bool
_hasPassword
=
false
,
int
_playerCount
=
-
1
,
int
_maxPlayers
=
-
1
,
const
QString
&
_creatorName
=
QString
(),
bool
_spectatorsAllowed
=
false
,
int
_spectatorCount
=
-
1
);
:
name
(
_name
),
description
(
_description
),
playerCount
(
_playerCount
),
autoJoin
(
_autoJoin
)
{
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Game
;
}
QString
getName
()
const
{
return
name
;
}
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
();
}
QString
getDescription
()
const
{
return
description
;
}
QString
getDescription
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"description"
))
->
getData
();
}
int
getPlayerCount
()
const
{
return
playerCount
;
}
bool
getHasPassword
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"has_password"
))
->
getData
();
}
bool
getAutoJoin
()
const
{
return
autoJoin
;
}
int
getPlayerCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_count"
))
->
getData
();
}
int
getMaxPlayers
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"max_players"
))
->
getData
();
}
QString
getCreatorName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"creator_name"
))
->
getData
();
}
bool
getSpectatorsAllowed
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectators_allowed"
))
->
getData
();
}
int
getSpectatorCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"spectator_count"
))
->
getData
();
}
};
};
class
ServerChatUserInfo
{
class
ServerInfo_Card
:
public
SerializableItem_Map
{
private:
QString
name
;
public:
public:
ServerChatUserInfo
(
const
QString
&
_name
)
ServerInfo_Card
(
int
_id
=
-
1
,
const
QString
&
_name
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
int
_counters
=
-
1
,
bool
_tapped
=
false
,
bool
_attacking
=
false
,
const
QString
&
_annotation
=
QString
());
:
name
(
_name
)
{
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Card
;
}
QString
getName
()
const
{
return
name
;
}
int
getId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"id"
))
->
getData
();
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
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
getCounters
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counters"
))
->
getData
();
}
bool
getTapped
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"tapped"
))
->
getData
();
}
bool
getAttacking
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"attacking"
))
->
getData
();
}
QString
getAnnotation
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"annotation"
))
->
getData
();
}
};
};
class
Server
Game
Info
{
class
ServerInfo
_Zone
:
public
SerializableItem_Map
{
private:
private:
int
gameId
;
ZoneType
typeFromString
(
const
QString
&
type
)
const
;
QString
description
;
QString
typeToString
(
ZoneType
type
)
const
;
bool
hasPassword
;
int
playerCount
;
int
maxPlayers
;
QString
creatorName
;
bool
spectatorsAllowed
;
int
spectatorCount
;
public:
public:
ServerGameInfo
(
int
_gameId
,
const
QString
&
_description
,
bool
_hasPassword
,
int
_playerCount
,
int
_maxPlayers
,
const
QString
&
_creatorName
,
bool
_spectatorsAllowed
,
int
_spectatorCount
)
ServerInfo_Zone
(
const
QString
&
_name
=
QString
(),
ZoneType
_type
=
PrivateZone
,
bool
_hasCoords
=
false
,
int
_cardCount
=
-
1
,
const
QList
<
ServerInfo_Card
*>
&
_cardList
=
QList
<
ServerInfo_Card
*>
());
:
gameId
(
_gameId
),
description
(
_description
),
hasPassword
(
_hasPassword
),
playerCount
(
_playerCount
),
maxPlayers
(
_maxPlayers
),
creatorName
(
_creatorName
),
spectatorsAllowed
(
_spectatorsAllowed
),
spectatorCount
(
_spectatorCount
)
{
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Zone
;
}
int
getGameId
()
const
{
return
gameId
;
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
QString
getDescription
()
const
{
return
description
;
}
ZoneType
getType
()
const
{
return
typeFromString
(
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"type"
))
->
getData
());
}
bool
getHasPassword
()
const
{
return
hasPassword
;
}
bool
getHasCoords
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"has_coords"
))
->
getData
();
}
int
getPlayerCount
()
const
{
return
playerCount
;
}
int
getCardCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_count"
))
->
getData
();
}
int
getMaxPlayers
()
const
{
return
maxPlayers
;
}
QList
<
ServerInfo_Card
*>
getCardList
()
const
;
QString
getCreatorName
()
const
{
return
creatorName
;
}
bool
getSpectatorsAllowed
()
const
{
return
spectatorsAllowed
;
}
int
getSpectatorCount
()
const
{
return
spectatorCount
;
}
};
};
class
ServerInfo_Card
:
public
SerializableItem
{
class
ServerInfo_Counter
:
public
SerializableItem_Map
{
private:
int
id
;
QString
name
;
int
x
,
y
;
int
counters
;
bool
tapped
;
bool
attacking
;
QString
annotation
;
public:
public:
ServerInfo_Card
(
int
_id
=
-
1
,
const
QString
&
_name
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
int
_counters
=
-
1
,
bool
_tapped
=
false
,
bool
_attacking
=
false
,
const
QString
&
_annotation
=
QString
())
ServerInfo_Counter
(
int
_id
=
-
1
,
const
QString
&
_name
=
QString
(),
const
QColor
&
_color
=
QColor
(),
int
_radius
=
-
1
,
int
_count
=
-
1
);
:
id
(
_id
),
name
(
_name
),
x
(
_x
),
y
(
_y
),
counters
(
_counters
),
tapped
(
_tapped
),
attacking
(
_attacking
),
annotation
(
_annotation
)
{
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Counter
;
}
int
getId
()
const
{
return
id
;
}
int
getId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"id"
))
->
getData
();
}
QString
getName
()
const
{
return
name
;
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
int
getX
()
const
{
return
x
;
}
QColor
getColor
()
const
{
return
static_cast
<
SerializableItem_Color
*>
(
itemMap
.
value
(
"color"
))
->
getData
();
}
int
getY
()
const
{
return
y
;
}
int
getRadius
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"radius"
))
->
getData
();
}
int
getCounters
()
const
{
return
counters
;
}
int
getCount
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"count"
))
->
getData
();
}
bool
getTapped
()
const
{
return
tapped
;
}
bool
getAttacking
()
const
{
return
attacking
;
}
QString
getAnnotation
()
const
{
return
annotation
;
}
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
};
class
ServerInfo_Zone
:
public
SerializableItem
{
class
ServerInfo_Arrow
:
public
SerializableItem_Map
{
private:
QString
name
;
ZoneType
type
;
bool
hasCoords
;
int
cardCount
;
QList
<
ServerInfo_Card
*>
cardList
;
public:
public:
ServerInfo_Zone
(
const
QString
&
_name
=
QString
(),
ZoneType
_type
=
PrivateZone
,
bool
_hasCoords
=
false
,
int
_cardCount
=
-
1
,
const
QList
<
ServerInfo_Card
*>
&
_cardList
=
QList
<
ServerInfo_Card
*>
())
ServerInfo_Arrow
(
int
_id
=
-
1
,
int
_startPlayerId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
int
_startCardId
=
-
1
,
int
_targetPlayerId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_targetCardId
=
-
1
,
const
QColor
&
_color
=
QColor
());
:
name
(
_name
),
type
(
_type
),
hasCoords
(
_hasCoords
),
cardCount
(
_cardCount
),
cardList
(
_cardList
)
{
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Arrow
;
}
~
ServerInfo_Zone
();
int
getId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"id"
))
->
getData
();
}
QString
getName
()
const
{
return
name
;
}
int
getStartPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"start_player_id"
))
->
getData
();
}
ZoneType
getType
()
const
{
return
type
;
}
QString
getStartZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
();
}
bool
getHasCoords
()
const
{
return
hasCoords
;
}
int
getStartCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"start_card_id"
))
->
getData
();
}
int
getCardCount
()
const
{
return
cardCount
;
}
int
getTargetPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"target_player_id"
))
->
getData
();
}
const
QList
<
ServerInfo_Card
*>
&
getCardList
()
const
{
return
cardList
;
}
QString
getTargetZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"target_zone"
))
->
getData
();
}
void
addCard
(
ServerInfo_Card
*
card
)
{
cardList
.
append
(
card
);
++
cardCount
;
}
int
getTargetCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"target_card_id"
))
->
getData
();
}
bool
readElement
(
QXmlStreamReader
*
xml
);
QColor
getColor
()
const
{
return
static_cast
<
SerializableItem_Color
*>
(
itemMap
.
value
(
"color"
))
->
getData
();
}
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
};
class
ServerInfo_
Count
er
:
public
SerializableItem
{
class
ServerInfo_
Play
er
:
public
SerializableItem
_Map
{
private:
private:
int
id
;
QString
name
;
QColor
color
;
int
radius
;
int
count
;
public:
ServerInfo_Counter
(
int
_id
=
-
1
,
const
QString
&
_name
=
QString
(),
const
QColor
&
_color
=
QColor
(),
int
_radius
=
-
1
,
int
_count
=
-
1
)
:
id
(
_id
),
name
(
_name
),
color
(
_color
),
radius
(
_radius
),
count
(
_count
)
{
}
int
getId
()
const
{
return
id
;
}
QString
getName
()
const
{
return
name
;
}
QColor
getColor
()
const
{
return
color
;
}
int
getRadius
()
const
{
return
radius
;
}
int
getCount
()
const
{
return
count
;
}
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
class
ServerInfo_Arrow
:
public
SerializableItem
{
private:
int
id
;
int
startPlayerId
;
QString
startZone
;
int
startCardId
;
int
targetPlayerId
;
QString
targetZone
;
int
targetCardId
;
QColor
color
;
public:
ServerInfo_Arrow
(
int
_id
=
-
1
,
int
_startPlayerId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
int
_startCardId
=
-
1
,
int
_targetPlayerId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_targetCardId
=
-
1
,
const
QColor
&
_color
=
QColor
())
:
id
(
_id
),
startPlayerId
(
_startPlayerId
),
startZone
(
_startZone
),
startCardId
(
_startCardId
),
targetPlayerId
(
_targetPlayerId
),
targetZone
(
_targetZone
),
targetCardId
(
_targetCardId
),
color
(
_color
)
{
}
int
getId
()
const
{
return
id
;
}
int
getStartPlayerId
()
const
{
return
startPlayerId
;
}
QString
getStartZone
()
const
{
return
startZone
;
}
int
getStartCardId
()
const
{
return
startCardId
;
}
int
getTargetPlayerId
()
const
{
return
targetPlayerId
;
}
QString
getTargetZone
()
const
{
return
targetZone
;
}
int
getTargetCardId
()
const
{
return
targetCardId
;
}
QColor
getColor
()
const
{
return
color
;
}
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
class
ServerInfo_Player
:
public
SerializableItem
{
private:
int
playerId
;
QString
name
;
QList
<
ServerInfo_Zone
*>
zoneList
;
QList
<
ServerInfo_Zone
*>
zoneList
;
QList
<
ServerInfo_Counter
*>
counterList
;
QList
<
ServerInfo_Counter
*>
counterList
;
QList
<
ServerInfo_Arrow
*>
arrowList
;
QList
<
ServerInfo_Arrow
*>
arrowList
;
protected:
void
extractData
();
public:
public:
ServerInfo_Player
(
int
_playerId
=
-
1
,
const
QString
&
_name
=
QString
(),
const
QList
<
ServerInfo_Zone
*>
&
_zoneList
=
QList
<
ServerInfo_Zone
*>
(),
const
QList
<
ServerInfo_Counter
*>
&
_counterList
=
QList
<
ServerInfo_Counter
*>
(),
const
QList
<
ServerInfo_Arrow
*>
&
_arrowList
=
QList
<
ServerInfo_Arrow
*>
())
ServerInfo_Player
(
int
_playerId
=
-
1
,
const
QString
&
_name
=
QString
(),
const
QList
<
ServerInfo_Zone
*>
&
_zoneList
=
QList
<
ServerInfo_Zone
*>
(),
const
QList
<
ServerInfo_Counter
*>
&
_counterList
=
QList
<
ServerInfo_Counter
*>
(),
const
QList
<
ServerInfo_Arrow
*>
&
_arrowList
=
QList
<
ServerInfo_Arrow
*>
());
:
playerId
(
_playerId
),
name
(
_name
),
zoneList
(
_zoneList
),
counterList
(
_counterList
),
arrowList
(
_arrowList
)
{
}
static
SerializableItem
*
newItem
()
{
return
new
ServerInfo_Player
;
}
~
ServerInfo_Player
();
int
getPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_id"
))
->
getData
();
}
int
getPlayerId
()
const
{
return
playerId
;
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
();
}
QString
getName
()
const
{
return
name
;
}
const
QList
<
ServerInfo_Zone
*>
&
getZoneList
()
const
{
return
zoneList
;
}
const
QList
<
ServerInfo_Zone
*>
&
getZoneList
()
const
{
return
zoneList
;
}
const
QList
<
ServerInfo_Counter
*>
&
getCounterList
()
const
{
return
counterList
;
}
const
QList
<
ServerInfo_Counter
*>
&
getCounterList
()
const
{
return
counterList
;
}
const
QList
<
ServerInfo_Arrow
*>
&
getArrowList
()
const
{
return
arrowList
;
}
const
QList
<
ServerInfo_Arrow
*>
&
getArrowList
()
const
{
return
arrowList
;
}
void
addZone
(
ServerInfo_Zone
*
zone
)
{
zoneList
.
append
(
zone
);
}
void
addCounter
(
ServerInfo_Counter
*
counter
)
{
counterList
.
append
(
counter
);
}
void
addArrow
(
ServerInfo_Arrow
*
arrow
)
{
arrowList
.
append
(
arrow
);
}
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
};
class
DeckList_TreeItem
:
public
SerializableItem
{
class
DeckList_TreeItem
:
public
SerializableItem_Map
{
protected:
QString
name
;
int
id
;
public:
public:
DeckList_TreeItem
(
const
QString
&
_
name
,
int
_id
)
:
name
(
_name
)
,
i
d
(
_id
)
{
}
DeckList_TreeItem
(
const
QString
&
_
itemType
,
const
QString
&
_name
,
i
nt
_id
)
;
QString
getName
()
const
{
return
name
;
}
QString
getName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"name"
))
->
getData
()
;
}
int
getId
()
const
{
return
id
;
}
int
getId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"id"
))
->
getData
()
;
}
};
};
class
DeckList_File
:
public
DeckList_TreeItem
{
class
DeckList_File
:
public
DeckList_TreeItem
{
private:
QDateTime
uploadTime
;
public:
public:
DeckList_File
(
const
QString
&
_name
,
int
_id
,
QDateTime
_uploadTime
)
:
DeckList_TreeItem
(
_name
,
_id
),
uploadTime
(
_uploadTime
)
{
}
DeckList_File
(
const
QString
&
_name
=
QString
(),
int
_id
=
-
1
,
QDateTime
_uploadTime
=
QDateTime
());
bool
readElement
(
QXmlStreamReader
*
xml
);
static
SerializableItem
*
newItem
()
{
return
new
DeckList_File
;
}
void
writeElement
(
QXmlStreamWriter
*
xml
);
QDateTime
getUploadTime
()
const
{
return
static_cast
<
SerializableItem_DateTime
*>
(
itemMap
.
value
(
"upload_time"
))
->
getData
();
}
QDateTime
getUploadTime
()
const
{
return
uploadTime
;
}
};
};
class
DeckList_Directory
:
public
DeckList_TreeItem
,
public
QList
<
DeckList_TreeItem
*>
{
class
DeckList_Directory
:
public
DeckList_TreeItem
{
public:
public:
DeckList_Directory
(
const
QString
&
_name
=
QString
(),
int
_id
=
0
)
:
DeckList_TreeItem
(
_name
,
_id
)
{
}
DeckList_Directory
(
const
QString
&
_name
=
QString
(),
int
_id
=
0
);
~
DeckList_Directory
();
static
SerializableItem
*
newItem
()
{
return
new
DeckList_Directory
;
}
bool
readElement
(
QXmlStreamReader
*
xml
);
QList
<
DeckList_TreeItem
*>
getTreeItems
()
const
{
return
typecastItemList
<
DeckList_TreeItem
*>
();
}
void
writeElement
(
QXmlStreamWriter
*
xml
);
};
};
#endif
#endif
common/protocol_items.cpp
View file @
69407072
...
@@ -6,378 +6,209 @@ Command_Ping::Command_Ping()
...
@@ -6,378 +6,209 @@ Command_Ping::Command_Ping()
{
{
}
}
Command_Login
::
Command_Login
(
const
QString
&
_username
,
const
QString
&
_password
)
Command_Login
::
Command_Login
(
const
QString
&
_username
,
const
QString
&
_password
)
:
Command
(
"login"
)
,
username
(
_username
),
password
(
_password
)
:
Command
(
"login"
)
{
{
setParameter
(
"username"
,
username
);
insertItem
(
new
SerializableItem_String
(
"username"
,
_username
));
setParameter
(
"password"
,
password
);
insertItem
(
new
SerializableItem_String
(
"password"
,
_password
));
}
void
Command_Login
::
extractParameters
()
{
Command
::
extractParameters
();
username
=
parameters
[
"username"
];
password
=
parameters
[
"password"
];
}
}
Command_DeckList
::
Command_DeckList
()
Command_DeckList
::
Command_DeckList
()
:
Command
(
"deck_list"
)
:
Command
(
"deck_list"
)
{
{
}
}
Command_DeckNewDir
::
Command_DeckNewDir
(
const
QString
&
_path
,
const
QString
&
_dirName
)
Command_DeckNewDir
::
Command_DeckNewDir
(
const
QString
&
_path
,
const
QString
&
_dirName
)
:
Command
(
"deck_new_dir"
),
path
(
_path
),
dirName
(
_dirName
)
:
Command
(
"deck_new_dir"
)
{
setParameter
(
"path"
,
path
);
setParameter
(
"dir_name"
,
dirName
);
}
void
Command_DeckNewDir
::
extractParameters
()
{
{
Command
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"path"
,
_path
));
path
=
parameters
[
"path"
];
insertItem
(
new
SerializableItem_String
(
"dir_name"
,
_dirName
));
dirName
=
parameters
[
"dir_name"
];
}
}
Command_DeckDelDir
::
Command_DeckDelDir
(
const
QString
&
_path
)
Command_DeckDelDir
::
Command_DeckDelDir
(
const
QString
&
_path
)
:
Command
(
"deck_del_dir"
),
path
(
_path
)
:
Command
(
"deck_del_dir"
)
{
setParameter
(
"path"
,
path
);
}
void
Command_DeckDelDir
::
extractParameters
()
{
{
Command
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"path"
,
_path
));
path
=
parameters
[
"path"
];
}
}
Command_DeckDel
::
Command_DeckDel
(
int
_deckId
)
Command_DeckDel
::
Command_DeckDel
(
int
_deckId
)
:
Command
(
"deck_del"
)
,
deckId
(
_deckId
)
:
Command
(
"deck_del"
)
{
{
setParameter
(
"deck_id"
,
deckId
);
insertItem
(
new
SerializableItem_Int
(
"deck_id"
,
_deckId
));
}
void
Command_DeckDel
::
extractParameters
()
{
Command
::
extractParameters
();
deckId
=
parameters
[
"deck_id"
].
toInt
();
}
}
Command_DeckDownload
::
Command_DeckDownload
(
int
_deckId
)
Command_DeckDownload
::
Command_DeckDownload
(
int
_deckId
)
:
Command
(
"deck_download"
)
,
deckId
(
_deckId
)
:
Command
(
"deck_download"
)
{
{
setParameter
(
"deck_id"
,
deckId
);
insertItem
(
new
SerializableItem_Int
(
"deck_id"
,
_deckId
));
}
void
Command_DeckDownload
::
extractParameters
()
{
Command
::
extractParameters
();
deckId
=
parameters
[
"deck_id"
].
toInt
();
}
}
Command_ListChatChannels
::
Command_ListChatChannels
()
Command_ListChatChannels
::
Command_ListChatChannels
()
:
Command
(
"list_chat_channels"
)
:
Command
(
"list_chat_channels"
)
{
{
}
}
Command_ChatJoinChannel
::
Command_ChatJoinChannel
(
const
QString
&
_channel
)
Command_ChatJoinChannel
::
Command_ChatJoinChannel
(
const
QString
&
_channel
)
:
Command
(
"chat_join_channel"
)
,
channel
(
_channel
)
:
Command
(
"chat_join_channel"
)
{
{
setParameter
(
"channel"
,
channel
);
insertItem
(
new
SerializableItem_String
(
"channel"
,
_channel
));
}
void
Command_ChatJoinChannel
::
extractParameters
()
{
Command
::
extractParameters
();
channel
=
parameters
[
"channel"
];
}
}
Command_ChatLeaveChannel
::
Command_ChatLeaveChannel
(
const
QString
&
_channel
)
Command_ChatLeaveChannel
::
Command_ChatLeaveChannel
(
const
QString
&
_channel
)
:
ChatCommand
(
"chat_leave_channel"
,
_channel
)
:
ChatCommand
(
"chat_leave_channel"
,
_channel
)
{
{
}
}
Command_ChatSay
::
Command_ChatSay
(
const
QString
&
_channel
,
const
QString
&
_message
)
Command_ChatSay
::
Command_ChatSay
(
const
QString
&
_channel
,
const
QString
&
_message
)
:
ChatCommand
(
"chat_say"
,
_channel
),
message
(
_message
)
:
ChatCommand
(
"chat_say"
,
_channel
)
{
setParameter
(
"message"
,
message
);
}
void
Command_ChatSay
::
extractParameters
()
{
{
ChatCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
message
=
parameters
[
"message"
];
}
}
Command_ListGames
::
Command_ListGames
()
Command_ListGames
::
Command_ListGames
()
:
Command
(
"list_games"
)
:
Command
(
"list_games"
)
{
{
}
}
Command_CreateGame
::
Command_CreateGame
(
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
)
Command_CreateGame
::
Command_CreateGame
(
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
)
:
Command
(
"create_game"
),
description
(
_description
),
password
(
_password
),
maxPlayers
(
_maxPlayers
),
spectatorsAllowed
(
_spectatorsAllowed
)
:
Command
(
"create_game"
)
{
setParameter
(
"description"
,
description
);
setParameter
(
"password"
,
password
);
setParameter
(
"max_players"
,
maxPlayers
);
setParameter
(
"spectators_allowed"
,
spectatorsAllowed
);
}
void
Command_CreateGame
::
extractParameters
()
{
{
Command
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"description"
,
_description
));
description
=
parameters
[
"description"
];
insertItem
(
new
SerializableItem_String
(
"password"
,
_password
));
password
=
parameters
[
"password"
];
insertItem
(
new
SerializableItem_Int
(
"max_players"
,
_maxPlayers
));
maxPlayers
=
parameters
[
"max_players"
].
toInt
();
insertItem
(
new
SerializableItem_Bool
(
"spectators_allowed"
,
_spectatorsAllowed
));
spectatorsAllowed
=
(
parameters
[
"spectators_allowed"
]
==
"1"
);
}
}
Command_JoinGame
::
Command_JoinGame
(
int
_gameId
,
const
QString
&
_password
,
bool
_spectator
)
Command_JoinGame
::
Command_JoinGame
(
int
_gameId
,
const
QString
&
_password
,
bool
_spectator
)
:
Command
(
"join_game"
)
,
gameId
(
_gameId
),
password
(
_password
),
spectator
(
_spectator
)
:
Command
(
"join_game"
)
{
{
setParameter
(
"game_id"
,
gameId
);
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
setParameter
(
"password"
,
password
);
insertItem
(
new
SerializableItem_String
(
"password"
,
_password
));
setParameter
(
"spectator"
,
spectator
);
insertItem
(
new
SerializableItem_Bool
(
"spectator"
,
_spectator
));
}
void
Command_JoinGame
::
extractParameters
()
{
Command
::
extractParameters
();
gameId
=
parameters
[
"game_id"
].
toInt
();
password
=
parameters
[
"password"
];
spectator
=
(
parameters
[
"spectator"
]
==
"1"
);
}
}
Command_LeaveGame
::
Command_LeaveGame
(
int
_gameId
)
Command_LeaveGame
::
Command_LeaveGame
(
int
_gameId
)
:
GameCommand
(
"leave_game"
,
_gameId
)
:
GameCommand
(
"leave_game"
,
_gameId
)
{
{
}
}
Command_Say
::
Command_Say
(
int
_gameId
,
const
QString
&
_message
)
Command_Say
::
Command_Say
(
int
_gameId
,
const
QString
&
_message
)
:
GameCommand
(
"say"
,
_gameId
)
,
message
(
_message
)
:
GameCommand
(
"say"
,
_gameId
)
{
{
setParameter
(
"message"
,
message
);
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
}
void
Command_Say
::
extractParameters
()
{
GameCommand
::
extractParameters
();
message
=
parameters
[
"message"
];
}
}
Command_Shuffle
::
Command_Shuffle
(
int
_gameId
)
Command_Shuffle
::
Command_Shuffle
(
int
_gameId
)
:
GameCommand
(
"shuffle"
,
_gameId
)
:
GameCommand
(
"shuffle"
,
_gameId
)
{
{
}
}
Command_RollDie
::
Command_RollDie
(
int
_gameId
,
int
_sides
)
Command_RollDie
::
Command_RollDie
(
int
_gameId
,
int
_sides
)
:
GameCommand
(
"roll_die"
,
_gameId
),
sides
(
_sides
)
:
GameCommand
(
"roll_die"
,
_gameId
)
{
setParameter
(
"sides"
,
sides
);
}
void
Command_RollDie
::
extractParameters
()
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"sides"
,
_sides
));
sides
=
parameters
[
"sides"
].
toInt
();
}
}
Command_DrawCards
::
Command_DrawCards
(
int
_gameId
,
int
_number
)
Command_DrawCards
::
Command_DrawCards
(
int
_gameId
,
int
_number
)
:
GameCommand
(
"draw_cards"
,
_gameId
),
number
(
_number
)
:
GameCommand
(
"draw_cards"
,
_gameId
)
{
setParameter
(
"number"
,
number
);
}
void
Command_DrawCards
::
extractParameters
()
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"number"
,
_number
));
number
=
parameters
[
"number"
].
toInt
();
}
}
Command_MoveCard
::
Command_MoveCard
(
int
_gameId
,
const
QString
&
_startZone
,
int
_cardId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
)
Command_MoveCard
::
Command_MoveCard
(
int
_gameId
,
const
QString
&
_startZone
,
int
_cardId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
)
:
GameCommand
(
"move_card"
,
_gameId
)
,
startZone
(
_startZone
),
cardId
(
_cardId
),
targetZone
(
_targetZone
),
x
(
_x
),
y
(
_y
),
faceDown
(
_faceDown
)
:
GameCommand
(
"move_card"
,
_gameId
)
{
{
setParameter
(
"start_zone"
,
startZone
);
insertItem
(
new
SerializableItem_String
(
"start_zone"
,
_startZone
));
setParameter
(
"card_id"
,
cardId
);
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
setParameter
(
"target_zone"
,
targetZone
);
insertItem
(
new
SerializableItem_String
(
"target_zone"
,
_targetZone
));
setParameter
(
"x"
,
x
);
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
setParameter
(
"y"
,
y
);
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
setParameter
(
"face_down"
,
faceDown
);
insertItem
(
new
SerializableItem_Bool
(
"face_down"
,
_faceDown
));
}
void
Command_MoveCard
::
extractParameters
()
{
GameCommand
::
extractParameters
();
startZone
=
parameters
[
"start_zone"
];
cardId
=
parameters
[
"card_id"
].
toInt
();
targetZone
=
parameters
[
"target_zone"
];
x
=
parameters
[
"x"
].
toInt
();
y
=
parameters
[
"y"
].
toInt
();
faceDown
=
(
parameters
[
"face_down"
]
==
"1"
);
}
}
Command_CreateToken
::
Command_CreateToken
(
int
_gameId
,
const
QString
&
_zone
,
const
QString
&
_cardName
,
const
QString
&
_pt
,
int
_x
,
int
_y
)
Command_CreateToken
::
Command_CreateToken
(
int
_gameId
,
const
QString
&
_zone
,
const
QString
&
_cardName
,
const
QString
&
_pt
,
int
_x
,
int
_y
)
:
GameCommand
(
"create_token"
,
_gameId
)
,
zone
(
_zone
),
cardName
(
_cardName
),
pt
(
_pt
),
x
(
_x
),
y
(
_y
)
:
GameCommand
(
"create_token"
,
_gameId
)
{
{
setParameter
(
"zone"
,
zone
);
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
setParameter
(
"card_name"
,
cardName
);
insertItem
(
new
SerializableItem_String
(
"card_name"
,
_cardName
));
setParameter
(
"pt"
,
pt
);
insertItem
(
new
SerializableItem_String
(
"pt"
,
_pt
));
setParameter
(
"x"
,
x
);
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
setParameter
(
"y"
,
y
);
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
}
void
Command_CreateToken
::
extractParameters
()
{
GameCommand
::
extractParameters
();
zone
=
parameters
[
"zone"
];
cardName
=
parameters
[
"card_name"
];
pt
=
parameters
[
"pt"
];
x
=
parameters
[
"x"
].
toInt
();
y
=
parameters
[
"y"
].
toInt
();
}
}
Command_CreateArrow
::
Command_CreateArrow
(
int
_gameId
,
int
_startPlayerId
,
const
QString
&
_startZone
,
int
_startCardId
,
int
_targetPlayerId
,
const
QString
&
_targetZone
,
int
_targetCardId
,
const
QColor
&
_color
)
Command_CreateArrow
::
Command_CreateArrow
(
int
_gameId
,
int
_startPlayerId
,
const
QString
&
_startZone
,
int
_startCardId
,
int
_targetPlayerId
,
const
QString
&
_targetZone
,
int
_targetCardId
,
const
QColor
&
_color
)
:
GameCommand
(
"create_arrow"
,
_gameId
),
startPlayerId
(
_startPlayerId
),
startZone
(
_startZone
),
startCardId
(
_startCardId
),
targetPlayerId
(
_targetPlayerId
),
targetZone
(
_targetZone
),
targetCardId
(
_targetCardId
),
color
(
_color
)
:
GameCommand
(
"create_arrow"
,
_gameId
)
{
setParameter
(
"start_player_id"
,
startPlayerId
);
setParameter
(
"start_zone"
,
startZone
);
setParameter
(
"start_card_id"
,
startCardId
);
setParameter
(
"target_player_id"
,
targetPlayerId
);
setParameter
(
"target_zone"
,
targetZone
);
setParameter
(
"target_card_id"
,
targetCardId
);
setParameter
(
"color"
,
color
);
}
void
Command_CreateArrow
::
extractParameters
()
{
GameCommand
::
extractParameters
();
startPlayerId
=
parameters
[
"start_player_id"
].
toInt
();
startZone
=
parameters
[
"start_zone"
];
startCardId
=
parameters
[
"start_card_id"
].
toInt
();
targetPlayerId
=
parameters
[
"target_player_id"
].
toInt
();
targetZone
=
parameters
[
"target_zone"
];
targetCardId
=
parameters
[
"target_card_id"
].
toInt
();
color
=
ColorConverter
::
colorFromInt
(
parameters
[
"color"
].
toInt
());
}
Command_DeleteArrow
::
Command_DeleteArrow
(
int
_gameId
,
int
_arrowId
)
:
GameCommand
(
"delete_arrow"
,
_gameId
),
arrowId
(
_arrowId
)
{
{
setParameter
(
"arrow_id"
,
arrowId
);
insertItem
(
new
SerializableItem_Int
(
"start_player_id"
,
_startPlayerId
));
insertItem
(
new
SerializableItem_String
(
"start_zone"
,
_startZone
));
insertItem
(
new
SerializableItem_Int
(
"start_card_id"
,
_startCardId
));
insertItem
(
new
SerializableItem_Int
(
"target_player_id"
,
_targetPlayerId
));
insertItem
(
new
SerializableItem_String
(
"target_zone"
,
_targetZone
));
insertItem
(
new
SerializableItem_Int
(
"target_card_id"
,
_targetCardId
));
insertItem
(
new
SerializableItem_Color
(
"color"
,
_color
));
}
}
void
Command_DeleteArrow
::
extractParameters
()
Command_DeleteArrow
::
Command_DeleteArrow
(
int
_gameId
,
int
_arrowId
)
:
GameCommand
(
"delete_arrow"
,
_gameId
)
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"arrow_id"
,
_arrowId
));
arrowId
=
parameters
[
"arrow_id"
].
toInt
();
}
}
Command_SetCardAttr
::
Command_SetCardAttr
(
int
_gameId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_attrName
,
const
QString
&
_attrValue
)
Command_SetCardAttr
::
Command_SetCardAttr
(
int
_gameId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_attrName
,
const
QString
&
_attrValue
)
:
GameCommand
(
"set_card_attr"
,
_gameId
)
,
zone
(
_zone
),
cardId
(
_cardId
),
attrName
(
_attrName
),
attrValue
(
_attrValue
)
:
GameCommand
(
"set_card_attr"
,
_gameId
)
{
{
setParameter
(
"zone"
,
zone
);
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
setParameter
(
"card_id"
,
cardId
);
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
setParameter
(
"attr_name"
,
attrName
);
insertItem
(
new
SerializableItem_String
(
"attr_name"
,
_attrName
));
setParameter
(
"attr_value"
,
attrValue
);
insertItem
(
new
SerializableItem_String
(
"attr_value"
,
_attrValue
));
}
void
Command_SetCardAttr
::
extractParameters
()
{
GameCommand
::
extractParameters
();
zone
=
parameters
[
"zone"
];
cardId
=
parameters
[
"card_id"
].
toInt
();
attrName
=
parameters
[
"attr_name"
];
attrValue
=
parameters
[
"attr_value"
];
}
}
Command_ReadyStart
::
Command_ReadyStart
(
int
_gameId
)
Command_ReadyStart
::
Command_ReadyStart
(
int
_gameId
)
:
GameCommand
(
"ready_start"
,
_gameId
)
:
GameCommand
(
"ready_start"
,
_gameId
)
{
{
}
}
Command_IncCounter
::
Command_IncCounter
(
int
_gameId
,
int
_counterId
,
int
_delta
)
Command_IncCounter
::
Command_IncCounter
(
int
_gameId
,
int
_counterId
,
int
_delta
)
:
GameCommand
(
"inc_counter"
,
_gameId
),
counterId
(
_counterId
),
delta
(
_delta
)
:
GameCommand
(
"inc_counter"
,
_gameId
)
{
setParameter
(
"counter_id"
,
counterId
);
setParameter
(
"delta"
,
delta
);
}
void
Command_IncCounter
::
extractParameters
()
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
counterId
=
parameters
[
"counter_id"
].
toInt
();
insertItem
(
new
SerializableItem_Int
(
"delta"
,
_delta
));
delta
=
parameters
[
"delta"
].
toInt
();
}
}
Command_CreateCounter
::
Command_CreateCounter
(
int
_gameId
,
const
QString
&
_counterName
,
const
QColor
&
_color
,
int
_radius
,
int
_value
)
Command_CreateCounter
::
Command_CreateCounter
(
int
_gameId
,
const
QString
&
_counterName
,
const
QColor
&
_color
,
int
_radius
,
int
_value
)
:
GameCommand
(
"create_counter"
,
_gameId
),
counterName
(
_counterName
),
color
(
_color
),
radius
(
_radius
),
value
(
_value
)
:
GameCommand
(
"create_counter"
,
_gameId
)
{
setParameter
(
"counter_name"
,
counterName
);
setParameter
(
"color"
,
color
);
setParameter
(
"radius"
,
radius
);
setParameter
(
"value"
,
value
);
}
void
Command_CreateCounter
::
extractParameters
()
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"counter_name"
,
_counterName
));
counterName
=
parameters
[
"counter_name"
];
insertItem
(
new
SerializableItem_Color
(
"color"
,
_color
));
color
=
ColorConverter
::
colorFromInt
(
parameters
[
"color"
].
toInt
());
insertItem
(
new
SerializableItem_Int
(
"radius"
,
_radius
));
radius
=
parameters
[
"radius"
].
toInt
();
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
value
=
parameters
[
"value"
].
toInt
();
}
}
Command_SetCounter
::
Command_SetCounter
(
int
_gameId
,
int
_counterId
,
int
_value
)
Command_SetCounter
::
Command_SetCounter
(
int
_gameId
,
int
_counterId
,
int
_value
)
:
GameCommand
(
"set_counter"
,
_gameId
)
,
counterId
(
_counterId
),
value
(
_value
)
:
GameCommand
(
"set_counter"
,
_gameId
)
{
{
setParameter
(
"counter_id"
,
counterId
);
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
setParameter
(
"value"
,
value
);
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
}
void
Command_SetCounter
::
extractParameters
()
{
GameCommand
::
extractParameters
();
counterId
=
parameters
[
"counter_id"
].
toInt
();
value
=
parameters
[
"value"
].
toInt
();
}
}
Command_DelCounter
::
Command_DelCounter
(
int
_gameId
,
int
_counterId
)
Command_DelCounter
::
Command_DelCounter
(
int
_gameId
,
int
_counterId
)
:
GameCommand
(
"del_counter"
,
_gameId
)
,
counterId
(
_counterId
)
:
GameCommand
(
"del_counter"
,
_gameId
)
{
{
setParameter
(
"counter_id"
,
counterId
);
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
}
void
Command_DelCounter
::
extractParameters
()
{
GameCommand
::
extractParameters
();
counterId
=
parameters
[
"counter_id"
].
toInt
();
}
}
Command_NextTurn
::
Command_NextTurn
(
int
_gameId
)
Command_NextTurn
::
Command_NextTurn
(
int
_gameId
)
:
GameCommand
(
"next_turn"
,
_gameId
)
:
GameCommand
(
"next_turn"
,
_gameId
)
{
{
}
}
Command_SetActivePhase
::
Command_SetActivePhase
(
int
_gameId
,
int
_phase
)
Command_SetActivePhase
::
Command_SetActivePhase
(
int
_gameId
,
int
_phase
)
:
GameCommand
(
"set_active_phase"
,
_gameId
),
phase
(
_phase
)
:
GameCommand
(
"set_active_phase"
,
_gameId
)
{
setParameter
(
"phase"
,
phase
);
}
void
Command_SetActivePhase
::
extractParameters
()
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"phase"
,
_phase
));
phase
=
parameters
[
"phase"
].
toInt
();
}
}
Command_DumpZone
::
Command_DumpZone
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zoneName
,
int
_numberCards
)
Command_DumpZone
::
Command_DumpZone
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zoneName
,
int
_numberCards
)
:
GameCommand
(
"dump_zone"
,
_gameId
),
playerId
(
_playerId
),
zoneName
(
_zoneName
),
numberCards
(
_numberCards
)
:
GameCommand
(
"dump_zone"
,
_gameId
)
{
setParameter
(
"player_id"
,
playerId
);
setParameter
(
"zone_name"
,
zoneName
);
setParameter
(
"number_cards"
,
numberCards
);
}
void
Command_DumpZone
::
extractParameters
()
{
{
GameCommand
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
playerId
=
parameters
[
"player_id"
].
toInt
();
insertItem
(
new
SerializableItem_String
(
"zone_name"
,
_zoneName
));
zoneName
=
parameters
[
"zone_name"
];
insertItem
(
new
SerializableItem_Int
(
"number_cards"
,
_numberCards
));
numberCards
=
parameters
[
"number_cards"
].
toInt
();
}
}
Command_StopDumpZone
::
Command_StopDumpZone
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zoneName
)
Command_StopDumpZone
::
Command_StopDumpZone
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zoneName
)
:
GameCommand
(
"stop_dump_zone"
,
_gameId
)
,
playerId
(
_playerId
),
zoneName
(
_zoneName
)
:
GameCommand
(
"stop_dump_zone"
,
_gameId
)
{
{
setParameter
(
"player_id"
,
playerId
);
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
setParameter
(
"zone_name"
,
zoneName
);
insertItem
(
new
SerializableItem_String
(
"zone_name"
,
_zoneName
));
}
void
Command_StopDumpZone
::
extractParameters
()
{
GameCommand
::
extractParameters
();
playerId
=
parameters
[
"player_id"
].
toInt
();
zoneName
=
parameters
[
"zone_name"
];
}
}
Event_Say
::
Event_Say
(
int
_gameId
,
int
_playerId
,
const
QString
&
_message
)
Event_Say
::
Event_Say
(
int
_gameId
,
int
_playerId
,
const
QString
&
_message
)
:
GameEvent
(
"say"
,
_gameId
,
_playerId
)
,
message
(
_message
)
:
GameEvent
(
"say"
,
_gameId
,
_playerId
)
{
{
setParameter
(
"message"
,
message
);
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
}
void
Event_Say
::
extractParameters
()
{
GameEvent
::
extractParameters
();
message
=
parameters
[
"message"
];
}
}
Event_Join
::
Event_Join
(
int
_gameId
,
int
_playerId
,
const
QString
&
_playerName
,
bool
_spectator
)
Event_Join
::
Event_Join
(
int
_gameId
,
int
_playerId
,
const
QString
&
_playerName
,
bool
_spectator
)
:
GameEvent
(
"join"
,
_gameId
,
_playerId
),
playerName
(
_playerName
),
spectator
(
_spectator
)
:
GameEvent
(
"join"
,
_gameId
,
_playerId
)
{
setParameter
(
"player_name"
,
playerName
);
setParameter
(
"spectator"
,
spectator
);
}
void
Event_Join
::
extractParameters
()
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"player_name"
,
_playerName
));
playerName
=
parameters
[
"player_name"
];
insertItem
(
new
SerializableItem_Bool
(
"spectator"
,
_spectator
));
spectator
=
(
parameters
[
"spectator"
]
==
"1"
);
}
}
Event_Leave
::
Event_Leave
(
int
_gameId
,
int
_playerId
)
Event_Leave
::
Event_Leave
(
int
_gameId
,
int
_playerId
)
:
GameEvent
(
"leave"
,
_gameId
,
_playerId
)
:
GameEvent
(
"leave"
,
_gameId
,
_playerId
)
{
{
}
}
Event_DeckSelect
::
Event_DeckSelect
(
int
_gameId
,
int
_playerId
,
int
_deckId
)
Event_DeckSelect
::
Event_DeckSelect
(
int
_gameId
,
int
_playerId
,
int
_deckId
)
:
GameEvent
(
"deck_select"
,
_gameId
,
_playerId
),
deckId
(
_deckId
)
:
GameEvent
(
"deck_select"
,
_gameId
,
_playerId
)
{
setParameter
(
"deck_id"
,
deckId
);
}
void
Event_DeckSelect
::
extractParameters
()
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"deck_id"
,
_deckId
));
deckId
=
parameters
[
"deck_id"
].
toInt
();
}
}
Event_GameClosed
::
Event_GameClosed
(
int
_gameId
,
int
_playerId
)
Event_GameClosed
::
Event_GameClosed
(
int
_gameId
,
int
_playerId
)
:
GameEvent
(
"game_closed"
,
_gameId
,
_playerId
)
:
GameEvent
(
"game_closed"
,
_gameId
,
_playerId
)
...
@@ -396,210 +227,107 @@ Event_Shuffle::Event_Shuffle(int _gameId, int _playerId)
...
@@ -396,210 +227,107 @@ Event_Shuffle::Event_Shuffle(int _gameId, int _playerId)
{
{
}
}
Event_RollDie
::
Event_RollDie
(
int
_gameId
,
int
_playerId
,
int
_sides
,
int
_value
)
Event_RollDie
::
Event_RollDie
(
int
_gameId
,
int
_playerId
,
int
_sides
,
int
_value
)
:
GameEvent
(
"roll_die"
,
_gameId
,
_playerId
)
,
sides
(
_sides
),
value
(
_value
)
:
GameEvent
(
"roll_die"
,
_gameId
,
_playerId
)
{
{
setParameter
(
"sides"
,
sides
);
insertItem
(
new
SerializableItem_Int
(
"sides"
,
_sides
));
setParameter
(
"value"
,
value
);
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
}
void
Event_RollDie
::
extractParameters
()
{
GameEvent
::
extractParameters
();
sides
=
parameters
[
"sides"
].
toInt
();
value
=
parameters
[
"value"
].
toInt
();
}
}
Event_MoveCard
::
Event_MoveCard
(
int
_gameId
,
int
_playerId
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_startZone
,
int
_position
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
)
Event_MoveCard
::
Event_MoveCard
(
int
_gameId
,
int
_playerId
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_startZone
,
int
_position
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
)
:
GameEvent
(
"move_card"
,
_gameId
,
_playerId
),
cardId
(
_cardId
),
cardName
(
_cardName
),
startZone
(
_startZone
),
position
(
_position
),
targetZone
(
_targetZone
),
x
(
_x
),
y
(
_y
),
faceDown
(
_faceDown
)
:
GameEvent
(
"move_card"
,
_gameId
,
_playerId
)
{
setParameter
(
"card_id"
,
cardId
);
setParameter
(
"card_name"
,
cardName
);
setParameter
(
"start_zone"
,
startZone
);
setParameter
(
"position"
,
position
);
setParameter
(
"target_zone"
,
targetZone
);
setParameter
(
"x"
,
x
);
setParameter
(
"y"
,
y
);
setParameter
(
"face_down"
,
faceDown
);
}
void
Event_MoveCard
::
extractParameters
()
{
GameEvent
::
extractParameters
();
cardId
=
parameters
[
"card_id"
].
toInt
();
cardName
=
parameters
[
"card_name"
];
startZone
=
parameters
[
"start_zone"
];
position
=
parameters
[
"position"
].
toInt
();
targetZone
=
parameters
[
"target_zone"
];
x
=
parameters
[
"x"
].
toInt
();
y
=
parameters
[
"y"
].
toInt
();
faceDown
=
(
parameters
[
"face_down"
]
==
"1"
);
}
Event_CreateToken
::
Event_CreateToken
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_pt
,
int
_x
,
int
_y
)
:
GameEvent
(
"create_token"
,
_gameId
,
_playerId
),
zone
(
_zone
),
cardId
(
_cardId
),
cardName
(
_cardName
),
pt
(
_pt
),
x
(
_x
),
y
(
_y
)
{
{
setParameter
(
"zone"
,
zone
);
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
setParameter
(
"card_id"
,
cardId
);
insertItem
(
new
SerializableItem_String
(
"card_name"
,
_cardName
));
setParameter
(
"card_name"
,
cardName
);
insertItem
(
new
SerializableItem_String
(
"start_zone"
,
_startZone
));
setParameter
(
"pt"
,
pt
);
insertItem
(
new
SerializableItem_Int
(
"position"
,
_position
));
setParameter
(
"x"
,
x
);
insertItem
(
new
SerializableItem_String
(
"target_zone"
,
_targetZone
));
setParameter
(
"y"
,
y
);
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
insertItem
(
new
SerializableItem_Bool
(
"face_down"
,
_faceDown
));
}
}
void
Event_CreateToken
::
extractParameters
()
Event_CreateToken
::
Event_CreateToken
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_pt
,
int
_x
,
int
_y
)
:
GameEvent
(
"create_token"
,
_gameId
,
_playerId
)
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
zone
=
parameters
[
"zone"
];
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
cardId
=
parameters
[
"card_id"
].
toInt
();
insertItem
(
new
SerializableItem_String
(
"card_name"
,
_cardName
));
cardName
=
parameters
[
"card_name"
];
insertItem
(
new
SerializableItem_String
(
"pt"
,
_pt
));
pt
=
parameters
[
"pt"
];
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
x
=
parameters
[
"x"
].
toInt
();
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
y
=
parameters
[
"y"
].
toInt
();
}
}
Event_DeleteArrow
::
Event_DeleteArrow
(
int
_gameId
,
int
_playerId
,
int
_arrowId
)
Event_DeleteArrow
::
Event_DeleteArrow
(
int
_gameId
,
int
_playerId
,
int
_arrowId
)
:
GameEvent
(
"delete_arrow"
,
_gameId
,
_playerId
)
,
arrowId
(
_arrowId
)
:
GameEvent
(
"delete_arrow"
,
_gameId
,
_playerId
)
{
{
setParameter
(
"arrow_id"
,
arrowId
);
insertItem
(
new
SerializableItem_Int
(
"arrow_id"
,
_arrowId
));
}
void
Event_DeleteArrow
::
extractParameters
()
{
GameEvent
::
extractParameters
();
arrowId
=
parameters
[
"arrow_id"
].
toInt
();
}
}
Event_SetCardAttr
::
Event_SetCardAttr
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_attrName
,
const
QString
&
_attrValue
)
Event_SetCardAttr
::
Event_SetCardAttr
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_attrName
,
const
QString
&
_attrValue
)
:
GameEvent
(
"set_card_attr"
,
_gameId
,
_playerId
)
,
zone
(
_zone
),
cardId
(
_cardId
),
attrName
(
_attrName
),
attrValue
(
_attrValue
)
:
GameEvent
(
"set_card_attr"
,
_gameId
,
_playerId
)
{
{
setParameter
(
"zone"
,
zone
);
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
setParameter
(
"card_id"
,
cardId
);
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
setParameter
(
"attr_name"
,
attrName
);
insertItem
(
new
SerializableItem_String
(
"attr_name"
,
_attrName
));
setParameter
(
"attr_value"
,
attrValue
);
insertItem
(
new
SerializableItem_String
(
"attr_value"
,
_attrValue
));
}
void
Event_SetCardAttr
::
extractParameters
()
{
GameEvent
::
extractParameters
();
zone
=
parameters
[
"zone"
];
cardId
=
parameters
[
"card_id"
].
toInt
();
attrName
=
parameters
[
"attr_name"
];
attrValue
=
parameters
[
"attr_value"
];
}
}
Event_SetCounter
::
Event_SetCounter
(
int
_gameId
,
int
_playerId
,
int
_counterId
,
int
_value
)
Event_SetCounter
::
Event_SetCounter
(
int
_gameId
,
int
_playerId
,
int
_counterId
,
int
_value
)
:
GameEvent
(
"set_counter"
,
_gameId
,
_playerId
),
counterId
(
_counterId
),
value
(
_value
)
:
GameEvent
(
"set_counter"
,
_gameId
,
_playerId
)
{
setParameter
(
"counter_id"
,
counterId
);
setParameter
(
"value"
,
value
);
}
void
Event_SetCounter
::
extractParameters
()
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
counterId
=
parameters
[
"counter_id"
].
toInt
();
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
value
=
parameters
[
"value"
].
toInt
();
}
}
Event_DelCounter
::
Event_DelCounter
(
int
_gameId
,
int
_playerId
,
int
_counterId
)
Event_DelCounter
::
Event_DelCounter
(
int
_gameId
,
int
_playerId
,
int
_counterId
)
:
GameEvent
(
"del_counter"
,
_gameId
,
_playerId
),
counterId
(
_counterId
)
:
GameEvent
(
"del_counter"
,
_gameId
,
_playerId
)
{
setParameter
(
"counter_id"
,
counterId
);
}
void
Event_DelCounter
::
extractParameters
()
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
counterId
=
parameters
[
"counter_id"
].
toInt
();
}
}
Event_SetActivePlayer
::
Event_SetActivePlayer
(
int
_gameId
,
int
_playerId
,
int
_activePlayerId
)
Event_SetActivePlayer
::
Event_SetActivePlayer
(
int
_gameId
,
int
_playerId
,
int
_activePlayerId
)
:
GameEvent
(
"set_active_player"
,
_gameId
,
_playerId
)
,
activePlayerId
(
_activePlayerId
)
:
GameEvent
(
"set_active_player"
,
_gameId
,
_playerId
)
{
{
setParameter
(
"active_player_id"
,
activePlayerId
);
insertItem
(
new
SerializableItem_Int
(
"active_player_id"
,
_activePlayerId
));
}
void
Event_SetActivePlayer
::
extractParameters
()
{
GameEvent
::
extractParameters
();
activePlayerId
=
parameters
[
"active_player_id"
].
toInt
();
}
}
Event_SetActivePhase
::
Event_SetActivePhase
(
int
_gameId
,
int
_playerId
,
int
_phase
)
Event_SetActivePhase
::
Event_SetActivePhase
(
int
_gameId
,
int
_playerId
,
int
_phase
)
:
GameEvent
(
"set_active_phase"
,
_gameId
,
_playerId
)
,
phase
(
_phase
)
:
GameEvent
(
"set_active_phase"
,
_gameId
,
_playerId
)
{
{
setParameter
(
"phase"
,
phase
);
insertItem
(
new
SerializableItem_Int
(
"phase"
,
_phase
));
}
void
Event_SetActivePhase
::
extractParameters
()
{
GameEvent
::
extractParameters
();
phase
=
parameters
[
"phase"
].
toInt
();
}
}
Event_DumpZone
::
Event_DumpZone
(
int
_gameId
,
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
,
int
_numberCards
)
Event_DumpZone
::
Event_DumpZone
(
int
_gameId
,
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
,
int
_numberCards
)
:
GameEvent
(
"dump_zone"
,
_gameId
,
_playerId
),
zoneOwnerId
(
_zoneOwnerId
),
zone
(
_zone
),
numberCards
(
_numberCards
)
:
GameEvent
(
"dump_zone"
,
_gameId
,
_playerId
)
{
setParameter
(
"zone_owner_id"
,
zoneOwnerId
);
setParameter
(
"zone"
,
zone
);
setParameter
(
"number_cards"
,
numberCards
);
}
void
Event_DumpZone
::
extractParameters
()
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"zone_owner_id"
,
_zoneOwnerId
));
zoneOwnerId
=
parameters
[
"zone_owner_id"
].
toInt
();
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
zone
=
parameters
[
"zone"
];
insertItem
(
new
SerializableItem_Int
(
"number_cards"
,
_numberCards
));
numberCards
=
parameters
[
"number_cards"
].
toInt
();
}
}
Event_StopDumpZone
::
Event_StopDumpZone
(
int
_gameId
,
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
)
Event_StopDumpZone
::
Event_StopDumpZone
(
int
_gameId
,
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
)
:
GameEvent
(
"stop_dump_zone"
,
_gameId
,
_playerId
),
zoneOwnerId
(
_zoneOwnerId
),
zone
(
_zone
)
:
GameEvent
(
"stop_dump_zone"
,
_gameId
,
_playerId
)
{
setParameter
(
"zone_owner_id"
,
zoneOwnerId
);
setParameter
(
"zone"
,
zone
);
}
void
Event_StopDumpZone
::
extractParameters
()
{
{
GameEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_Int
(
"zone_owner_id"
,
_zoneOwnerId
));
zoneOwnerId
=
parameters
[
"zone_owner_id"
].
toInt
();
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
zone
=
parameters
[
"zone"
];
}
}
Event_ServerMessage
::
Event_ServerMessage
(
const
QString
&
_message
)
Event_ServerMessage
::
Event_ServerMessage
(
const
QString
&
_message
)
:
GenericEvent
(
"server_message"
)
,
message
(
_message
)
:
GenericEvent
(
"server_message"
)
{
{
setParameter
(
"message"
,
message
);
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
}
void
Event_ServerMessage
::
extractParameters
()
{
GenericEvent
::
extractParameters
();
message
=
parameters
[
"message"
];
}
}
Event_GameJoined
::
Event_GameJoined
(
int
_gameId
,
int
_playerId
,
bool
_spectator
)
Event_GameJoined
::
Event_GameJoined
(
int
_gameId
,
int
_playerId
,
bool
_spectator
)
:
GenericEvent
(
"game_joined"
)
,
gameId
(
_gameId
),
playerId
(
_playerId
),
spectator
(
_spectator
)
:
GenericEvent
(
"game_joined"
)
{
{
setParameter
(
"game_id"
,
gameId
);
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
setParameter
(
"player_id"
,
playerId
);
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
setParameter
(
"spectator"
,
spectator
);
insertItem
(
new
SerializableItem_Bool
(
"spectator"
,
_spectator
));
}
void
Event_GameJoined
::
extractParameters
()
{
GenericEvent
::
extractParameters
();
gameId
=
parameters
[
"game_id"
].
toInt
();
playerId
=
parameters
[
"player_id"
].
toInt
();
spectator
=
(
parameters
[
"spectator"
]
==
"1"
);
}
}
Event_ChatJoinChannel
::
Event_ChatJoinChannel
(
const
QString
&
_channel
,
const
QString
&
_playerName
)
Event_ChatJoinChannel
::
Event_ChatJoinChannel
(
const
QString
&
_channel
,
const
QString
&
_playerName
)
:
ChatEvent
(
"chat_join_channel"
,
_channel
),
playerName
(
_playerName
)
:
ChatEvent
(
"chat_join_channel"
,
_channel
)
{
setParameter
(
"player_name"
,
playerName
);
}
void
Event_ChatJoinChannel
::
extractParameters
()
{
{
ChatEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"player_name"
,
_playerName
));
playerName
=
parameters
[
"player_name"
];
}
}
Event_ChatLeaveChannel
::
Event_ChatLeaveChannel
(
const
QString
&
_channel
,
const
QString
&
_playerName
)
Event_ChatLeaveChannel
::
Event_ChatLeaveChannel
(
const
QString
&
_channel
,
const
QString
&
_playerName
)
:
ChatEvent
(
"chat_leave_channel"
,
_channel
),
playerName
(
_playerName
)
:
ChatEvent
(
"chat_leave_channel"
,
_channel
)
{
setParameter
(
"player_name"
,
playerName
);
}
void
Event_ChatLeaveChannel
::
extractParameters
()
{
{
ChatEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"player_name"
,
_playerName
));
playerName
=
parameters
[
"player_name"
];
}
}
Event_ChatSay
::
Event_ChatSay
(
const
QString
&
_channel
,
const
QString
&
_playerName
,
const
QString
&
_message
)
Event_ChatSay
::
Event_ChatSay
(
const
QString
&
_channel
,
const
QString
&
_playerName
,
const
QString
&
_message
)
:
ChatEvent
(
"chat_say"
,
_channel
),
playerName
(
_playerName
),
message
(
_message
)
:
ChatEvent
(
"chat_say"
,
_channel
)
{
setParameter
(
"player_name"
,
playerName
);
setParameter
(
"message"
,
message
);
}
void
Event_ChatSay
::
extractParameters
()
{
{
ChatEvent
::
extractParameters
();
insertItem
(
new
SerializableItem_String
(
"player_name"
,
_playerName
));
playerName
=
parameters
[
"player_name"
];
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
message
=
parameters
[
"message"
];
}
}
void
ProtocolItem
::
initializeHashAuto
()
void
ProtocolItem
::
initializeHashAuto
()
{
{
...
...
common/protocol_items.h
View file @
69407072
...
@@ -5,745 +5,502 @@
...
@@ -5,745 +5,502 @@
class
Command_Ping
:
public
Command
{
class
Command_Ping
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_Ping
();
Command_Ping
();
static
Protocol
Item
*
newItem
()
{
return
new
Command_Ping
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_Ping
;
}
int
getItemId
()
const
{
return
ItemId_Command_Ping
;
}
int
getItemId
()
const
{
return
ItemId_Command_Ping
;
}
};
};
class
Command_Login
:
public
Command
{
class
Command_Login
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
QString
username
;
QString
password
;
public:
public:
Command_Login
(
const
QString
&
_username
=
QString
(),
const
QString
&
_password
=
QString
());
Command_Login
(
const
QString
&
_username
=
QString
(),
const
QString
&
_password
=
QString
());
QString
getUsername
()
const
{
return
username
;
}
QString
getUsername
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"username"
))
->
getData
()
;
}
;
QString
getPassword
()
const
{
return
password
;
}
QString
getPassword
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"password"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_Login
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_Login
;
}
int
getItemId
()
const
{
return
ItemId_Command_Login
;
}
int
getItemId
()
const
{
return
ItemId_Command_Login
;
}
protected:
void
extractParameters
();
};
};
class
Command_DeckList
:
public
Command
{
class
Command_DeckList
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_DeckList
();
Command_DeckList
();
static
Protocol
Item
*
newItem
()
{
return
new
Command_DeckList
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DeckList
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckList
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckList
;
}
};
};
class
Command_DeckNewDir
:
public
Command
{
class
Command_DeckNewDir
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
QString
path
;
QString
dirName
;
public:
public:
Command_DeckNewDir
(
const
QString
&
_path
=
QString
(),
const
QString
&
_dirName
=
QString
());
Command_DeckNewDir
(
const
QString
&
_path
=
QString
(),
const
QString
&
_dirName
=
QString
());
QString
getPath
()
const
{
return
path
;
}
QString
getPath
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"path"
))
->
getData
()
;
}
;
QString
getDirName
()
const
{
return
dir
N
ame
;
}
QString
getDirName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
dir
_n
ame
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DeckNewDir
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DeckNewDir
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckNewDir
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckNewDir
;
}
protected:
void
extractParameters
();
};
};
class
Command_DeckDelDir
:
public
Command
{
class
Command_DeckDelDir
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
QString
path
;
public:
public:
Command_DeckDelDir
(
const
QString
&
_path
=
QString
());
Command_DeckDelDir
(
const
QString
&
_path
=
QString
());
QString
getPath
()
const
{
return
path
;
}
QString
getPath
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"path"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DeckDelDir
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DeckDelDir
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckDelDir
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckDelDir
;
}
protected:
void
extractParameters
();
};
};
class
Command_DeckDel
:
public
Command
{
class
Command_DeckDel
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
int
deckId
;
public:
public:
Command_DeckDel
(
int
_deckId
=
-
1
);
Command_DeckDel
(
int
_deckId
=
-
1
);
int
getDeckId
()
const
{
return
deckId
;
}
int
getDeckId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"deck_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DeckDel
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DeckDel
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckDel
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckDel
;
}
protected:
void
extractParameters
();
};
};
class
Command_DeckDownload
:
public
Command
{
class
Command_DeckDownload
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
int
deckId
;
public:
public:
Command_DeckDownload
(
int
_deckId
=
-
1
);
Command_DeckDownload
(
int
_deckId
=
-
1
);
int
getDeckId
()
const
{
return
deckId
;
}
int
getDeckId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"deck_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DeckDownload
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DeckDownload
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckDownload
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeckDownload
;
}
protected:
void
extractParameters
();
};
};
class
Command_ListChatChannels
:
public
Command
{
class
Command_ListChatChannels
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_ListChatChannels
();
Command_ListChatChannels
();
static
Protocol
Item
*
newItem
()
{
return
new
Command_ListChatChannels
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_ListChatChannels
;
}
int
getItemId
()
const
{
return
ItemId_Command_ListChatChannels
;
}
int
getItemId
()
const
{
return
ItemId_Command_ListChatChannels
;
}
};
};
class
Command_ChatJoinChannel
:
public
Command
{
class
Command_ChatJoinChannel
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
QString
channel
;
public:
public:
Command_ChatJoinChannel
(
const
QString
&
_channel
=
QString
());
Command_ChatJoinChannel
(
const
QString
&
_channel
=
QString
());
QString
getChannel
()
const
{
return
channel
;
}
QString
getChannel
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"channel"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_ChatJoinChannel
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_ChatJoinChannel
;
}
int
getItemId
()
const
{
return
ItemId_Command_ChatJoinChannel
;
}
int
getItemId
()
const
{
return
ItemId_Command_ChatJoinChannel
;
}
protected:
void
extractParameters
();
};
};
class
Command_ChatLeaveChannel
:
public
ChatCommand
{
class
Command_ChatLeaveChannel
:
public
ChatCommand
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_ChatLeaveChannel
(
const
QString
&
_channel
=
QString
());
Command_ChatLeaveChannel
(
const
QString
&
_channel
=
QString
());
static
Protocol
Item
*
newItem
()
{
return
new
Command_ChatLeaveChannel
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_ChatLeaveChannel
;
}
int
getItemId
()
const
{
return
ItemId_Command_ChatLeaveChannel
;
}
int
getItemId
()
const
{
return
ItemId_Command_ChatLeaveChannel
;
}
};
};
class
Command_ChatSay
:
public
ChatCommand
{
class
Command_ChatSay
:
public
ChatCommand
{
Q_OBJECT
Q_OBJECT
private:
QString
message
;
public:
public:
Command_ChatSay
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_message
=
QString
());
Command_ChatSay
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_message
=
QString
());
QString
getMessage
()
const
{
return
message
;
}
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_ChatSay
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_ChatSay
;
}
int
getItemId
()
const
{
return
ItemId_Command_ChatSay
;
}
int
getItemId
()
const
{
return
ItemId_Command_ChatSay
;
}
protected:
void
extractParameters
();
};
};
class
Command_ListGames
:
public
Command
{
class
Command_ListGames
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_ListGames
();
Command_ListGames
();
static
Protocol
Item
*
newItem
()
{
return
new
Command_ListGames
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_ListGames
;
}
int
getItemId
()
const
{
return
ItemId_Command_ListGames
;
}
int
getItemId
()
const
{
return
ItemId_Command_ListGames
;
}
};
};
class
Command_CreateGame
:
public
Command
{
class
Command_CreateGame
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
QString
description
;
QString
password
;
int
maxPlayers
;
bool
spectatorsAllowed
;
public:
public:
Command_CreateGame
(
const
QString
&
_description
=
QString
(),
const
QString
&
_password
=
QString
(),
int
_maxPlayers
=
-
1
,
bool
_spectatorsAllowed
=
false
);
Command_CreateGame
(
const
QString
&
_description
=
QString
(),
const
QString
&
_password
=
QString
(),
int
_maxPlayers
=
-
1
,
bool
_spectatorsAllowed
=
false
);
QString
getDescription
()
const
{
return
description
;
}
QString
getDescription
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"description"
))
->
getData
()
;
}
;
QString
getPassword
()
const
{
return
password
;
}
QString
getPassword
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"password"
))
->
getData
()
;
}
;
int
getMaxPlayers
()
const
{
return
max
P
layers
;
}
int
getMaxPlayers
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
max
_p
layers
"
))
->
getData
()
;
}
;
bool
getSpectatorsAllowed
()
const
{
return
spectators
A
llowed
;
}
bool
getSpectatorsAllowed
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"
spectators
_a
llowed
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_CreateGame
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_CreateGame
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateGame
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateGame
;
}
protected:
void
extractParameters
();
};
};
class
Command_JoinGame
:
public
Command
{
class
Command_JoinGame
:
public
Command
{
Q_OBJECT
Q_OBJECT
private:
int
gameId
;
QString
password
;
bool
spectator
;
public:
public:
Command_JoinGame
(
int
_gameId
=
-
1
,
const
QString
&
_password
=
QString
(),
bool
_spectator
=
false
);
Command_JoinGame
(
int
_gameId
=
-
1
,
const
QString
&
_password
=
QString
(),
bool
_spectator
=
false
);
int
getGameId
()
const
{
return
gameId
;
}
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
()
;
}
;
QString
getPassword
()
const
{
return
password
;
}
QString
getPassword
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"password"
))
->
getData
()
;
}
;
bool
getSpectator
()
const
{
return
s
pectator
;
}
bool
getSpectator
()
const
{
return
s
tatic_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectator"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_JoinGame
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_JoinGame
;
}
int
getItemId
()
const
{
return
ItemId_Command_JoinGame
;
}
int
getItemId
()
const
{
return
ItemId_Command_JoinGame
;
}
protected:
void
extractParameters
();
};
};
class
Command_LeaveGame
:
public
GameCommand
{
class
Command_LeaveGame
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_LeaveGame
(
int
_gameId
=
-
1
);
Command_LeaveGame
(
int
_gameId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Command_LeaveGame
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_LeaveGame
;
}
int
getItemId
()
const
{
return
ItemId_Command_LeaveGame
;
}
int
getItemId
()
const
{
return
ItemId_Command_LeaveGame
;
}
};
};
class
Command_Say
:
public
GameCommand
{
class
Command_Say
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
QString
message
;
public:
public:
Command_Say
(
int
_gameId
=
-
1
,
const
QString
&
_message
=
QString
());
Command_Say
(
int
_gameId
=
-
1
,
const
QString
&
_message
=
QString
());
QString
getMessage
()
const
{
return
message
;
}
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_Say
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_Say
;
}
int
getItemId
()
const
{
return
ItemId_Command_Say
;
}
int
getItemId
()
const
{
return
ItemId_Command_Say
;
}
protected:
void
extractParameters
();
};
};
class
Command_Shuffle
:
public
GameCommand
{
class
Command_Shuffle
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_Shuffle
(
int
_gameId
=
-
1
);
Command_Shuffle
(
int
_gameId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Command_Shuffle
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_Shuffle
;
}
int
getItemId
()
const
{
return
ItemId_Command_Shuffle
;
}
int
getItemId
()
const
{
return
ItemId_Command_Shuffle
;
}
};
};
class
Command_RollDie
:
public
GameCommand
{
class
Command_RollDie
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
sides
;
public:
public:
Command_RollDie
(
int
_gameId
=
-
1
,
int
_sides
=
-
1
);
Command_RollDie
(
int
_gameId
=
-
1
,
int
_sides
=
-
1
);
int
getSides
()
const
{
return
s
ides
;
}
int
getSides
()
const
{
return
s
tatic_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"sides"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_RollDie
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_RollDie
;
}
int
getItemId
()
const
{
return
ItemId_Command_RollDie
;
}
int
getItemId
()
const
{
return
ItemId_Command_RollDie
;
}
protected:
void
extractParameters
();
};
};
class
Command_DrawCards
:
public
GameCommand
{
class
Command_DrawCards
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
number
;
public:
public:
Command_DrawCards
(
int
_gameId
=
-
1
,
int
_number
=
-
1
);
Command_DrawCards
(
int
_gameId
=
-
1
,
int
_number
=
-
1
);
int
getNumber
()
const
{
return
number
;
}
int
getNumber
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"number"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DrawCards
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DrawCards
;
}
int
getItemId
()
const
{
return
ItemId_Command_DrawCards
;
}
int
getItemId
()
const
{
return
ItemId_Command_DrawCards
;
}
protected:
void
extractParameters
();
};
};
class
Command_MoveCard
:
public
GameCommand
{
class
Command_MoveCard
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
QString
startZone
;
int
cardId
;
QString
targetZone
;
int
x
;
int
y
;
bool
faceDown
;
public:
public:
Command_MoveCard
(
int
_gameId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
bool
_faceDown
=
false
);
Command_MoveCard
(
int
_gameId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
bool
_faceDown
=
false
);
QString
getStartZone
()
const
{
return
sta
rtZone
;
}
QString
getStartZone
()
const
{
return
sta
tic_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
()
;
}
;
int
getCardId
()
const
{
return
cardId
;
}
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
()
;
}
;
QString
getTargetZone
()
const
{
return
ta
rgetZone
;
}
QString
getTargetZone
()
const
{
return
s
ta
tic_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"target_zone"
))
->
getData
()
;
}
;
int
getX
()
const
{
return
x
;
}
int
getX
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"x"
))
->
getData
()
;
}
;
int
getY
()
const
{
return
y
;
}
int
getY
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"y"
))
->
getData
()
;
}
;
bool
getFaceDown
()
const
{
return
face
D
own
;
}
bool
getFaceDown
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"
face
_d
own
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_MoveCard
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_MoveCard
;
}
int
getItemId
()
const
{
return
ItemId_Command_MoveCard
;
}
int
getItemId
()
const
{
return
ItemId_Command_MoveCard
;
}
protected:
void
extractParameters
();
};
};
class
Command_CreateToken
:
public
GameCommand
{
class
Command_CreateToken
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
QString
zone
;
QString
cardName
;
QString
pt
;
int
x
;
int
y
;
public:
public:
Command_CreateToken
(
int
_gameId
=
-
1
,
const
QString
&
_zone
=
QString
(),
const
QString
&
_cardName
=
QString
(),
const
QString
&
_pt
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
);
Command_CreateToken
(
int
_gameId
=
-
1
,
const
QString
&
_zone
=
QString
(),
const
QString
&
_cardName
=
QString
(),
const
QString
&
_pt
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
);
QString
getZone
()
const
{
return
zone
;
}
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
()
;
}
;
QString
getCardName
()
const
{
return
card
N
ame
;
}
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
card
_n
ame
"
))
->
getData
()
;
}
;
QString
getPt
()
const
{
return
pt
;
}
QString
getPt
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"pt"
))
->
getData
()
;
}
;
int
getX
()
const
{
return
x
;
}
int
getX
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"x"
))
->
getData
()
;
}
;
int
getY
()
const
{
return
y
;
}
int
getY
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"y"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_CreateToken
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_CreateToken
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateToken
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateToken
;
}
protected:
void
extractParameters
();
};
};
class
Command_CreateArrow
:
public
GameCommand
{
class
Command_CreateArrow
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
startPlayerId
;
QString
startZone
;
int
startCardId
;
int
targetPlayerId
;
QString
targetZone
;
int
targetCardId
;
QColor
color
;
public:
public:
Command_CreateArrow
(
int
_gameId
=
-
1
,
int
_startPlayerId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
int
_startCardId
=
-
1
,
int
_targetPlayerId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_targetCardId
=
-
1
,
const
QColor
&
_color
=
QColor
());
Command_CreateArrow
(
int
_gameId
=
-
1
,
int
_startPlayerId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
int
_startCardId
=
-
1
,
int
_targetPlayerId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_targetCardId
=
-
1
,
const
QColor
&
_color
=
QColor
());
int
getStartPlayerId
()
const
{
return
sta
rtPlayerId
;
}
int
getStartPlayerId
()
const
{
return
sta
tic_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"start_player_id"
))
->
getData
()
;
}
;
QString
getStartZone
()
const
{
return
sta
rtZone
;
}
QString
getStartZone
()
const
{
return
sta
tic_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
()
;
}
;
int
getStartCardId
()
const
{
return
sta
rtCardId
;
}
int
getStartCardId
()
const
{
return
sta
tic_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"start_card_id"
))
->
getData
()
;
}
;
int
getTargetPlayerId
()
const
{
return
target
P
layer
Id
;
}
int
getTargetPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
target
_p
layer
_id"
))
->
getData
()
;
}
;
QString
getTargetZone
()
const
{
return
ta
rgetZone
;
}
QString
getTargetZone
()
const
{
return
s
ta
tic_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"target_zone"
))
->
getData
()
;
}
;
int
getTargetCardId
()
const
{
return
target
C
ard
Id
;
}
int
getTargetCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
target
_c
ard
_id"
))
->
getData
()
;
}
;
QColor
getColor
()
const
{
return
color
;
}
QColor
getColor
()
const
{
return
static_cast
<
SerializableItem_Color
*>
(
itemMap
.
value
(
"color"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_CreateArrow
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_CreateArrow
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateArrow
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateArrow
;
}
protected:
void
extractParameters
();
};
};
class
Command_DeleteArrow
:
public
GameCommand
{
class
Command_DeleteArrow
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
arrowId
;
public:
public:
Command_DeleteArrow
(
int
_gameId
=
-
1
,
int
_arrowId
=
-
1
);
Command_DeleteArrow
(
int
_gameId
=
-
1
,
int
_arrowId
=
-
1
);
int
getArrowId
()
const
{
return
arrowId
;
}
int
getArrowId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"arrow_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DeleteArrow
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DeleteArrow
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeleteArrow
;
}
int
getItemId
()
const
{
return
ItemId_Command_DeleteArrow
;
}
protected:
void
extractParameters
();
};
};
class
Command_SetCardAttr
:
public
GameCommand
{
class
Command_SetCardAttr
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
QString
zone
;
int
cardId
;
QString
attrName
;
QString
attrValue
;
public:
public:
Command_SetCardAttr
(
int
_gameId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_attrName
=
QString
(),
const
QString
&
_attrValue
=
QString
());
Command_SetCardAttr
(
int
_gameId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_attrName
=
QString
(),
const
QString
&
_attrValue
=
QString
());
QString
getZone
()
const
{
return
zone
;
}
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
()
;
}
;
int
getCardId
()
const
{
return
cardId
;
}
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
()
;
}
;
QString
getAttrName
()
const
{
return
attrName
;
}
QString
getAttrName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"attr_name"
))
->
getData
()
;
}
;
QString
getAttrValue
()
const
{
return
attrValue
;
}
QString
getAttrValue
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"attr_value"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_SetCardAttr
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_SetCardAttr
;
}
int
getItemId
()
const
{
return
ItemId_Command_SetCardAttr
;
}
int
getItemId
()
const
{
return
ItemId_Command_SetCardAttr
;
}
protected:
void
extractParameters
();
};
};
class
Command_ReadyStart
:
public
GameCommand
{
class
Command_ReadyStart
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_ReadyStart
(
int
_gameId
=
-
1
);
Command_ReadyStart
(
int
_gameId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Command_ReadyStart
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_ReadyStart
;
}
int
getItemId
()
const
{
return
ItemId_Command_ReadyStart
;
}
int
getItemId
()
const
{
return
ItemId_Command_ReadyStart
;
}
};
};
class
Command_IncCounter
:
public
GameCommand
{
class
Command_IncCounter
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
counterId
;
int
delta
;
public:
public:
Command_IncCounter
(
int
_gameId
=
-
1
,
int
_counterId
=
-
1
,
int
_delta
=
-
1
);
Command_IncCounter
(
int
_gameId
=
-
1
,
int
_counterId
=
-
1
,
int
_delta
=
-
1
);
int
getCounterId
()
const
{
return
counterId
;
}
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
()
;
}
;
int
getDelta
()
const
{
return
delta
;
}
int
getDelta
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"delta"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_IncCounter
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_IncCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_IncCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_IncCounter
;
}
protected:
void
extractParameters
();
};
};
class
Command_CreateCounter
:
public
GameCommand
{
class
Command_CreateCounter
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
QString
counterName
;
QColor
color
;
int
radius
;
int
value
;
public:
public:
Command_CreateCounter
(
int
_gameId
=
-
1
,
const
QString
&
_counterName
=
QString
(),
const
QColor
&
_color
=
QColor
(),
int
_radius
=
-
1
,
int
_value
=
-
1
);
Command_CreateCounter
(
int
_gameId
=
-
1
,
const
QString
&
_counterName
=
QString
(),
const
QColor
&
_color
=
QColor
(),
int
_radius
=
-
1
,
int
_value
=
-
1
);
QString
getCounterName
()
const
{
return
counter
N
ame
;
}
QString
getCounterName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
counter
_n
ame
"
))
->
getData
()
;
}
;
QColor
getColor
()
const
{
return
color
;
}
QColor
getColor
()
const
{
return
static_cast
<
SerializableItem_Color
*>
(
itemMap
.
value
(
"color"
))
->
getData
()
;
}
;
int
getRadius
()
const
{
return
radius
;
}
int
getRadius
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"radius"
))
->
getData
()
;
}
;
int
getValue
()
const
{
return
value
;
}
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_CreateCounter
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_CreateCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_CreateCounter
;
}
protected:
void
extractParameters
();
};
};
class
Command_SetCounter
:
public
GameCommand
{
class
Command_SetCounter
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
counterId
;
int
value
;
public:
public:
Command_SetCounter
(
int
_gameId
=
-
1
,
int
_counterId
=
-
1
,
int
_value
=
-
1
);
Command_SetCounter
(
int
_gameId
=
-
1
,
int
_counterId
=
-
1
,
int
_value
=
-
1
);
int
getCounterId
()
const
{
return
counterId
;
}
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
()
;
}
;
int
getValue
()
const
{
return
value
;
}
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_SetCounter
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_SetCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_SetCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_SetCounter
;
}
protected:
void
extractParameters
();
};
};
class
Command_DelCounter
:
public
GameCommand
{
class
Command_DelCounter
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
counterId
;
public:
public:
Command_DelCounter
(
int
_gameId
=
-
1
,
int
_counterId
=
-
1
);
Command_DelCounter
(
int
_gameId
=
-
1
,
int
_counterId
=
-
1
);
int
getCounterId
()
const
{
return
counterId
;
}
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DelCounter
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DelCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_DelCounter
;
}
int
getItemId
()
const
{
return
ItemId_Command_DelCounter
;
}
protected:
void
extractParameters
();
};
};
class
Command_NextTurn
:
public
GameCommand
{
class
Command_NextTurn
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Command_NextTurn
(
int
_gameId
=
-
1
);
Command_NextTurn
(
int
_gameId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Command_NextTurn
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_NextTurn
;
}
int
getItemId
()
const
{
return
ItemId_Command_NextTurn
;
}
int
getItemId
()
const
{
return
ItemId_Command_NextTurn
;
}
};
};
class
Command_SetActivePhase
:
public
GameCommand
{
class
Command_SetActivePhase
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
phase
;
public:
public:
Command_SetActivePhase
(
int
_gameId
=
-
1
,
int
_phase
=
-
1
);
Command_SetActivePhase
(
int
_gameId
=
-
1
,
int
_phase
=
-
1
);
int
getPhase
()
const
{
return
phase
;
}
int
getPhase
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"phase"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_SetActivePhase
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_SetActivePhase
;
}
int
getItemId
()
const
{
return
ItemId_Command_SetActivePhase
;
}
int
getItemId
()
const
{
return
ItemId_Command_SetActivePhase
;
}
protected:
void
extractParameters
();
};
};
class
Command_DumpZone
:
public
GameCommand
{
class
Command_DumpZone
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
playerId
;
QString
zoneName
;
int
numberCards
;
public:
public:
Command_DumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zoneName
=
QString
(),
int
_numberCards
=
-
1
);
Command_DumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zoneName
=
QString
(),
int
_numberCards
=
-
1
);
int
getPlayerId
()
const
{
return
playerId
;
}
int
getPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_id"
))
->
getData
()
;
}
;
QString
getZoneName
()
const
{
return
zone
N
ame
;
}
QString
getZoneName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
zone
_n
ame
"
))
->
getData
()
;
}
;
int
getNumberCards
()
const
{
return
number
C
ards
;
}
int
getNumberCards
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
number
_c
ards
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_DumpZone
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_DumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Command_DumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Command_DumpZone
;
}
protected:
void
extractParameters
();
};
};
class
Command_StopDumpZone
:
public
GameCommand
{
class
Command_StopDumpZone
:
public
GameCommand
{
Q_OBJECT
Q_OBJECT
private:
int
playerId
;
QString
zoneName
;
public:
public:
Command_StopDumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zoneName
=
QString
());
Command_StopDumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zoneName
=
QString
());
int
getPlayerId
()
const
{
return
playerId
;
}
int
getPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_id"
))
->
getData
()
;
}
;
QString
getZoneName
()
const
{
return
zone
N
ame
;
}
QString
getZoneName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
zone
_n
ame
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Command_StopDumpZone
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Command_StopDumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Command_StopDumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Command_StopDumpZone
;
}
protected:
void
extractParameters
();
};
};
class
Event_Say
:
public
GameEvent
{
class
Event_Say
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
message
;
public:
public:
Event_Say
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_message
=
QString
());
Event_Say
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_message
=
QString
());
QString
getMessage
()
const
{
return
message
;
}
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_Say
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_Say
;
}
int
getItemId
()
const
{
return
ItemId_Event_Say
;
}
int
getItemId
()
const
{
return
ItemId_Event_Say
;
}
protected:
void
extractParameters
();
};
};
class
Event_Join
:
public
GameEvent
{
class
Event_Join
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
playerName
;
bool
spectator
;
public:
public:
Event_Join
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_playerName
=
QString
(),
bool
_spectator
=
false
);
Event_Join
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_playerName
=
QString
(),
bool
_spectator
=
false
);
QString
getPlayerName
()
const
{
return
player
N
ame
;
}
QString
getPlayerName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
player
_n
ame
"
))
->
getData
()
;
}
;
bool
getSpectator
()
const
{
return
s
pectator
;
}
bool
getSpectator
()
const
{
return
s
tatic_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectator"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_Join
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_Join
;
}
int
getItemId
()
const
{
return
ItemId_Event_Join
;
}
int
getItemId
()
const
{
return
ItemId_Event_Join
;
}
protected:
void
extractParameters
();
};
};
class
Event_Leave
:
public
GameEvent
{
class
Event_Leave
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Event_Leave
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_Leave
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Event_Leave
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_Leave
;
}
int
getItemId
()
const
{
return
ItemId_Event_Leave
;
}
int
getItemId
()
const
{
return
ItemId_Event_Leave
;
}
};
};
class
Event_DeckSelect
:
public
GameEvent
{
class
Event_DeckSelect
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
deckId
;
public:
public:
Event_DeckSelect
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_deckId
=
-
1
);
Event_DeckSelect
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_deckId
=
-
1
);
int
getDeckId
()
const
{
return
deckId
;
}
int
getDeckId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"deck_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_DeckSelect
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_DeckSelect
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeckSelect
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeckSelect
;
}
protected:
void
extractParameters
();
};
};
class
Event_GameClosed
:
public
GameEvent
{
class
Event_GameClosed
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Event_GameClosed
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_GameClosed
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Event_GameClosed
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_GameClosed
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameClosed
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameClosed
;
}
};
};
class
Event_ReadyStart
:
public
GameEvent
{
class
Event_ReadyStart
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Event_ReadyStart
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_ReadyStart
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Event_ReadyStart
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_ReadyStart
;
}
int
getItemId
()
const
{
return
ItemId_Event_ReadyStart
;
}
int
getItemId
()
const
{
return
ItemId_Event_ReadyStart
;
}
};
};
class
Event_GameStart
:
public
GameEvent
{
class
Event_GameStart
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Event_GameStart
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_GameStart
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Event_GameStart
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_GameStart
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameStart
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameStart
;
}
};
};
class
Event_Shuffle
:
public
GameEvent
{
class
Event_Shuffle
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
public:
public:
Event_Shuffle
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_Shuffle
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
static
Protocol
Item
*
newItem
()
{
return
new
Event_Shuffle
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_Shuffle
;
}
int
getItemId
()
const
{
return
ItemId_Event_Shuffle
;
}
int
getItemId
()
const
{
return
ItemId_Event_Shuffle
;
}
};
};
class
Event_RollDie
:
public
GameEvent
{
class
Event_RollDie
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
sides
;
int
value
;
public:
public:
Event_RollDie
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_sides
=
-
1
,
int
_value
=
-
1
);
Event_RollDie
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_sides
=
-
1
,
int
_value
=
-
1
);
int
getSides
()
const
{
return
s
ides
;
}
int
getSides
()
const
{
return
s
tatic_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"sides"
))
->
getData
()
;
}
;
int
getValue
()
const
{
return
value
;
}
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_RollDie
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_RollDie
;
}
int
getItemId
()
const
{
return
ItemId_Event_RollDie
;
}
int
getItemId
()
const
{
return
ItemId_Event_RollDie
;
}
protected:
void
extractParameters
();
};
};
class
Event_MoveCard
:
public
GameEvent
{
class
Event_MoveCard
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
cardId
;
QString
cardName
;
QString
startZone
;
int
position
;
QString
targetZone
;
int
x
;
int
y
;
bool
faceDown
;
public:
public:
Event_MoveCard
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_cardId
=
-
1
,
const
QString
&
_cardName
=
QString
(),
const
QString
&
_startZone
=
QString
(),
int
_position
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
bool
_faceDown
=
false
);
Event_MoveCard
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_cardId
=
-
1
,
const
QString
&
_cardName
=
QString
(),
const
QString
&
_startZone
=
QString
(),
int
_position
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
bool
_faceDown
=
false
);
int
getCardId
()
const
{
return
cardId
;
}
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
()
;
}
;
QString
getCardName
()
const
{
return
card
N
ame
;
}
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
card
_n
ame
"
))
->
getData
()
;
}
;
QString
getStartZone
()
const
{
return
sta
rtZone
;
}
QString
getStartZone
()
const
{
return
sta
tic_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
()
;
}
;
int
getPosition
()
const
{
return
position
;
}
int
getPosition
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"position"
))
->
getData
()
;
}
;
QString
getTargetZone
()
const
{
return
ta
rgetZone
;
}
QString
getTargetZone
()
const
{
return
s
ta
tic_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"target_zone"
))
->
getData
()
;
}
;
int
getX
()
const
{
return
x
;
}
int
getX
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"x"
))
->
getData
()
;
}
;
int
getY
()
const
{
return
y
;
}
int
getY
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"y"
))
->
getData
()
;
}
;
bool
getFaceDown
()
const
{
return
face
D
own
;
}
bool
getFaceDown
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"
face
_d
own
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_MoveCard
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_MoveCard
;
}
int
getItemId
()
const
{
return
ItemId_Event_MoveCard
;
}
int
getItemId
()
const
{
return
ItemId_Event_MoveCard
;
}
protected:
void
extractParameters
();
};
};
class
Event_CreateToken
:
public
GameEvent
{
class
Event_CreateToken
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
zone
;
int
cardId
;
QString
cardName
;
QString
pt
;
int
x
;
int
y
;
public:
public:
Event_CreateToken
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_cardName
=
QString
(),
const
QString
&
_pt
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
);
Event_CreateToken
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_cardName
=
QString
(),
const
QString
&
_pt
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
);
QString
getZone
()
const
{
return
zone
;
}
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
()
;
}
;
int
getCardId
()
const
{
return
cardId
;
}
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
()
;
}
;
QString
getCardName
()
const
{
return
card
N
ame
;
}
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
card
_n
ame
"
))
->
getData
()
;
}
;
QString
getPt
()
const
{
return
pt
;
}
QString
getPt
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"pt"
))
->
getData
()
;
}
;
int
getX
()
const
{
return
x
;
}
int
getX
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"x"
))
->
getData
()
;
}
;
int
getY
()
const
{
return
y
;
}
int
getY
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"y"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_CreateToken
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_CreateToken
;
}
int
getItemId
()
const
{
return
ItemId_Event_CreateToken
;
}
int
getItemId
()
const
{
return
ItemId_Event_CreateToken
;
}
protected:
void
extractParameters
();
};
};
class
Event_DeleteArrow
:
public
GameEvent
{
class
Event_DeleteArrow
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
arrowId
;
public:
public:
Event_DeleteArrow
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_arrowId
=
-
1
);
Event_DeleteArrow
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_arrowId
=
-
1
);
int
getArrowId
()
const
{
return
arrowId
;
}
int
getArrowId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"arrow_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_DeleteArrow
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_DeleteArrow
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeleteArrow
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeleteArrow
;
}
protected:
void
extractParameters
();
};
};
class
Event_SetCardAttr
:
public
GameEvent
{
class
Event_SetCardAttr
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
zone
;
int
cardId
;
QString
attrName
;
QString
attrValue
;
public:
public:
Event_SetCardAttr
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_attrName
=
QString
(),
const
QString
&
_attrValue
=
QString
());
Event_SetCardAttr
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_attrName
=
QString
(),
const
QString
&
_attrValue
=
QString
());
QString
getZone
()
const
{
return
zone
;
}
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
()
;
}
;
int
getCardId
()
const
{
return
cardId
;
}
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
()
;
}
;
QString
getAttrName
()
const
{
return
attrName
;
}
QString
getAttrName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"attr_name"
))
->
getData
()
;
}
;
QString
getAttrValue
()
const
{
return
attrValue
;
}
QString
getAttrValue
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"attr_value"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_SetCardAttr
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_SetCardAttr
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetCardAttr
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetCardAttr
;
}
protected:
void
extractParameters
();
};
};
class
Event_SetCounter
:
public
GameEvent
{
class
Event_SetCounter
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
counterId
;
int
value
;
public:
public:
Event_SetCounter
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_counterId
=
-
1
,
int
_value
=
-
1
);
Event_SetCounter
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_counterId
=
-
1
,
int
_value
=
-
1
);
int
getCounterId
()
const
{
return
counterId
;
}
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
()
;
}
;
int
getValue
()
const
{
return
value
;
}
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_SetCounter
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_SetCounter
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetCounter
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetCounter
;
}
protected:
void
extractParameters
();
};
};
class
Event_DelCounter
:
public
GameEvent
{
class
Event_DelCounter
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
counterId
;
public:
public:
Event_DelCounter
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_counterId
=
-
1
);
Event_DelCounter
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_counterId
=
-
1
);
int
getCounterId
()
const
{
return
counterId
;
}
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_DelCounter
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_DelCounter
;
}
int
getItemId
()
const
{
return
ItemId_Event_DelCounter
;
}
int
getItemId
()
const
{
return
ItemId_Event_DelCounter
;
}
protected:
void
extractParameters
();
};
};
class
Event_SetActivePlayer
:
public
GameEvent
{
class
Event_SetActivePlayer
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
activePlayerId
;
public:
public:
Event_SetActivePlayer
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_activePlayerId
=
-
1
);
Event_SetActivePlayer
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_activePlayerId
=
-
1
);
int
getActivePlayerId
()
const
{
return
activePlayerId
;
}
int
getActivePlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"active_player_id"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_SetActivePlayer
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_SetActivePlayer
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePlayer
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePlayer
;
}
protected:
void
extractParameters
();
};
};
class
Event_SetActivePhase
:
public
GameEvent
{
class
Event_SetActivePhase
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
phase
;
public:
public:
Event_SetActivePhase
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_phase
=
-
1
);
Event_SetActivePhase
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_phase
=
-
1
);
int
getPhase
()
const
{
return
phase
;
}
int
getPhase
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"phase"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_SetActivePhase
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_SetActivePhase
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePhase
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePhase
;
}
protected:
void
extractParameters
();
};
};
class
Event_DumpZone
:
public
GameEvent
{
class
Event_DumpZone
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
zoneOwnerId
;
QString
zone
;
int
numberCards
;
public:
public:
Event_DumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_numberCards
=
-
1
);
Event_DumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_numberCards
=
-
1
);
int
getZoneOwnerId
()
const
{
return
zone
O
wner
Id
;
}
int
getZoneOwnerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
zone
_o
wner
_id"
))
->
getData
()
;
}
;
QString
getZone
()
const
{
return
zone
;
}
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
()
;
}
;
int
getNumberCards
()
const
{
return
number
C
ards
;
}
int
getNumberCards
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
number
_c
ards
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_DumpZone
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_DumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Event_DumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Event_DumpZone
;
}
protected:
void
extractParameters
();
};
};
class
Event_StopDumpZone
:
public
GameEvent
{
class
Event_StopDumpZone
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
private:
int
zoneOwnerId
;
QString
zone
;
public:
public:
Event_StopDumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
());
Event_StopDumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
());
int
getZoneOwnerId
()
const
{
return
zone
O
wner
Id
;
}
int
getZoneOwnerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"
zone
_o
wner
_id"
))
->
getData
()
;
}
;
QString
getZone
()
const
{
return
zone
;
}
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_StopDumpZone
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_StopDumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Event_StopDumpZone
;
}
int
getItemId
()
const
{
return
ItemId_Event_StopDumpZone
;
}
protected:
void
extractParameters
();
};
};
class
Event_ServerMessage
:
public
GenericEvent
{
class
Event_ServerMessage
:
public
GenericEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
message
;
public:
public:
Event_ServerMessage
(
const
QString
&
_message
=
QString
());
Event_ServerMessage
(
const
QString
&
_message
=
QString
());
QString
getMessage
()
const
{
return
message
;
}
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_ServerMessage
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_ServerMessage
;
}
int
getItemId
()
const
{
return
ItemId_Event_ServerMessage
;
}
int
getItemId
()
const
{
return
ItemId_Event_ServerMessage
;
}
protected:
void
extractParameters
();
};
};
class
Event_GameJoined
:
public
GenericEvent
{
class
Event_GameJoined
:
public
GenericEvent
{
Q_OBJECT
Q_OBJECT
private:
int
gameId
;
int
playerId
;
bool
spectator
;
public:
public:
Event_GameJoined
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
bool
_spectator
=
false
);
Event_GameJoined
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
bool
_spectator
=
false
);
int
getGameId
()
const
{
return
gameId
;
}
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
()
;
}
;
int
getPlayerId
()
const
{
return
playerId
;
}
int
getPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_id"
))
->
getData
()
;
}
;
bool
getSpectator
()
const
{
return
s
pectator
;
}
bool
getSpectator
()
const
{
return
s
tatic_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"spectator"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_GameJoined
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_GameJoined
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameJoined
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameJoined
;
}
protected:
void
extractParameters
();
};
};
class
Event_ChatJoinChannel
:
public
ChatEvent
{
class
Event_ChatJoinChannel
:
public
ChatEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
playerName
;
public:
public:
Event_ChatJoinChannel
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_playerName
=
QString
());
Event_ChatJoinChannel
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_playerName
=
QString
());
QString
getPlayerName
()
const
{
return
player
N
ame
;
}
QString
getPlayerName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
player
_n
ame
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_ChatJoinChannel
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_ChatJoinChannel
;
}
int
getItemId
()
const
{
return
ItemId_Event_ChatJoinChannel
;
}
int
getItemId
()
const
{
return
ItemId_Event_ChatJoinChannel
;
}
protected:
void
extractParameters
();
};
};
class
Event_ChatLeaveChannel
:
public
ChatEvent
{
class
Event_ChatLeaveChannel
:
public
ChatEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
playerName
;
public:
public:
Event_ChatLeaveChannel
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_playerName
=
QString
());
Event_ChatLeaveChannel
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_playerName
=
QString
());
QString
getPlayerName
()
const
{
return
player
N
ame
;
}
QString
getPlayerName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
player
_n
ame
"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_ChatLeaveChannel
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_ChatLeaveChannel
;
}
int
getItemId
()
const
{
return
ItemId_Event_ChatLeaveChannel
;
}
int
getItemId
()
const
{
return
ItemId_Event_ChatLeaveChannel
;
}
protected:
void
extractParameters
();
};
};
class
Event_ChatSay
:
public
ChatEvent
{
class
Event_ChatSay
:
public
ChatEvent
{
Q_OBJECT
Q_OBJECT
private:
QString
playerName
;
QString
message
;
public:
public:
Event_ChatSay
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_playerName
=
QString
(),
const
QString
&
_message
=
QString
());
Event_ChatSay
(
const
QString
&
_channel
=
QString
(),
const
QString
&
_playerName
=
QString
(),
const
QString
&
_message
=
QString
());
QString
getPlayerName
()
const
{
return
player
N
ame
;
}
QString
getPlayerName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"
player
_n
ame
"
))
->
getData
()
;
}
;
QString
getMessage
()
const
{
return
message
;
}
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
()
;
}
;
static
Protocol
Item
*
newItem
()
{
return
new
Event_ChatSay
;
}
static
Serializable
Item
*
newItem
()
{
return
new
Event_ChatSay
;
}
int
getItemId
()
const
{
return
ItemId_Event_ChatSay
;
}
int
getItemId
()
const
{
return
ItemId_Event_ChatSay
;
}
protected:
void
extractParameters
();
};
};
#endif
#endif
common/protocol_mc.pl
View file @
69407072
...
@@ -70,12 +70,9 @@ while (<file>) {
...
@@ -70,12 +70,9 @@ while (<file>) {
$className
=
$namePrefix
.
'
_
'
.
$name2
;
$className
=
$namePrefix
.
'
_
'
.
$name2
;
$itemEnum
.=
"
ItemId_
$className
=
"
.
++
$itemId
.
"
,
\n
";
$itemEnum
.=
"
ItemId_
$className
=
"
.
++
$itemId
.
"
,
\n
";
$headerfileBuffer
.=
"
class
$className
: public
$baseClass
{
\n
"
$headerfileBuffer
.=
"
class
$className
: public
$baseClass
{
\n
"
.
"
\t
Q_OBJECT
\n
"
.
"
\t
Q_OBJECT
\n
";
.
"
private:
\n
";
$constructorCode
=
'';
$paramStr2
=
'';
$getFunctionCode
=
'';
$paramStr3
=
'';
$paramStr4
=
'';
$paramStr5
=
'';
while
(
$param
=
shift
(
@line
))
{
while
(
$param
=
shift
(
@line
))
{
(
$key
,
$value
)
=
split
(
/,/
,
$param
);
(
$key
,
$value
)
=
split
(
/,/
,
$param
);
(
$prettyVarName
=
$value
)
=~
s/_(.)/\U$1\E/g
;
(
$prettyVarName
=
$value
)
=~
s/_(.)/\U$1\E/g
;
...
@@ -85,52 +82,44 @@ while (<file>) {
...
@@ -85,52 +82,44 @@ while (<file>) {
if
(
!
(
$constructorParamsCpp
eq
''))
{
if
(
!
(
$constructorParamsCpp
eq
''))
{
$constructorParamsCpp
.=
'
,
';
$constructorParamsCpp
.=
'
,
';
}
}
$paramStr2
.=
"
,
$prettyVarName
(_
$prettyVarName
)
";
(
$prettyVarName2
=
$prettyVarName
)
=~
s/^(.)/\U$1\E/
;
$paramStr3
.=
"
\t
setParameter(
\"
$value
\"
,
$prettyVarName
);
\n
";
if
(
$key
eq
'
b
')
{
if
(
$key
eq
'
b
')
{
$dataType
=
'
bool
';
$dataType
=
'
bool
';
$constructorParamsH
.=
"
bool _
$prettyVarName
= false
";
$constructorParamsH
.=
"
bool _
$prettyVarName
= false
";
$constructorParamsCpp
.=
"
bool _
$prettyVarName
";
$constructorParamsCpp
.=
"
bool _
$prettyVarName
";
$paramStr5
.=
"
\t
$prettyVarName
= (parameters[
\"
$value
\"
] ==
\"
1
\"
);
\n
";
$constructorCode
.=
"
\t
insertItem(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
')
{
}
elsif
(
$key
eq
'
s
')
{
$dataType
=
'
QString
';
$dataType
=
'
QString
';
$constructorParamsH
.=
"
const QString &_
$prettyVarName
= QString()
";
$constructorParamsH
.=
"
const QString &_
$prettyVarName
= QString()
";
$constructorParamsCpp
.=
"
const QString &_
$prettyVarName
";
$constructorParamsCpp
.=
"
const QString &_
$prettyVarName
";
$paramStr5
.=
"
\t
$prettyVarName
= parameters[
\"
$value
\"
];
\n
";
$constructorCode
.=
"
\t
insertItem(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
')
{
}
elsif
(
$key
eq
'
i
')
{
$dataType
=
'
int
';
$dataType
=
'
int
';
$constructorParamsH
.=
"
int _
$prettyVarName
= -1
";
$constructorParamsH
.=
"
int _
$prettyVarName
= -1
";
$constructorParamsCpp
.=
"
int _
$prettyVarName
";
$constructorParamsCpp
.=
"
int _
$prettyVarName
";
$paramStr5
.=
"
\t
$prettyVarName
= parameters[
\"
$value
\"
].toInt();
\n
";
$constructorCode
.=
"
\t
insertItem(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
')
{
}
elsif
(
$key
eq
'
c
')
{
$dataType
=
'
QColor
';
$dataType
=
'
QColor
';
$constructorParamsH
.=
"
const QColor &_
$prettyVarName
= QColor()
";
$constructorParamsH
.=
"
const QColor &_
$prettyVarName
= QColor()
";
$constructorParamsCpp
.=
"
const QColor &_
$prettyVarName
";
$constructorParamsCpp
.=
"
const QColor &_
$prettyVarName
";
$paramStr5
.=
"
\t
$prettyVarName
= ColorConverter::colorFromInt(parameters[
\"
$value
\"
].toInt());
\n
";
$constructorCode
.=
"
\t
insertItem(new SerializableItem_Color(
\"
$value
\"
, _
$prettyVarName
));
\n
";
$getFunctionCode
.=
"
\t
$dataType
get
$prettyVarName2
() const { return static_cast<SerializableItem_Color *>(itemMap.value(
\"
$value
\"
))->getData(); };
\n
";
}
}
(
$prettyVarName2
=
$prettyVarName
)
=~
s/^(.)/\U$1\E/
;
$paramStr4
.=
"
\t
$dataType
get
$prettyVarName2
() const { return
$prettyVarName
; }
\n
";
$headerfileBuffer
.=
"
\t
$dataType
$prettyVarName
;
\n
";
}
}
$headerfileBuffer
.=
"
public:
\n
"
$headerfileBuffer
.=
"
public:
\n
"
.
"
\t
$className
(
$constructorParamsH
);
\n
"
.
"
\t
$className
(
$constructorParamsH
);
\n
"
.
$
paramStr4
.
$
getFunctionCode
.
"
\t
static
Protocol
Item *newItem() { return new
$className
; }
\n
"
.
"
\t
static
Serializable
Item *newItem() { return new
$className
; }
\n
"
.
"
\t
int getItemId() const { return ItemId_
$className
; }
\n
"
.
"
\t
int getItemId() const { return ItemId_
$className
; }
\n
"
.
(
$paramStr5
eq
''
?
''
:
"
protected:
\n\t
void extractParameters();
\n
")
.
"
};
\n
";
.
"
};
\n
";
print
cppfile
$className
.
"
::
$className
(
$constructorParamsCpp
)
\n
"
print
cppfile
$className
.
"
::
$className
(
$constructorParamsCpp
)
\n
"
.
"
\t
:
$parentConstructorCall
$paramStr2
\n
"
.
"
\t
:
$parentConstructorCall
\n
"
.
"
{
\n
"
.
"
{
\n
"
.
$
paramStr3
.
$
constructorCode
.
"
}
\n
";
.
"
}
\n
";
if
(
!
(
$paramStr5
eq
''))
{
print
cppfile
"
void
$className
"
.
"
::extractParameters()
\n
"
.
"
{
\n
"
.
"
\t
$baseClass
"
.
"
::extractParameters();
\n
"
.
$paramStr5
.
"
}
\n
";
}
$initializeHash
.=
"
\t
itemNameHash.insert(
\"
$type$name1
\"
,
$className
"
.
"
::newItem);
\n
";
$initializeHash
.=
"
\t
itemNameHash.insert(
\"
$type$name1
\"
,
$className
"
.
"
::newItem);
\n
";
}
}
close
(
file
);
close
(
file
);
...
...
common/serializable_item.cpp
0 → 100644
View file @
69407072
#include
"serializable_item.h"
#include
<QXmlStreamReader>
#include
<QXmlStreamWriter>
#include
<QDebug>
QHash
<
QString
,
SerializableItem
::
NewItemFunction
>
SerializableItem
::
itemNameHash
;
SerializableItem
*
SerializableItem
::
getNewItem
(
const
QString
&
name
)
{
if
(
!
itemNameHash
.
contains
(
name
))
return
0
;
return
itemNameHash
.
value
(
name
)();
}
void
SerializableItem
::
registerSerializableItem
(
const
QString
&
name
,
NewItemFunction
func
)
{
itemNameHash
.
insert
(
name
,
func
);
}
bool
SerializableItem
::
read
(
QXmlStreamReader
*
xml
)
{
while
(
!
xml
->
atEnd
())
{
xml
->
readNext
();
readElement
(
xml
);
if
(
xml
->
isEndElement
()
&&
(
xml
->
name
()
==
itemType
))
return
true
;
}
return
false
;
}
void
SerializableItem
::
write
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeStartElement
(
itemType
);
if
(
!
itemSubType
.
isEmpty
())
xml
->
writeAttribute
(
"type"
,
itemSubType
);
writeElement
(
xml
);
xml
->
writeEndElement
();
}
SerializableItem_Map
::~
SerializableItem_Map
()
{
QMapIterator
<
QString
,
SerializableItem
*>
mapIterator
(
itemMap
);
while
(
mapIterator
.
hasNext
())
delete
mapIterator
.
next
().
value
();
for
(
int
i
=
0
;
i
<
itemList
.
size
();
++
i
)
delete
itemList
[
i
];
}
void
SerializableItem_Map
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
currentItem
)
{
if
(
currentItem
->
read
(
xml
))
currentItem
=
0
;
}
else
if
(
xml
->
isEndElement
()
&&
(
xml
->
name
()
==
itemType
))
extractData
();
else
if
(
xml
->
isStartElement
())
{
QString
childName
=
xml
->
name
().
toString
();
QString
childSubType
=
xml
->
attributes
().
value
(
"type"
).
toString
();
qDebug
()
<<
"Map: started new item, name="
<<
childName
<<
"subtype="
<<
childSubType
;
currentItem
=
itemMap
.
value
(
childName
);
if
(
!
currentItem
)
{
qDebug
()
<<
"Item not found in map"
;
currentItem
=
getNewItem
(
childName
+
childSubType
);
itemList
.
append
(
currentItem
);
if
(
!
currentItem
)
{
qDebug
()
<<
"Item still not found"
;
currentItem
=
new
SerializableItem_Invalid
(
childName
);
}
}
if
(
currentItem
->
read
(
xml
))
currentItem
=
0
;
}
}
void
SerializableItem_Map
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
QMapIterator
<
QString
,
SerializableItem
*>
mapIterator
(
itemMap
);
while
(
mapIterator
.
hasNext
())
mapIterator
.
next
().
value
()
->
write
(
xml
);
for
(
int
i
=
0
;
i
<
itemList
.
size
();
++
i
)
itemList
[
i
]
->
write
(
xml
);
}
void
SerializableItem_String
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
data
=
xml
->
text
().
toString
();
}
void
SerializableItem_String
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeCharacters
(
data
);
}
void
SerializableItem_Int
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
{
bool
ok
;
data
=
xml
->
text
().
toString
().
toInt
(
&
ok
);
if
(
!
ok
)
data
=
-
1
;
}
}
void
SerializableItem_Int
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeCharacters
(
QString
::
number
(
data
));
}
void
SerializableItem_Bool
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
data
=
xml
->
text
().
toString
()
==
"1"
;
}
void
SerializableItem_Bool
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeCharacters
(
data
?
"1"
:
"0"
);
}
int
SerializableItem_Color
::
colorToInt
(
const
QColor
&
color
)
const
{
return
color
.
red
()
*
65536
+
color
.
green
()
*
256
+
color
.
blue
();
}
QColor
SerializableItem_Color
::
colorFromInt
(
int
colorValue
)
const
{
return
QColor
(
colorValue
/
65536
,
(
colorValue
%
65536
)
/
256
,
colorValue
%
256
);
}
void
SerializableItem_Color
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
{
bool
ok
;
int
colorValue
=
xml
->
text
().
toString
().
toInt
(
&
ok
);
data
=
ok
?
colorFromInt
(
colorValue
)
:
Qt
::
black
;
}
}
void
SerializableItem_Color
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeCharacters
(
QString
::
number
(
colorToInt
(
data
)));
}
void
SerializableItem_DateTime
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
{
bool
ok
;
unsigned
int
dateTimeValue
=
xml
->
text
().
toString
().
toUInt
(
&
ok
);
data
=
ok
?
QDateTime
::
fromTime_t
(
dateTimeValue
)
:
QDateTime
();
}
}
void
SerializableItem_DateTime
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeCharacters
(
QString
::
number
(
data
.
toTime_t
()));
}
common/serializable_item.h
0 → 100644
View file @
69407072
#ifndef SERIALIZABLE_ITEM_H
#define SERIALIZABLE_ITEM_H
#include
<QObject>
#include
<QMap>
#include
<QList>
#include
<QHash>
#include
<QColor>
#include
<QDateTime>
class
QXmlStreamReader
;
class
QXmlStreamWriter
;
class
SerializableItem
:
public
QObject
{
Q_OBJECT
protected:
typedef
SerializableItem
*
(
*
NewItemFunction
)();
static
QHash
<
QString
,
NewItemFunction
>
itemNameHash
;
QString
itemType
,
itemSubType
;
public:
SerializableItem
(
const
QString
&
_itemType
,
const
QString
&
_itemSubType
=
QString
())
:
QObject
(),
itemType
(
_itemType
),
itemSubType
(
_itemSubType
)
{
}
static
void
registerSerializableItem
(
const
QString
&
name
,
NewItemFunction
func
);
static
SerializableItem
*
getNewItem
(
const
QString
&
name
);
const
QString
&
getItemType
()
const
{
return
itemType
;
}
const
QString
&
getItemSubType
()
const
{
return
itemSubType
;
}
virtual
void
readElement
(
QXmlStreamReader
*
xml
)
=
0
;
virtual
void
writeElement
(
QXmlStreamWriter
*
xml
)
=
0
;
bool
read
(
QXmlStreamReader
*
xml
);
void
write
(
QXmlStreamWriter
*
xml
);
};
class
SerializableItem_Invalid
:
public
SerializableItem
{
public:
SerializableItem_Invalid
(
const
QString
&
_itemType
)
:
SerializableItem
(
_itemType
)
{
}
void
readElement
(
QXmlStreamReader
*
/*xml*/
)
{
}
void
writeElement
(
QXmlStreamWriter
*
/*xml*/
)
{
}
};
class
SerializableItem_Map
:
public
SerializableItem
{
private:
SerializableItem
*
currentItem
;
protected:
QMap
<
QString
,
SerializableItem
*>
itemMap
;
QList
<
SerializableItem
*>
itemList
;
virtual
void
extractData
()
{
}
void
insertItem
(
SerializableItem
*
item
)
{
itemMap
.
insert
(
item
->
getItemType
(),
item
);
}
template
<
class
T
>
QList
<
T
>
typecastItemList
()
const
{
QList
<
T
>
result
;
for
(
int
i
=
0
;
i
<
itemList
.
size
();
++
i
)
{
T
item
=
dynamic_cast
<
T
>
(
itemList
[
i
]);
if
(
item
)
result
.
append
(
item
);
}
return
result
;
}
public:
SerializableItem_Map
(
const
QString
&
_itemType
,
const
QString
&
_itemSubType
=
QString
())
:
SerializableItem
(
_itemType
,
_itemSubType
),
currentItem
(
0
)
{
}
~
SerializableItem_Map
();
void
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
void
appendItem
(
SerializableItem
*
item
)
{
itemList
.
append
(
item
);
}
};
class
SerializableItem_String
:
public
SerializableItem
{
private:
QString
data
;
protected:
void
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
public:
SerializableItem_String
(
const
QString
&
_itemType
,
const
QString
&
_data
)
:
SerializableItem
(
_itemType
),
data
(
_data
)
{
}
const
QString
&
getData
()
{
return
data
;
}
void
setData
(
const
QString
&
_data
)
{
data
=
_data
;
}
};
class
SerializableItem_Int
:
public
SerializableItem
{
private:
int
data
;
protected:
void
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
public:
SerializableItem_Int
(
const
QString
&
_itemType
,
int
_data
)
:
SerializableItem
(
_itemType
),
data
(
_data
)
{
}
int
getData
()
{
return
data
;
}
void
setData
(
int
_data
)
{
data
=
_data
;
}
};
class
SerializableItem_Bool
:
public
SerializableItem
{
private:
bool
data
;
protected:
void
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
public:
SerializableItem_Bool
(
const
QString
&
_itemType
,
bool
_data
)
:
SerializableItem
(
_itemType
),
data
(
_data
)
{
}
bool
getData
()
{
return
data
;
}
void
setData
(
bool
_data
)
{
data
=
_data
;
}
};
class
SerializableItem_Color
:
public
SerializableItem
{
private:
QColor
data
;
int
colorToInt
(
const
QColor
&
color
)
const
;
QColor
colorFromInt
(
int
colorValue
)
const
;
protected:
void
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
public:
SerializableItem_Color
(
const
QString
&
_itemType
,
const
QColor
&
_data
)
:
SerializableItem
(
_itemType
),
data
(
_data
)
{
}
const
QColor
&
getData
()
{
return
data
;
}
void
setData
(
const
QColor
&
_data
)
{
data
=
_data
;
}
};
class
SerializableItem_DateTime
:
public
SerializableItem
{
private:
QDateTime
data
;
protected:
void
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
public:
SerializableItem_DateTime
(
const
QString
&
_itemType
,
const
QDateTime
&
_data
)
:
SerializableItem
(
_itemType
),
data
(
_data
)
{
}
const
QDateTime
&
getData
()
{
return
data
;
}
void
setData
(
const
QDateTime
&
_data
)
{
data
=
_data
;
}
};
#endif
common/server.cpp
View file @
69407072
...
@@ -61,10 +61,10 @@ Server_Game *Server::getGame(int gameId) const
...
@@ -61,10 +61,10 @@ Server_Game *Server::getGame(int gameId) const
void
Server
::
broadcastGameListUpdate
(
Server_Game
*
game
)
void
Server
::
broadcastGameListUpdate
(
Server_Game
*
game
)
{
{
Event_List
Game
s
*
event
=
new
Event_ListGames
;
QList
<
ServerInfo_
Game
*
>
eventGameList
;
if
(
game
->
getPlayerCount
())
if
(
game
->
getPlayerCount
())
// Game is open
// Game is open
event
->
add
Game
(
event
GameList
.
append
(
new
ServerInfo_
Game
(
game
->
getGameId
(),
game
->
getGameId
(),
game
->
getDescription
(),
game
->
getDescription
(),
!
game
->
getPassword
().
isEmpty
(),
!
game
->
getPassword
().
isEmpty
(),
...
@@ -73,10 +73,11 @@ void Server::broadcastGameListUpdate(Server_Game *game)
...
@@ -73,10 +73,11 @@ void Server::broadcastGameListUpdate(Server_Game *game)
game
->
getCreatorName
(),
game
->
getCreatorName
(),
game
->
getSpectatorsAllowed
(),
game
->
getSpectatorsAllowed
(),
game
->
getSpectatorCount
()
game
->
getSpectatorCount
()
);
)
);
else
else
// Game is closing
// Game is closing
event
->
addGame
(
game
->
getGameId
(),
QString
(),
false
,
0
,
game
->
getMaxPlayers
(),
QString
(),
false
,
0
);
eventGameList
.
append
(
new
ServerInfo_Game
(
game
->
getGameId
(),
QString
(),
false
,
0
,
game
->
getMaxPlayers
(),
QString
(),
false
,
0
));
Event_ListGames
*
event
=
new
Event_ListGames
(
eventGameList
);
for
(
int
i
=
0
;
i
<
clients
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
clients
.
size
();
i
++
)
if
(
clients
[
i
]
->
getAcceptsGameListChanges
())
if
(
clients
[
i
]
->
getAcceptsGameListChanges
())
...
@@ -87,8 +88,9 @@ void Server::broadcastGameListUpdate(Server_Game *game)
...
@@ -87,8 +88,9 @@ void Server::broadcastGameListUpdate(Server_Game *game)
void
Server
::
broadcastChannelUpdate
()
void
Server
::
broadcastChannelUpdate
()
{
{
Server_ChatChannel
*
channel
=
static_cast
<
Server_ChatChannel
*>
(
sender
());
Server_ChatChannel
*
channel
=
static_cast
<
Server_ChatChannel
*>
(
sender
());
Event_ListChatChannels
*
event
=
new
Event_ListChatChannels
;
QList
<
ServerInfo_ChatChannel
*>
eventChannelList
;
event
->
addChannel
(
channel
->
getName
(),
channel
->
getDescription
(),
channel
->
size
(),
channel
->
getAutoJoin
());
eventChannelList
.
append
(
new
ServerInfo_ChatChannel
(
channel
->
getName
(),
channel
->
getDescription
(),
channel
->
size
(),
channel
->
getAutoJoin
()));
Event_ListChatChannels
*
event
=
new
Event_ListChatChannels
(
eventChannelList
);
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
if
(
clients
[
i
]
->
getAcceptsChatChannelListChanges
())
if
(
clients
[
i
]
->
getAcceptsChatChannelListChanges
())
...
...
common/server_chatchannel.cpp
View file @
69407072
...
@@ -11,9 +11,10 @@ void Server_ChatChannel::addClient(Server_ProtocolHandler *client)
...
@@ -11,9 +11,10 @@ void Server_ChatChannel::addClient(Server_ProtocolHandler *client)
sendChatEvent
(
new
Event_ChatJoinChannel
(
name
,
client
->
getPlayerName
()));
sendChatEvent
(
new
Event_ChatJoinChannel
(
name
,
client
->
getPlayerName
()));
append
(
client
);
append
(
client
);
Event_ChatListPlay
er
s
*
event
CLP
=
new
Event_ChatListPlayers
(
name
)
;
QList
<
ServerInfo_ChatUs
er
*
>
event
UserList
;
for
(
int
i
=
0
;
i
<
size
();
++
i
)
for
(
int
i
=
0
;
i
<
size
();
++
i
)
eventCLP
->
addPlayer
(
at
(
i
)
->
getPlayerName
());
eventUserList
.
append
(
new
ServerInfo_ChatUser
(
at
(
i
)
->
getPlayerName
()));
Event_ChatListPlayers
*
eventCLP
=
new
Event_ChatListPlayers
(
name
,
eventUserList
);
client
->
enqueueProtocolItem
(
eventCLP
);
client
->
enqueueProtocolItem
(
eventCLP
);
client
->
enqueueProtocolItem
(
new
Event_ChatSay
(
name
,
QString
(),
joinMessage
));
client
->
enqueueProtocolItem
(
new
Event_ChatSay
(
name
,
QString
(),
joinMessage
));
...
...
common/server_protocolhandler.cpp
View file @
69407072
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
#include
"server_counter.h"
#include
"server_counter.h"
#include
"server_game.h"
#include
"server_game.h"
#include
"server_player.h"
#include
"server_player.h"
#include
"decklist.h"
Server_ProtocolHandler
::
Server_ProtocolHandler
(
Server
*
_server
,
QObject
*
parent
)
Server_ProtocolHandler
::
Server_ProtocolHandler
(
Server
*
_server
,
QObject
*
parent
)
:
QObject
(
parent
),
server
(
_server
),
authState
(
PasswordWrong
),
acceptsGameListChanges
(
false
)
:
QObject
(
parent
),
server
(
_server
),
authState
(
PasswordWrong
),
acceptsGameListChanges
(
false
)
...
@@ -148,13 +149,13 @@ ResponseCode Server_ProtocolHandler::cmdListChatChannels(Command_ListChatChannel
...
@@ -148,13 +149,13 @@ ResponseCode Server_ProtocolHandler::cmdListChatChannels(Command_ListChatChannel
if
(
authState
==
PasswordWrong
)
if
(
authState
==
PasswordWrong
)
return
RespLoginNeeded
;
return
RespLoginNeeded
;
Event_List
ChatChannel
s
*
even
t
=
new
Event_ListCha
tChannel
s
;
QList
<
ServerInfo_
ChatChannel
*
>
eventChannel
List
;
QMapIterator
<
QString
,
Server_ChatChannel
*>
channelIterator
(
server
->
getChatChannels
());
QMapIterator
<
QString
,
Server_ChatChannel
*>
channelIterator
(
server
->
getChatChannels
());
while
(
channelIterator
.
hasNext
())
{
while
(
channelIterator
.
hasNext
())
{
Server_ChatChannel
*
c
=
channelIterator
.
next
().
value
();
Server_ChatChannel
*
c
=
channelIterator
.
next
().
value
();
event
->
add
Channel
(
c
->
getName
(),
c
->
getDescription
(),
c
->
size
(),
c
->
getAutoJoin
());
event
ChannelList
.
append
(
new
ServerInfo_Chat
Channel
(
c
->
getName
(),
c
->
getDescription
(),
c
->
size
(),
c
->
getAutoJoin
())
)
;
}
}
sendProtocolItem
(
event
);
sendProtocolItem
(
new
Event_ListChatChannels
(
eventChannelList
)
);
acceptsChatChannelListChanges
=
true
;
acceptsChatChannelListChanges
=
true
;
return
RespOk
;
return
RespOk
;
...
@@ -193,11 +194,11 @@ ResponseCode Server_ProtocolHandler::cmdChatSay(Command_ChatSay *cmd, Server_Cha
...
@@ -193,11 +194,11 @@ ResponseCode Server_ProtocolHandler::cmdChatSay(Command_ChatSay *cmd, Server_Cha
ResponseCode
Server_ProtocolHandler
::
cmdListGames
(
Command_ListGames
*
/*cmd*/
)
ResponseCode
Server_ProtocolHandler
::
cmdListGames
(
Command_ListGames
*
/*cmd*/
)
{
{
Event_ListGames
*
event
=
new
Event_ListGames
;
const
QList
<
Server_Game
*>
&
gameList
=
server
->
getGames
();
const
QList
<
Server_Game
*>
&
gameList
=
server
->
getGames
();
QList
<
ServerInfo_Game
*>
eventGameList
;
for
(
int
i
=
0
;
i
<
gameList
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
gameList
.
size
();
++
i
)
{
Server_Game
*
g
=
gameList
[
i
];
Server_Game
*
g
=
gameList
[
i
];
event
->
add
Game
(
event
GameList
.
append
(
new
ServerInfo_
Game
(
g
->
getGameId
(),
g
->
getGameId
(),
g
->
getDescription
(),
g
->
getDescription
(),
!
g
->
getPassword
().
isEmpty
(),
!
g
->
getPassword
().
isEmpty
(),
...
@@ -206,9 +207,9 @@ ResponseCode Server_ProtocolHandler::cmdListGames(Command_ListGames * /*cmd*/)
...
@@ -206,9 +207,9 @@ ResponseCode Server_ProtocolHandler::cmdListGames(Command_ListGames * /*cmd*/)
g
->
getCreatorName
(),
g
->
getCreatorName
(),
g
->
getSpectatorsAllowed
(),
g
->
getSpectatorsAllowed
(),
g
->
getSpectatorCount
()
g
->
getSpectatorCount
()
);
)
);
}
}
sendProtocolItem
(
event
);
sendProtocolItem
(
new
Event_ListGames
(
eventGameList
)
);
acceptsGameListChanges
=
true
;
acceptsGameListChanges
=
true
;
return
RespOk
;
return
RespOk
;
...
@@ -253,7 +254,7 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Serv
...
@@ -253,7 +254,7 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Serv
if
(
cmd
->
getDeckId
()
==
-
1
)
{
if
(
cmd
->
getDeckId
()
==
-
1
)
{
if
(
!
cmd
->
getDeck
())
if
(
!
cmd
->
getDeck
())
return
RespInvalidData
;
return
RespInvalidData
;
deck
=
cmd
->
getDeck
();
deck
=
new
DeckList
(
cmd
->
getDeck
()
)
;
}
else
{
}
else
{
try
{
try
{
deck
=
getDeckFromDatabase
(
cmd
->
getDeckId
());
deck
=
getDeckFromDatabase
(
cmd
->
getDeckId
());
...
@@ -265,7 +266,7 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Serv
...
@@ -265,7 +266,7 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(Command_DeckSelect *cmd, Serv
game
->
sendGameEvent
(
new
Event_DeckSelect
(
-
1
,
player
->
getPlayerId
(),
cmd
->
getDeckId
()));
game
->
sendGameEvent
(
new
Event_DeckSelect
(
-
1
,
player
->
getPlayerId
(),
cmd
->
getDeckId
()));
sendProtocolItem
(
new
Response_DeckDownload
(
cmd
->
getCmdId
(),
RespOk
,
deck
));
sendProtocolItem
(
new
Response_DeckDownload
(
cmd
->
getCmdId
(),
RespOk
,
new
DeckList
(
deck
))
)
;
return
RespNothing
;
return
RespNothing
;
}
}
...
@@ -427,7 +428,7 @@ ResponseCode Server_ProtocolHandler::cmdCreateArrow(Command_CreateArrow *cmd, Se
...
@@ -427,7 +428,7 @@ ResponseCode Server_ProtocolHandler::cmdCreateArrow(Command_CreateArrow *cmd, Se
Server_Arrow
*
arrow
=
new
Server_Arrow
(
player
->
newArrowId
(),
startCard
,
targetCard
,
cmd
->
getColor
());
Server_Arrow
*
arrow
=
new
Server_Arrow
(
player
->
newArrowId
(),
startCard
,
targetCard
,
cmd
->
getColor
());
player
->
addArrow
(
arrow
);
player
->
addArrow
(
arrow
);
game
->
sendGameEvent
(
new
Event_CreateArrow
(
-
1
,
player
->
getPlayerId
(),
new
ServerInfo_Arrow
(
game
->
sendGameEvent
(
new
Event_CreateArrow
s
(
-
1
,
player
->
getPlayerId
(),
QList
<
ServerInfo_Arrow
*>
()
<<
new
ServerInfo_Arrow
(
arrow
->
getId
(),
arrow
->
getId
(),
startPlayer
->
getPlayerId
(),
startPlayer
->
getPlayerId
(),
startZone
->
getName
(),
startZone
->
getName
(),
...
@@ -500,7 +501,7 @@ ResponseCode Server_ProtocolHandler::cmdCreateCounter(Command_CreateCounter *cmd
...
@@ -500,7 +501,7 @@ ResponseCode Server_ProtocolHandler::cmdCreateCounter(Command_CreateCounter *cmd
{
{
Server_Counter
*
c
=
new
Server_Counter
(
player
->
newCounterId
(),
cmd
->
getCounterName
(),
cmd
->
getColor
(),
cmd
->
getRadius
(),
cmd
->
getValue
());
Server_Counter
*
c
=
new
Server_Counter
(
player
->
newCounterId
(),
cmd
->
getCounterName
(),
cmd
->
getColor
(),
cmd
->
getRadius
(),
cmd
->
getValue
());
player
->
addCounter
(
c
);
player
->
addCounter
(
c
);
game
->
sendGameEvent
(
new
Event_CreateCounter
(
-
1
,
player
->
getPlayerId
(),
new
ServerInfo_Counter
(
c
->
getId
(),
c
->
getName
(),
c
->
getColor
(),
c
->
getRadius
(),
c
->
getCount
())));
game
->
sendGameEvent
(
new
Event_CreateCounter
s
(
-
1
,
player
->
getPlayerId
(),
QList
<
ServerInfo_Counter
*>
()
<<
new
ServerInfo_Counter
(
c
->
getId
(),
c
->
getName
(),
c
->
getColor
(),
c
->
getRadius
(),
c
->
getCount
())));
return
RespOk
;
return
RespOk
;
}
}
...
...
servatrice/servatrice.pro
View file @
69407072
...
@@ -14,6 +14,7 @@ QT += network sql
...
@@ -14,6 +14,7 @@ QT += network sql
HEADERS
+=
src
/
servatrice
.
h
\
HEADERS
+=
src
/
servatrice
.
h
\
src
/
serversocketinterface
.
h
\
src
/
serversocketinterface
.
h
\
..
/
common
/
serializable_item
.
h
\
..
/
common
/
decklist
.
h
\
..
/
common
/
decklist
.
h
\
..
/
common
/
protocol
.
h
\
..
/
common
/
protocol
.
h
\
..
/
common
/
protocol_items
.
h
\
..
/
common
/
protocol_items
.
h
\
...
@@ -33,6 +34,7 @@ HEADERS += src/servatrice.h \
...
@@ -33,6 +34,7 @@ HEADERS += src/servatrice.h \
SOURCES
+=
src
/
main
.
cpp
\
SOURCES
+=
src
/
main
.
cpp
\
src
/
servatrice
.
cpp
\
src
/
servatrice
.
cpp
\
src
/
serversocketinterface
.
cpp
\
src
/
serversocketinterface
.
cpp
\
..
/
common
/
serializable_item
.
cpp
\
..
/
common
/
decklist
.
cpp
\
..
/
common
/
decklist
.
cpp
\
..
/
common
/
protocol
.
cpp
\
..
/
common
/
protocol
.
cpp
\
..
/
common
/
protocol_items
.
cpp
\
..
/
common
/
protocol_items
.
cpp
\
...
...
servatrice/src/serversocketinterface.cpp
View file @
69407072
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include
"server_player.h"
#include
"server_player.h"
ServerSocketInterface
::
ServerSocketInterface
(
Servatrice
*
_server
,
QTcpSocket
*
_socket
,
QObject
*
parent
)
ServerSocketInterface
::
ServerSocketInterface
(
Servatrice
*
_server
,
QTcpSocket
*
_socket
,
QObject
*
parent
)
:
Server_ProtocolHandler
(
_server
,
parent
),
servatrice
(
_server
),
socket
(
_socket
),
current
Item
(
0
)
:
Server_ProtocolHandler
(
_server
,
parent
),
servatrice
(
_server
),
socket
(
_socket
),
topLevel
Item
(
0
)
{
{
xmlWriter
=
new
QXmlStreamWriter
;
xmlWriter
=
new
QXmlStreamWriter
;
xmlWriter
->
setDevice
(
socket
);
xmlWriter
->
setDevice
(
socket
);
...
@@ -57,41 +57,31 @@ ServerSocketInterface::~ServerSocketInterface()
...
@@ -57,41 +57,31 @@ ServerSocketInterface::~ServerSocketInterface()
delete
socket
;
delete
socket
;
}
}
void
ServerSocketInterface
::
itemFinishedReading
(
)
void
ServerSocketInterface
::
processProtocolItem
(
ProtocolItem
*
item
)
{
{
Command
*
command
=
qobject_cast
<
Command
*>
(
currentI
tem
);
Command
*
command
=
qobject_cast
<
Command
*>
(
i
tem
);
if
(
qobject_cast
<
InvalidCommand
*>
(
command
)
)
if
(
!
command
)
sendProtocolItem
(
new
ProtocolResponse
(
command
->
getCmdId
(),
RespInvalidCommand
));
sendProtocolItem
(
new
ProtocolResponse
(
command
->
getCmdId
(),
RespInvalidCommand
));
else
else
processCommand
(
command
);
processCommand
(
command
);
currentItem
=
0
;
}
}
void
ServerSocketInterface
::
readClient
()
void
ServerSocketInterface
::
readClient
()
{
{
xmlReader
->
addData
(
socket
->
readAll
());
xmlReader
->
addData
(
socket
->
readAll
());
if
(
currentItem
)
{
if
(
topLevelItem
)
if
(
!
currentItem
->
read
(
xmlReader
))
topLevelItem
->
read
(
xmlReader
);
return
;
else
itemFinishedReading
();
while
(
!
xmlReader
->
atEnd
())
{
}
xmlReader
->
readNext
();
while
(
!
xmlReader
->
atEnd
())
{
if
(
xmlReader
->
isStartElement
()
&&
(
xmlReader
->
name
().
toString
()
==
"cockatrice_client_stream"
))
{
xmlReader
->
readNext
();
topLevelItem
=
new
TopLevelProtocolItem
;
if
(
xmlReader
->
isStartElement
())
{
connect
(
topLevelItem
,
SIGNAL
(
protocolItemReceived
(
ProtocolItem
*
)),
this
,
SLOT
(
processProtocolItem
(
ProtocolItem
*
)));
QString
itemType
=
xmlReader
->
name
().
toString
();
if
(
itemType
==
"cockatrice_client_stream"
)
topLevelItem
->
read
(
xmlReader
);
continue
;
}
QString
itemName
=
xmlReader
->
attributes
().
value
(
"name"
).
toString
();
qDebug
()
<<
"parseXml: startElement: "
<<
"type ="
<<
itemType
<<
", name ="
<<
itemName
;
currentItem
=
ProtocolItem
::
getNewItem
(
itemType
+
itemName
);
if
(
!
currentItem
)
currentItem
=
new
InvalidCommand
;
if
(
!
currentItem
->
read
(
xmlReader
))
return
;
itemFinishedReading
();
}
}
}
}
}
void
ServerSocketInterface
::
catchSocketError
(
QAbstractSocket
::
SocketError
socketError
)
void
ServerSocketInterface
::
catchSocketError
(
QAbstractSocket
::
SocketError
socketError
)
...
@@ -147,7 +137,7 @@ bool ServerSocketInterface::deckListHelper(DeckList_Directory *folder)
...
@@ -147,7 +137,7 @@ bool ServerSocketInterface::deckListHelper(DeckList_Directory *folder)
while
(
query
.
next
())
{
while
(
query
.
next
())
{
DeckList_Directory
*
newFolder
=
new
DeckList_Directory
(
query
.
value
(
1
).
toString
(),
query
.
value
(
0
).
toInt
());
DeckList_Directory
*
newFolder
=
new
DeckList_Directory
(
query
.
value
(
1
).
toString
(),
query
.
value
(
0
).
toInt
());
folder
->
append
(
newFolder
);
folder
->
append
Item
(
newFolder
);
if
(
!
deckListHelper
(
newFolder
))
if
(
!
deckListHelper
(
newFolder
))
return
false
;
return
false
;
}
}
...
@@ -160,7 +150,7 @@ bool ServerSocketInterface::deckListHelper(DeckList_Directory *folder)
...
@@ -160,7 +150,7 @@ bool ServerSocketInterface::deckListHelper(DeckList_Directory *folder)
while
(
query
.
next
())
{
while
(
query
.
next
())
{
DeckList_File
*
newFile
=
new
DeckList_File
(
query
.
value
(
1
).
toString
(),
query
.
value
(
0
).
toInt
(),
query
.
value
(
2
).
toDateTime
());
DeckList_File
*
newFile
=
new
DeckList_File
(
query
.
value
(
1
).
toString
(),
query
.
value
(
0
).
toInt
(),
query
.
value
(
2
).
toDateTime
());
folder
->
append
(
newFile
);
folder
->
append
Item
(
newFile
);
}
}
return
true
;
return
true
;
...
@@ -266,7 +256,7 @@ ResponseCode ServerSocketInterface::cmdDeckUpload(Command_DeckUpload *cmd)
...
@@ -266,7 +256,7 @@ ResponseCode ServerSocketInterface::cmdDeckUpload(Command_DeckUpload *cmd)
QString
deckContents
;
QString
deckContents
;
QXmlStreamWriter
deckWriter
(
&
deckContents
);
QXmlStreamWriter
deckWriter
(
&
deckContents
);
deckWriter
.
writeStartDocument
();
deckWriter
.
writeStartDocument
();
cmd
->
getDeck
()
->
write
Element
(
&
deckWriter
);
cmd
->
getDeck
()
->
write
(
&
deckWriter
);
deckWriter
.
writeEndDocument
();
deckWriter
.
writeEndDocument
();
QString
deckName
=
cmd
->
getDeck
()
->
getName
();
QString
deckName
=
cmd
->
getDeck
()
->
getName
();
...
@@ -281,8 +271,6 @@ ResponseCode ServerSocketInterface::cmdDeckUpload(Command_DeckUpload *cmd)
...
@@ -281,8 +271,6 @@ ResponseCode ServerSocketInterface::cmdDeckUpload(Command_DeckUpload *cmd)
query
.
bindValue
(
":content"
,
deckContents
);
query
.
bindValue
(
":content"
,
deckContents
);
servatrice
->
execSqlQuery
(
query
);
servatrice
->
execSqlQuery
(
query
);
delete
cmd
->
getDeck
();
sendProtocolItem
(
new
Response_DeckUpload
(
cmd
->
getCmdId
(),
RespOk
,
new
DeckList_File
(
deckName
,
query
.
lastInsertId
().
toInt
(),
QDateTime
::
currentDateTime
())));
sendProtocolItem
(
new
Response_DeckUpload
(
cmd
->
getCmdId
(),
RespOk
,
new
DeckList_File
(
deckName
,
query
.
lastInsertId
().
toInt
(),
QDateTime
::
currentDateTime
())));
return
RespNothing
;
return
RespNothing
;
}
}
...
@@ -302,8 +290,7 @@ DeckList *ServerSocketInterface::getDeckFromDatabase(int deckId)
...
@@ -302,8 +290,7 @@ DeckList *ServerSocketInterface::getDeckFromDatabase(int deckId)
QXmlStreamReader
deckReader
(
query
.
value
(
0
).
toString
());
QXmlStreamReader
deckReader
(
query
.
value
(
0
).
toString
());
DeckList
*
deck
=
new
DeckList
;
DeckList
*
deck
=
new
DeckList
;
if
(
!
deck
->
loadFromXml
(
&
deckReader
))
deck
->
loadFromXml
(
&
deckReader
);
throw
RespInvalidData
;
return
deck
;
return
deck
;
}
}
...
@@ -317,6 +304,5 @@ ResponseCode ServerSocketInterface::cmdDeckDownload(Command_DeckDownload *cmd)
...
@@ -317,6 +304,5 @@ ResponseCode ServerSocketInterface::cmdDeckDownload(Command_DeckDownload *cmd)
return
r
;
return
r
;
}
}
sendProtocolItem
(
new
Response_DeckDownload
(
cmd
->
getCmdId
(),
RespOk
,
deck
));
sendProtocolItem
(
new
Response_DeckDownload
(
cmd
->
getCmdId
(),
RespOk
,
deck
));
delete
deck
;
return
RespNothing
;
return
RespNothing
;
}
}
servatrice/src/serversocketinterface.h
View file @
69407072
...
@@ -28,6 +28,7 @@ class Servatrice;
...
@@ -28,6 +28,7 @@ class Servatrice;
class
QXmlStreamReader
;
class
QXmlStreamReader
;
class
QXmlStreamWriter
;
class
QXmlStreamWriter
;
class
DeckList
;
class
DeckList
;
class
TopLevelProtocolItem
;
class
ServerSocketInterface
:
public
Server_ProtocolHandler
class
ServerSocketInterface
:
public
Server_ProtocolHandler
{
{
...
@@ -35,12 +36,13 @@ class ServerSocketInterface : public Server_ProtocolHandler
...
@@ -35,12 +36,13 @@ class ServerSocketInterface : public Server_ProtocolHandler
private
slots
:
private
slots
:
void
readClient
();
void
readClient
();
void
catchSocketError
(
QAbstractSocket
::
SocketError
socketError
);
void
catchSocketError
(
QAbstractSocket
::
SocketError
socketError
);
void
processProtocolItem
(
ProtocolItem
*
item
);
private:
private:
Servatrice
*
servatrice
;
Servatrice
*
servatrice
;
QTcpSocket
*
socket
;
QTcpSocket
*
socket
;
QXmlStreamWriter
*
xmlWriter
;
QXmlStreamWriter
*
xmlWriter
;
QXmlStreamReader
*
xmlReader
;
QXmlStreamReader
*
xmlReader
;
ProtocolItem
*
current
Item
;
TopLevel
ProtocolItem
*
topLevel
Item
;
int
getDeckPathId
(
int
basePathId
,
QStringList
path
);
int
getDeckPathId
(
int
basePathId
,
QStringList
path
);
int
getDeckPathId
(
const
QString
&
path
);
int
getDeckPathId
(
const
QString
&
path
);
...
@@ -53,8 +55,6 @@ private:
...
@@ -53,8 +55,6 @@ private:
ResponseCode
cmdDeckUpload
(
Command_DeckUpload
*
cmd
);
ResponseCode
cmdDeckUpload
(
Command_DeckUpload
*
cmd
);
DeckList
*
getDeckFromDatabase
(
int
deckId
);
DeckList
*
getDeckFromDatabase
(
int
deckId
);
ResponseCode
cmdDeckDownload
(
Command_DeckDownload
*
cmd
);
ResponseCode
cmdDeckDownload
(
Command_DeckDownload
*
cmd
);
void
itemFinishedReading
();
public:
public:
ServerSocketInterface
(
Servatrice
*
_server
,
QTcpSocket
*
_socket
,
QObject
*
parent
=
0
);
ServerSocketInterface
(
Servatrice
*
_server
,
QTcpSocket
*
_socket
,
QObject
*
parent
=
0
);
~
ServerSocketInterface
();
~
ServerSocketInterface
();
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment