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
d5c62896
Commit
d5c62896
authored
Jan 01, 2012
by
Max-Wilhelm Bruker
Browse files
PB: everything compiles except for deck storage
parent
695fde75
Changes
51
Hide whitespace changes
Inline
Side-by-side
common/.directory
View file @
d5c62896
[Dolphin]
Timestamp=2009,10,26,13,45,44
ViewMode=1
Timestamp=2011,12,31,17,13,2
Version=2
[Settings]
ShowDotFiles=true
common/color.h
View file @
d5c62896
...
...
@@ -7,32 +7,29 @@
#include
"pb/color.pb.h"
class
Color
{
private:
int
value
;
public:
Color
(
const
color
&
other
)
:
value
(
other
.
r
()
*
65536
+
other
.
g
()
*
256
+
other
.
b
())
{
}
// TEMPORARY HACK
Color
(
int
_value
=
0
)
:
value
(
_value
)
{
}
Color
(
int
r
,
int
g
,
int
b
)
:
value
(
r
*
65536
+
g
*
256
+
b
)
{
}
int
getValue
()
const
{
return
value
;
}
#ifdef QT_GUI_LIB
Color
(
const
QColor
&
_color
)
{
value
=
_color
.
red
()
*
65536
+
_color
.
green
()
*
256
+
_color
.
blue
();
}
QColor
getQColor
()
const
{
return
QColor
(
value
/
65536
,
(
value
%
65536
)
/
256
,
value
%
256
);
}
inline
QColor
convertColorToQColor
(
const
color
&
c
)
{
return
QColor
(
c
.
r
(),
c
.
g
(),
c
.
b
());
}
inline
color
convertQColorToColor
(
const
QColor
&
c
)
{
color
result
;
result
.
set_r
(
c
.
red
());
result
.
set_g
(
c
.
green
());
result
.
set_b
(
c
.
blue
());
return
result
;
}
#endif
color
get_color
()
const
// HACK
{
color
c
;
c
.
set_r
(
value
/
65536
)
;
c
.
set_g
((
value
%
65536
)
/
256
);
c
.
set_b
(
value
%
256
);
re
turn
c
;
}
}
;
inline
color
makeColor
(
int
r
,
int
g
,
int
b
)
{
c
olor
result
;
result
.
set_r
(
r
);
result
.
set_g
(
g
);
re
sult
.
set_b
(
b
)
;
return
result
;
}
#endif
\ No newline at end of file
common/pb/proto/event_move_card.proto
View file @
d5c62896
...
...
@@ -4,14 +4,14 @@ message Event_MoveCard {
extend
GameEvent
{
optional
Event_MoveCard
ext
=
2009
;
}
optional
sint32
card_id
=
1
;
optional
sint32
card_id
=
1
[
default
=
-
1
]
;
optional
string
card_name
=
2
;
optional
string
start_zone
=
3
;
optional
sint32
position
=
4
;
optional
sint32
target_player_id
=
5
;
optional
sint32
position
=
4
[
default
=
-
1
]
;
optional
sint32
target_player_id
=
5
[
default
=
-
1
]
;
optional
string
target_zone
=
6
;
optional
sint32
x
=
7
;
optional
sint32
y
=
8
;
optional
sint32
new_card_id
=
9
;
optional
sint32
x
=
7
[
default
=
-
1
]
;
optional
sint32
y
=
8
[
default
=
-
1
]
;
optional
sint32
new_card_id
=
9
[
default
=
-
1
]
;
optional
bool
face_down
=
10
;
}
common/pb/proto/game_event.proto
View file @
d5c62896
...
...
@@ -31,6 +31,6 @@ message GameEvent {
DUMP_ZONE
=
2018
;
STOP_DUMP_ZONE
=
2019
;
}
optional
sint32
player_id
=
1
;
optional
sint32
player_id
=
1
[
default
=
-
1
]
;
extensions
100
to
max
;
}
common/serializable_item.cpp
View file @
d5c62896
...
...
@@ -163,21 +163,6 @@ void SerializableItem_Bool::writeElement(QXmlStreamWriter *xml)
xml
->
writeCharacters
(
data
?
"1"
:
"0"
);
}
bool
SerializableItem_Color
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
{
bool
ok
;
int
colorValue
=
xml
->
text
().
toString
().
toInt
(
&
ok
);
data
=
ok
?
Color
(
colorValue
)
:
Color
();
}
return
SerializableItem
::
readElement
(
xml
);
}
void
SerializableItem_Color
::
writeElement
(
QXmlStreamWriter
*
xml
)
{
xml
->
writeCharacters
(
QString
::
number
(
data
.
getValue
()));
}
bool
SerializableItem_DateTime
::
readElement
(
QXmlStreamReader
*
xml
)
{
if
(
xml
->
isCharacters
()
&&
!
xml
->
isWhitespace
())
{
...
...
common/serializable_item.h
View file @
d5c62896
...
...
@@ -122,20 +122,6 @@ public:
bool
isEmpty
()
const
{
return
data
==
false
;
}
};
class
SerializableItem_Color
:
public
SerializableItem
{
private:
Color
data
;
protected:
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
public:
SerializableItem_Color
(
const
QString
&
_itemType
,
const
Color
&
_data
=
Color
())
:
SerializableItem
(
_itemType
),
data
(
_data
)
{
}
const
Color
&
getData
()
{
return
data
;
}
void
setData
(
const
Color
&
_data
)
{
data
=
_data
;
}
bool
isEmpty
()
const
{
return
data
.
getValue
()
==
0
;
}
};
class
SerializableItem_DateTime
:
public
SerializableItem
{
private:
QDateTime
data
;
...
...
common/server_arrow.h
View file @
d5c62896
#ifndef SERVER_ARROW_H
#define SERVER_ARROW_H
#include
"color.h"
#include
"
pb/
color.
pb.
h"
class
Server_Card
;
class
Server_ArrowTarget
;
...
...
@@ -11,14 +11,14 @@ private:
int
id
;
Server_Card
*
startCard
;
Server_ArrowTarget
*
targetItem
;
C
olor
c
olor
;
c
olor
arrowC
olor
;
public:
Server_Arrow
(
int
_id
,
Server_Card
*
_startCard
,
Server_ArrowTarget
*
_targetItem
,
const
C
olor
&
_
c
olor
)
:
id
(
_id
),
startCard
(
_startCard
),
targetItem
(
_targetItem
),
color
(
_c
olor
)
{
}
Server_Arrow
(
int
_id
,
Server_Card
*
_startCard
,
Server_ArrowTarget
*
_targetItem
,
const
c
olor
&
_
arrowC
olor
)
:
id
(
_id
),
startCard
(
_startCard
),
targetItem
(
_targetItem
),
arrowColor
(
_arrowC
olor
)
{
}
int
getId
()
const
{
return
id
;
}
Server_Card
*
getStartCard
()
const
{
return
startCard
;
}
Server_ArrowTarget
*
getTargetItem
()
const
{
return
targetItem
;
}
const
C
olor
&
getColor
()
const
{
return
c
olor
;
}
const
c
olor
&
getColor
()
const
{
return
arrowC
olor
;
}
};
#endif
common/server_counter.h
View file @
d5c62896
...
...
@@ -21,21 +21,21 @@
#define SERVER_COUNTER_H
#include
<QString>
#include
"color.h"
#include
"
pb/
color.
pb.
h"
class
Server_Counter
{
protected:
int
id
;
QString
name
;
C
olor
color
;
c
olor
co
unterCo
lor
;
int
radius
;
int
count
;
public:
Server_Counter
(
int
_id
,
const
QString
&
_name
,
const
C
olor
&
_color
,
int
_radius
,
int
_count
=
0
)
:
id
(
_id
),
name
(
_name
),
co
lor
(
_c
olor
),
radius
(
_radius
),
count
(
_count
)
{
}
Server_Counter
(
int
_id
,
const
QString
&
_name
,
const
c
olor
&
_co
unterCo
lor
,
int
_radius
,
int
_count
=
0
)
:
id
(
_id
),
name
(
_name
),
co
unterColor
(
_counterC
olor
),
radius
(
_radius
),
count
(
_count
)
{
}
~
Server_Counter
()
{
}
int
getId
()
const
{
return
id
;
}
QString
getName
()
const
{
return
name
;
}
C
olor
getColor
()
const
{
return
color
;
}
const
c
olor
&
getColor
()
const
{
return
co
unterCo
lor
;
}
int
getRadius
()
const
{
return
radius
;
}
int
getCount
()
const
{
return
count
;
}
void
setCount
(
int
_count
)
{
count
=
_count
;
}
...
...
common/server_game.cpp
View file @
d5c62896
...
...
@@ -460,7 +460,8 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
ServerInfo_Player
playerInfo
;
playerInfo
.
mutable_properties
()
->
CopyFrom
(
player
->
getProperties
());
if
(
player
==
playerWhosAsking
)
playerInfo
.
set_deck_list
(
player
->
getDeck
()
->
writeToString_Native
().
toStdString
());
if
(
player
->
getDeck
())
playerInfo
.
set_deck_list
(
player
->
getDeck
()
->
writeToString_Native
().
toStdString
());
QList
<
ServerInfo_Arrow
*>
arrowList
;
QMapIterator
<
int
,
Server_Arrow
*>
arrowIterator
(
player
->
getArrows
());
...
...
@@ -472,7 +473,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
arrowInfo
->
set_start_player_id
(
arrow
->
getStartCard
()
->
getZone
()
->
getPlayer
()
->
getPlayerId
());
arrowInfo
->
set_start_zone
(
arrow
->
getStartCard
()
->
getZone
()
->
getName
().
toStdString
());
arrowInfo
->
set_start_card_id
(
arrow
->
getStartCard
()
->
getId
());
arrowInfo
->
mutable_arrow_color
()
->
CopyFrom
(
arrow
->
getColor
()
.
get_color
()
);
arrowInfo
->
mutable_arrow_color
()
->
CopyFrom
(
arrow
->
getColor
());
if
(
targetCard
)
{
arrowInfo
->
set_target_player_id
(
targetCard
->
getZone
()
->
getPlayer
()
->
getPlayerId
());
arrowInfo
->
set_target_zone
(
targetCard
->
getZone
()
->
getName
().
toStdString
());
...
...
@@ -487,7 +488,7 @@ QList<ServerInfo_Player> Server_Game::getGameState(Server_Player *playerWhosAski
ServerInfo_Counter
*
counterInfo
=
playerInfo
.
add_counter_list
();
counterInfo
->
set_id
(
counter
->
getId
());
counterInfo
->
set_name
(
counter
->
getName
().
toStdString
());
counterInfo
->
mutable_counter_color
()
->
CopyFrom
(
counter
->
getColor
()
.
get_color
()
);
counterInfo
->
mutable_counter_color
()
->
CopyFrom
(
counter
->
getColor
());
counterInfo
->
set_radius
(
counter
->
getRadius
());
counterInfo
->
set_count
(
counter
->
getCount
());
}
...
...
common/server_player.cpp
View file @
d5c62896
...
...
@@ -99,14 +99,14 @@ void Server_Player::setupZones()
addZone
(
new
Server_CardZone
(
this
,
"grave"
,
false
,
ServerInfo_Zone
::
PublicZone
));
addZone
(
new
Server_CardZone
(
this
,
"rfg"
,
false
,
ServerInfo_Zone
::
PublicZone
));
addCounter
(
new
Server_Counter
(
0
,
"life"
,
Color
(
255
,
255
,
255
),
25
,
20
));
addCounter
(
new
Server_Counter
(
1
,
"w"
,
Color
(
255
,
255
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
2
,
"u"
,
Color
(
150
,
150
,
255
),
20
,
0
));
addCounter
(
new
Server_Counter
(
3
,
"b"
,
Color
(
150
,
150
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
4
,
"r"
,
Color
(
250
,
150
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
5
,
"g"
,
Color
(
150
,
255
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
6
,
"x"
,
Color
(
255
,
255
,
255
),
20
,
0
));
addCounter
(
new
Server_Counter
(
7
,
"storm"
,
Color
(
255
,
255
,
255
),
20
,
0
));
addCounter
(
new
Server_Counter
(
0
,
"life"
,
make
Color
(
255
,
255
,
255
),
25
,
20
));
addCounter
(
new
Server_Counter
(
1
,
"w"
,
make
Color
(
255
,
255
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
2
,
"u"
,
make
Color
(
150
,
150
,
255
),
20
,
0
));
addCounter
(
new
Server_Counter
(
3
,
"b"
,
make
Color
(
150
,
150
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
4
,
"r"
,
make
Color
(
250
,
150
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
5
,
"g"
,
make
Color
(
150
,
255
,
150
),
20
,
0
));
addCounter
(
new
Server_Counter
(
6
,
"x"
,
make
Color
(
255
,
255
,
255
),
20
,
0
));
addCounter
(
new
Server_Counter
(
7
,
"storm"
,
make
Color
(
255
,
255
,
255
),
20
,
0
));
initialCards
=
7
;
...
...
@@ -467,7 +467,8 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
Event_MoveCard
eventOthers
;
eventOthers
.
set_start_zone
(
startzone
->
getName
().
toStdString
());
eventOthers
.
set_target_player_id
(
targetzone
->
getPlayer
()
->
getPlayerId
());
eventOthers
.
set_target_zone
(
targetzone
->
getName
().
toStdString
());
if
(
startzone
!=
targetzone
)
eventOthers
.
set_target_zone
(
targetzone
->
getName
().
toStdString
());
eventOthers
.
set_x
(
newX
);
eventOthers
.
set_y
(
y
);
eventOthers
.
set_face_down
(
thisCardProperties
->
face_down
());
...
...
common/server_protocolhandler.cpp
View file @
d5c62896
...
...
@@ -532,7 +532,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdLogin(const Command_Login &cmd
server
->
serverMutex
.
lock
();
QList
<
ServerInfo_Game
*>
gameList
;
QMapIterator
<
int
,
Server_Room
*>
roomIterator
(
server
->
getRooms
());
QMutexLocker
gameListLocker
(
&
gameListMutex
);
while
(
roomIterator
.
hasNext
())
{
...
...
@@ -613,8 +612,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetGamesOfUser(const Command_G
return
Response
::
RespNameNotFound
;
Response_GetGamesOfUser
*
re
=
new
Response_GetGamesOfUser
;
QList
<
ServerInfo_Room
*>
roomList
;
QList
<
ServerInfo_Game
*>
gameList
;
QMapIterator
<
int
,
Server_Room
*>
roomIterator
(
server
->
getRooms
());
while
(
roomIterator
.
hasNext
())
{
Server_Room
*
room
=
roomIterator
.
next
().
value
();
...
...
@@ -1574,7 +1571,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon
zoneInfo
->
set_with_coords
(
zone
->
hasCoords
());
zoneInfo
->
set_card_count
(
numberCards
<
zone
->
cards
.
size
()
?
zone
->
cards
.
size
()
:
numberCards
);
QList
<
ServerInfo_Card
*>
respCardList
;
for
(
int
i
=
0
;
(
i
<
zone
->
cards
.
size
())
&&
(
i
<
numberCards
||
numberCards
==
-
1
);
++
i
)
{
Server_Card
*
card
=
zone
->
cards
[
i
];
QString
displayedName
=
card
->
getFaceDown
()
?
QString
()
:
card
->
getName
();
...
...
@@ -1595,7 +1591,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdDumpZone(const Command_DumpZon
cardInfo
->
set_destroy_on_zone_change
(
card
->
getDestroyOnZoneChange
());
cardInfo
->
set_doesnt_untap
(
card
->
getDoesntUntap
());
QList
<
ServerInfo_CardCounter
*>
cardCounterList
;
QMapIterator
<
int
,
int
>
cardCounterIterator
(
card
->
getCounters
());
while
(
cardCounterIterator
.
hasNext
())
{
cardCounterIterator
.
next
();
...
...
@@ -1692,7 +1687,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve
Event_RevealCards
eventPrivate
(
eventOthers
);
QList
<
ServerInfo_Card
*>
respCardListPrivate
,
respCardListOmniscient
;
for
(
int
i
=
0
;
i
<
cardsToReveal
.
size
();
++
i
)
{
Server_Card
*
card
=
cardsToReveal
[
i
];
ServerInfo_Card
*
cardInfo
=
eventPrivate
.
add_cards
();
...
...
@@ -1710,7 +1704,6 @@ Response::ResponseCode Server_ProtocolHandler::cmdRevealCards(const Command_Reve
cardInfo
->
set_destroy_on_zone_change
(
card
->
getDestroyOnZoneChange
());
cardInfo
->
set_doesnt_untap
(
card
->
getDoesntUntap
());
QList
<
ServerInfo_CardCounter
*>
cardCounterList
;
QMapIterator
<
int
,
int
>
cardCounterIterator
(
card
->
getCounters
());
while
(
cardCounterIterator
.
hasNext
())
{
cardCounterIterator
.
next
();
...
...
Prev
1
2
3
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