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
13b6a360
Commit
13b6a360
authored
May 27, 2009
by
Max-Wilhelm Bruker
Browse files
minor fixes
parent
748d9bb6
Changes
15
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddragitem.cpp
View file @
13b6a360
...
@@ -15,6 +15,7 @@ CardDragItem::CardDragItem(QGraphicsScene *scene, CardZone *_startZone, QPixmap
...
@@ -15,6 +15,7 @@ CardDragItem::CardDragItem(QGraphicsScene *scene, CardZone *_startZone, QPixmap
setZValue
(
2000000000
);
setZValue
(
2000000000
);
setCacheMode
(
DeviceCoordinateCache
);
setCacheMode
(
DeviceCoordinateCache
);
setCursor
(
Qt
::
ClosedHandCursor
);
if
(
!
parent
)
if
(
!
parent
)
scene
->
addItem
(
this
);
scene
->
addItem
(
this
);
...
...
cockatrice/src/carditem.cpp
View file @
13b6a360
...
@@ -10,8 +10,6 @@
...
@@ -10,8 +10,6 @@
CardItem
::
CardItem
(
CardDatabase
*
_db
,
const
QString
&
_name
,
int
_cardid
,
QGraphicsItem
*
parent
)
CardItem
::
CardItem
(
CardDatabase
*
_db
,
const
QString
&
_name
,
int
_cardid
,
QGraphicsItem
*
parent
)
:
QGraphicsItem
(
parent
),
db
(
_db
),
name
(
_name
),
id
(
_cardid
),
tapped
(
false
),
attacking
(
false
),
facedown
(
false
),
counters
(
0
),
doesntUntap
(
false
),
dragItem
(
NULL
)
:
QGraphicsItem
(
parent
),
db
(
_db
),
name
(
_name
),
id
(
_cardid
),
tapped
(
false
),
attacking
(
false
),
facedown
(
false
),
counters
(
0
),
doesntUntap
(
false
),
dragItem
(
NULL
)
{
{
width
=
CARD_WIDTH
;
height
=
CARD_HEIGHT
;
image
=
db
->
getCard
(
name
)
->
getPixmap
();
image
=
db
->
getCard
(
name
)
->
getPixmap
();
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
setFlag
(
ItemIsSelectable
);
setFlag
(
ItemIsSelectable
);
...
@@ -27,13 +25,11 @@ CardItem::~CardItem()
...
@@ -27,13 +25,11 @@ CardItem::~CardItem()
QRectF
CardItem
::
boundingRect
()
const
QRectF
CardItem
::
boundingRect
()
const
{
{
return
QRectF
(
0
,
0
,
width
,
height
);
return
QRectF
(
0
,
0
,
CARD_WIDTH
,
CARD_HEIGHT
);
}
}
void
CardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
CardItem
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*/
*
widget
*/
)
{
{
Q_UNUSED
(
widget
);
painter
->
save
();
painter
->
save
();
QRectF
foo
=
option
->
matrix
.
mapRect
(
boundingRect
());
QRectF
foo
=
option
->
matrix
.
mapRect
(
boundingRect
());
qDebug
(
QString
(
"%1: w=%2,h=%3"
).
arg
(
name
).
arg
(
foo
.
width
()).
arg
(
foo
.
height
()).
toLatin1
());
qDebug
(
QString
(
"%1: w=%2,h=%3"
).
arg
(
name
).
arg
(
foo
.
width
()).
arg
(
foo
.
height
()).
toLatin1
());
...
@@ -46,7 +42,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
...
@@ -46,7 +42,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter
->
drawPixmap
(
boundingRect
(),
bar
,
bar
.
rect
());
painter
->
drawPixmap
(
boundingRect
(),
bar
,
bar
.
rect
());
if
(
isSelected
())
{
if
(
isSelected
())
{
painter
->
setPen
(
QPen
(
QColor
(
"red"
)));
painter
->
setPen
(
QPen
(
QColor
(
"red"
)));
painter
->
drawRect
(
QRectF
(
1
,
1
,
width
-
2
,
height
-
2
));
painter
->
drawRect
(
QRectF
(
1
,
1
,
CARD_WIDTH
-
2
,
CARD_HEIGHT
-
2
));
}
}
if
(
counters
)
{
if
(
counters
)
{
painter
->
setFont
(
QFont
(
"Times"
,
32
,
QFont
::
Bold
));
painter
->
setFont
(
QFont
(
"Times"
,
32
,
QFont
::
Bold
));
...
@@ -69,7 +65,7 @@ void CardItem::setTapped(bool _tapped)
...
@@ -69,7 +65,7 @@ void CardItem::setTapped(bool _tapped)
{
{
tapped
=
_tapped
;
tapped
=
_tapped
;
if
(
tapped
)
if
(
tapped
)
setTransform
(
QTransform
().
translate
((
float
)
width
/
2
,
(
float
)
height
/
2
).
rotate
(
90
).
translate
((
float
)
-
width
/
2
,
(
float
)
-
height
/
2
));
setTransform
(
QTransform
().
translate
((
float
)
CARD_WIDTH
/
2
,
(
float
)
CARD_HEIGHT
/
2
).
rotate
(
90
).
translate
((
float
)
-
CARD_WIDTH
/
2
,
(
float
)
-
CARD_HEIGHT
/
2
));
else
else
setTransform
(
QTransform
());
setTransform
(
QTransform
());
update
(
boundingRect
());
update
(
boundingRect
());
...
@@ -161,19 +157,16 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -161,19 +157,16 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
CardDragItem
*
drag
=
new
CardDragItem
(
scene
(),
(
CardZone
*
)
parentItem
(),
c
->
getImage
(),
c
->
getId
(),
QPointF
(),
false
,
dragItem
);
CardDragItem
*
drag
=
new
CardDragItem
(
scene
(),
(
CardZone
*
)
parentItem
(),
c
->
getImage
(),
c
->
getId
(),
QPointF
(),
false
,
dragItem
);
drag
->
setPos
(
c
->
pos
()
-
pos
());
drag
->
setPos
(
c
->
pos
()
-
pos
());
}
}
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
}
}
void
CardItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
CardItem
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*/
*
event
*/
)
{
{
Q_UNUSED
(
event
);
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
}
}
void
CardItem
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
CardItem
::
mouseDoubleClickEvent
(
QGraphicsSceneMouseEvent
*
event
)
{
{
Q_UNUSED
(
event
);
if
(
!
isSelected
())
{
if
(
!
isSelected
())
{
// Unselect all items, then select this one
// Unselect all items, then select this one
scene
()
->
setSelectionArea
(
QPainterPath
());
scene
()
->
setSelectionArea
(
QPainterPath
());
...
...
cockatrice/src/carditem.h
View file @
13b6a360
...
@@ -34,7 +34,6 @@ private:
...
@@ -34,7 +34,6 @@ private:
CardDatabase
*
db
;
CardDatabase
*
db
;
QString
name
;
QString
name
;
int
id
;
int
id
;
int
width
,
height
;
QPixmap
*
image
;
QPixmap
*
image
;
bool
tapped
;
bool
tapped
;
bool
attacking
;
bool
attacking
;
...
...
cockatrice/src/client.cpp
View file @
13b6a360
...
@@ -2,13 +2,12 @@
...
@@ -2,13 +2,12 @@
#include
"client.h"
#include
"client.h"
Client
::
Client
(
QObject
*
parent
)
Client
::
Client
(
QObject
*
parent
)
:
QObject
(
parent
),
MsgId
(
0
)
:
QObject
(
parent
),
status
(
StatusDisconnected
),
MsgId
(
0
)
{
{
timer
=
new
QTimer
(
this
);
timer
=
new
QTimer
(
this
);
timer
->
setInterval
(
1000
);
timer
->
setInterval
(
1000
);
connect
(
timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
checkTimeout
()));
connect
(
timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
checkTimeout
()));
status
=
StatusDisconnected
;
socket
=
new
QTcpSocket
(
this
);
socket
=
new
QTcpSocket
(
this
);
socket
->
setTextModeEnabled
(
true
);
socket
->
setTextModeEnabled
(
true
);
connect
(
socket
,
SIGNAL
(
connected
()),
this
,
SLOT
(
slotConnected
()));
connect
(
socket
,
SIGNAL
(
connected
()),
this
,
SLOT
(
slotConnected
()));
...
@@ -19,7 +18,6 @@ Client::Client(QObject *parent)
...
@@ -19,7 +18,6 @@ Client::Client(QObject *parent)
Client
::~
Client
()
Client
::~
Client
()
{
{
disconnectFromServer
();
disconnectFromServer
();
delete
socket
;
}
}
void
Client
::
checkTimeout
()
void
Client
::
checkTimeout
()
...
@@ -54,11 +52,8 @@ void Client::slotConnected()
...
@@ -54,11 +52,8 @@ void Client::slotConnected()
void
Client
::
readLine
()
void
Client
::
readLine
()
{
{
QString
line
;
while
(
socket
->
canReadLine
())
{
for
(;;)
{
QString
line
=
QString
(
socket
->
readLine
()).
trimmed
();
if
(
!
socket
->
canReadLine
())
break
;
line
=
QString
(
socket
->
readLine
()).
trimmed
();
if
(
line
.
isNull
())
if
(
line
.
isNull
())
break
;
break
;
...
@@ -67,9 +62,9 @@ void Client::readLine()
...
@@ -67,9 +62,9 @@ void Client::readLine()
QString
prefix
=
values
.
takeFirst
();
QString
prefix
=
values
.
takeFirst
();
// prefix is one of {welcome, private, public, resp, list_games, list_players, list_counters, list_zones, dump_zone}
// prefix is one of {welcome, private, public, resp, list_games, list_players, list_counters, list_zones, dump_zone}
if
(
!
(
prefix
.
compare
(
"private"
)
&&
prefix
.
compare
(
"public"
)))
{
if
(
!
(
prefix
.
compare
(
"private"
)
&&
prefix
.
compare
(
"public"
)))
{
ServerEventData
*
event
=
new
ServerEventData
(
line
);
ServerEventData
event
(
line
);
if
(
event
->
getEventType
()
==
eventPlayerId
)
{
if
(
event
.
getEventType
()
==
eventPlayerId
)
{
QStringList
data
=
event
->
getEventData
();
QStringList
data
=
event
.
getEventData
();
if
(
data
.
size
()
!=
2
)
{
if
(
data
.
size
()
!=
2
)
{
// XXX
// XXX
}
}
...
@@ -78,7 +73,6 @@ void Client::readLine()
...
@@ -78,7 +73,6 @@ void Client::readLine()
if
(
!
ok
)
{
if
(
!
ok
)
{
// XXX
// XXX
}
}
delete
event
;
emit
playerIdReceived
(
id
,
data
[
1
]);
emit
playerIdReceived
(
id
,
data
[
1
]);
}
else
}
else
emit
gameEvent
(
event
);
emit
gameEvent
(
event
);
...
...
cockatrice/src/client.h
View file @
13b6a360
...
@@ -32,7 +32,7 @@ signals:
...
@@ -32,7 +32,7 @@ signals:
void
zoneDumpReceived
(
int
commandId
,
QList
<
ServerZoneCard
*>
cards
);
void
zoneDumpReceived
(
int
commandId
,
QList
<
ServerZoneCard
*>
cards
);
void
responseReceived
(
ServerResponse
*
response
);
void
responseReceived
(
ServerResponse
*
response
);
void
playerIdReceived
(
int
id
,
QString
name
);
void
playerIdReceived
(
int
id
,
QString
name
);
void
gameEvent
(
ServerEventData
*
msg
);
void
gameEvent
(
const
ServerEventData
&
msg
);
void
serverTimeout
();
void
serverTimeout
();
void
logSocketError
(
const
QString
&
errorString
);
void
logSocketError
(
const
QString
&
errorString
);
...
@@ -57,7 +57,7 @@ private:
...
@@ -57,7 +57,7 @@ private:
public:
public:
Client
(
QObject
*
parent
=
0
);
Client
(
QObject
*
parent
=
0
);
~
Client
();
~
Client
();
ProtocolStatus
getStatus
()
{
return
status
;
}
ProtocolStatus
getStatus
()
const
{
return
status
;
}
QString
peerName
()
const
{
return
socket
->
peerName
();
}
QString
peerName
()
const
{
return
socket
->
peerName
();
}
void
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
playername
,
const
QString
&
password
);
void
connectToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
playername
,
const
QString
&
password
);
...
...
cockatrice/src/game.cpp
View file @
13b6a360
...
@@ -18,7 +18,7 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
...
@@ -18,7 +18,7 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
QRectF
sr
=
scene
->
sceneRect
();
QRectF
sr
=
scene
->
sceneRect
();
localPlayer
=
addPlayer
(
playerId
,
playerName
,
QPointF
(
0
,
sr
.
y
()
+
sr
.
height
()
/
2
+
2
),
true
);
localPlayer
=
addPlayer
(
playerId
,
playerName
,
QPointF
(
0
,
sr
.
y
()
+
sr
.
height
()
/
2
+
2
),
true
);
connect
(
client
,
SIGNAL
(
gameEvent
(
ServerEventData
*
)),
this
,
SLOT
(
gameEvent
(
ServerEventData
*
)));
connect
(
client
,
SIGNAL
(
gameEvent
(
const
ServerEventData
&
)),
this
,
SLOT
(
gameEvent
(
const
ServerEventData
&
)));
connect
(
client
,
SIGNAL
(
playerListReceived
(
QList
<
ServerPlayer
*>
)),
this
,
SLOT
(
playerListReceived
(
QList
<
ServerPlayer
*>
)));
connect
(
client
,
SIGNAL
(
playerListReceived
(
QList
<
ServerPlayer
*>
)),
this
,
SLOT
(
playerListReceived
(
QList
<
ServerPlayer
*>
)));
aUntapAll
=
new
QAction
(
tr
(
"&Untap all permanents"
),
this
);
aUntapAll
=
new
QAction
(
tr
(
"&Untap all permanents"
),
this
);
...
@@ -154,36 +154,38 @@ void Game::restartGameDialog()
...
@@ -154,36 +154,38 @@ void Game::restartGameDialog()
dlgStartGame
->
show
();
dlgStartGame
->
show
();
}
}
void
Game
::
gameEvent
(
ServerEventData
*
msg
)
void
Game
::
gameEvent
(
const
ServerEventData
&
msg
)
{
{
qDebug
(
QString
(
"game::gameEvent: public=%1, player=%2, name=%3, type=%4, data=%5"
).
arg
(
msg
->
getPublic
()).
arg
(
msg
->
getPlayerId
()).
arg
(
msg
->
getPlayerName
()).
arg
(
msg
->
getEventType
()).
arg
(
msg
->
getEventData
().
join
(
"/"
)).
toLatin1
());
qDebug
(
QString
(
"game::gameEvent: public=%1, player=%2, name=%3, type=%4, data=%5"
).
arg
(
msg
.
getPublic
()).
arg
(
msg
.
getPlayerId
()).
arg
(
msg
.
getPlayerName
()).
arg
(
msg
.
getEventType
()).
arg
(
msg
.
getEventData
().
join
(
"/"
)).
toLatin1
());
if
(
!
msg
->
getPublic
())
if
(
!
msg
.
getPublic
())
localPlayer
->
gameEvent
(
msg
);
localPlayer
->
gameEvent
(
msg
);
else
{
else
{
Player
*
p
=
players
.
findPlayer
(
msg
->
getPlayerId
());
Player
*
p
=
players
.
findPlayer
(
msg
.
getPlayerId
());
if
(
!
p
)
{
if
(
!
p
)
{
// XXX
// XXX
}
}
switch
(
msg
->
getEventType
())
{
switch
(
msg
.
getEventType
())
{
case
eventSay
:
case
eventSay
:
emit
logSay
(
p
->
getName
(),
msg
->
getEventData
()[
0
]);
emit
logSay
(
p
->
getName
(),
msg
.
getEventData
()[
0
]);
break
;
break
;
case
eventJoin
:
{
case
eventJoin
:
{
emit
logJoin
(
msg
->
getPlayerName
());
emit
logJoin
(
msg
.
getPlayerName
());
addPlayer
(
msg
->
getPlayerId
(),
msg
->
getPlayerName
(),
QPointF
(
0
,
0
),
false
);
addPlayer
(
msg
.
getPlayerId
(),
msg
.
getPlayerName
(),
QPointF
(
0
,
0
),
false
);
break
;
break
;
}
}
case
eventLeave
:
case
eventLeave
:
emit
logLeave
(
msg
->
getPlayerName
());
emit
logLeave
(
msg
.
getPlayerName
());
// XXX Spieler natürlich noch rauswerfen
// XXX Spieler natürlich noch rauswerfen
break
;
break
;
case
eventReadyStart
:
case
eventReadyStart
:
if
(
started
)
{
if
(
started
)
{
started
=
false
;
started
=
false
;
emit
logReadyStart
(
p
->
getName
());
emit
logReadyStart
(
p
->
getName
());
if
(
!
p
->
getLocal
())
if
(
!
p
->
getLocal
())
{
// XXX Zoneviews schließen
restartGameDialog
();
restartGameDialog
();
}
}
}
break
;
break
;
case
eventGameStart
:
case
eventGameStart
:
...
@@ -194,7 +196,7 @@ void Game::gameEvent(ServerEventData *msg)
...
@@ -194,7 +196,7 @@ void Game::gameEvent(ServerEventData *msg)
emit
logShuffle
(
p
->
getName
());
emit
logShuffle
(
p
->
getName
());
break
;
break
;
case
eventRollDice
:
{
case
eventRollDice
:
{
QStringList
data
=
msg
->
getEventData
();
QStringList
data
=
msg
.
getEventData
();
int
sides
=
data
[
0
].
toInt
();
int
sides
=
data
[
0
].
toInt
();
int
roll
=
data
[
1
].
toInt
();
int
roll
=
data
[
1
].
toInt
();
emit
logRollDice
(
p
->
getName
(),
sides
,
roll
);
emit
logRollDice
(
p
->
getName
(),
sides
,
roll
);
...
@@ -217,19 +219,19 @@ void Game::gameEvent(ServerEventData *msg)
...
@@ -217,19 +219,19 @@ void Game::gameEvent(ServerEventData *msg)
break
;
break
;
}
}
case
eventDumpZone
:
{
case
eventDumpZone
:
{
QStringList
data
=
msg
->
getEventData
();
QStringList
data
=
msg
.
getEventData
();
emit
logDumpZone
(
p
->
getName
(),
data
[
1
],
players
.
findPlayer
(
data
[
0
].
toInt
())
->
getName
(),
data
[
2
].
toInt
());
emit
logDumpZone
(
p
->
getName
(),
data
[
1
],
players
.
findPlayer
(
data
[
0
].
toInt
())
->
getName
(),
data
[
2
].
toInt
());
break
;
break
;
}
}
case
eventMoveCard
:
{
case
eventMoveCard
:
{
if
(
msg
->
getPlayerId
()
==
localPlayer
->
getId
())
if
(
msg
.
getPlayerId
()
==
localPlayer
->
getId
())
break
;
break
;
p
->
gameEvent
(
msg
);
p
->
gameEvent
(
msg
);
break
;
break
;
}
}
case
eventDraw
:
{
case
eventDraw
:
{
emit
logDraw
(
p
->
getName
(),
msg
->
getEventData
()[
0
].
toInt
());
emit
logDraw
(
p
->
getName
(),
msg
.
getEventData
()[
0
].
toInt
());
if
(
msg
->
getPlayerId
()
==
localPlayer
->
getId
())
if
(
msg
.
getPlayerId
()
==
localPlayer
->
getId
())
break
;
break
;
p
->
gameEvent
(
msg
);
p
->
gameEvent
(
msg
);
break
;
break
;
...
...
cockatrice/src/game.h
View file @
13b6a360
...
@@ -47,7 +47,7 @@ private slots:
...
@@ -47,7 +47,7 @@ private slots:
void
actSetCounters
();
void
actSetCounters
();
void
actRearrange
();
void
actRearrange
();
void
gameEvent
(
ServerEventData
*
msg
);
void
gameEvent
(
const
ServerEventData
&
msg
);
void
playerListReceived
(
QList
<
ServerPlayer
*>
playerList
);
void
playerListReceived
(
QList
<
ServerPlayer
*>
playerList
);
void
readyStart
();
void
readyStart
();
signals:
signals:
...
...
cockatrice/src/gravezone.cpp
View file @
13b6a360
...
@@ -10,6 +10,7 @@ GraveZone::GraveZone(Player *_p, QGraphicsItem *parent)
...
@@ -10,6 +10,7 @@ GraveZone::GraveZone(Player *_p, QGraphicsItem *parent)
{
{
cards
=
new
CardList
(
true
);
cards
=
new
CardList
(
true
);
setCacheMode
(
DeviceCoordinateCache
);
// Do not move this line to the parent constructor!
setCacheMode
(
DeviceCoordinateCache
);
// Do not move this line to the parent constructor!
setCursor
(
Qt
::
OpenHandCursor
);
}
}
QRectF
GraveZone
::
boundingRect
()
const
QRectF
GraveZone
::
boundingRect
()
const
...
@@ -19,6 +20,7 @@ QRectF GraveZone::boundingRect() const
...
@@ -19,6 +20,7 @@ QRectF GraveZone::boundingRect() const
void
GraveZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
void
GraveZone
::
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
)
{
{
qDebug
(
"grave: paint"
);
if
(
!
cards
->
isEmpty
())
if
(
!
cards
->
isEmpty
())
cards
->
at
(
0
)
->
paint
(
painter
,
option
,
widget
);
cards
->
at
(
0
)
->
paint
(
painter
,
option
,
widget
);
...
@@ -46,6 +48,7 @@ void GraveZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/
...
@@ -46,6 +48,7 @@ void GraveZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &/
void
GraveZone
::
reorganizeCards
()
void
GraveZone
::
reorganizeCards
()
{
{
qDebug
(
QString
(
"grave: reorganize, x=%1, y=%2, w=%3, h=%4"
).
arg
(
boundingRect
().
x
()).
arg
(
boundingRect
().
y
()).
arg
(
boundingRect
().
width
()).
arg
(
boundingRect
().
height
()).
toLatin1
());
update
(
boundingRect
());
update
(
boundingRect
());
}
}
...
...
cockatrice/src/player.cpp
View file @
13b6a360
...
@@ -143,10 +143,10 @@ void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QStri
...
@@ -143,10 +143,10 @@ void Player::setCardAttrHelper(CardItem *card, const QString &aname, const QStri
}
}
}
}
void
Player
::
gameEvent
(
ServerEventData
*
event
)
void
Player
::
gameEvent
(
const
ServerEventData
&
event
)
{
{
QStringList
data
=
event
->
getEventData
();
QStringList
data
=
event
.
getEventData
();
switch
(
event
->
getEventType
())
{
switch
(
event
.
getEventType
())
{
case
eventSetupZones
:
{
case
eventSetupZones
:
{
// XXX Life counter
// XXX Life counter
int
deck_cards
=
data
[
0
].
toInt
();
int
deck_cards
=
data
[
0
].
toInt
();
...
@@ -186,7 +186,7 @@ void Player::gameEvent(ServerEventData *event)
...
@@ -186,7 +186,7 @@ void Player::gameEvent(ServerEventData *event)
case
eventDraw
:
{
case
eventDraw
:
{
CardZone
*
deck
=
zones
.
findZone
(
"deck"
);
CardZone
*
deck
=
zones
.
findZone
(
"deck"
);
CardZone
*
hand
=
zones
.
findZone
(
"hand"
);
CardZone
*
hand
=
zones
.
findZone
(
"hand"
);
if
(
!
event
->
getPublic
())
{
if
(
!
event
.
getPublic
())
{
hand
->
addCard
(
deck
->
takeCard
(
0
,
data
[
0
].
toInt
(),
data
[
1
]),
true
,
-
1
);
hand
->
addCard
(
deck
->
takeCard
(
0
,
data
[
0
].
toInt
(),
data
[
1
]),
true
,
-
1
);
}
else
{
}
else
{
int
number
=
data
[
0
].
toInt
();
int
number
=
data
[
0
].
toInt
();
...
...
cockatrice/src/player.h
View file @
13b6a360
...
@@ -62,7 +62,7 @@ public:
...
@@ -62,7 +62,7 @@ public:
QString
getName
()
const
{
return
name
;
}
QString
getName
()
const
{
return
name
;
}
bool
getLocal
()
const
{
return
local
;
}
bool
getLocal
()
const
{
return
local
;
}
const
ZoneList
*
getZones
()
const
{
return
&
zones
;
}
const
ZoneList
*
getZones
()
const
{
return
&
zones
;
}
void
gameEvent
(
ServerEventData
*
event
);
void
gameEvent
(
const
ServerEventData
&
event
);
void
hoverCardEvent
(
CardItem
*
card
);
void
hoverCardEvent
(
CardItem
*
card
);
CardDatabase
*
getDb
()
const
{
return
db
;
}
CardDatabase
*
getDb
()
const
{
return
db
;
}
void
showCardMenu
(
const
QPoint
&
p
);
void
showCardMenu
(
const
QPoint
&
p
);
...
...
cockatrice/src/rfgzone.cpp
View file @
13b6a360
...
@@ -10,6 +10,7 @@ RfgZone::RfgZone(Player *_p, QGraphicsItem *parent)
...
@@ -10,6 +10,7 @@ RfgZone::RfgZone(Player *_p, QGraphicsItem *parent)
{
{
cards
=
new
CardList
(
true
);
cards
=
new
CardList
(
true
);
setCacheMode
(
DeviceCoordinateCache
);
// Do not move this line to the parent constructor!
setCacheMode
(
DeviceCoordinateCache
);
// Do not move this line to the parent constructor!
setCursor
(
Qt
::
OpenHandCursor
);
}
}
QRectF
RfgZone
::
boundingRect
()
const
QRectF
RfgZone
::
boundingRect
()
const
...
...
cockatrice/src/servereventdata.h
View file @
13b6a360
...
@@ -45,11 +45,11 @@ private:
...
@@ -45,11 +45,11 @@ private:
QStringList
EventData
;
QStringList
EventData
;
public:
public:
ServerEventData
(
const
QString
&
line
);
ServerEventData
(
const
QString
&
line
);
bool
getPublic
()
{
return
IsPublic
;
}
bool
getPublic
()
const
{
return
IsPublic
;
}
int
getPlayerId
()
{
return
PlayerId
;
}
int
getPlayerId
()
const
{
return
PlayerId
;
}
QString
getPlayerName
()
{
return
PlayerName
;
}
QString
getPlayerName
()
const
{
return
PlayerName
;
}
ServerEventType
getEventType
()
{
return
EventType
;
}
ServerEventType
getEventType
()
const
{
return
EventType
;
}
QStringList
getEventData
()
{
return
EventData
;
}
QStringList
getEventData
()
const
{
return
EventData
;
}
};
};
#endif
#endif
cockatrice/src/servergame.h
View file @
13b6a360
...
@@ -12,12 +12,12 @@ private:
...
@@ -12,12 +12,12 @@ private:
public:
public:
ServerGame
(
int
_gameId
,
const
QString
&
_creator
,
const
QString
&
_description
,
bool
_hasPassword
,
unsigned
char
_playerCount
,
unsigned
char
_maxPlayers
)
ServerGame
(
int
_gameId
,
const
QString
&
_creator
,
const
QString
&
_description
,
bool
_hasPassword
,
unsigned
char
_playerCount
,
unsigned
char
_maxPlayers
)
:
gameId
(
_gameId
),
creator
(
_creator
),
description
(
_description
),
hasPassword
(
_hasPassword
),
playerCount
(
_playerCount
),
maxPlayers
(
_maxPlayers
)
{
}
:
gameId
(
_gameId
),
creator
(
_creator
),
description
(
_description
),
hasPassword
(
_hasPassword
),
playerCount
(
_playerCount
),
maxPlayers
(
_maxPlayers
)
{
}
int
getGameId
()
{
return
gameId
;
}
int
getGameId
()
const
{
return
gameId
;
}
QString
getCreator
()
{
return
creator
;
}
QString
getCreator
()
const
{
return
creator
;
}
QString
getDescription
()
{
return
description
;
}
QString
getDescription
()
const
{
return
description
;
}
bool
getHasPassword
()
{
return
hasPassword
;
}
bool
getHasPassword
()
const
{
return
hasPassword
;
}
unsigned
char
getPlayerCount
()
{
return
playerCount
;
}
unsigned
char
getPlayerCount
()
const
{
return
playerCount
;
}
unsigned
char
getMaxPlayers
()
{
return
maxPlayers
;
}
unsigned
char
getMaxPlayers
()
const
{
return
maxPlayers
;
}
};
};
#endif
#endif
cockatrice/src/serverplayer.h
View file @
13b6a360
...
@@ -10,8 +10,8 @@ private:
...
@@ -10,8 +10,8 @@ private:
public:
public:
ServerPlayer
(
int
_PlayerId
,
const
QString
&
_name
)
ServerPlayer
(
int
_PlayerId
,
const
QString
&
_name
)
:
PlayerId
(
_PlayerId
),
name
(
_name
)
{
}
:
PlayerId
(
_PlayerId
),
name
(
_name
)
{
}
int
getPlayerId
()
{
return
PlayerId
;
}
int
getPlayerId
()
const
{
return
PlayerId
;
}
QString
getName
()
{
return
name
;
}
QString
getName
()
const
{
return
name
;
}
};
};
#endif
#endif
cockatrice/src/serverresponse.h
View file @
13b6a360
...
@@ -14,9 +14,9 @@ private:
...
@@ -14,9 +14,9 @@ private:
public:
public:
ServerResponse
(
int
_msgId
,
bool
_ok
,
ServerErrorMessage
_message
)
ServerResponse
(
int
_msgId
,
bool
_ok
,
ServerErrorMessage
_message
)
:
msgId
(
_msgId
),
ok
(
_ok
),
message
(
_message
)
{
}
:
msgId
(
_msgId
),
ok
(
_ok
),
message
(
_message
)
{
}
int
getMsgId
()
{
return
msgId
;
}
int
getMsgId
()
const
{
return
msgId
;
}
bool
getOk
()
{
return
ok
;
}
bool
getOk
()
const
{
return
ok
;
}
ServerErrorMessage
getMessage
()
{
return
message
;
}
ServerErrorMessage
getMessage
()
const
{
return
message
;
}
};
};
#endif
#endif
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