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
5544de32
Commit
5544de32
authored
Jan 08, 2011
by
Max-Wilhelm Bruker
Browse files
minor fixes; added round clock
parent
02f2fb97
Changes
9
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/handzone.cpp
View file @
5544de32
...
@@ -67,9 +67,6 @@ void HandZone::reorganizeCards()
...
@@ -67,9 +67,6 @@ void HandZone::reorganizeCards()
qreal
totalWidth
=
boundingRect
().
width
()
-
2
*
xPadding
;
qreal
totalWidth
=
boundingRect
().
width
()
-
2
*
xPadding
;
qreal
cardWidth
=
cards
.
at
(
0
)
->
boundingRect
().
width
();
qreal
cardWidth
=
cards
.
at
(
0
)
->
boundingRect
().
width
();
if
(
cardWidth
*
cardCount
<
totalWidth
)
cardWidth
+=
5
;
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
for
(
int
i
=
0
;
i
<
cardCount
;
i
++
)
{
CardItem
*
c
=
cards
.
at
(
i
);
CardItem
*
c
=
cards
.
at
(
i
);
...
...
cockatrice/src/selectzone.cpp
View file @
5544de32
...
@@ -38,7 +38,8 @@ void SelectZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
...
@@ -38,7 +38,8 @@ void SelectZone::mousePressEvent(QGraphicsSceneMouseEvent *event)
selectionOrigin
=
event
->
pos
();
selectionOrigin
=
event
->
pos
();
static_cast
<
GameScene
*>
(
scene
())
->
startRubberBand
(
event
->
scenePos
());
static_cast
<
GameScene
*>
(
scene
())
->
startRubberBand
(
event
->
scenePos
());
event
->
accept
();
event
->
accept
();
}
}
else
CardZone
::
mousePressEvent
(
event
);
}
}
void
SelectZone
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
void
SelectZone
::
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
)
...
...
cockatrice/src/tab_game.cpp
View file @
5544de32
...
@@ -169,6 +169,8 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
...
@@ -169,6 +169,8 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
cardInfo
=
new
CardInfoWidget
(
CardInfoWidget
::
ModeGameTab
);
cardInfo
=
new
CardInfoWidget
(
CardInfoWidget
::
ModeGameTab
);
playerListWidget
=
new
PlayerListWidget
;
playerListWidget
=
new
PlayerListWidget
;
playerListWidget
->
setFocusPolicy
(
Qt
::
NoFocus
);
playerListWidget
->
setFocusPolicy
(
Qt
::
NoFocus
);
timeElapsedLabel
=
new
QLabel
;
timeElapsedLabel
->
setAlignment
(
Qt
::
AlignCenter
);
messageLog
=
new
MessageLogWidget
;
messageLog
=
new
MessageLogWidget
;
connect
(
messageLog
,
SIGNAL
(
cardNameHovered
(
QString
)),
cardInfo
,
SLOT
(
setCard
(
QString
)));
connect
(
messageLog
,
SIGNAL
(
cardNameHovered
(
QString
)),
cardInfo
,
SLOT
(
setCard
(
QString
)));
connect
(
messageLog
,
SIGNAL
(
showCardInfoPopup
(
QPoint
,
QString
)),
this
,
SLOT
(
showCardInfoPopup
(
QPoint
,
QString
)));
connect
(
messageLog
,
SIGNAL
(
showCardInfoPopup
(
QPoint
,
QString
)),
this
,
SLOT
(
showCardInfoPopup
(
QPoint
,
QString
)));
...
@@ -190,6 +192,7 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
...
@@ -190,6 +192,7 @@ TabGame::TabGame(QList<AbstractClient *> &_clients, int _gameId, const QString &
QVBoxLayout
*
verticalLayout
=
new
QVBoxLayout
;
QVBoxLayout
*
verticalLayout
=
new
QVBoxLayout
;
verticalLayout
->
addWidget
(
cardInfo
);
verticalLayout
->
addWidget
(
cardInfo
);
verticalLayout
->
addWidget
(
playerListWidget
,
1
);
verticalLayout
->
addWidget
(
playerListWidget
,
1
);
verticalLayout
->
addWidget
(
timeElapsedLabel
);
verticalLayout
->
addWidget
(
messageLog
,
5
);
verticalLayout
->
addWidget
(
messageLog
,
5
);
verticalLayout
->
addLayout
(
hLayout
);
verticalLayout
->
addLayout
(
hLayout
);
...
@@ -651,6 +654,13 @@ void TabGame::eventPing(Event_Ping *event, GameEventContext * /*context*/)
...
@@ -651,6 +654,13 @@ void TabGame::eventPing(Event_Ping *event, GameEventContext * /*context*/)
const
QList
<
ServerInfo_PlayerPing
*>
&
pingList
=
event
->
getPingList
();
const
QList
<
ServerInfo_PlayerPing
*>
&
pingList
=
event
->
getPingList
();
for
(
int
i
=
0
;
i
<
pingList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
pingList
.
size
();
++
i
)
playerListWidget
->
updatePing
(
pingList
[
i
]
->
getPlayerId
(),
pingList
[
i
]
->
getPingTime
());
playerListWidget
->
updatePing
(
pingList
[
i
]
->
getPlayerId
(),
pingList
[
i
]
->
getPingTime
());
int
seconds
=
event
->
getSecondsElapsed
();
int
minutes
=
seconds
/
60
;
seconds
-=
minutes
*
60
;
int
hours
=
minutes
/
60
;
minutes
-=
hours
*
60
;
timeElapsedLabel
->
setText
(
QString
::
number
(
hours
).
rightJustified
(
2
,
'0'
)
+
":"
+
QString
::
number
(
minutes
).
rightJustified
(
2
,
'0'
)
+
":"
+
QString
::
number
(
seconds
).
rightJustified
(
2
,
'0'
));
}
}
void
TabGame
::
newCardAdded
(
AbstractCardItem
*
card
)
void
TabGame
::
newCardAdded
(
AbstractCardItem
*
card
)
...
...
cockatrice/src/tab_game.h
View file @
5544de32
...
@@ -99,6 +99,7 @@ private:
...
@@ -99,6 +99,7 @@ private:
CardInfoWidget
*
infoPopup
;
CardInfoWidget
*
infoPopup
;
CardInfoWidget
*
cardInfo
;
CardInfoWidget
*
cardInfo
;
PlayerListWidget
*
playerListWidget
;
PlayerListWidget
*
playerListWidget
;
QLabel
*
timeElapsedLabel
;
MessageLogWidget
*
messageLog
;
MessageLogWidget
*
messageLog
;
QLabel
*
sayLabel
;
QLabel
*
sayLabel
;
QLineEdit
*
sayEdit
;
QLineEdit
*
sayEdit
;
...
...
common/protocol.cpp
View file @
5544de32
...
@@ -414,9 +414,10 @@ Event_PlayerPropertiesChanged::Event_PlayerPropertiesChanged(int _playerId, Serv
...
@@ -414,9 +414,10 @@ Event_PlayerPropertiesChanged::Event_PlayerPropertiesChanged(int _playerId, Serv
insertItem
(
_properties
);
insertItem
(
_properties
);
}
}
Event_Ping
::
Event_Ping
(
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
)
Event_Ping
::
Event_Ping
(
int
_secondsElapsed
,
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
)
:
GameEvent
(
"ping"
,
-
1
)
:
GameEvent
(
"ping"
,
-
1
)
{
{
insertItem
(
new
SerializableItem_Int
(
"seconds_elapsed"
,
_secondsElapsed
));
for
(
int
i
=
0
;
i
<
_pingList
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
_pingList
.
size
();
++
i
)
itemList
.
append
(
_pingList
[
i
]);
itemList
.
append
(
_pingList
[
i
]);
}
}
...
...
common/protocol.h
View file @
5544de32
...
@@ -399,9 +399,10 @@ public:
...
@@ -399,9 +399,10 @@ public:
class
Event_Ping
:
public
GameEvent
{
class
Event_Ping
:
public
GameEvent
{
Q_OBJECT
Q_OBJECT
public:
public:
Event_Ping
(
const
QList
<
ServerInfo_PlayerPing
*>
&
_pingList
=
QList
<
ServerInfo_PlayerPing
*>
());
Event_Ping
(
int
_secondsElapsed
=
-
1
,
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
;
}
int
getSecondsElapsed
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"seconds_elapsed"
))
->
getData
();
}
QList
<
ServerInfo_PlayerPing
*>
getPingList
()
const
{
return
typecastItemList
<
ServerInfo_PlayerPing
*>
();
}
QList
<
ServerInfo_PlayerPing
*>
getPingList
()
const
{
return
typecastItemList
<
ServerInfo_PlayerPing
*>
();
}
};
};
...
...
common/server_cardzone.cpp
View file @
5544de32
...
@@ -119,6 +119,9 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName) co
...
@@ -119,6 +119,9 @@ int Server_CardZone::getFreeGridColumn(int x, int y, const QString &cardName) co
bool
Server_CardZone
::
isColumnStacked
(
int
x
,
int
y
)
const
bool
Server_CardZone
::
isColumnStacked
(
int
x
,
int
y
)
const
{
{
if
(
!
has_coords
)
return
false
;
QMap
<
int
,
Server_Card
*>
coordMap
;
QMap
<
int
,
Server_Card
*>
coordMap
;
for
(
int
i
=
0
;
i
<
cards
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
cards
.
size
();
++
i
)
if
(
cards
[
i
]
->
getY
()
==
y
)
if
(
cards
[
i
]
->
getY
()
==
y
)
...
@@ -129,6 +132,9 @@ bool Server_CardZone::isColumnStacked(int x, int y) const
...
@@ -129,6 +132,9 @@ bool Server_CardZone::isColumnStacked(int x, int y) const
bool
Server_CardZone
::
isColumnEmpty
(
int
x
,
int
y
)
const
bool
Server_CardZone
::
isColumnEmpty
(
int
x
,
int
y
)
const
{
{
if
(
!
has_coords
)
return
true
;
QMap
<
int
,
Server_Card
*>
coordMap
;
QMap
<
int
,
Server_Card
*>
coordMap
;
for
(
int
i
=
0
;
i
<
cards
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
cards
.
size
();
++
i
)
if
(
cards
[
i
]
->
getY
()
==
y
)
if
(
cards
[
i
]
->
getY
()
==
y
)
...
...
common/server_game.cpp
View file @
5544de32
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include
<QDebug>
#include
<QDebug>
Server_Game
::
Server_Game
(
Server_ProtocolHandler
*
_creator
,
int
_gameId
,
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
Server_Room
*
parent
)
Server_Game
::
Server_Game
(
Server_ProtocolHandler
*
_creator
,
int
_gameId
,
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
Server_Room
*
parent
)
:
QObject
(
parent
),
creatorInfo
(
new
ServerInfo_User
(
_creator
->
getUserInfo
())),
gameStarted
(
false
),
gameId
(
_gameId
),
description
(
_description
),
password
(
_password
),
maxPlayers
(
_maxPlayers
),
activePlayer
(
-
1
),
activePhase
(
-
1
),
spectatorsAllowed
(
_spectatorsAllowed
),
spectatorsNeedPassword
(
_spectatorsNeedPassword
),
spectatorsCanTalk
(
_spectatorsCanTalk
),
spectatorsSeeEverything
(
_spectatorsSeeEverything
),
inactivityCounter
(
0
)
:
QObject
(
parent
),
creatorInfo
(
new
ServerInfo_User
(
_creator
->
getUserInfo
())),
gameStarted
(
false
),
gameId
(
_gameId
),
description
(
_description
),
password
(
_password
),
maxPlayers
(
_maxPlayers
),
activePlayer
(
-
1
),
activePhase
(
-
1
),
spectatorsAllowed
(
_spectatorsAllowed
),
spectatorsNeedPassword
(
_spectatorsNeedPassword
),
spectatorsCanTalk
(
_spectatorsCanTalk
),
spectatorsSeeEverything
(
_spectatorsSeeEverything
),
inactivityCounter
(
0
)
,
secondsElapsed
(
0
)
{
{
addPlayer
(
_creator
,
false
,
false
);
addPlayer
(
_creator
,
false
,
false
);
...
@@ -56,6 +56,8 @@ Server_Game::~Server_Game()
...
@@ -56,6 +56,8 @@ Server_Game::~Server_Game()
void
Server_Game
::
pingClockTimeout
()
void
Server_Game
::
pingClockTimeout
()
{
{
++
secondsElapsed
;
QDateTime
now
=
QDateTime
::
currentDateTime
();
QDateTime
now
=
QDateTime
::
currentDateTime
();
QList
<
ServerInfo_PlayerPing
*>
pingList
;
QList
<
ServerInfo_PlayerPing
*>
pingList
;
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
...
@@ -70,7 +72,7 @@ void Server_Game::pingClockTimeout()
...
@@ -70,7 +72,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
(
pingList
));
sendGameEvent
(
new
Event_Ping
(
secondsElapsed
,
pingList
));
const
int
maxTime
=
static_cast
<
Server_Room
*>
(
parent
())
->
getServer
()
->
getMaxGameInactivityTime
();
const
int
maxTime
=
static_cast
<
Server_Room
*>
(
parent
())
->
getServer
()
->
getMaxGameInactivityTime
();
if
(
allPlayersInactive
)
{
if
(
allPlayersInactive
)
{
...
...
common/server_game.h
View file @
5544de32
...
@@ -46,6 +46,7 @@ private:
...
@@ -46,6 +46,7 @@ private:
bool
spectatorsCanTalk
;
bool
spectatorsCanTalk
;
bool
spectatorsSeeEverything
;
bool
spectatorsSeeEverything
;
int
inactivityCounter
;
int
inactivityCounter
;
int
secondsElapsed
;
QTimer
*
pingClock
;
QTimer
*
pingClock
;
signals:
signals:
void
gameClosing
();
void
gameClosing
();
...
...
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