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
888a64b0
Commit
888a64b0
authored
Feb 26, 2010
by
Max-Wilhelm Bruker
Browse files
new protocol code
parent
ba8d4021
Changes
25
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabase.cpp
View file @
888a64b0
...
@@ -56,8 +56,8 @@ void SetList::sortByKey()
...
@@ -56,8 +56,8 @@ void SetList::sortByKey()
qSort
(
begin
(),
end
(),
CompareFunctor
());
qSort
(
begin
(),
end
(),
CompareFunctor
());
}
}
CardInfo
::
CardInfo
(
CardDatabase
*
_db
,
const
QString
&
_name
,
const
QString
&
_manacost
,
const
QString
&
_cardtype
,
const
QString
&
_powtough
,
const
QString
&
_text
,
const
QStringList
&
_colors
,
int
_tableRow
,
const
SetList
&
_sets
,
const
QString
&
_picURL
)
CardInfo
::
CardInfo
(
CardDatabase
*
_db
,
const
QString
&
_name
,
const
QString
&
_manacost
,
const
QString
&
_cardtype
,
const
QString
&
_powtough
,
const
QString
&
_text
,
const
QStringList
&
_colors
,
bool
_cipt
,
int
_tableRow
,
const
SetList
&
_sets
,
const
QString
&
_picURL
)
:
db
(
_db
),
name
(
_name
),
sets
(
_sets
),
manacost
(
_manacost
),
cardtype
(
_cardtype
),
powtough
(
_powtough
),
text
(
_text
),
colors
(
_colors
),
picURL
(
_picURL
),
tableRow
(
_tableRow
),
pixmap
(
NULL
)
:
db
(
_db
),
name
(
_name
),
sets
(
_sets
),
manacost
(
_manacost
),
cardtype
(
_cardtype
),
powtough
(
_powtough
),
text
(
_text
),
colors
(
_colors
),
picURL
(
_picURL
),
cipt
(
_cipt
),
tableRow
(
_tableRow
),
pixmap
(
NULL
)
{
{
for
(
int
i
=
0
;
i
<
sets
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
sets
.
size
();
i
++
)
sets
[
i
]
->
append
(
this
);
sets
[
i
]
->
append
(
this
);
...
@@ -220,6 +220,8 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
...
@@ -220,6 +220,8 @@ QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
xml
.
writeTextElement
(
"tablerow"
,
QString
::
number
(
info
->
getTableRow
()));
xml
.
writeTextElement
(
"tablerow"
,
QString
::
number
(
info
->
getTableRow
()));
xml
.
writeTextElement
(
"text"
,
info
->
getText
());
xml
.
writeTextElement
(
"text"
,
info
->
getText
());
xml
.
writeTextElement
(
"picURL"
,
info
->
getPicURL
());
xml
.
writeTextElement
(
"picURL"
,
info
->
getPicURL
());
if
(
info
->
getCipt
())
xml
.
writeTextElement
(
"cipt"
,
"1"
);
xml
.
writeEndElement
();
// card
xml
.
writeEndElement
();
// card
return
xml
;
return
xml
;
...
@@ -383,6 +385,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
...
@@ -383,6 +385,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
QStringList
colors
;
QStringList
colors
;
SetList
sets
;
SetList
sets
;
int
tableRow
=
0
;
int
tableRow
=
0
;
bool
cipt
=
false
;
while
(
!
xml
.
atEnd
())
{
while
(
!
xml
.
atEnd
())
{
if
(
xml
.
readNext
()
==
QXmlStreamReader
::
EndElement
)
if
(
xml
.
readNext
()
==
QXmlStreamReader
::
EndElement
)
break
;
break
;
...
@@ -404,8 +407,10 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
...
@@ -404,8 +407,10 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml)
tableRow
=
xml
.
readElementText
().
toInt
();
tableRow
=
xml
.
readElementText
().
toInt
();
else
if
(
xml
.
name
()
==
"picURL"
)
else
if
(
xml
.
name
()
==
"picURL"
)
picURL
=
xml
.
readElementText
();
picURL
=
xml
.
readElementText
();
else
if
(
xml
.
name
()
==
"cipt"
)
cipt
=
(
xml
.
readElementText
()
==
"1"
);
}
}
cardHash
.
insert
(
name
,
new
CardInfo
(
this
,
name
,
manacost
,
type
,
pt
,
text
,
colors
,
tableRow
,
sets
,
picURL
));
cardHash
.
insert
(
name
,
new
CardInfo
(
this
,
name
,
manacost
,
type
,
pt
,
text
,
colors
,
cipt
,
tableRow
,
sets
,
picURL
));
}
}
}
}
}
}
...
...
cockatrice/src/carddatabase.h
View file @
888a64b0
...
@@ -46,6 +46,7 @@ private:
...
@@ -46,6 +46,7 @@ private:
QString
text
;
QString
text
;
QStringList
colors
;
QStringList
colors
;
QString
picURL
;
QString
picURL
;
bool
cipt
;
int
tableRow
;
int
tableRow
;
QPixmap
*
pixmap
;
QPixmap
*
pixmap
;
QMap
<
int
,
QPixmap
*>
scaledPixmapCache
;
QMap
<
int
,
QPixmap
*>
scaledPixmapCache
;
...
@@ -57,6 +58,7 @@ public:
...
@@ -57,6 +58,7 @@ public:
const
QString
&
_powtough
=
QString
(),
const
QString
&
_powtough
=
QString
(),
const
QString
&
_text
=
QString
(),
const
QString
&
_text
=
QString
(),
const
QStringList
&
_colors
=
QStringList
(),
const
QStringList
&
_colors
=
QStringList
(),
bool
cipt
=
false
,
int
_tableRow
=
0
,
int
_tableRow
=
0
,
const
SetList
&
_sets
=
SetList
(),
const
SetList
&
_sets
=
SetList
(),
const
QString
&
_picURL
=
QString
());
const
QString
&
_picURL
=
QString
());
...
@@ -67,6 +69,7 @@ public:
...
@@ -67,6 +69,7 @@ public:
const
QString
&
getCardType
()
const
{
return
cardtype
;
}
const
QString
&
getCardType
()
const
{
return
cardtype
;
}
const
QString
&
getPowTough
()
const
{
return
powtough
;
}
const
QString
&
getPowTough
()
const
{
return
powtough
;
}
const
QString
&
getText
()
const
{
return
text
;
}
const
QString
&
getText
()
const
{
return
text
;
}
bool
getCipt
()
const
{
return
cipt
;
}
void
setText
(
const
QString
&
_text
)
{
text
=
_text
;
}
void
setText
(
const
QString
&
_text
)
{
text
=
_text
;
}
const
QStringList
&
getColors
()
const
{
return
colors
;
}
const
QStringList
&
getColors
()
const
{
return
colors
;
}
const
QString
&
getPicURL
()
const
{
return
picURL
;
}
const
QString
&
getPicURL
()
const
{
return
picURL
;
}
...
...
cockatrice/src/cardzone.cpp
View file @
888a64b0
...
@@ -142,12 +142,6 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName,
...
@@ -142,12 +142,6 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName,
return
c
;
return
c
;
}
}
void
CardZone
::
setCardAttr
(
int
cardId
,
const
QString
&
aname
,
const
QString
&
avalue
)
{
if
(
hasCardAttr
)
player
->
sendGameCommand
(
new
Command_SetCardAttr
(
-
1
,
name
,
cardId
,
aname
,
avalue
));
}
void
CardZone
::
moveAllToZone
()
void
CardZone
::
moveAllToZone
()
{
{
QList
<
QVariant
>
data
=
static_cast
<
QAction
*>
(
sender
())
->
data
().
toList
();
QList
<
QVariant
>
data
=
static_cast
<
QAction
*>
(
sender
())
->
data
().
toList
();
...
...
cockatrice/src/cardzone.h
View file @
888a64b0
...
@@ -52,7 +52,6 @@ public:
...
@@ -52,7 +52,6 @@ public:
CardItem
*
getCard
(
int
cardId
,
const
QString
&
cardName
);
CardItem
*
getCard
(
int
cardId
,
const
QString
&
cardName
);
// takeCard() finds a card by position and removes it from the zone and from all of its views.
// takeCard() finds a card by position and removes it from the zone and from all of its views.
virtual
CardItem
*
takeCard
(
int
position
,
int
cardId
,
const
QString
&
cardName
,
bool
canResize
=
true
);
virtual
CardItem
*
takeCard
(
int
position
,
int
cardId
,
const
QString
&
cardName
,
bool
canResize
=
true
);
void
setCardAttr
(
int
cardId
,
const
QString
&
aname
,
const
QString
&
avalue
);
ZoneViewZone
*
getView
()
const
{
return
view
;
}
ZoneViewZone
*
getView
()
const
{
return
view
;
}
void
setView
(
ZoneViewZone
*
_view
)
{
view
=
_view
;
}
void
setView
(
ZoneViewZone
*
_view
)
{
view
=
_view
;
}
virtual
void
reorganizeCards
()
=
0
;
virtual
void
reorganizeCards
()
=
0
;
...
...
cockatrice/src/client.cpp
View file @
888a64b0
...
@@ -90,14 +90,14 @@ void Client::processProtocolItem(ProtocolItem *item)
...
@@ -90,14 +90,14 @@ void Client::processProtocolItem(ProtocolItem *item)
{
{
ProtocolResponse
*
response
=
qobject_cast
<
ProtocolResponse
*>
(
item
);
ProtocolResponse
*
response
=
qobject_cast
<
ProtocolResponse
*>
(
item
);
if
(
response
)
{
if
(
response
)
{
Command
*
cmd
=
pendingCommands
.
value
(
response
->
getCmdId
(),
0
);
Command
Container
*
cmd
Cont
=
pendingCommands
.
value
(
response
->
getCmdId
(),
0
);
if
(
!
cmd
)
if
(
!
cmd
Cont
)
return
;
return
;
pendingCommands
.
remove
(
cmd
->
getCmdId
());
pendingCommands
.
remove
(
cmd
Cont
->
getCmdId
());
cmd
->
processResponse
(
response
);
cmd
Cont
->
processResponse
(
response
);
delete
response
;
delete
response
;
delete
cmd
;
delete
cmd
Cont
;
return
;
return
;
}
}
...
@@ -114,10 +114,10 @@ void Client::processProtocolItem(ProtocolItem *item)
...
@@ -114,10 +114,10 @@ void Client::processProtocolItem(ProtocolItem *item)
return
;
return
;
}
}
GameEvent
*
gameEvent
=
qobject_cast
<
GameEvent
*>
(
item
);
GameEvent
Container
*
gameEvent
Container
=
qobject_cast
<
GameEvent
Container
*>
(
item
);
if
(
gameEvent
)
{
if
(
gameEvent
Container
)
{
emit
gameEventReceived
(
gameEvent
);
emit
gameEvent
Container
Received
(
gameEvent
Container
);
delete
gameEvent
;
delete
gameEvent
Container
;
return
;
return
;
}
}
...
@@ -139,8 +139,13 @@ void Client::setStatus(const ClientStatus _status)
...
@@ -139,8 +139,13 @@ void Client::setStatus(const ClientStatus _status)
void
Client
::
sendCommand
(
Command
*
cmd
)
void
Client
::
sendCommand
(
Command
*
cmd
)
{
{
cmd
->
write
(
xmlWriter
);
sendCommandContainer
(
new
CommandContainer
(
QList
<
Command
*>
()
<<
cmd
));
pendingCommands
.
insert
(
cmd
->
getCmdId
(),
cmd
);
}
void
Client
::
sendCommandContainer
(
CommandContainer
*
cont
)
{
cont
->
write
(
xmlWriter
);
pendingCommands
.
insert
(
cont
->
getCmdId
(),
cont
);
}
}
void
Client
::
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
)
void
Client
::
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
)
...
@@ -162,7 +167,7 @@ void Client::disconnectFromServer()
...
@@ -162,7 +167,7 @@ void Client::disconnectFromServer()
timer
->
stop
();
timer
->
stop
();
QList
<
Command
*>
pc
=
pendingCommands
.
values
();
QList
<
Command
Container
*>
pc
=
pendingCommands
.
values
();
for
(
int
i
=
0
;
i
<
pc
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
pc
.
size
();
i
++
)
delete
pc
[
i
];
delete
pc
[
i
];
pendingCommands
.
clear
();
pendingCommands
.
clear
();
...
@@ -174,7 +179,7 @@ void Client::disconnectFromServer()
...
@@ -174,7 +179,7 @@ void Client::disconnectFromServer()
void
Client
::
ping
()
void
Client
::
ping
()
{
{
int
maxTime
=
0
;
int
maxTime
=
0
;
QMapIterator
<
int
,
Command
*>
i
(
pendingCommands
);
QMapIterator
<
int
,
Command
Container
*>
i
(
pendingCommands
);
while
(
i
.
hasNext
())
{
while
(
i
.
hasNext
())
{
int
time
=
i
.
next
().
value
()
->
tick
();
int
time
=
i
.
next
().
value
()
->
tick
();
if
(
time
>
maxTime
)
if
(
time
>
maxTime
)
...
...
cockatrice/src/client.h
View file @
888a64b0
...
@@ -9,14 +9,16 @@
...
@@ -9,14 +9,16 @@
class
QTimer
;
class
QTimer
;
class
Command
;
class
Command
;
class
CommandContainer
;
class
QXmlStreamReader
;
class
QXmlStreamReader
;
class
QXmlStreamWriter
;
class
QXmlStreamWriter
;
class
ProtocolItem
;
class
ProtocolItem
;
class
ProtocolResponse
;
class
ProtocolResponse
;
class
TopLevelProtocolItem
;
class
TopLevelProtocolItem
;
class
CommandContainer
;
class
ChatEvent
;
class
ChatEvent
;
class
GameEvent
;
class
GameEvent
Container
;
class
Event_ListGames
;
class
Event_ListGames
;
class
Event_ServerMessage
;
class
Event_ServerMessage
;
class
Event_ListChatChannels
;
class
Event_ListChatChannels
;
...
@@ -45,7 +47,7 @@ signals:
...
@@ -45,7 +47,7 @@ signals:
// Chat events
// Chat events
void
chatEventReceived
(
ChatEvent
*
event
);
void
chatEventReceived
(
ChatEvent
*
event
);
// Game events
// Game events
void
gameEventReceived
(
GameEvent
*
event
);
void
gameEvent
Container
Received
(
GameEvent
Container
*
event
);
// Generic events
// Generic events
void
listGamesEventReceived
(
Event_ListGames
*
event
);
void
listGamesEventReceived
(
Event_ListGames
*
event
);
void
serverMessageEventReceived
(
Event_ServerMessage
*
event
);
void
serverMessageEventReceived
(
Event_ServerMessage
*
event
);
...
@@ -63,7 +65,7 @@ private:
...
@@ -63,7 +65,7 @@ private:
static
const
int
maxTimeout
=
10
;
static
const
int
maxTimeout
=
10
;
QTimer
*
timer
;
QTimer
*
timer
;
QMap
<
int
,
Command
*>
pendingCommands
;
QMap
<
int
,
Command
Container
*>
pendingCommands
;
QTcpSocket
*
socket
;
QTcpSocket
*
socket
;
QXmlStreamReader
*
xmlReader
;
QXmlStreamReader
*
xmlReader
;
QXmlStreamWriter
*
xmlWriter
;
QXmlStreamWriter
*
xmlWriter
;
...
@@ -80,6 +82,7 @@ public:
...
@@ -80,6 +82,7 @@ public:
void
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
);
void
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
);
void
disconnectFromServer
();
void
disconnectFromServer
();
void
sendCommand
(
Command
*
cmd
);
void
sendCommand
(
Command
*
cmd
);
void
sendCommandContainer
(
CommandContainer
*
cont
);
};
};
#endif
#endif
cockatrice/src/player.cpp
View file @
888a64b0
...
@@ -908,6 +908,11 @@ void Player::sendGameCommand(GameCommand *command)
...
@@ -908,6 +908,11 @@ void Player::sendGameCommand(GameCommand *command)
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
command
);
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
command
);
}
}
void
Player
::
sendCommandContainer
(
CommandContainer
*
cont
)
{
static_cast
<
TabGame
*>
(
parent
())
->
sendCommandContainer
(
cont
);
}
void
Player
::
cardMenuAction
()
void
Player
::
cardMenuAction
()
{
{
// Determine the appropriate handler function.
// Determine the appropriate handler function.
...
...
cockatrice/src/player.h
View file @
888a64b0
...
@@ -20,6 +20,7 @@ class HandZone;
...
@@ -20,6 +20,7 @@ class HandZone;
class
ServerInfo_Player
;
class
ServerInfo_Player
;
class
ServerInfo_Arrow
;
class
ServerInfo_Arrow
;
class
ServerInfo_Counter
;
class
ServerInfo_Counter
;
class
CommandContainer
;
class
GameCommand
;
class
GameCommand
;
class
GameEvent
;
class
GameEvent
;
class
Event_DeckSelect
;
class
Event_DeckSelect
;
...
@@ -190,6 +191,7 @@ public:
...
@@ -190,6 +191,7 @@ public:
void
processPlayerInfo
(
ServerInfo_Player
*
info
);
void
processPlayerInfo
(
ServerInfo_Player
*
info
);
void
processGameEvent
(
GameEvent
*
event
);
void
processGameEvent
(
GameEvent
*
event
);
void
sendGameCommand
(
GameCommand
*
command
);
void
sendGameCommand
(
GameCommand
*
command
);
void
sendCommandContainer
(
CommandContainer
*
cont
);
};
};
#endif
#endif
cockatrice/src/tab_game.cpp
View file @
888a64b0
...
@@ -226,8 +226,12 @@ Player *TabGame::addPlayer(int playerId, const QString &playerName)
...
@@ -226,8 +226,12 @@ Player *TabGame::addPlayer(int playerId, const QString &playerName)
return
newPlayer
;
return
newPlayer
;
}
}
void
TabGame
::
processGameEvent
(
GameEvent
*
eve
nt
)
void
TabGame
::
processGameEvent
Container
(
GameEvent
Container
*
co
nt
)
{
{
const
QList
<
GameEvent
*>
&
eventList
=
cont
->
getEventList
();
for
(
int
i
=
0
;
i
<
eventList
.
size
();
++
i
)
{
GameEvent
*
event
=
eventList
[
i
];
switch
(
event
->
getItemId
())
{
switch
(
event
->
getItemId
())
{
case
ItemId_Event_GameStateChanged
:
eventGameStateChanged
(
qobject_cast
<
Event_GameStateChanged
*>
(
event
));
break
;
case
ItemId_Event_GameStateChanged
:
eventGameStateChanged
(
qobject_cast
<
Event_GameStateChanged
*>
(
event
));
break
;
case
ItemId_Event_Join
:
eventJoin
(
qobject_cast
<
Event_Join
*>
(
event
));
break
;
case
ItemId_Event_Join
:
eventJoin
(
qobject_cast
<
Event_Join
*>
(
event
));
break
;
...
@@ -247,6 +251,7 @@ void TabGame::processGameEvent(GameEvent *event)
...
@@ -247,6 +251,7 @@ void TabGame::processGameEvent(GameEvent *event)
emit
userEvent
();
emit
userEvent
();
}
}
}
}
}
}
}
void
TabGame
::
sendGameCommand
(
GameCommand
*
command
)
void
TabGame
::
sendGameCommand
(
GameCommand
*
command
)
...
@@ -255,6 +260,17 @@ void TabGame::sendGameCommand(GameCommand *command)
...
@@ -255,6 +260,17 @@ void TabGame::sendGameCommand(GameCommand *command)
client
->
sendCommand
(
command
);
client
->
sendCommand
(
command
);
}
}
void
TabGame
::
sendCommandContainer
(
CommandContainer
*
cont
)
{
const
QList
<
Command
*>
&
cmdList
=
cont
->
getCommandList
();
for
(
int
i
=
0
;
i
<
cmdList
.
size
();
++
i
)
{
GameCommand
*
cmd
=
qobject_cast
<
GameCommand
*>
(
cmdList
[
i
]);
if
(
cmd
)
cmd
->
setGameId
(
gameId
);
}
client
->
sendCommandContainer
(
cont
);
}
void
TabGame
::
startGame
()
void
TabGame
::
startGame
()
{
{
currentPhase
=
-
1
;
currentPhase
=
-
1
;
...
...
cockatrice/src/tab_game.h
View file @
888a64b0
...
@@ -20,8 +20,9 @@ class ZoneViewWidget;
...
@@ -20,8 +20,9 @@ class ZoneViewWidget;
class
PhasesToolbar
;
class
PhasesToolbar
;
class
PlayerListWidget
;
class
PlayerListWidget
;
class
ProtocolResponse
;
class
ProtocolResponse
;
class
GameEvent
;
class
GameEvent
Container
;
class
GameCommand
;
class
GameCommand
;
class
CommandContainer
;
class
Event_GameStateChanged
;
class
Event_GameStateChanged
;
class
Event_Join
;
class
Event_Join
;
class
Event_Leave
;
class
Event_Leave
;
...
@@ -103,9 +104,10 @@ public:
...
@@ -103,9 +104,10 @@ public:
int
getGameId
()
const
{
return
gameId
;
}
int
getGameId
()
const
{
return
gameId
;
}
QString
getTabText
()
const
{
return
tr
(
"Game %1: %2"
).
arg
(
gameId
).
arg
(
gameDescription
);
}
QString
getTabText
()
const
{
return
tr
(
"Game %1: %2"
).
arg
(
gameId
).
arg
(
gameDescription
);
}
void
processGameEvent
(
GameEvent
*
eve
nt
);
void
processGameEvent
Container
(
GameEvent
Container
*
co
nt
);
public
slots
:
public
slots
:
void
sendGameCommand
(
GameCommand
*
command
);
void
sendGameCommand
(
GameCommand
*
command
);
void
sendCommandContainer
(
CommandContainer
*
cont
);
};
};
#endif
#endif
cockatrice/src/tab_supervisor.cpp
View file @
888a64b0
...
@@ -52,7 +52,7 @@ void TabSupervisor::start(Client *_client)
...
@@ -52,7 +52,7 @@ void TabSupervisor::start(Client *_client)
{
{
client
=
_client
;
client
=
_client
;
connect
(
client
,
SIGNAL
(
chatEventReceived
(
ChatEvent
*
)),
this
,
SLOT
(
processChatEvent
(
ChatEvent
*
)));
connect
(
client
,
SIGNAL
(
chatEventReceived
(
ChatEvent
*
)),
this
,
SLOT
(
processChatEvent
(
ChatEvent
*
)));
connect
(
client
,
SIGNAL
(
gameEventReceived
(
GameEvent
*
)),
this
,
SLOT
(
processGameEvent
(
GameEvent
*
)));
connect
(
client
,
SIGNAL
(
gameEvent
Container
Received
(
GameEvent
Container
*
)),
this
,
SLOT
(
processGameEvent
Container
(
GameEvent
Container
*
)));
connect
(
client
,
SIGNAL
(
gameJoinedEventReceived
(
Event_GameJoined
*
)),
this
,
SLOT
(
gameJoined
(
Event_GameJoined
*
)));
connect
(
client
,
SIGNAL
(
gameJoinedEventReceived
(
Event_GameJoined
*
)),
this
,
SLOT
(
gameJoined
(
Event_GameJoined
*
)));
connect
(
client
,
SIGNAL
(
maxPingTime
(
int
,
int
)),
this
,
SLOT
(
updatePingTime
(
int
,
int
)));
connect
(
client
,
SIGNAL
(
maxPingTime
(
int
,
int
)),
this
,
SLOT
(
updatePingTime
(
int
,
int
)));
...
@@ -152,12 +152,12 @@ void TabSupervisor::processChatEvent(ChatEvent *event)
...
@@ -152,12 +152,12 @@ void TabSupervisor::processChatEvent(ChatEvent *event)
tab
->
processChatEvent
(
event
);
tab
->
processChatEvent
(
event
);
}
}
void
TabSupervisor
::
processGameEvent
(
GameEvent
*
eve
nt
)
void
TabSupervisor
::
processGameEvent
Container
(
GameEvent
Container
*
co
nt
)
{
{
TabGame
*
tab
=
gameTabs
.
value
(
eve
nt
->
getGameId
());
TabGame
*
tab
=
gameTabs
.
value
(
co
nt
->
getGameId
());
if
(
tab
)
{
if
(
tab
)
{
qDebug
()
<<
"gameEvent gameId ="
<<
eve
nt
->
getGameId
();
qDebug
()
<<
"gameEvent gameId ="
<<
co
nt
->
getGameId
();
tab
->
processGameEvent
(
eve
nt
);
tab
->
processGameEvent
Container
(
co
nt
);
}
else
}
else
qDebug
()
<<
"gameEvent: invalid gameId"
;
qDebug
()
<<
"gameEvent: invalid gameId"
;
}
}
...
...
cockatrice/src/tab_supervisor.h
View file @
888a64b0
...
@@ -12,7 +12,7 @@ class TabChatChannel;
...
@@ -12,7 +12,7 @@ class TabChatChannel;
class
TabGame
;
class
TabGame
;
class
TabDeckStorage
;
class
TabDeckStorage
;
class
ChatEvent
;
class
ChatEvent
;
class
GameEvent
;
class
GameEvent
Container
;
class
Event_GameJoined
;
class
Event_GameJoined
;
class
TabSupervisor
:
public
QTabWidget
{
class
TabSupervisor
:
public
QTabWidget
{
...
@@ -42,7 +42,7 @@ private slots:
...
@@ -42,7 +42,7 @@ private slots:
void
chatChannelLeft
(
TabChatChannel
*
tab
);
void
chatChannelLeft
(
TabChatChannel
*
tab
);
void
tabUserEvent
();
void
tabUserEvent
();
void
processChatEvent
(
ChatEvent
*
event
);
void
processChatEvent
(
ChatEvent
*
event
);
void
processGameEvent
(
GameEvent
*
eve
nt
);
void
processGameEvent
Container
(
GameEvent
Container
*
co
nt
);
};
};
#endif
#endif
cockatrice/src/tablezone.cpp
View file @
888a64b0
...
@@ -85,11 +85,13 @@ void TableZone::toggleTapped()
...
@@ -85,11 +85,13 @@ void TableZone::toggleTapped()
tapAll
=
true
;
tapAll
=
true
;
break
;
break
;
}
}
QList
<
Command
*>
cmdList
;
for
(
int
i
=
0
;
i
<
selectedItems
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
selectedItems
.
size
();
i
++
)
{
CardItem
*
temp
=
qgraphicsitem_cast
<
CardItem
*>
(
selectedItems
[
i
]);
CardItem
*
temp
=
qgraphicsitem_cast
<
CardItem
*>
(
selectedItems
[
i
]);
if
(
temp
->
getTapped
()
!=
tapAll
)
if
(
temp
->
getTapped
()
!=
tapAll
)
s
etCardAttr
(
temp
->
getId
(),
"tapped"
,
tapAll
?
"1"
:
"0"
);
cmdList
.
append
(
new
Command_S
etCardAttr
(
-
1
,
name
,
temp
->
getId
(),
"tapped"
,
tapAll
?
"1"
:
"0"
)
)
;
}
}
player
->
sendCommandContainer
(
new
CommandContainer
(
cmdList
));
}
}
CardItem
*
TableZone
::
takeCard
(
int
position
,
int
cardId
,
const
QString
&
cardName
,
bool
canResize
)
CardItem
*
TableZone
::
takeCard
(
int
position
,
int
cardId
,
const
QString
&
cardName
,
bool
canResize
)
...
...
common/protocol.cpp
View file @
888a64b0
...
@@ -26,6 +26,9 @@ void ProtocolItem::initializeHash()
...
@@ -26,6 +26,9 @@ void ProtocolItem::initializeHash()
registerSerializableItem
(
"file"
,
DeckList_File
::
newItem
);
registerSerializableItem
(
"file"
,
DeckList_File
::
newItem
);
registerSerializableItem
(
"directory"
,
DeckList_Directory
::
newItem
);
registerSerializableItem
(
"directory"
,
DeckList_Directory
::
newItem
);
registerSerializableItem
(
"containercmd"
,
CommandContainer
::
newItem
);
registerSerializableItem
(
"containergame_event"
,
GameEventContainer
::
newItem
);
registerSerializableItem
(
"cmddeck_upload"
,
Command_DeckUpload
::
newItem
);
registerSerializableItem
(
"cmddeck_upload"
,
Command_DeckUpload
::
newItem
);
registerSerializableItem
(
"cmddeck_select"
,
Command_DeckSelect
::
newItem
);
registerSerializableItem
(
"cmddeck_select"
,
Command_DeckSelect
::
newItem
);
...
@@ -83,20 +86,51 @@ void TopLevelProtocolItem::writeElement(QXmlStreamWriter * /*xml*/)
...
@@ -83,20 +86,51 @@ void TopLevelProtocolItem::writeElement(QXmlStreamWriter * /*xml*/)
{
{
}
}
int
Command
::
lastCmdId
=
0
;
int
CommandContainer
::
lastCmdId
=
0
;
Command
::
Command
(
const
QString
&
_itemName
)
:
ProtocolItem
(
"cmd"
,
_itemName
)
{
}
void
Command
::
processResponse
(
ProtocolResponse
*
response
)
{
emit
finished
(
response
);
emit
finished
(
response
->
getResponseCode
());
}
Command
::
Command
(
const
QString
&
_itemName
,
int
_cmdId
)
Command
Container
::
CommandContainer
(
const
QList
<
Command
*>
&
_commandList
,
int
_cmdId
)
:
ProtocolItem
(
"c
md"
,
_itemName
),
ticks
(
0
)
:
ProtocolItem
(
"c
ontainer"
,
"cmd"
),
ticks
(
0
),
resp
(
0
),
gameEventQueue
(
0
)
{
{
if
(
_cmdId
==
-
1
)
if
(
_cmdId
==
-
1
)
_cmdId
=
lastCmdId
++
;
_cmdId
=
lastCmdId
++
;
insertItem
(
new
SerializableItem_Int
(
"cmd_id"
,
_cmdId
));
insertItem
(
new
SerializableItem_Int
(
"cmd_id"
,
_cmdId
));
for
(
int
i
=
0
;
i
<
_commandList
.
size
();
++
i
)
itemList
.
append
(
_commandList
[
i
]);
}
}
void
Command
::
processResponse
(
ProtocolResponse
*
response
)
void
Command
Container
::
processResponse
(
ProtocolResponse
*
response
)
{
{
emit
finished
(
response
);
emit
finished
(
response
);
emit
finished
(
response
->
getResponseCode
());
emit
finished
(
response
->
getResponseCode
());
const
QList
<
Command
*>
&
cmdList
=
getCommandList
();
for
(
int
i
=
0
;
i
<
cmdList
.
size
();
++
i
)
cmdList
[
i
]
->
processResponse
(
response
);
}
void
CommandContainer
::
setResponse
(
ProtocolResponse
*
_resp
)
{
delete
resp
;
resp
=
_resp
;
}
void
CommandContainer
::
enqueueGameEvent
(
GameEvent
*
event
,
int
gameId
)
{
if
(
!
gameEventQueue
)
gameEventQueue
=
new
GameEventContainer
(
QList
<
GameEvent
*>
(),
gameId
);
gameEventQueue
->
appendItem
(
event
);
}
}
Command_DeckUpload
::
Command_DeckUpload
(
DeckList
*
_deck
,
const
QString
&
_path
)
Command_DeckUpload
::
Command_DeckUpload
(
DeckList
*
_deck
,
const
QString
&
_path
)
...
@@ -187,10 +221,9 @@ Response_DumpZone::Response_DumpZone(int _cmdId, ResponseCode _responseCode, Ser
...
@@ -187,10 +221,9 @@ Response_DumpZone::Response_DumpZone(int _cmdId, ResponseCode _responseCode, Ser
insertItem
(
_zone
);
insertItem
(
_zone
);
}
}
GameEvent
::
GameEvent
(
const
QString
&
_eventName
,
int
_gameId
,
int
_playerId
)
GameEvent
::
GameEvent
(
const
QString
&
_eventName
,
int
_playerId
)
:
ProtocolItem
(
"game_event"
,
_eventName
)
:
ProtocolItem
(
"game_event"
,
_eventName
)
{
{
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
}
}
...
@@ -221,16 +254,30 @@ Event_ListGames::Event_ListGames(const QList<ServerInfo_Game *> &_gameList)
...
@@ -221,16 +254,30 @@ Event_ListGames::Event_ListGames(const QList<ServerInfo_Game *> &_gameList)
itemList
.
append
(
_gameList
[
i
]);
itemList
.
append
(
_gameList
[
i
]);
}
}
Event_Join
::
Event_Join
(
int
_gameId
,
ServerInfo_Player
*
player
)
Event_Join
::
Event_Join
(
ServerInfo_Player
*
player
)
:
GameEvent
(
"join"
,
_gameId
,
-
1
)
:
GameEvent
(
"join"
,
-
1
)
{
{
if
(
!
player
)
if
(
!
player
)
player
=
new
ServerInfo_Player
;
player
=
new
ServerInfo_Player
;
insertItem
(
player
);
insertItem
(
player
);
}
}
Event_GameStateChanged
::
Event_GameStateChanged
(
int
_gameId
,
bool
_gameStarted
,
int
_activePlayer
,
int
_activePhase
,
const
QList
<
ServerInfo_Player
*>
&
_playerList
)
GameEventContainer
::
GameEventContainer
(
const
QList
<
GameEvent
*>
&
_eventList
,
int
_gameId
)
:
GameEvent
(
"game_state_changed"
,
_gameId
,
-
1
)
:
ProtocolItem
(
"container"
,
"game_event"
)
{
insertItem
(
new
SerializableItem_Int
(
"game_id"
,
_gameId
));
for
(
int
i
=
0
;
i
<
_eventList
.
size
();
++
i
)
itemList
.
append
(
_eventList
[
i
]);
}
GameEventContainer
*
GameEventContainer
::
makeNew
(
GameEvent
*
event
,
int
_gameId
)
{
return
new
GameEventContainer
(
QList
<
GameEvent
*>
()
<<
event
,
_gameId
);
}
Event_GameStateChanged
::
Event_GameStateChanged
(
bool
_gameStarted
,
int
_activePlayer
,
int
_activePhase
,
const
QList
<
ServerInfo_Player
*>
&
_playerList
)
:
GameEvent
(
"game_state_changed"
,
-
1
)
{
{
insertItem
(
new
SerializableItem_Bool
(
"game_started"
,
_gameStarted
));
insertItem
(
new
SerializableItem_Bool
(
"game_started"
,
_gameStarted
));
insertItem
(
new
SerializableItem_Int
(
"active_player"
,
_activePlayer
));
insertItem
(
new
SerializableItem_Int
(
"active_player"
,
_activePlayer
));
...
@@ -239,29 +286,29 @@ Event_GameStateChanged::Event_GameStateChanged(int _gameId, bool _gameStarted, i
...
@@ -239,29 +286,29 @@ Event_GameStateChanged::Event_GameStateChanged(int _gameId, bool _gameStarted, i
itemList
.
append
(
_playerList
[
i
]);
itemList
.
append
(
_playerList
[
i
]);
}
}
Event_Ping
::
Event_Ping
(
int
_gameId
,
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
)
Event_Ping
::
Event_Ping
(
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
)
:
GameEvent
(
"ping"
,
_gameId
,
-
1
)
:
GameEvent
(
"ping"
,
-
1
)
{
{
for
(
int
i
=
0
;
i
<
_pingList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
_pingList
.
size
();
++
i
)
itemList
.
append
(
_pingList
[
i
]);
itemList
.
append
(
_pingList
[
i
]);
}
}
Event_CreateArrows
::
Event_CreateArrows
(
int
_gameId
,
int
_playerId
,
const
QList
<
ServerInfo_Arrow
*>
&
_arrowList
)
Event_CreateArrows
::
Event_CreateArrows
(
int
_playerId
,
const
QList
<
ServerInfo_Arrow
*>
&
_arrowList
)
:
GameEvent
(
"create_arrows"
,
_gameId
,
_playerId
)
:
GameEvent
(
"create_arrows"
,
_playerId
)
{
{
for
(
int
i
=
0
;
i
<
_arrowList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
_arrowList
.
size
();
++
i
)
itemList
.
append
(
_arrowList
[
i
]);
itemList
.
append
(
_arrowList
[
i
]);
}
}
Event_CreateCounters
::
Event_CreateCounters
(
int
_gameId
,
int
_playerId
,
const
QList
<
ServerInfo_Counter
*>
&
_counterList
)
Event_CreateCounters
::
Event_CreateCounters
(
int
_playerId
,
const
QList
<
ServerInfo_Counter
*>
&
_counterList
)
:
GameEvent
(
"create_counters"
,
_gameId
,
_playerId
)
:
GameEvent
(
"create_counters"
,
_playerId
)
{
{
for
(
int
i
=
0
;
i
<
_counterList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
_counterList
.
size
();
++
i
)
itemList
.
append
(
_counterList
[
i
]);
itemList
.
append
(
_counterList
[
i
]);
}
}
Event_DrawCards
::
Event_DrawCards
(
int
_gameId
,
int
_playerId
,
int
_numberCards
,
const
QList
<
ServerInfo_Card
*>
&
_cardList
)
Event_DrawCards
::
Event_DrawCards
(
int
_playerId
,
int
_numberCards
,
const
QList
<
ServerInfo_Card
*>
&
_cardList
)
:
GameEvent
(
"draw_cards"
,
_gameId
,
_playerId
)
:
GameEvent
(
"draw_cards"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"number_cards"
,
_numberCards
));
insertItem
(
new
SerializableItem_Int
(
"number_cards"
,
_numberCards
));
for
(
int
i
=
0
;
i
<
_cardList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
_cardList
.
size
();
++
i
)
...
...
common/protocol.h
View file @
888a64b0
...
@@ -15,8 +15,12 @@ class QXmlStreamAttributes;
...
@@ -15,8 +15,12 @@ class QXmlStreamAttributes;
class
ProtocolResponse
;
class
ProtocolResponse
;
class
DeckList
;
class
DeckList
;
class
GameEvent
;
class
GameEventContainer
;
enum
ItemId
{
enum
ItemId
{
ItemId_CommandContainer
=
ItemId_Other
+
50
,
ItemId_GameEventContainer
=
ItemId_Other
+
51
,
ItemId_Command_DeckUpload
=
ItemId_Other
+
100
,
ItemId_Command_DeckUpload
=
ItemId_Other
+
100
,
ItemId_Command_DeckSelect
=
ItemId_Other
+
101
,
ItemId_Command_DeckSelect
=
ItemId_Other
+
101
,
ItemId_Event_ListChatChannels
=
ItemId_Other
+
200
,
ItemId_Event_ListChatChannels
=
ItemId_Other
+
200
,
...
@@ -40,7 +44,7 @@ class ProtocolItem : public SerializableItem_Map {
...
@@ -40,7 +44,7 @@ class ProtocolItem : public SerializableItem_Map {
private:
private:
static
void
initializeHashAuto
();
static
void
initializeHashAuto
();
public:
public:
static
const
int
protocolVersion
=
5
;
static
const
int
protocolVersion
=
6
;
static
void
initializeHash
();
static
void
initializeHash
();
virtual
int
getItemId
()
const
=
0
;
virtual
int
getItemId
()
const
=
0
;
ProtocolItem
(
const
QString
&
_itemType
,
const
QString
&
_itemSubType
);
ProtocolItem
(
const
QString
&
_itemType
,
const
QString
&
_itemSubType
);
...
@@ -74,17 +78,43 @@ class Command : public ProtocolItem {
...
@@ -74,17 +78,43 @@ class Command : public ProtocolItem {
signals:
signals:
void
finished
(
ProtocolResponse
*
response
);
void
finished
(
ProtocolResponse
*
response
);
void
finished
(
ResponseCode
response
);
void
finished
(
ResponseCode
response
);
private:
QVariant
extraData
;
public:
Command
(
const
QString
&
_itemName
=
QString
());
void
setExtraData
(
const
QVariant
&
_extraData
)
{
extraData
=
_extraData
;
}
QVariant
getExtraData
()
const
{
return
extraData
;
}
void
processResponse
(
ProtocolResponse
*
response
);
};
class
CommandContainer
:
public
ProtocolItem
{
Q_OBJECT
signals:
void
finished
(
ProtocolResponse
*
response
);
void
finished
(
ResponseCode
response
);
private:
private:
int
ticks
;
int
ticks
;
static
int
lastCmdId
;
static
int
lastCmdId
;
QVariant
extraData
;
// These are only for processing inside the server.
ProtocolResponse
*
resp
;
QList
<
ProtocolItem
*>
itemQueue
;
GameEventContainer
*
gameEventQueue
;
public:
public:
Command
(
const
QString
&
_itemName
=
QString
(),
int
_cmdId
=
-
1
);
CommandContainer
(
const
QList
<
Command
*>
&
_commandList
=
QList
<
Command
*>
(),
int
_cmdId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
CommandContainer
;
}
int
getItemId
()
const
{
return
ItemId_CommandContainer
;
}
int
getCmdId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"cmd_id"
))
->
getData
();
}
int
getCmdId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"cmd_id"
))
->
getData
();
}
int
tick
()
{
return
++
ticks
;
}
int
tick
()
{
return
++
ticks
;
}
void
processResponse
(
ProtocolResponse
*
response
);
void
processResponse
(
ProtocolResponse
*
response
);
void
setExtraData
(
const
QVariant
&
_extraData
)
{
extraData
=
_extraData
;
}
QList
<
Command
*>
getCommandList
()
const
{
return
typecastItemList
<
Command
*>
();
}
QVariant
getExtraData
()
const
{
return
extraData
;
}
ProtocolResponse
*
getResponse
()
const
{
return
resp
;
}
void
setResponse
(
ProtocolResponse
*
_resp
);
const
QList
<
ProtocolItem
*>
&
getItemQueue
()
const
{
return
itemQueue
;
}
void
enqueueItem
(
ProtocolItem
*
item
)
{
itemQueue
.
append
(
item
);
}
GameEventContainer
*
getGameEventQueue
()
const
{
return
gameEventQueue
;
}
void
enqueueGameEvent
(
GameEvent
*
event
,
int
gameId
);
};
};
class
ChatCommand
:
public
Command
{
class
ChatCommand
:
public
Command
{
...
@@ -197,9 +227,20 @@ public:
...
@@ -197,9 +227,20 @@ public:
class
GameEvent
:
public
ProtocolItem
{
class
GameEvent
:
public
ProtocolItem
{
Q_OBJECT
Q_OBJECT
public:
public:
GameEvent
(
const
QString
&
_eventName
,
int
_gameId
,
int
_playerId
);
GameEvent
(
const
QString
&
_eventName
,
int
_playerId
);
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
();
}
int
getPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_id"
))
->
getData
();
}
int
getPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"player_id"
))
->
getData
();
}
};
class
GameEventContainer
:
public
ProtocolItem
{
Q_OBJECT
public:
GameEventContainer
(
const
QList
<
GameEvent
*>
&
_eventList
=
QList
<
GameEvent
*>
(),
int
_gameId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
GameEventContainer
;
}
int
getItemId
()
const
{
return
ItemId_GameEventContainer
;
}
QList
<
GameEvent
*>
getEventList
()
const
{
return
typecastItemList
<
GameEvent
*>
();
}
static
GameEventContainer
*
makeNew
(
GameEvent
*
event
,
int
_gameId
);
int
getGameId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
getData
();
}
void
setGameId
(
int
_gameId
)
{
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
setData
(
_gameId
);
}
void
setGameId
(
int
_gameId
)
{
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"game_id"
))
->
setData
(
_gameId
);
}
};
};
...
@@ -240,7 +281,7 @@ public:
...
@@ -240,7 +281,7 @@ public:
class
Event_Join
:
public
GameEvent
{
class
Event_Join
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Join
(
int
_gameId
=
-
1
,
ServerInfo_Player
*
player
=
0
);
Event_Join
(
ServerInfo_Player
*
player
=
0
);
static
SerializableItem
*
newItem
()
{
return
new
Event_Join
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_Join
;
}
int
getItemId
()
const
{
return
ItemId_Event_Join
;
}
int
getItemId
()
const
{
return
ItemId_Event_Join
;
}
ServerInfo_Player
*
getPlayer
()
const
{
return
static_cast
<
ServerInfo_Player
*>
(
itemMap
.
value
(
"player"
));
}
ServerInfo_Player
*
getPlayer
()
const
{
return
static_cast
<
ServerInfo_Player
*>
(
itemMap
.
value
(
"player"
));
}
...
@@ -249,7 +290,7 @@ public:
...
@@ -249,7 +290,7 @@ public:
class
Event_GameStateChanged
:
public
GameEvent
{
class
Event_GameStateChanged
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_GameStateChanged
(
int
_gameId
=
-
1
,
bool
_gameStarted
=
false
,
int
_activePlayer
=
-
1
,
int
_activePhase
=
-
1
,
const
QList
<
ServerInfo_Player
*>
&
_playerList
=
QList
<
ServerInfo_Player
*>
());
Event_GameStateChanged
(
bool
_gameStarted
=
false
,
int
_activePlayer
=
-
1
,
int
_activePhase
=
-
1
,
const
QList
<
ServerInfo_Player
*>
&
_playerList
=
QList
<
ServerInfo_Player
*>
());
static
SerializableItem
*
newItem
()
{
return
new
Event_GameStateChanged
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_GameStateChanged
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameStateChanged
;
}
int
getItemId
()
const
{
return
ItemId_Event_GameStateChanged
;
}
QList
<
ServerInfo_Player
*>
getPlayerList
()
const
{
return
typecastItemList
<
ServerInfo_Player
*>
();
}
QList
<
ServerInfo_Player
*>
getPlayerList
()
const
{
return
typecastItemList
<
ServerInfo_Player
*>
();
}
...
@@ -261,7 +302,7 @@ public:
...
@@ -261,7 +302,7 @@ public:
class
Event_Ping
:
public
GameEvent
{
class
Event_Ping
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Ping
(
int
_gameId
=
-
1
,
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
=
QList
<
ServerInfo_PlayerPing
*>
());
Event_Ping
(
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
=
QList
<
ServerInfo_PlayerPing
*>
());
static
SerializableItem
*
newItem
()
{
return
new
Event_Ping
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_Ping
;
}
int
getItemId
()
const
{
return
ItemId_Event_Ping
;
}
int
getItemId
()
const
{
return
ItemId_Event_Ping
;
}
QList
<
ServerInfo_PlayerPing
*>
getPingList
()
const
{
return
typecastItemList
<
ServerInfo_PlayerPing
*>
();
}
QList
<
ServerInfo_PlayerPing
*>
getPingList
()
const
{
return
typecastItemList
<
ServerInfo_PlayerPing
*>
();
}
...
@@ -270,7 +311,7 @@ public:
...
@@ -270,7 +311,7 @@ public:
class
Event_CreateArrows
:
public
GameEvent
{
class
Event_CreateArrows
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_CreateArrows
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QList
<
ServerInfo_Arrow
*>
&
_arrowList
=
QList
<
ServerInfo_Arrow
*>
());
Event_CreateArrows
(
int
_playerId
=
-
1
,
const
QList
<
ServerInfo_Arrow
*>
&
_arrowList
=
QList
<
ServerInfo_Arrow
*>
());
int
getItemId
()
const
{
return
ItemId_Event_CreateArrows
;
}
int
getItemId
()
const
{
return
ItemId_Event_CreateArrows
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_CreateArrows
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_CreateArrows
;
}
QList
<
ServerInfo_Arrow
*>
getArrowList
()
const
{
return
typecastItemList
<
ServerInfo_Arrow
*>
();
}
QList
<
ServerInfo_Arrow
*>
getArrowList
()
const
{
return
typecastItemList
<
ServerInfo_Arrow
*>
();
}
...
@@ -279,7 +320,7 @@ public:
...
@@ -279,7 +320,7 @@ public:
class
Event_CreateCounters
:
public
GameEvent
{
class
Event_CreateCounters
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_CreateCounters
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QList
<
ServerInfo_Counter
*>
&
_counterList
=
QList
<
ServerInfo_Counter
*>
());
Event_CreateCounters
(
int
_playerId
=
-
1
,
const
QList
<
ServerInfo_Counter
*>
&
_counterList
=
QList
<
ServerInfo_Counter
*>
());
int
getItemId
()
const
{
return
ItemId_Event_CreateCounters
;
}
int
getItemId
()
const
{
return
ItemId_Event_CreateCounters
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_CreateCounters
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_CreateCounters
;
}
QList
<
ServerInfo_Counter
*>
getCounterList
()
const
{
return
typecastItemList
<
ServerInfo_Counter
*>
();
}
QList
<
ServerInfo_Counter
*>
getCounterList
()
const
{
return
typecastItemList
<
ServerInfo_Counter
*>
();
}
...
@@ -288,7 +329,7 @@ public:
...
@@ -288,7 +329,7 @@ public:
class
Event_DrawCards
:
public
GameEvent
{
class
Event_DrawCards
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_DrawCards
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
numberCards
=
-
1
,
const
QList
<
ServerInfo_Card
*>
&
_cardList
=
QList
<
ServerInfo_Card
*>
());
Event_DrawCards
(
int
_playerId
=
-
1
,
int
numberCards
=
-
1
,
const
QList
<
ServerInfo_Card
*>
&
_cardList
=
QList
<
ServerInfo_Card
*>
());
int
getItemId
()
const
{
return
ItemId_Event_DrawCards
;
}
int
getItemId
()
const
{
return
ItemId_Event_DrawCards
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_DrawCards
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_DrawCards
;
}
int
getNumberCards
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"number_cards"
))
->
getData
();
}
int
getNumberCards
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"number_cards"
))
->
getData
();
}
...
...
common/protocol_items.cpp
View file @
888a64b0
...
@@ -198,44 +198,44 @@ Command_StopDumpZone::Command_StopDumpZone(int _gameId, int _playerId, const QSt
...
@@ -198,44 +198,44 @@ Command_StopDumpZone::Command_StopDumpZone(int _gameId, int _playerId, const QSt
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
insertItem
(
new
SerializableItem_Int
(
"player_id"
,
_playerId
));
insertItem
(
new
SerializableItem_String
(
"zone_name"
,
_zoneName
));
insertItem
(
new
SerializableItem_String
(
"zone_name"
,
_zoneName
));
}
}
Event_Say
::
Event_Say
(
int
_gameId
,
int
_playerId
,
const
QString
&
_message
)
Event_Say
::
Event_Say
(
int
_playerId
,
const
QString
&
_message
)
:
GameEvent
(
"say"
,
_gameId
,
_playerId
)
:
GameEvent
(
"say"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
insertItem
(
new
SerializableItem_String
(
"message"
,
_message
));
}
}
Event_Leave
::
Event_Leave
(
int
_gameId
,
int
_playerId
)
Event_Leave
::
Event_Leave
(
int
_playerId
)
:
GameEvent
(
"leave"
,
_gameId
,
_playerId
)
:
GameEvent
(
"leave"
,
_playerId
)
{
{
}
}
Event_DeckSelect
::
Event_DeckSelect
(
int
_gameId
,
int
_playerId
,
int
_deckId
)
Event_DeckSelect
::
Event_DeckSelect
(
int
_playerId
,
int
_deckId
)
:
GameEvent
(
"deck_select"
,
_gameId
,
_playerId
)
:
GameEvent
(
"deck_select"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"deck_id"
,
_deckId
));
insertItem
(
new
SerializableItem_Int
(
"deck_id"
,
_deckId
));
}
}
Event_GameClosed
::
Event_GameClosed
(
int
_gameId
,
int
_playerId
)
Event_GameClosed
::
Event_GameClosed
(
int
_playerId
)
:
GameEvent
(
"game_closed"
,
_gameId
,
_playerId
)
:
GameEvent
(
"game_closed"
,
_playerId
)
{
{
}
}
Event_ReadyStart
::
Event_ReadyStart
(
int
_gameId
,
int
_playerId
)
Event_ReadyStart
::
Event_ReadyStart
(
int
_playerId
)
:
GameEvent
(
"ready_start"
,
_gameId
,
_playerId
)
:
GameEvent
(
"ready_start"
,
_playerId
)
{
{
}
}
Event_Concede
::
Event_Concede
(
int
_gameId
,
int
_playerId
)
Event_Concede
::
Event_Concede
(
int
_playerId
)
:
GameEvent
(
"concede"
,
_gameId
,
_playerId
)
:
GameEvent
(
"concede"
,
_playerId
)
{
{
}
}
Event_Shuffle
::
Event_Shuffle
(
int
_gameId
,
int
_playerId
)
Event_Shuffle
::
Event_Shuffle
(
int
_playerId
)
:
GameEvent
(
"shuffle"
,
_gameId
,
_playerId
)
:
GameEvent
(
"shuffle"
,
_playerId
)
{
{
}
}
Event_RollDie
::
Event_RollDie
(
int
_gameId
,
int
_playerId
,
int
_sides
,
int
_value
)
Event_RollDie
::
Event_RollDie
(
int
_playerId
,
int
_sides
,
int
_value
)
:
GameEvent
(
"roll_die"
,
_gameId
,
_playerId
)
:
GameEvent
(
"roll_die"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"sides"
,
_sides
));
insertItem
(
new
SerializableItem_Int
(
"sides"
,
_sides
));
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
}
}
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
,
int
_newCardId
,
bool
_faceDown
)
Event_MoveCard
::
Event_MoveCard
(
int
_playerId
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_startZone
,
int
_position
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
int
_newCardId
,
bool
_faceDown
)
:
GameEvent
(
"move_card"
,
_gameId
,
_playerId
)
:
GameEvent
(
"move_card"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_String
(
"card_name"
,
_cardName
));
insertItem
(
new
SerializableItem_String
(
"card_name"
,
_cardName
));
...
@@ -247,8 +247,8 @@ Event_MoveCard::Event_MoveCard(int _gameId, int _playerId, int _cardId, const QS
...
@@ -247,8 +247,8 @@ Event_MoveCard::Event_MoveCard(int _gameId, int _playerId, int _cardId, const QS
insertItem
(
new
SerializableItem_Int
(
"new_card_id"
,
_newCardId
));
insertItem
(
new
SerializableItem_Int
(
"new_card_id"
,
_newCardId
));
insertItem
(
new
SerializableItem_Bool
(
"face_down"
,
_faceDown
));
insertItem
(
new
SerializableItem_Bool
(
"face_down"
,
_faceDown
));
}
}
Event_CreateToken
::
Event_CreateToken
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_pt
,
int
_x
,
int
_y
)
Event_CreateToken
::
Event_CreateToken
(
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_cardName
,
const
QString
&
_pt
,
int
_x
,
int
_y
)
:
GameEvent
(
"create_token"
,
_gameId
,
_playerId
)
:
GameEvent
(
"create_token"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
...
@@ -257,49 +257,49 @@ Event_CreateToken::Event_CreateToken(int _gameId, int _playerId, const QString &
...
@@ -257,49 +257,49 @@ Event_CreateToken::Event_CreateToken(int _gameId, int _playerId, const QString &
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
}
}
Event_DeleteArrow
::
Event_DeleteArrow
(
int
_gameId
,
int
_playerId
,
int
_arrowId
)
Event_DeleteArrow
::
Event_DeleteArrow
(
int
_playerId
,
int
_arrowId
)
:
GameEvent
(
"delete_arrow"
,
_gameId
,
_playerId
)
:
GameEvent
(
"delete_arrow"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"arrow_id"
,
_arrowId
));
insertItem
(
new
SerializableItem_Int
(
"arrow_id"
,
_arrowId
));
}
}
Event_SetCardAttr
::
Event_SetCardAttr
(
int
_gameId
,
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_attrName
,
const
QString
&
_attrValue
)
Event_SetCardAttr
::
Event_SetCardAttr
(
int
_playerId
,
const
QString
&
_zone
,
int
_cardId
,
const
QString
&
_attrName
,
const
QString
&
_attrValue
)
:
GameEvent
(
"set_card_attr"
,
_gameId
,
_playerId
)
:
GameEvent
(
"set_card_attr"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_String
(
"attr_name"
,
_attrName
));
insertItem
(
new
SerializableItem_String
(
"attr_name"
,
_attrName
));
insertItem
(
new
SerializableItem_String
(
"attr_value"
,
_attrValue
));
insertItem
(
new
SerializableItem_String
(
"attr_value"
,
_attrValue
));
}
}
Event_SetCounter
::
Event_SetCounter
(
int
_gameId
,
int
_playerId
,
int
_counterId
,
int
_value
)
Event_SetCounter
::
Event_SetCounter
(
int
_playerId
,
int
_counterId
,
int
_value
)
:
GameEvent
(
"set_counter"
,
_gameId
,
_playerId
)
:
GameEvent
(
"set_counter"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
insertItem
(
new
SerializableItem_Int
(
"value"
,
_value
));
}
}
Event_DelCounter
::
Event_DelCounter
(
int
_gameId
,
int
_playerId
,
int
_counterId
)
Event_DelCounter
::
Event_DelCounter
(
int
_playerId
,
int
_counterId
)
:
GameEvent
(
"del_counter"
,
_gameId
,
_playerId
)
:
GameEvent
(
"del_counter"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
insertItem
(
new
SerializableItem_Int
(
"counter_id"
,
_counterId
));
}
}
Event_SetActivePlayer
::
Event_SetActivePlayer
(
int
_gameId
,
int
_playerId
,
int
_activePlayerId
)
Event_SetActivePlayer
::
Event_SetActivePlayer
(
int
_playerId
,
int
_activePlayerId
)
:
GameEvent
(
"set_active_player"
,
_gameId
,
_playerId
)
:
GameEvent
(
"set_active_player"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"active_player_id"
,
_activePlayerId
));
insertItem
(
new
SerializableItem_Int
(
"active_player_id"
,
_activePlayerId
));
}
}
Event_SetActivePhase
::
Event_SetActivePhase
(
int
_gameId
,
int
_playerId
,
int
_phase
)
Event_SetActivePhase
::
Event_SetActivePhase
(
int
_playerId
,
int
_phase
)
:
GameEvent
(
"set_active_phase"
,
_gameId
,
_playerId
)
:
GameEvent
(
"set_active_phase"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"phase"
,
_phase
));
insertItem
(
new
SerializableItem_Int
(
"phase"
,
_phase
));
}
}
Event_DumpZone
::
Event_DumpZone
(
int
_gameId
,
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
,
int
_numberCards
)
Event_DumpZone
::
Event_DumpZone
(
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
,
int
_numberCards
)
:
GameEvent
(
"dump_zone"
,
_gameId
,
_playerId
)
:
GameEvent
(
"dump_zone"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"zone_owner_id"
,
_zoneOwnerId
));
insertItem
(
new
SerializableItem_Int
(
"zone_owner_id"
,
_zoneOwnerId
));
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_Int
(
"number_cards"
,
_numberCards
));
insertItem
(
new
SerializableItem_Int
(
"number_cards"
,
_numberCards
));
}
}
Event_StopDumpZone
::
Event_StopDumpZone
(
int
_gameId
,
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
)
Event_StopDumpZone
::
Event_StopDumpZone
(
int
_playerId
,
int
_zoneOwnerId
,
const
QString
&
_zone
)
:
GameEvent
(
"stop_dump_zone"
,
_gameId
,
_playerId
)
:
GameEvent
(
"stop_dump_zone"
,
_playerId
)
{
{
insertItem
(
new
SerializableItem_Int
(
"zone_owner_id"
,
_zoneOwnerId
));
insertItem
(
new
SerializableItem_Int
(
"zone_owner_id"
,
_zoneOwnerId
));
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
insertItem
(
new
SerializableItem_String
(
"zone"
,
_zone
));
...
...
common/protocol_items.h
View file @
888a64b0
...
@@ -308,7 +308,7 @@ public:
...
@@ -308,7 +308,7 @@ public:
class
Event_Say
:
public
GameEvent
{
class
Event_Say
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Say
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
const
QString
&
_message
=
QString
());
Event_Say
(
int
_playerId
=
-
1
,
const
QString
&
_message
=
QString
());
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
();
};
QString
getMessage
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"message"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_Say
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_Say
;
}
int
getItemId
()
const
{
return
ItemId_Event_Say
;
}
int
getItemId
()
const
{
return
ItemId_Event_Say
;
}
...
@@ -316,14 +316,14 @@ public:
...
@@ -316,14 +316,14 @@ public:
class
Event_Leave
:
public
GameEvent
{
class
Event_Leave
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Leave
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_Leave
(
int
_playerId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
Event_Leave
;
}
static
SerializableItem
*
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
public:
public:
Event_DeckSelect
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_deckId
=
-
1
);
Event_DeckSelect
(
int
_playerId
=
-
1
,
int
_deckId
=
-
1
);
int
getDeckId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"deck_id"
))
->
getData
();
};
int
getDeckId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"deck_id"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_DeckSelect
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_DeckSelect
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeckSelect
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeckSelect
;
}
...
@@ -331,35 +331,35 @@ public:
...
@@ -331,35 +331,35 @@ public:
class
Event_GameClosed
:
public
GameEvent
{
class
Event_GameClosed
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_GameClosed
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_GameClosed
(
int
_playerId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
Event_GameClosed
;
}
static
SerializableItem
*
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
public:
public:
Event_ReadyStart
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_ReadyStart
(
int
_playerId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
Event_ReadyStart
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_ReadyStart
;
}
int
getItemId
()
const
{
return
ItemId_Event_ReadyStart
;
}
int
getItemId
()
const
{
return
ItemId_Event_ReadyStart
;
}
};
};
class
Event_Concede
:
public
GameEvent
{
class
Event_Concede
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Concede
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_Concede
(
int
_playerId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
Event_Concede
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_Concede
;
}
int
getItemId
()
const
{
return
ItemId_Event_Concede
;
}
int
getItemId
()
const
{
return
ItemId_Event_Concede
;
}
};
};
class
Event_Shuffle
:
public
GameEvent
{
class
Event_Shuffle
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Shuffle
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
);
Event_Shuffle
(
int
_playerId
=
-
1
);
static
SerializableItem
*
newItem
()
{
return
new
Event_Shuffle
;
}
static
SerializableItem
*
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
public:
public:
Event_RollDie
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_sides
=
-
1
,
int
_value
=
-
1
);
Event_RollDie
(
int
_playerId
=
-
1
,
int
_sides
=
-
1
,
int
_value
=
-
1
);
int
getSides
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"sides"
))
->
getData
();
};
int
getSides
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"sides"
))
->
getData
();
};
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
();
};
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_RollDie
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_RollDie
;
}
...
@@ -368,7 +368,7 @@ public:
...
@@ -368,7 +368,7 @@ public:
class
Event_MoveCard
:
public
GameEvent
{
class
Event_MoveCard
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
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
,
int
_newCardId
=
-
1
,
bool
_faceDown
=
false
);
Event_MoveCard
(
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
,
int
_newCardId
=
-
1
,
bool
_faceDown
=
false
);
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
};
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
};
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"card_name"
))
->
getData
();
};
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"card_name"
))
->
getData
();
};
QString
getStartZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
();
};
QString
getStartZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
();
};
...
@@ -384,7 +384,7 @@ public:
...
@@ -384,7 +384,7 @@ public:
class
Event_CreateToken
:
public
GameEvent
{
class
Event_CreateToken
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
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
_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
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
};
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
};
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"card_name"
))
->
getData
();
};
QString
getCardName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"card_name"
))
->
getData
();
};
...
@@ -397,7 +397,7 @@ public:
...
@@ -397,7 +397,7 @@ public:
class
Event_DeleteArrow
:
public
GameEvent
{
class
Event_DeleteArrow
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_DeleteArrow
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_arrowId
=
-
1
);
Event_DeleteArrow
(
int
_playerId
=
-
1
,
int
_arrowId
=
-
1
);
int
getArrowId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"arrow_id"
))
->
getData
();
};
int
getArrowId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"arrow_id"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_DeleteArrow
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_DeleteArrow
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeleteArrow
;
}
int
getItemId
()
const
{
return
ItemId_Event_DeleteArrow
;
}
...
@@ -405,7 +405,7 @@ public:
...
@@ -405,7 +405,7 @@ public:
class
Event_SetCardAttr
:
public
GameEvent
{
class
Event_SetCardAttr
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
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
_playerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_cardId
=
-
1
,
const
QString
&
_attrName
=
QString
(),
const
QString
&
_attrValue
=
QString
());
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
};
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
};
QString
getAttrName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"attr_name"
))
->
getData
();
};
QString
getAttrName
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"attr_name"
))
->
getData
();
};
...
@@ -416,7 +416,7 @@ public:
...
@@ -416,7 +416,7 @@ public:
class
Event_SetCounter
:
public
GameEvent
{
class
Event_SetCounter
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_SetCounter
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_counterId
=
-
1
,
int
_value
=
-
1
);
Event_SetCounter
(
int
_playerId
=
-
1
,
int
_counterId
=
-
1
,
int
_value
=
-
1
);
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
();
};
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
();
};
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
();
};
int
getValue
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"value"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_SetCounter
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_SetCounter
;
}
...
@@ -425,7 +425,7 @@ public:
...
@@ -425,7 +425,7 @@ public:
class
Event_DelCounter
:
public
GameEvent
{
class
Event_DelCounter
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_DelCounter
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_counterId
=
-
1
);
Event_DelCounter
(
int
_playerId
=
-
1
,
int
_counterId
=
-
1
);
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
();
};
int
getCounterId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"counter_id"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_DelCounter
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_DelCounter
;
}
int
getItemId
()
const
{
return
ItemId_Event_DelCounter
;
}
int
getItemId
()
const
{
return
ItemId_Event_DelCounter
;
}
...
@@ -433,7 +433,7 @@ public:
...
@@ -433,7 +433,7 @@ public:
class
Event_SetActivePlayer
:
public
GameEvent
{
class
Event_SetActivePlayer
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_SetActivePlayer
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_activePlayerId
=
-
1
);
Event_SetActivePlayer
(
int
_playerId
=
-
1
,
int
_activePlayerId
=
-
1
);
int
getActivePlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"active_player_id"
))
->
getData
();
};
int
getActivePlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"active_player_id"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_SetActivePlayer
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_SetActivePlayer
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePlayer
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePlayer
;
}
...
@@ -441,7 +441,7 @@ public:
...
@@ -441,7 +441,7 @@ public:
class
Event_SetActivePhase
:
public
GameEvent
{
class
Event_SetActivePhase
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_SetActivePhase
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_phase
=
-
1
);
Event_SetActivePhase
(
int
_playerId
=
-
1
,
int
_phase
=
-
1
);
int
getPhase
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"phase"
))
->
getData
();
};
int
getPhase
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"phase"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_SetActivePhase
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_SetActivePhase
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePhase
;
}
int
getItemId
()
const
{
return
ItemId_Event_SetActivePhase
;
}
...
@@ -449,7 +449,7 @@ public:
...
@@ -449,7 +449,7 @@ public:
class
Event_DumpZone
:
public
GameEvent
{
class
Event_DumpZone
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_DumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_numberCards
=
-
1
);
Event_DumpZone
(
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
(),
int
_numberCards
=
-
1
);
int
getZoneOwnerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"zone_owner_id"
))
->
getData
();
};
int
getZoneOwnerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"zone_owner_id"
))
->
getData
();
};
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
int
getNumberCards
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"number_cards"
))
->
getData
();
};
int
getNumberCards
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"number_cards"
))
->
getData
();
};
...
@@ -459,7 +459,7 @@ public:
...
@@ -459,7 +459,7 @@ public:
class
Event_StopDumpZone
:
public
GameEvent
{
class
Event_StopDumpZone
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_StopDumpZone
(
int
_gameId
=
-
1
,
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
());
Event_StopDumpZone
(
int
_playerId
=
-
1
,
int
_zoneOwnerId
=
-
1
,
const
QString
&
_zone
=
QString
());
int
getZoneOwnerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"zone_owner_id"
))
->
getData
();
};
int
getZoneOwnerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"zone_owner_id"
))
->
getData
();
};
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
QString
getZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"zone"
))
->
getData
();
};
static
SerializableItem
*
newItem
()
{
return
new
Event_StopDumpZone
;
}
static
SerializableItem
*
newItem
()
{
return
new
Event_StopDumpZone
;
}
...
...
common/protocol_mc.pl
View file @
888a64b0
...
@@ -49,9 +49,9 @@ while (<file>) {
...
@@ -49,9 +49,9 @@ while (<file>) {
$type
=
'
game_event
';
$type
=
'
game_event
';
$namePrefix
=
'
Event
';
$namePrefix
=
'
Event
';
$baseClass
=
'
GameEvent
';
$baseClass
=
'
GameEvent
';
$parentConstructorCall
=
"
$baseClass
(
\"
$name1
\"
,
_gameId,
_playerId)
";
$parentConstructorCall
=
"
$baseClass
(
\"
$name1
\"
, _playerId)
";
$constructorParamsH
=
"
int
_gameId = -1, int
_playerId = -1
";
$constructorParamsH
=
"
int _playerId = -1
";
$constructorParamsCpp
=
"
int
_gameId, int
_playerId
";
$constructorParamsCpp
=
"
int _playerId
";
}
elsif
(
$type
==
4
)
{
}
elsif
(
$type
==
4
)
{
$type
=
'
generic_event
';
$type
=
'
generic_event
';
$namePrefix
=
'
Event
';
$namePrefix
=
'
Event
';
...
...
common/server_game.cpp
View file @
888a64b0
...
@@ -66,7 +66,7 @@ void Server_Game::pingClockTimeout()
...
@@ -66,7 +66,7 @@ void Server_Game::pingClockTimeout()
pingTime
=
-
1
;
pingTime
=
-
1
;
pingList
.
append
(
new
ServerInfo_PlayerPing
(
player
->
getPlayerId
(),
pingTime
));
pingList
.
append
(
new
ServerInfo_PlayerPing
(
player
->
getPlayerId
(),
pingTime
));
}
}
sendGameEvent
(
new
Event_Ping
(
-
1
,
pingList
));
sendGameEvent
(
new
Event_Ping
(
pingList
));
const
int
maxTime
=
static_cast
<
Server
*>
(
parent
())
->
getMaxGameInactivityTime
();
const
int
maxTime
=
static_cast
<
Server
*>
(
parent
())
->
getMaxGameInactivityTime
();
if
(
allPlayersInactive
)
{
if
(
allPlayersInactive
)
{
...
@@ -119,7 +119,7 @@ void Server_Game::startGameIfReady()
...
@@ -119,7 +119,7 @@ void Server_Game::startGameIfReady()
Server_Player
*
player
=
playerIterator
.
next
().
value
();
Server_Player
*
player
=
playerIterator
.
next
().
value
();
player
->
setConceded
(
false
);
player
->
setConceded
(
false
);
player
->
setReadyStart
(
false
);
player
->
setReadyStart
(
false
);
player
->
sendProtocolItem
(
new
Event_GameStateChanged
(
gameId
,
gameStarted
,
0
,
0
,
getGameState
(
player
)));
sendGameEventToPlayer
(
player
,
new
Event_GameStateChanged
(
gameStarted
,
0
,
0
,
getGameState
(
player
)));
}
}
/* QSqlQuery query;
/* QSqlQuery query;
...
@@ -157,7 +157,7 @@ void Server_Game::stopGameIfFinished()
...
@@ -157,7 +157,7 @@ void Server_Game::stopGameIfFinished()
playerIterator
.
toFront
();
playerIterator
.
toFront
();
while
(
playerIterator
.
hasNext
())
{
while
(
playerIterator
.
hasNext
())
{
Server_Player
*
player
=
playerIterator
.
next
().
value
();
Server_Player
*
player
=
playerIterator
.
next
().
value
();
player
->
sendProtocolItem
(
new
Event_GameStateChanged
(
gameId
,
gameStarted
,
-
1
,
-
1
,
getGameState
(
player
)));
sendGameEventToPlayer
(
player
,
new
Event_GameStateChanged
(
gameStarted
,
-
1
,
-
1
,
getGameState
(
player
)));
}
}
}
}
...
@@ -180,7 +180,7 @@ Server_Player *Server_Game::addPlayer(Server_ProtocolHandler *handler, bool spec
...
@@ -180,7 +180,7 @@ Server_Player *Server_Game::addPlayer(Server_ProtocolHandler *handler, bool spec
int
playerId
=
keyList
.
isEmpty
()
?
0
:
(
keyList
.
last
()
+
1
);
int
playerId
=
keyList
.
isEmpty
()
?
0
:
(
keyList
.
last
()
+
1
);
Server_Player
*
newPlayer
=
new
Server_Player
(
this
,
playerId
,
handler
->
getPlayerName
(),
spectator
,
handler
);
Server_Player
*
newPlayer
=
new
Server_Player
(
this
,
playerId
,
handler
->
getPlayerName
(),
spectator
,
handler
);
sendGameEvent
(
new
Event_Join
(
-
1
,
new
ServerInfo_Player
(
playerId
,
handler
->
getPlayerName
(),
spectator
)));
sendGameEvent
(
new
Event_Join
(
new
ServerInfo_Player
(
playerId
,
handler
->
getPlayerName
(),
spectator
)));
players
.
insert
(
playerId
,
newPlayer
);
players
.
insert
(
playerId
,
newPlayer
);
if
(
broadcastUpdate
)
if
(
broadcastUpdate
)
...
@@ -192,7 +192,7 @@ Server_Player *Server_Game::addPlayer(Server_ProtocolHandler *handler, bool spec
...
@@ -192,7 +192,7 @@ Server_Player *Server_Game::addPlayer(Server_ProtocolHandler *handler, bool spec
void
Server_Game
::
removePlayer
(
Server_Player
*
player
)
void
Server_Game
::
removePlayer
(
Server_Player
*
player
)
{
{
players
.
remove
(
player
->
getPlayerId
());
players
.
remove
(
player
->
getPlayerId
());
sendGameEvent
(
new
Event_Leave
(
-
1
,
player
->
getPlayerId
()));
sendGameEvent
(
new
Event_Leave
(
player
->
getPlayerId
()));
delete
player
;
delete
player
;
if
(
!
getPlayerCount
())
if
(
!
getPlayerCount
())
...
@@ -205,7 +205,7 @@ void Server_Game::removePlayer(Server_Player *player)
...
@@ -205,7 +205,7 @@ void Server_Game::removePlayer(Server_Player *player)
void
Server_Game
::
setActivePlayer
(
int
_activePlayer
)
void
Server_Game
::
setActivePlayer
(
int
_activePlayer
)
{
{
activePlayer
=
_activePlayer
;
activePlayer
=
_activePlayer
;
sendGameEvent
(
new
Event_SetActivePlayer
(
-
1
,
-
1
,
activePlayer
));
sendGameEvent
(
new
Event_SetActivePlayer
(
-
1
,
activePlayer
));
setActivePhase
(
0
);
setActivePhase
(
0
);
}
}
...
@@ -217,13 +217,13 @@ void Server_Game::setActivePhase(int _activePhase)
...
@@ -217,13 +217,13 @@ void Server_Game::setActivePhase(int _activePhase)
QList
<
Server_Arrow
*>
toDelete
=
player
->
getArrows
().
values
();
QList
<
Server_Arrow
*>
toDelete
=
player
->
getArrows
().
values
();
for
(
int
i
=
0
;
i
<
toDelete
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
toDelete
.
size
();
++
i
)
{
Server_Arrow
*
a
=
toDelete
[
i
];
Server_Arrow
*
a
=
toDelete
[
i
];
sendGameEvent
(
new
Event_DeleteArrow
(
-
1
,
player
->
getPlayerId
(),
a
->
getId
()));
sendGameEvent
(
new
Event_DeleteArrow
(
player
->
getPlayerId
(),
a
->
getId
()));
player
->
deleteArrow
(
a
->
getId
());
player
->
deleteArrow
(
a
->
getId
());
}
}
}
}
activePhase
=
_activePhase
;
activePhase
=
_activePhase
;
sendGameEvent
(
new
Event_SetActivePhase
(
-
1
,
-
1
,
activePhase
));
sendGameEvent
(
new
Event_SetActivePhase
(
-
1
,
activePhase
));
}
}
QList
<
ServerInfo_Player
*>
Server_Game
::
getGameState
(
Server_Player
*
playerWhosAsking
)
const
QList
<
ServerInfo_Player
*>
Server_Game
::
getGameState
(
Server_Player
*
playerWhosAsking
)
const
...
@@ -282,13 +282,23 @@ QList<ServerInfo_Player *> Server_Game::getGameState(Server_Player *playerWhosAs
...
@@ -282,13 +282,23 @@ QList<ServerInfo_Player *> Server_Game::getGameState(Server_Player *playerWhosAs
void
Server_Game
::
sendGameEvent
(
GameEvent
*
event
,
Server_Player
*
exclude
)
void
Server_Game
::
sendGameEvent
(
GameEvent
*
event
,
Server_Player
*
exclude
)
{
{
event
->
setGameId
(
gameId
);
sendGameEventContainer
(
new
GameEventContainer
(
QList
<
GameEvent
*>
()
<<
event
),
exclude
);
}
void
Server_Game
::
sendGameEventContainer
(
GameEventContainer
*
cont
,
Server_Player
*
exclude
)
{
cont
->
setGameId
(
gameId
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
while
(
playerIterator
.
hasNext
())
{
while
(
playerIterator
.
hasNext
())
{
Server_Player
*
p
=
playerIterator
.
next
().
value
();
Server_Player
*
p
=
playerIterator
.
next
().
value
();
if
(
p
!=
exclude
)
if
(
p
!=
exclude
)
p
->
sendProtocolItem
(
eve
nt
,
false
);
p
->
sendProtocolItem
(
co
nt
,
false
);
}
}
delete
event
;
delete
cont
;
}
void
Server_Game
::
sendGameEventToPlayer
(
Server_Player
*
player
,
GameEvent
*
event
)
{
player
->
sendProtocolItem
(
new
GameEventContainer
(
QList
<
GameEvent
*>
()
<<
event
,
gameId
));
}
}
common/server_game.h
View file @
888a64b0
...
@@ -73,6 +73,8 @@ public:
...
@@ -73,6 +73,8 @@ public:
QList
<
ServerInfo_Player
*>
getGameState
(
Server_Player
*
playerWhosAsking
)
const
;
QList
<
ServerInfo_Player
*>
getGameState
(
Server_Player
*
playerWhosAsking
)
const
;
void
sendGameEvent
(
GameEvent
*
event
,
Server_Player
*
exclude
=
0
);
void
sendGameEvent
(
GameEvent
*
event
,
Server_Player
*
exclude
=
0
);
void
sendGameEventContainer
(
GameEventContainer
*
cont
,
Server_Player
*
exclude
=
0
);
void
sendGameEventToPlayer
(
Server_Player
*
player
,
GameEvent
*
event
);
};
};
#endif
#endif
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