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
da467468
Commit
da467468
authored
Sep 15, 2011
by
unknown
Browse files
improved facedown moving
parent
1047ab08
Changes
22
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/carddragitem.cpp
View file @
da467468
...
...
@@ -83,7 +83,7 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
sc
->
removeItem
(
c
);
}
}
currentZone
->
handleDropEvent
(
dragItemList
,
startZone
,
(
sp
-
currentZone
->
scenePos
()).
toPoint
()
,
faceDown
);
currentZone
->
handleDropEvent
(
dragItemList
,
startZone
,
(
sp
-
currentZone
->
scenePos
()).
toPoint
());
event
->
accept
();
}
cockatrice/src/carddragitem.h
View file @
da467468
...
...
@@ -14,10 +14,11 @@ private:
public:
CardDragItem
(
CardItem
*
_item
,
int
_id
,
const
QPointF
&
_hotSpot
,
bool
_faceDown
,
AbstractCardDragItem
*
parentDrag
=
0
);
int
getId
()
const
{
return
id
;
}
bool
getFaceDown
()
const
{
return
faceDown
;
}
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
updatePosition
(
const
QPointF
&
cursorScenePos
);
protected:
void
mouseReleaseEvent
(
QGraphicsSceneMouseEvent
*
event
);
};
#endif
\ No newline at end of file
#endif
cockatrice/src/carditem.cpp
View file @
da467468
...
...
@@ -471,7 +471,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
childPos
=
c
->
pos
()
-
pos
();
else
childPos
=
QPointF
(
j
*
CARD_WIDTH
/
2
,
0
);
CardDragItem
*
drag
=
new
CardDragItem
(
c
,
c
->
getId
(),
childPos
,
false
,
dragItem
);
CardDragItem
*
drag
=
new
CardDragItem
(
c
,
c
->
getId
(),
childPos
,
c
->
getFaceDown
()
,
dragItem
);
drag
->
setPos
(
dragItem
->
pos
()
+
childPos
);
scene
()
->
addItem
(
drag
);
}
...
...
cockatrice/src/cardzone.h
View file @
da467468
...
...
@@ -35,7 +35,7 @@ public slots:
public:
enum
{
Type
=
typeZone
};
int
type
()
const
{
return
Type
;
}
virtual
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
=
0
;
virtual
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItem
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
)
=
0
;
CardZone
(
Player
*
_player
,
const
QString
&
_name
,
bool
_hasCardAttr
,
bool
_isShufflable
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
=
0
,
bool
isView
=
false
);
~
CardZone
();
void
retranslateUi
();
...
...
cockatrice/src/handzone.cpp
View file @
da467468
...
...
@@ -37,13 +37,13 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
card
->
update
();
}
void
HandZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
HandZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
)
{
QList
<
CardToMove
*>
idList
;
for
(
int
i
=
0
;
i
<
dragItems
.
size
();
++
i
)
idList
.
append
(
new
CardToMove
(
dragItems
[
i
]
->
getId
()));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
cards
.
size
(),
-
1
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
cards
.
size
(),
-
1
));
}
QRectF
HandZone
::
boundingRect
()
const
...
...
cockatrice/src/handzone.h
View file @
da467468
...
...
@@ -14,7 +14,7 @@ public slots:
void
updateOrientation
();
public:
HandZone
(
Player
*
_p
,
bool
_contentsKnown
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
...
...
cockatrice/src/pilezone.cpp
View file @
da467468
...
...
@@ -48,13 +48,13 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
card
->
setParentItem
(
this
);
}
void
PileZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
PileZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
)
{
QList
<
CardToMove
*>
idList
;
for
(
int
i
=
0
;
i
<
dragItems
.
size
();
++
i
)
idList
.
append
(
new
CardToMove
(
dragItems
[
i
]
->
getId
()));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
0
,
0
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
0
,
0
));
}
void
PileZone
::
reorganizeCards
()
...
...
cockatrice/src/pilezone.h
View file @
da467468
...
...
@@ -9,7 +9,7 @@ public:
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
cockatrice/src/player.cpp
View file @
da467468
...
...
@@ -615,7 +615,7 @@ void Player::actMoveTopCardsToGrave()
QList
<
CardToMove
*>
idList
;
for
(
int
i
=
0
;
i
<
number
;
++
i
)
idList
.
append
(
new
CardToMove
(
i
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
idList
,
getId
(),
"grave"
,
0
,
0
,
false
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
idList
,
getId
(),
"grave"
,
0
,
0
));
}
void
Player
::
actMoveTopCardsToExile
()
...
...
@@ -631,12 +631,12 @@ void Player::actMoveTopCardsToExile()
QList
<
CardToMove
*>
idList
;
for
(
int
i
=
0
;
i
<
number
;
++
i
)
idList
.
append
(
new
CardToMove
(
i
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
idList
,
getId
(),
"rfg"
,
0
,
0
,
false
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
idList
,
getId
(),
"rfg"
,
0
,
0
));
}
void
Player
::
actMoveTopCardToBottom
()
{
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
QList
<
CardToMove
*>
()
<<
new
CardToMove
(
0
),
getId
(),
"deck"
,
-
1
,
0
,
false
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
"deck"
,
QList
<
CardToMove
*>
()
<<
new
CardToMove
(
0
),
getId
(),
"deck"
,
-
1
,
0
));
}
void
Player
::
actUntapAll
()
...
...
@@ -1155,10 +1155,10 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
{
CardInfo
*
ci
=
c
->
getInfo
();
if
(
ci
->
getTableRow
()
==
3
)
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
c
->
getZone
()
->
getName
(),
QList
<
CardToMove
*>
()
<<
new
CardToMove
(
c
->
getId
()),
getId
(),
"stack"
,
0
,
0
,
false
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
c
->
getZone
()
->
getName
(),
QList
<
CardToMove
*>
()
<<
new
CardToMove
(
c
->
getId
()),
getId
(),
"stack"
,
0
,
0
));
else
{
QPoint
gridPoint
=
QPoint
(
-
1
,
2
-
ci
->
getTableRow
());
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
c
->
getZone
()
->
getName
(),
QList
<
CardToMove
*>
()
<<
new
CardToMove
(
c
->
getId
(),
ci
->
getPowTough
(),
tapped
),
getId
(),
"table"
,
gridPoint
.
x
(),
gridPoint
.
y
()
,
faceDown
));
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
c
->
getZone
()
->
getName
(),
QList
<
CardToMove
*>
()
<<
new
CardToMove
(
c
->
getId
(),
faceDown
,
ci
->
getPowTough
(),
tapped
),
getId
(),
"table"
,
gridPoint
.
x
(),
gridPoint
.
y
()));
}
}
...
...
@@ -1374,16 +1374,16 @@ void Player::cardMenuAction(QAction *a)
switch
(
a
->
data
().
toInt
())
{
case
5
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"deck"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"deck"
,
0
,
0
));
break
;
case
6
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"deck"
,
-
1
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"deck"
,
-
1
,
0
));
break
;
case
7
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"grave"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"grave"
,
0
,
0
));
break
;
case
8
:
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"rfg"
,
0
,
0
,
false
));
commandList
.
append
(
new
Command_MoveCard
(
-
1
,
startZone
,
idList
,
getId
(),
"rfg"
,
0
,
0
));
break
;
default:
;
}
...
...
cockatrice/src/stackzone.cpp
View file @
da467468
...
...
@@ -52,7 +52,7 @@ void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
painter
->
fillRect
(
boundingRect
(),
QBrush
(
bgPixmap
));
}
void
StackZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
StackZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
)
{
if
(
startZone
==
this
)
return
;
...
...
@@ -61,7 +61,7 @@ void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
for
(
int
i
=
0
;
i
<
dragItems
.
size
();
++
i
)
idList
.
append
(
new
CardToMove
(
dragItems
[
i
]
->
getId
()));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
0
,
0
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
0
,
0
));
}
void
StackZone
::
reorganizeCards
()
...
...
cockatrice/src/stackzone.h
View file @
da467468
...
...
@@ -12,7 +12,7 @@ private slots:
void
updateBgPixmap
();
public:
StackZone
(
Player
*
_p
,
int
_zoneHeight
,
QGraphicsItem
*
parent
=
0
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
reorganizeCards
();
...
...
cockatrice/src/tablezone.cpp
View file @
da467468
...
...
@@ -86,18 +86,18 @@ void TableZone::addCardImpl(CardItem *card, int _x, int _y)
card
->
update
();
}
void
TableZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
void
TableZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
)
{
handleDropEventByGrid
(
dragItems
,
startZone
,
mapToGrid
(
dropPoint
)
,
faceDown
);
handleDropEventByGrid
(
dragItems
,
startZone
,
mapToGrid
(
dropPoint
));
}
void
TableZone
::
handleDropEventByGrid
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
,
bool
tapped
)
void
TableZone
::
handleDropEventByGrid
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
)
{
QList
<
CardToMove
*>
idList
;
for
(
int
i
=
0
;
i
<
dragItems
.
size
();
++
i
)
idList
.
append
(
new
CardToMove
(
dragItems
[
i
]
->
getId
(),
startZone
->
getName
()
==
name
?
QString
()
:
dragItems
[
i
]
->
getItem
()
->
getInfo
()
->
getPowTough
()
,
tapped
));
idList
.
append
(
new
CardToMove
(
dragItems
[
i
]
->
getId
(),
dragItems
[
i
]
->
getFaceDown
(),
startZone
->
getName
()
==
name
?
QString
()
:
dragItems
[
i
]
->
getItem
()
->
getInfo
()
->
getPowTough
()));
startZone
->
getPlayer
()
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
gridPoint
.
x
(),
gridPoint
.
y
()
,
faceDown
));
startZone
->
getPlayer
()
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
gridPoint
.
x
(),
gridPoint
.
y
()));
}
void
TableZone
::
reorganizeCards
()
...
...
cockatrice/src/tablezone.h
View file @
da467468
...
...
@@ -29,8 +29,8 @@ public:
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
toggleTapped
();
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
=
false
);
void
handleDropEventByGrid
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
,
bool
faceDown
=
false
,
bool
tapped
=
false
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
void
handleDropEventByGrid
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
gridPoint
);
CardItem
*
getCardFromGrid
(
const
QPoint
&
gridPoint
)
const
;
CardItem
*
getCardFromCoords
(
const
QPointF
&
point
)
const
;
QPointF
mapFromGrid
(
QPoint
gridPoint
)
const
;
...
...
cockatrice/src/zoneviewzone.cpp
View file @
da467468
...
...
@@ -124,13 +124,13 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
card
->
update
();
}
void
ZoneViewZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
,
bool
/*faceDown*/
)
void
ZoneViewZone
::
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
/*dropPoint*/
)
{
QList
<
CardToMove
*>
idList
;
for
(
int
i
=
0
;
i
<
dragItems
.
size
();
++
i
)
idList
.
append
(
new
CardToMove
(
dragItems
[
i
]
->
getId
()));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
0
,
0
,
false
));
player
->
sendGameCommand
(
new
Command_MoveCard
(
-
1
,
startZone
->
getName
(),
idList
,
player
->
getId
(),
getName
(),
0
,
0
));
}
void
ZoneViewZone
::
removeCard
(
int
position
)
...
...
cockatrice/src/zoneviewzone.h
View file @
da467468
...
...
@@ -13,7 +13,7 @@ class ZoneViewZone : public SelectZone, public QGraphicsLayoutItem {
private:
QRectF
bRect
,
optimumRect
;
int
minRows
,
numberCards
;
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
void
handleDropEvent
(
const
QList
<
CardDragItem
*>
&
dragItems
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
CardZone
*
origZone
;
bool
revealZone
;
bool
sortByName
,
sortByType
;
...
...
common/protocol.cpp
View file @
da467468
...
...
@@ -230,7 +230,7 @@ QList<MoveCardToZone *> Command_SetSideboardPlan::getMoveList() const
return
typecastItemList
<
MoveCardToZone
*>
();
}
Command_MoveCard
::
Command_MoveCard
(
int
_gameId
,
const
QString
&
_startZone
,
const
QList
<
CardToMove
*>
&
_cards
,
int
_targetPlayerId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
,
bool
_faceDown
)
Command_MoveCard
::
Command_MoveCard
(
int
_gameId
,
const
QString
&
_startZone
,
const
QList
<
CardToMove
*>
&
_cards
,
int
_targetPlayerId
,
const
QString
&
_targetZone
,
int
_x
,
int
_y
)
:
GameCommand
(
"move_card"
,
_gameId
)
{
insertItem
(
new
SerializableItem_String
(
"start_zone"
,
_startZone
));
...
...
@@ -238,7 +238,6 @@ Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const
insertItem
(
new
SerializableItem_String
(
"target_zone"
,
_targetZone
));
insertItem
(
new
SerializableItem_Int
(
"x"
,
_x
));
insertItem
(
new
SerializableItem_Int
(
"y"
,
_y
));
insertItem
(
new
SerializableItem_Bool
(
"face_down"
,
_faceDown
));
for
(
int
i
=
0
;
i
<
_cards
.
size
();
++
i
)
itemList
.
append
(
_cards
[
i
]);
...
...
common/protocol.h
View file @
da467468
...
...
@@ -236,14 +236,13 @@ public:
class
Command_MoveCard
:
public
GameCommand
{
Q_OBJECT
public:
Command_MoveCard
(
int
_gameId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
const
QList
<
CardToMove
*>
&
_cards
=
QList
<
CardToMove
*>
(),
int
_targetPlayerId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
,
bool
_faceDown
=
false
);
Command_MoveCard
(
int
_gameId
=
-
1
,
const
QString
&
_startZone
=
QString
(),
const
QList
<
CardToMove
*>
&
_cards
=
QList
<
CardToMove
*>
(),
int
_targetPlayerId
=
-
1
,
const
QString
&
_targetZone
=
QString
(),
int
_x
=
-
1
,
int
_y
=
-
1
);
QString
getStartZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"start_zone"
))
->
getData
();
}
QList
<
CardToMove
*>
getCards
()
const
{
return
typecastItemList
<
CardToMove
*>
();
}
int
getTargetPlayerId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"target_player_id"
))
->
getData
();
}
QString
getTargetZone
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"target_zone"
))
->
getData
();
}
int
getX
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"x"
))
->
getData
();
}
int
getY
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"y"
))
->
getData
();
}
bool
getFaceDown
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"face_down"
))
->
getData
();
}
static
SerializableItem
*
newItem
()
{
return
new
Command_MoveCard
;
}
int
getItemId
()
const
{
return
ItemId_Command_MoveCard
;
}
};
...
...
common/protocol_datastructures.cpp
View file @
da467468
...
...
@@ -3,10 +3,11 @@
#include
<QXmlStreamReader>
#include
<QXmlStreamWriter>
CardToMove
::
CardToMove
(
int
_cardId
,
const
QString
&
_pt
,
bool
_tapped
)
CardToMove
::
CardToMove
(
int
_cardId
,
bool
_faceDown
,
const
QString
&
_pt
,
bool
_tapped
)
:
SerializableItem_Map
(
"card_to_move"
)
{
insertItem
(
new
SerializableItem_Int
(
"card_id"
,
_cardId
));
insertItem
(
new
SerializableItem_Bool
(
"facedown"
,
_faceDown
));
insertItem
(
new
SerializableItem_String
(
"pt"
,
_pt
));
insertItem
(
new
SerializableItem_Bool
(
"tapped"
,
_tapped
));
}
...
...
common/protocol_datastructures.h
View file @
da467468
...
...
@@ -22,9 +22,10 @@ enum ZoneType { PrivateZone, PublicZone, HiddenZone };
class
CardToMove
:
public
SerializableItem_Map
{
public:
CardToMove
(
int
_cardId
=
-
1
,
const
QString
&
_pt
=
QString
(),
bool
_tapped
=
false
);
CardToMove
(
int
_cardId
=
-
1
,
bool
_faceDown
=
false
,
const
QString
&
_pt
=
QString
(),
bool
_tapped
=
false
);
static
SerializableItem
*
newItem
()
{
return
new
CardToMove
;
}
int
getCardId
()
const
{
return
static_cast
<
SerializableItem_Int
*>
(
itemMap
.
value
(
"card_id"
))
->
getData
();
}
bool
getFaceDown
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"facedown"
))
->
getData
();
}
QString
getPT
()
const
{
return
static_cast
<
SerializableItem_String
*>
(
itemMap
.
value
(
"pt"
))
->
getData
();
}
bool
getTapped
()
const
{
return
static_cast
<
SerializableItem_Bool
*>
(
itemMap
.
value
(
"tapped"
))
->
getData
();
}
};
...
...
common/server_player.cpp
View file @
da467468
...
...
@@ -278,12 +278,12 @@ ResponseCode Server_Player::undoDraw(CommandContainer *cont)
ResponseCode
retVal
;
CardToMove
*
cardToMove
=
new
CardToMove
(
lastDrawList
.
takeLast
());
retVal
=
moveCard
(
cont
,
zones
.
value
(
"hand"
),
QList
<
CardToMove
*>
()
<<
cardToMove
,
zones
.
value
(
"deck"
),
0
,
0
,
false
,
false
,
true
);
retVal
=
moveCard
(
cont
,
zones
.
value
(
"hand"
),
QList
<
CardToMove
*>
()
<<
cardToMove
,
zones
.
value
(
"deck"
),
0
,
0
,
false
,
true
);
delete
cardToMove
;
return
retVal
;
}
ResponseCode
Server_Player
::
moveCard
(
CommandContainer
*
cont
,
const
QString
&
_startZone
,
const
QList
<
CardToMove
*>
&
_cards
,
int
targetPlayerId
,
const
QString
&
_targetZone
,
int
x
,
int
y
,
bool
faceDown
)
ResponseCode
Server_Player
::
moveCard
(
CommandContainer
*
cont
,
const
QString
&
_startZone
,
const
QList
<
CardToMove
*>
&
_cards
,
int
targetPlayerId
,
const
QString
&
_targetZone
,
int
x
,
int
y
)
{
QMutexLocker
locker
(
&
game
->
gameMutex
);
...
...
@@ -295,7 +295,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_sta
if
((
!
startzone
)
||
(
!
targetzone
))
return
RespNameNotFound
;
return
moveCard
(
cont
,
startzone
,
_cards
,
targetzone
,
x
,
y
,
faceDown
);
return
moveCard
(
cont
,
startzone
,
_cards
,
targetzone
,
x
,
y
);
}
class
Server_Player
::
MoveCardCompareFunctor
{
...
...
@@ -319,7 +319,7 @@ public:
}
};
ResponseCode
Server_Player
::
moveCard
(
CommandContainer
*
cont
,
Server_CardZone
*
startzone
,
const
QList
<
CardToMove
*>
&
_cards
,
Server_CardZone
*
targetzone
,
int
x
,
int
y
,
bool
faceDown
,
bool
fixFreeSpaces
,
bool
undoingDraw
)
ResponseCode
Server_Player
::
moveCard
(
CommandContainer
*
cont
,
Server_CardZone
*
startzone
,
const
QList
<
CardToMove
*>
&
_cards
,
Server_CardZone
*
targetzone
,
int
x
,
int
y
,
bool
fixFreeSpaces
,
bool
undoingDraw
)
{
QMutexLocker
locker
(
&
game
->
gameMutex
);
...
...
@@ -417,8 +417,8 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
bool
targetBeingLookedAt
=
(
targetzone
->
getType
()
!=
HiddenZone
)
||
(
targetzone
->
getCardsBeingLookedAt
()
>
newX
)
||
(
targetzone
->
getCardsBeingLookedAt
()
==
-
1
);
bool
sourceBeingLookedAt
=
(
startzone
->
getType
()
!=
HiddenZone
)
||
(
startzone
->
getCardsBeingLookedAt
()
>
position
)
||
(
startzone
->
getCardsBeingLookedAt
()
==
-
1
);
bool
targetHiddenToPlayer
=
f
aceDown
||
!
targetBeingLookedAt
;
bool
targetHiddenToOthers
=
f
aceDown
||
(
targetzone
->
getType
()
!=
PublicZone
);
bool
targetHiddenToPlayer
=
thisCardProperties
->
getF
aceDown
()
||
!
targetBeingLookedAt
;
bool
targetHiddenToOthers
=
thisCardProperties
->
getF
aceDown
()
||
(
targetzone
->
getType
()
!=
PublicZone
);
bool
sourceHiddenToPlayer
=
card
->
getFaceDown
()
||
!
sourceBeingLookedAt
;
bool
sourceHiddenToOthers
=
card
->
getFaceDown
()
||
(
startzone
->
getType
()
!=
PublicZone
);
...
...
@@ -429,9 +429,9 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
publicCardName
=
card
->
getName
();
int
oldCardId
=
card
->
getId
();
if
(
f
aceDown
||
(
targetzone
->
getPlayer
()
!=
startzone
->
getPlayer
()))
if
(
thisCardProperties
->
getF
aceDown
()
||
(
targetzone
->
getPlayer
()
!=
startzone
->
getPlayer
()))
card
->
setId
(
targetzone
->
getPlayer
()
->
newCardId
());
card
->
setFaceDown
(
f
aceDown
);
card
->
setFaceDown
(
thisCardProperties
->
getF
aceDown
()
);
// The player does not get to see which card he moved if it moves between two parts of hidden zones which
// are not being looked at.
...
...
@@ -445,8 +445,8 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
int
privatePosition
=
-
1
;
if
(
startzone
->
getType
()
==
HiddenZone
)
privatePosition
=
position
;
cont
->
enqueueGameEventPrivate
(
new
Event_MoveCard
(
getPlayerId
(),
privateOldCardId
,
privateCardName
,
startzone
->
getName
(),
privatePosition
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
privateNewCardId
,
f
aceDown
),
game
->
getGameId
(),
-
1
,
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
cont
->
enqueueGameEventOmniscient
(
new
Event_MoveCard
(
getPlayerId
(),
privateOldCardId
,
privateCardName
,
startzone
->
getName
(),
privatePosition
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
privateNewCardId
,
f
aceDown
),
game
->
getGameId
(),
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
cont
->
enqueueGameEventPrivate
(
new
Event_MoveCard
(
getPlayerId
(),
privateOldCardId
,
privateCardName
,
startzone
->
getName
(),
privatePosition
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
privateNewCardId
,
thisCardProperties
->
getF
aceDown
()
),
game
->
getGameId
(),
-
1
,
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
cont
->
enqueueGameEventOmniscient
(
new
Event_MoveCard
(
getPlayerId
(),
privateOldCardId
,
privateCardName
,
startzone
->
getName
(),
privatePosition
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
privateNewCardId
,
thisCardProperties
->
getF
aceDown
()
),
game
->
getGameId
(),
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
// Other players do not get to see the start and/or target position of the card if the respective
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
...
...
@@ -460,13 +460,13 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
newX
=
-
1
;
if
((
startzone
->
getType
()
==
PublicZone
)
||
(
targetzone
->
getType
()
==
PublicZone
))
cont
->
enqueueGameEventPublic
(
new
Event_MoveCard
(
getPlayerId
(),
oldCardId
,
publicCardName
,
startzone
->
getName
(),
position
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
card
->
getId
(),
f
aceDown
),
game
->
getGameId
(),
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
cont
->
enqueueGameEventPublic
(
new
Event_MoveCard
(
getPlayerId
(),
oldCardId
,
publicCardName
,
startzone
->
getName
(),
position
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
card
->
getId
(),
thisCardProperties
->
getF
aceDown
()
),
game
->
getGameId
(),
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
else
cont
->
enqueueGameEventPublic
(
new
Event_MoveCard
(
getPlayerId
(),
-
1
,
QString
(),
startzone
->
getName
(),
position
,
targetzone
->
getPlayer
()
->
getPlayerId
(),
targetzone
->
getName
(),
newX
,
y
,
-
1
,
false
),
game
->
getGameId
(),
undoingDraw
?
static_cast
<
GameEventContext
*>
(
new
Context_UndoDraw
)
:
static_cast
<
GameEventContext
*>
(
new
Context_MoveCard
));
if
(
thisCardProperties
->
getTapped
())
setCardAttrHelper
(
cont
,
targetzone
->
getName
(),
card
->
getId
(),
"tapped"
,
"1"
);
if
(
!
thisCardProperties
->
getPT
().
isEmpty
()
&&
!
f
aceDown
)
if
(
!
thisCardProperties
->
getPT
().
isEmpty
()
&&
!
thisCardProperties
->
getF
aceDown
()
)
setCardAttrHelper
(
cont
,
targetzone
->
getName
(),
card
->
getId
(),
"pt"
,
thisCardProperties
->
getPT
());
}
}
...
...
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