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
a429a4a0
Commit
a429a4a0
authored
Apr 07, 2009
by
Max-Wilhelm Bruker
Browse files
minor changes, implemented 'doesn't untap' and facedown cards
parent
e6d61624
Changes
37
Show whitespace changes
Inline
Side-by-side
cockatrice/src/carddatabasemodel.cpp
View file @
a429a4a0
...
@@ -65,7 +65,7 @@ private:
...
@@ -65,7 +65,7 @@ private:
Qt
::
SortOrder
order
;
Qt
::
SortOrder
order
;
public:
public:
CardInfoCompare
(
int
_column
,
Qt
::
SortOrder
_order
)
:
column
(
_column
),
order
(
_order
)
{
}
CardInfoCompare
(
int
_column
,
Qt
::
SortOrder
_order
)
:
column
(
_column
),
order
(
_order
)
{
}
bool
operator
()(
CardInfo
*
a
,
CardInfo
*
b
)
const
inline
bool
operator
()(
CardInfo
*
a
,
CardInfo
*
b
)
const
{
{
bool
result
;
bool
result
;
switch
(
column
)
{
switch
(
column
)
{
...
...
cockatrice/src/carddragitem.cpp
View file @
a429a4a0
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
#include
"cardzone.h"
#include
"cardzone.h"
#include
<QtGui>
#include
<QtGui>
CardDragItem
::
CardDragItem
(
QGraphicsScene
*
scene
,
CardZone
*
_startZone
,
QPixmap
*
_image
,
int
_id
,
const
QPointF
&
_hotSpot
,
QGraphicsItem
*
parent
)
CardDragItem
::
CardDragItem
(
QGraphicsScene
*
scene
,
CardZone
*
_startZone
,
QPixmap
*
_image
,
int
_id
,
const
QPointF
&
_hotSpot
,
bool
_faceDown
,
QGraphicsItem
*
parent
)
:
QGraphicsItem
(
parent
),
image
(
_image
),
id
(
_id
),
hotSpot
(
_hotSpot
),
startZone
(
_startZone
)
:
QGraphicsItem
(
parent
),
image
(
_image
),
id
(
_id
),
hotSpot
(
_hotSpot
),
startZone
(
_startZone
)
,
faceDown
(
_faceDown
)
{
{
if
((
hotSpot
.
x
()
<
0
)
||
(
hotSpot
.
y
()
<
0
))
{
if
((
hotSpot
.
x
()
<
0
)
||
(
hotSpot
.
y
()
<
0
))
{
qDebug
(
QString
(
"CardDragItem: coordinate overflow: x = %1, y = %2"
).
arg
(
hotSpot
.
x
()).
arg
(
hotSpot
.
y
()).
toLatin1
());
qDebug
(
QString
(
"CardDragItem: coordinate overflow: x = %1, y = %2"
).
arg
(
hotSpot
.
x
()).
arg
(
hotSpot
.
y
()).
toLatin1
());
...
@@ -16,6 +16,7 @@ CardDragItem::CardDragItem(QGraphicsScene *scene, CardZone *_startZone, QPixmap
...
@@ -16,6 +16,7 @@ CardDragItem::CardDragItem(QGraphicsScene *scene, CardZone *_startZone, QPixmap
setZValue
(
2000000000
);
setZValue
(
2000000000
);
setCacheMode
(
DeviceCoordinateCache
);
setCacheMode
(
DeviceCoordinateCache
);
if
(
!
parent
)
scene
->
addItem
(
this
);
scene
->
addItem
(
this
);
}
}
...
@@ -82,16 +83,13 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
...
@@ -82,16 +83,13 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
if
(
dropZone
)
{
if
(
dropZone
)
{
dropZone
->
handleDropEvent
(
id
,
startZone
,
(
sp
-
dropZone
->
scenePos
()).
toPoint
());
dropZone
->
handleDropEvent
(
id
,
startZone
,
(
sp
-
dropZone
->
scenePos
()).
toPoint
()
,
faceDown
);
QList
<
QGraphicsItem
*>
childList
=
childItems
();
QList
<
QGraphicsItem
*>
childList
=
childItems
();
for
(
int
i
=
0
;
i
<
childList
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
childList
.
size
();
i
++
)
{
CardDragItem
*
c
=
qgraphicsitem_cast
<
CardDragItem
*>
(
childList
.
at
(
i
));
CardDragItem
*
c
=
qgraphicsitem_cast
<
CardDragItem
*>
(
childList
.
at
(
i
));
if
(
!
c
)
dropZone
->
handleDropEvent
(
c
->
id
,
startZone
,
(
sp
-
dropZone
->
scenePos
()
+
c
->
pos
()).
toPoint
(),
faceDown
);
QMessageBox
::
critical
(
0
,
"fehler"
,
"null"
);
}
dropZone
->
handleDropEvent
(
c
->
id
,
startZone
,
(
sp
-
dropZone
->
scenePos
()
+
c
->
pos
()).
toPoint
());
}
}
}
else
QMessageBox
::
critical
(
0
,
"fehler"
,
"fehler"
);
event
->
accept
();
event
->
accept
();
}
}
cockatrice/src/carddragitem.h
View file @
a429a4a0
...
@@ -12,10 +12,11 @@ private:
...
@@ -12,10 +12,11 @@ private:
int
id
;
int
id
;
QPointF
hotSpot
;
QPointF
hotSpot
;
CardZone
*
startZone
;
CardZone
*
startZone
;
bool
faceDown
;
public:
public:
enum
{
Type
=
typeCardDrag
};
enum
{
Type
=
typeCardDrag
};
int
type
()
const
{
return
Type
;
}
int
type
()
const
{
return
Type
;
}
CardDragItem
(
QGraphicsScene
*
scene
,
CardZone
*
_startZone
,
QPixmap
*
_image
,
int
_id
,
const
QPointF
&
_hotSpot
,
QGraphicsItem
*
parent
=
0
);
CardDragItem
(
QGraphicsScene
*
scene
,
CardZone
*
_startZone
,
QPixmap
*
_image
,
int
_id
,
const
QPointF
&
_hotSpot
,
bool
_faceDown
,
QGraphicsItem
*
parent
=
0
);
~
CardDragItem
();
~
CardDragItem
();
QRectF
boundingRect
()
const
;
QRectF
boundingRect
()
const
;
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
...
...
cockatrice/src/carditem.cpp
View file @
a429a4a0
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
#include
"player.h"
#include
"player.h"
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
),
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
;
width
=
CARD_WIDTH
;
height
=
CARD_HEIGHT
;
height
=
CARD_HEIGHT
;
...
@@ -21,6 +21,7 @@ CardItem::CardItem(CardDatabase *_db, const QString &_name, int _cardid, QGraphi
...
@@ -21,6 +21,7 @@ CardItem::CardItem(CardDatabase *_db, const QString &_name, int _cardid, QGraphi
CardItem
::~
CardItem
()
CardItem
::~
CardItem
()
{
{
deleteDragItem
();
qDebug
(
QString
(
"CardItem destructor: %1"
).
arg
(
name
).
toLatin1
());
qDebug
(
QString
(
"CardItem destructor: %1"
).
arg
(
name
).
toLatin1
());
}
}
...
@@ -80,7 +81,7 @@ void CardItem::setAttacking(bool _attacking)
...
@@ -80,7 +81,7 @@ void CardItem::setAttacking(bool _attacking)
update
(
boundingRect
());
update
(
boundingRect
());
}
}
void
CardItem
::
setFace
d
own
(
bool
_facedown
)
void
CardItem
::
setFace
D
own
(
bool
_facedown
)
{
{
facedown
=
_facedown
;
facedown
=
_facedown
;
update
(
boundingRect
());
update
(
boundingRect
());
...
@@ -98,6 +99,11 @@ void CardItem::setAnnotation(const QString &_annotation)
...
@@ -98,6 +99,11 @@ void CardItem::setAnnotation(const QString &_annotation)
update
(
boundingRect
());
update
(
boundingRect
());
}
}
void
CardItem
::
setDoesntUntap
(
bool
_doesntUntap
)
{
doesntUntap
=
_doesntUntap
;
}
void
CardItem
::
resetState
()
void
CardItem
::
resetState
()
{
{
attacking
=
false
;
attacking
=
false
;
...
@@ -105,12 +111,14 @@ void CardItem::resetState()
...
@@ -105,12 +111,14 @@ void CardItem::resetState()
counters
=
0
;
counters
=
0
;
annotation
=
QString
();
annotation
=
QString
();
setTapped
(
false
);
setTapped
(
false
);
setDoesntUntap
(
false
);
update
(
boundingRect
());
update
(
boundingRect
());
}
}
CardDragItem
*
CardItem
::
createDragItem
(
CardZone
*
startZone
,
int
_id
,
const
QPointF
&
_pos
,
const
QPointF
&
_scenePos
)
CardDragItem
*
CardItem
::
createDragItem
(
CardZone
*
startZone
,
int
_id
,
const
QPointF
&
_pos
,
const
QPointF
&
_scenePos
,
bool
faceDown
)
{
{
dragItem
=
new
CardDragItem
(
scene
(),
startZone
,
image
,
_id
,
_pos
);
deleteDragItem
();
dragItem
=
new
CardDragItem
(
scene
(),
startZone
,
image
,
_id
,
_pos
,
faceDown
);
dragItem
->
setPos
(
_scenePos
-
dragItem
->
getHotSpot
());
dragItem
->
setPos
(
_scenePos
-
dragItem
->
getHotSpot
());
return
dragItem
;
return
dragItem
;
...
@@ -140,8 +148,9 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -140,8 +148,9 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
{
if
((
event
->
screenPos
()
-
event
->
buttonDownScreenPos
(
Qt
::
LeftButton
)).
manhattanLength
()
<
QApplication
::
startDragDistance
())
if
((
event
->
screenPos
()
-
event
->
buttonDownScreenPos
(
Qt
::
LeftButton
)).
manhattanLength
()
<
QApplication
::
startDragDistance
())
return
;
return
;
bool
faceDown
=
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
);
createDragItem
((
CardZone
*
)
parentItem
(),
id
,
event
->
pos
(),
event
->
scenePos
());
createDragItem
((
CardZone
*
)
parentItem
(),
id
,
event
->
pos
(),
event
->
scenePos
()
,
faceDown
);
dragItem
->
grabMouse
();
dragItem
->
grabMouse
();
QList
<
QGraphicsItem
*>
sel
=
scene
()
->
selectedItems
();
QList
<
QGraphicsItem
*>
sel
=
scene
()
->
selectedItems
();
...
@@ -149,7 +158,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -149,7 +158,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
CardItem
*
c
=
(
CardItem
*
)
sel
.
at
(
i
);
CardItem
*
c
=
(
CardItem
*
)
sel
.
at
(
i
);
if
(
c
==
this
)
if
(
c
==
this
)
continue
;
continue
;
CardDragItem
*
drag
=
new
CardDragItem
(
scene
(),
(
CardZone
*
)
parentItem
(),
c
->
getImage
(),
c
->
getId
(),
QPointF
(),
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
());
}
}
...
...
cockatrice/src/carditem.h
View file @
a429a4a0
...
@@ -41,6 +41,7 @@ private:
...
@@ -41,6 +41,7 @@ private:
bool
facedown
;
bool
facedown
;
int
counters
;
int
counters
;
QString
annotation
;
QString
annotation
;
bool
doesntUntap
;
CardDragItem
*
dragItem
;
CardDragItem
*
dragItem
;
public:
public:
enum
{
Type
=
typeCard
};
enum
{
Type
=
typeCard
};
...
@@ -58,15 +59,17 @@ public:
...
@@ -58,15 +59,17 @@ public:
void
setTapped
(
bool
_tapped
);
void
setTapped
(
bool
_tapped
);
bool
getAttacking
()
const
{
return
attacking
;
}
bool
getAttacking
()
const
{
return
attacking
;
}
void
setAttacking
(
bool
_attacking
);
void
setAttacking
(
bool
_attacking
);
bool
getFace
d
own
()
const
{
return
facedown
;
}
bool
getFace
D
own
()
const
{
return
facedown
;
}
void
setFace
d
own
(
bool
_facedown
);
void
setFace
D
own
(
bool
_facedown
);
int
getCounters
()
const
{
return
counters
;
}
int
getCounters
()
const
{
return
counters
;
}
void
setCounters
(
int
_counters
);
void
setCounters
(
int
_counters
);
QString
getAnnotation
()
const
{
return
annotation
;
}
QString
getAnnotation
()
const
{
return
annotation
;
}
void
setAnnotation
(
const
QString
&
_annotation
);
void
setAnnotation
(
const
QString
&
_annotation
);
bool
getDoesntUntap
()
const
{
return
doesntUntap
;
}
void
setDoesntUntap
(
bool
_doesntUntap
);
void
resetState
();
void
resetState
();
CardDragItem
*
createDragItem
(
CardZone
*
startZone
,
int
_id
,
const
QPointF
&
_pos
,
const
QPointF
&
_scenePos
);
CardDragItem
*
createDragItem
(
CardZone
*
startZone
,
int
_id
,
const
QPointF
&
_pos
,
const
QPointF
&
_scenePos
,
bool
faceDown
);
void
deleteDragItem
();
void
deleteDragItem
();
protected:
protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
cockatrice/src/cardzone.cpp
View file @
a429a4a0
...
@@ -56,14 +56,17 @@ CardItem *CardZone::getCard(int cardId, const QString &cardName)
...
@@ -56,14 +56,17 @@ CardItem *CardZone::getCard(int cardId, const QString &cardName)
CardItem
*
CardZone
::
takeCard
(
int
position
,
int
cardId
,
const
QString
&
cardName
)
CardItem
*
CardZone
::
takeCard
(
int
position
,
int
cardId
,
const
QString
&
cardName
)
{
{
if
(
position
>=
cards
->
size
())
return
NULL
;
CardItem
*
c
=
cards
->
takeAt
(
position
);
CardItem
*
c
=
cards
->
takeAt
(
position
);
for
(
int
i
=
0
;
i
<
views
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
views
.
size
();
i
++
)
views
[
i
]
->
removeCard
(
position
);
views
[
i
]
->
removeCard
(
position
);
if
(
c
->
getId
()
==
-
1
)
{
//
if (c->getId() == -1) {
c
->
setId
(
cardId
);
c
->
setId
(
cardId
);
c
->
setName
(
cardName
);
c
->
setName
(
cardName
);
}
//
}
reorganizeCards
();
reorganizeCards
();
return
c
;
return
c
;
}
}
...
...
cockatrice/src/cardzone.h
View file @
a429a4a0
...
@@ -21,7 +21,7 @@ protected:
...
@@ -21,7 +21,7 @@ protected:
public:
public:
enum
{
Type
=
typeZone
};
enum
{
Type
=
typeZone
};
int
type
()
const
{
return
Type
;
}
int
type
()
const
{
return
Type
;
}
virtual
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
)
=
0
;
virtual
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
=
0
;
CardZone
(
Player
*
_player
,
const
QString
&
_name
,
QGraphicsItem
*
parent
=
0
,
bool
isView
=
false
);
CardZone
(
Player
*
_player
,
const
QString
&
_name
,
QGraphicsItem
*
parent
=
0
,
bool
isView
=
false
);
~
CardZone
();
~
CardZone
();
void
clearContents
();
void
clearContents
();
...
...
cockatrice/src/client.cpp
View file @
a429a4a0
...
@@ -254,11 +254,11 @@ int Client::drawCards(unsigned int number)
...
@@ -254,11 +254,11 @@ int Client::drawCards(unsigned int number)
return
cmd
(
QString
(
"draw_cards|%1"
).
arg
(
number
));
return
cmd
(
QString
(
"draw_cards|%1"
).
arg
(
number
));
}
}
int
Client
::
moveCard
(
int
cardid
,
const
QString
&
startzone
,
const
QString
&
targetzone
,
int
x
,
int
y
)
int
Client
::
moveCard
(
int
cardid
,
const
QString
&
startzone
,
const
QString
&
targetzone
,
int
x
,
int
y
,
bool
faceDown
)
{
{
// if startzone is public: cardid is the card's id
// if startzone is public: cardid is the card's id
// else: cardid is the position of the card in the zone (e.g. deck)
// else: cardid is the position of the card in the zone (e.g. deck)
return
cmd
(
QString
(
"move_card|%1|%2|%3|%4|%5"
).
arg
(
cardid
).
arg
(
startzone
).
arg
(
targetzone
).
arg
(
x
).
arg
(
y
));
return
cmd
(
QString
(
"move_card|%1|%2|%3|%4|%5
|%6
"
).
arg
(
cardid
).
arg
(
startzone
).
arg
(
targetzone
).
arg
(
x
).
arg
(
y
)
.
arg
(
faceDown
?
1
:
0
)
);
}
}
int
Client
::
createToken
(
const
QString
&
zone
,
const
QString
&
name
,
const
QString
&
powtough
,
int
x
,
int
y
)
int
Client
::
createToken
(
const
QString
&
zone
,
const
QString
&
name
,
const
QString
&
powtough
,
int
x
,
int
y
)
...
...
cockatrice/src/client.h
View file @
a429a4a0
...
@@ -70,7 +70,7 @@ public:
...
@@ -70,7 +70,7 @@ public:
int
shuffle
();
int
shuffle
();
int
rollDice
(
unsigned
int
sides
);
int
rollDice
(
unsigned
int
sides
);
int
drawCards
(
unsigned
int
number
);
int
drawCards
(
unsigned
int
number
);
int
moveCard
(
int
cardid
,
const
QString
&
startzone
,
const
QString
&
targetzone
,
int
x
,
int
y
=
0
);
int
moveCard
(
int
cardid
,
const
QString
&
startzone
,
const
QString
&
targetzone
,
int
x
,
int
y
=
0
,
bool
faceDown
=
false
);
int
createToken
(
const
QString
&
zone
,
const
QString
&
name
,
const
QString
&
powtough
,
int
x
,
int
y
);
int
createToken
(
const
QString
&
zone
,
const
QString
&
name
,
const
QString
&
powtough
,
int
x
,
int
y
);
int
setCardAttr
(
const
QString
&
zone
,
int
cardid
,
const
QString
&
aname
,
const
QString
&
avalue
);
int
setCardAttr
(
const
QString
&
zone
,
int
cardid
,
const
QString
&
aname
,
const
QString
&
avalue
);
int
readyStart
();
int
readyStart
();
...
...
cockatrice/src/game.cpp
View file @
a429a4a0
...
@@ -66,6 +66,8 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
...
@@ -66,6 +66,8 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
connect
(
aTap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actTap
()));
connect
(
aTap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actTap
()));
aUntap
=
new
QAction
(
tr
(
"&Untap"
),
this
);
aUntap
=
new
QAction
(
tr
(
"&Untap"
),
this
);
connect
(
aUntap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actUntap
()));
connect
(
aUntap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actUntap
()));
aDoesntUntap
=
new
QAction
(
tr
(
"Toggle &normal untapping"
),
this
);
connect
(
aDoesntUntap
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actDoesntUntap
()));
aAddCounter
=
new
QAction
(
tr
(
"&Add counter"
),
this
);
aAddCounter
=
new
QAction
(
tr
(
"&Add counter"
),
this
);
connect
(
aAddCounter
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actAddCounter
()));
connect
(
aAddCounter
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actAddCounter
()));
aRemoveCounter
=
new
QAction
(
tr
(
"&Remove counter"
),
this
);
aRemoveCounter
=
new
QAction
(
tr
(
"&Remove counter"
),
this
);
...
@@ -77,6 +79,8 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
...
@@ -77,6 +79,8 @@ Game::Game(CardDatabase *_db, Client *_client, QGraphicsScene *_scene, QMenu *_a
cardMenu
->
addAction
(
aTap
);
cardMenu
->
addAction
(
aTap
);
cardMenu
->
addAction
(
aUntap
);
cardMenu
->
addAction
(
aUntap
);
cardMenu
->
addAction
(
aDoesntUntap
);
cardMenu
->
addSeparator
();
cardMenu
->
addAction
(
aAddCounter
);
cardMenu
->
addAction
(
aAddCounter
);
cardMenu
->
addAction
(
aRemoveCounter
);
cardMenu
->
addAction
(
aRemoveCounter
);
cardMenu
->
addAction
(
aSetCounters
);
cardMenu
->
addAction
(
aSetCounters
);
...
@@ -108,6 +112,7 @@ Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, b
...
@@ -108,6 +112,7 @@ Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, b
connect
(
newPlayer
,
SIGNAL
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)),
this
,
SIGNAL
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)));
connect
(
newPlayer
,
SIGNAL
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)),
this
,
SIGNAL
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)));
connect
(
newPlayer
,
SIGNAL
(
logSetTapped
(
QString
,
QString
,
bool
)),
this
,
SIGNAL
(
logSetTapped
(
QString
,
QString
,
bool
)));
connect
(
newPlayer
,
SIGNAL
(
logSetTapped
(
QString
,
QString
,
bool
)),
this
,
SIGNAL
(
logSetTapped
(
QString
,
QString
,
bool
)));
connect
(
newPlayer
,
SIGNAL
(
logSetCounter
(
QString
,
QString
,
int
,
int
)),
this
,
SIGNAL
(
logSetCounter
(
QString
,
QString
,
int
,
int
)));
connect
(
newPlayer
,
SIGNAL
(
logSetCounter
(
QString
,
QString
,
int
,
int
)),
this
,
SIGNAL
(
logSetCounter
(
QString
,
QString
,
int
,
int
)));
connect
(
newPlayer
,
SIGNAL
(
logSetDoesntUntap
(
QString
,
QString
,
bool
)),
this
,
SIGNAL
(
logSetDoesntUntap
(
QString
,
QString
,
bool
)));
players
<<
newPlayer
;
players
<<
newPlayer
;
emit
playerAdded
(
newPlayer
);
emit
playerAdded
(
newPlayer
);
...
@@ -147,6 +152,7 @@ void Game::restartGameDialog()
...
@@ -147,6 +152,7 @@ void Game::restartGameDialog()
void
Game
::
gameEvent
(
ServerEventData
*
msg
)
void
Game
::
gameEvent
(
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
());
if
(
!
msg
->
getPublic
())
if
(
!
msg
->
getPublic
())
localPlayer
->
gameEvent
(
msg
);
localPlayer
->
gameEvent
(
msg
);
else
{
else
{
...
@@ -231,9 +237,7 @@ void Game::gameEvent(ServerEventData *msg)
...
@@ -231,9 +237,7 @@ void Game::gameEvent(ServerEventData *msg)
void
Game
::
actUntapAll
()
void
Game
::
actUntapAll
()
{
{
CardList
*
const
cards
=
localPlayer
->
getZones
()
->
findZone
(
"table"
)
->
getCards
();
client
->
setCardAttr
(
"table"
,
-
1
,
"tapped"
,
"false"
);
for
(
int
i
=
0
;
i
<
cards
->
size
();
i
++
)
client
->
setCardAttr
(
"table"
,
cards
->
at
(
i
)
->
getId
(),
"tapped"
,
"false"
);
}
}
void
Game
::
actIncLife
()
void
Game
::
actIncLife
()
...
@@ -308,6 +312,15 @@ void Game::actUntap()
...
@@ -308,6 +312,15 @@ void Game::actUntap()
}
}
}
}
void
Game
::
actDoesntUntap
()
{
QListIterator
<
QGraphicsItem
*>
i
(
scene
->
selectedItems
());
while
(
i
.
hasNext
())
{
CardItem
*
temp
=
(
CardItem
*
)
i
.
next
();
client
->
setCardAttr
(
qgraphicsitem_cast
<
CardZone
*>
(
temp
->
parentItem
())
->
getName
(),
temp
->
getId
(),
"doesnt_untap"
,
QString
::
number
(
!
temp
->
getDoesntUntap
()));
}
}
void
Game
::
actAddCounter
()
void
Game
::
actAddCounter
()
{
{
QListIterator
<
QGraphicsItem
*>
i
(
scene
->
selectedItems
());
QListIterator
<
QGraphicsItem
*>
i
(
scene
->
selectedItems
());
...
...
cockatrice/src/game.h
View file @
a429a4a0
...
@@ -15,7 +15,7 @@ class Game : public QObject {
...
@@ -15,7 +15,7 @@ class Game : public QObject {
Q_OBJECT
Q_OBJECT
private:
private:
QMenu
*
actionsMenu
,
*
cardMenu
;
QMenu
*
actionsMenu
,
*
cardMenu
;
QAction
*
aTap
,
*
aUntap
,
*
aAddCounter
,
*
aRemoveCounter
,
*
aSetCounters
,
*
aRearrange
,
QAction
*
aTap
,
*
aUntap
,
*
aDoesntUntap
,
*
aAddCounter
,
*
aRemoveCounter
,
*
aSetCounters
,
*
aRearrange
,
*
aUntapAll
,
*
aDecLife
,
*
aIncLife
,
*
aSetLife
,
*
aShuffle
,
*
aDraw
,
*
aDrawCards
,
*
aRollDice
,
*
aCreateToken
;
*
aUntapAll
,
*
aDecLife
,
*
aIncLife
,
*
aSetLife
,
*
aShuffle
,
*
aDraw
,
*
aDrawCards
,
*
aRollDice
,
*
aCreateToken
;
DlgStartGame
*
dlgStartGame
;
DlgStartGame
*
dlgStartGame
;
...
@@ -40,6 +40,7 @@ private slots:
...
@@ -40,6 +40,7 @@ private slots:
void
showCardMenu
(
QPoint
p
);
void
showCardMenu
(
QPoint
p
);
void
actTap
();
void
actTap
();
void
actUntap
();
void
actUntap
();
void
actDoesntUntap
();
void
actAddCounter
();
void
actAddCounter
();
void
actRemoveCounter
();
void
actRemoveCounter
();
void
actSetCounters
();
void
actSetCounters
();
...
@@ -69,6 +70,7 @@ signals:
...
@@ -69,6 +70,7 @@ signals:
void
logSetCardCounters
(
QString
playerName
,
QString
cardName
,
int
value
,
int
oldValue
);
void
logSetCardCounters
(
QString
playerName
,
QString
cardName
,
int
value
,
int
oldValue
);
void
logSetTapped
(
QString
playerName
,
QString
cardName
,
bool
tapped
);
void
logSetTapped
(
QString
playerName
,
QString
cardName
,
bool
tapped
);
void
logSetCounter
(
QString
playerName
,
QString
counterName
,
int
value
,
int
oldValue
);
void
logSetCounter
(
QString
playerName
,
QString
counterName
,
int
value
,
int
oldValue
);
void
logSetDoesntUntap
(
QString
playerName
,
QString
cardName
,
bool
doesntUntap
);
void
logDumpZone
(
QString
playerName
,
QString
zoneName
,
QString
zoneOwner
,
int
numberCards
);
void
logDumpZone
(
QString
playerName
,
QString
zoneName
,
QString
zoneOwner
,
int
numberCards
);
public
slots
:
public
slots
:
void
restartGameDialog
();
void
restartGameDialog
();
...
...
cockatrice/src/gravezone.cpp
View file @
a429a4a0
...
@@ -48,7 +48,7 @@ void GraveZone::addCard(CardItem *card, bool reorganize, int x, int y)
...
@@ -48,7 +48,7 @@ void GraveZone::addCard(CardItem *card, bool reorganize, int x, int y)
reorganizeCards
();
reorganizeCards
();
}
}
void
GraveZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
)
void
GraveZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
{
{
player
->
client
->
moveCard
(
cardId
,
startZone
->
getName
(),
getName
(),
0
,
0
);
player
->
client
->
moveCard
(
cardId
,
startZone
->
getName
(),
getName
(),
0
,
0
);
}
}
...
@@ -79,8 +79,9 @@ void GraveZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -79,8 +79,9 @@ void GraveZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if
(
cards
->
empty
())
if
(
cards
->
empty
())
return
;
return
;
bool
faceDown
=
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
);
CardItem
*
card
=
cards
->
at
(
0
);
CardItem
*
card
=
cards
->
at
(
0
);
CardDragItem
*
drag
=
card
->
createDragItem
(
this
,
card
->
getId
(),
event
->
pos
(),
event
->
scenePos
());
CardDragItem
*
drag
=
card
->
createDragItem
(
this
,
card
->
getId
(),
event
->
pos
(),
event
->
scenePos
()
,
faceDown
);
drag
->
grabMouse
();
drag
->
grabMouse
();
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
}
}
...
...
cockatrice/src/gravezone.h
View file @
a429a4a0
...
@@ -11,7 +11,7 @@ public:
...
@@ -11,7 +11,7 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
addCard
(
CardItem
*
card
,
bool
reorganize
=
true
,
int
x
=
0
,
int
y
=
-
1
);
void
addCard
(
CardItem
*
card
,
bool
reorganize
=
true
,
int
x
=
0
,
int
y
=
-
1
);
void
reorganizeCards
();
void
reorganizeCards
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
protected:
protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
cockatrice/src/handzone.cpp
View file @
a429a4a0
...
@@ -66,7 +66,7 @@ void HandZone::addCard(CardItem *card, bool reorganize, int x, int y)
...
@@ -66,7 +66,7 @@ void HandZone::addCard(CardItem *card, bool reorganize, int x, int y)
reorganizeCards
();
reorganizeCards
();
}
}
void
HandZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
)
void
HandZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
{
{
Q_UNUSED
(
dropPoint
);
Q_UNUSED
(
dropPoint
);
player
->
client
->
moveCard
(
cardId
,
startZone
->
getName
(),
getName
(),
cards
->
size
(),
0
);
player
->
client
->
moveCard
(
cardId
,
startZone
->
getName
(),
getName
(),
cards
->
size
(),
0
);
...
...
cockatrice/src/handzone.h
View file @
a429a4a0
...
@@ -11,7 +11,7 @@ public:
...
@@ -11,7 +11,7 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
addCard
(
CardItem
*
card
,
bool
reorganize
=
true
,
int
x
=
-
1
,
int
y
=
-
1
);
void
addCard
(
CardItem
*
card
,
bool
reorganize
=
true
,
int
x
=
-
1
,
int
y
=
-
1
);
void
reorganizeCards
();
void
reorganizeCards
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
};
};
#endif
#endif
cockatrice/src/libraryzone.cpp
View file @
a429a4a0
...
@@ -57,7 +57,7 @@ void LibraryZone::addCard(CardItem *card, bool reorganize, int x, int y)
...
@@ -57,7 +57,7 @@ void LibraryZone::addCard(CardItem *card, bool reorganize, int x, int y)
reorganizeCards
();
reorganizeCards
();
}
}
void
LibraryZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
)
void
LibraryZone
::
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
)
{
{
player
->
client
->
moveCard
(
cardId
,
startZone
->
getName
(),
getName
(),
0
,
0
);
player
->
client
->
moveCard
(
cardId
,
startZone
->
getName
(),
getName
(),
0
,
0
);
}
}
...
@@ -88,8 +88,9 @@ void LibraryZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
...
@@ -88,8 +88,9 @@ void LibraryZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if
(
cards
->
empty
())
if
(
cards
->
empty
())
return
;
return
;
bool
faceDown
=
event
->
modifiers
().
testFlag
(
Qt
::
ShiftModifier
);
CardItem
*
card
=
cards
->
at
(
0
);
CardItem
*
card
=
cards
->
at
(
0
);
CardDragItem
*
drag
=
card
->
createDragItem
(
this
,
0
,
event
->
pos
(),
event
->
scenePos
());
CardDragItem
*
drag
=
card
->
createDragItem
(
this
,
0
,
event
->
pos
(),
event
->
scenePos
()
,
faceDown
);
drag
->
grabMouse
();
drag
->
grabMouse
();
setCursor
(
Qt
::
OpenHandCursor
);
setCursor
(
Qt
::
OpenHandCursor
);
}
}
...
...
cockatrice/src/libraryzone.h
View file @
a429a4a0
...
@@ -11,7 +11,7 @@ public:
...
@@ -11,7 +11,7 @@ public:
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
paint
(
QPainter
*
painter
,
const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
);
void
addCard
(
CardItem
*
card
,
bool
reorganize
=
true
,
int
x
=
0
,
int
y
=
-
1
);
void
addCard
(
CardItem
*
card
,
bool
reorganize
=
true
,
int
x
=
0
,
int
y
=
-
1
);
void
reorganizeCards
();
void
reorganizeCards
();
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
);
void
handleDropEvent
(
int
cardId
,
CardZone
*
startZone
,
const
QPoint
&
dropPoint
,
bool
faceDown
);
protected:
protected:
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mousePressEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
void
mouseMoveEvent
(
QGraphicsSceneMouseEvent
*
event
);
...
...
cockatrice/src/messagelogwidget.cpp
View file @
a429a4a0
...
@@ -112,6 +112,14 @@ void MessageLogWidget::logSetCounter(QString playerName, QString counterName, in
...
@@ -112,6 +112,14 @@ void MessageLogWidget::logSetCounter(QString playerName, QString counterName, in
appendAndScroll
(
tr
(
"%1 sets counter
\"
%2
\"
to %3 (%4%5)"
).
arg
(
playerName
).
arg
(
counterName
).
arg
(
value
).
arg
(
value
>
oldValue
?
"+"
:
""
).
arg
(
value
-
oldValue
));
appendAndScroll
(
tr
(
"%1 sets counter
\"
%2
\"
to %3 (%4%5)"
).
arg
(
playerName
).
arg
(
counterName
).
arg
(
value
).
arg
(
value
>
oldValue
?
"+"
:
""
).
arg
(
value
-
oldValue
));
}
}
void
MessageLogWidget
::
logSetDoesntUntap
(
QString
playerName
,
QString
cardName
,
bool
doesntUntap
)
{
if
(
doesntUntap
)
appendAndScroll
(
tr
(
"%1 sets %2 to not untap normally."
).
arg
(
playerName
).
arg
(
cardName
));
else
appendAndScroll
(
tr
(
"%1 sets %2 to untap normally."
).
arg
(
playerName
).
arg
(
cardName
));
}
void
MessageLogWidget
::
logDumpZone
(
QString
playerName
,
QString
zoneName
,
QString
zoneOwner
,
int
numberCards
)
void
MessageLogWidget
::
logDumpZone
(
QString
playerName
,
QString
zoneName
,
QString
zoneOwner
,
int
numberCards
)
{
{
if
(
numberCards
)
if
(
numberCards
)
...
@@ -137,6 +145,7 @@ void MessageLogWidget::connectToGame(Game *game)
...
@@ -137,6 +145,7 @@ void MessageLogWidget::connectToGame(Game *game)
connect
(
game
,
SIGNAL
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)),
this
,
SLOT
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)));
connect
(
game
,
SIGNAL
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)),
this
,
SLOT
(
logSetCardCounters
(
QString
,
QString
,
int
,
int
)));
connect
(
game
,
SIGNAL
(
logSetTapped
(
QString
,
QString
,
bool
)),
this
,
SLOT
(
logSetTapped
(
QString
,
QString
,
bool
)));
connect
(
game
,
SIGNAL
(
logSetTapped
(
QString
,
QString
,
bool
)),
this
,
SLOT
(
logSetTapped
(
QString
,
QString
,
bool
)));
connect
(
game
,
SIGNAL
(
logSetCounter
(
QString
,
QString
,
int
,
int
)),
this
,
SLOT
(
logSetCounter
(
QString
,
QString
,
int
,
int
)));
connect
(
game
,
SIGNAL
(
logSetCounter
(
QString
,
QString
,
int
,
int
)),
this
,
SLOT
(
logSetCounter
(
QString
,
QString
,
int
,
int
)));
connect
(
game
,
SIGNAL
(
logSetDoesntUntap
(
QString
,
QString
,
bool
)),
this
,
SLOT
(
logSetDoesntUntap
(
QString
,
QString
,
bool
)));
connect
(
game
,
SIGNAL
(
logDumpZone
(
QString
,
QString
,
QString
,
int
)),
this
,
SLOT
(
logDumpZone
(
QString
,
QString
,
QString
,
int
)));
connect
(
game
,
SIGNAL
(
logDumpZone
(
QString
,
QString
,
QString
,
int
)),
this
,
SLOT
(
logDumpZone
(
QString
,
QString
,
QString
,
int
)));
}
}
...
...
cockatrice/src/messagelogwidget.h
View file @
a429a4a0
...
@@ -28,6 +28,7 @@ private slots:
...
@@ -28,6 +28,7 @@ private slots:
void
logSetCardCounters
(
QString
playerName
,
QString
cardName
,
int
value
,
int
oldValue
);
void
logSetCardCounters
(
QString
playerName
,
QString
cardName
,
int
value
,
int
oldValue
);
void
logSetTapped
(
QString
playerName
,
QString
cardName
,
bool
tapped
);
void
logSetTapped
(
QString
playerName
,
QString
cardName
,
bool
tapped
);
void
logSetCounter
(
QString
playerName
,
QString
counterName
,
int
value
,
int
oldValue
);
void
logSetCounter
(
QString
playerName
,
QString
counterName
,
int
value
,
int
oldValue
);
void
logSetDoesntUntap
(
QString
playerName
,
QString
cardName
,
bool
doesntUntap
);
void
logDumpZone
(
QString
playerName
,
QString
zoneName
,
QString
zoneOwner
,
int
numberCards
);
void
logDumpZone
(
QString
playerName
,
QString
zoneName
,
QString
zoneOwner
,
int
numberCards
);
private:
private:
void
appendAndScroll
(
const
QString
&
s
);
void
appendAndScroll
(
const
QString
&
s
);
...
...
cockatrice/src/player.cpp
View file @
a429a4a0
...
@@ -128,6 +128,31 @@ void Player::addCounter(Counter *c)
...
@@ -128,6 +128,31 @@ void Player::addCounter(Counter *c)
counters
<<
c
;
counters
<<
c
;
}
}
void
Player
::
setCardAttrHelper
(
CardItem
*
card
,
const
QString
&
aname
,
const
QString
&
avalue
,
bool
allCards
)
{
if
(
aname
==
"tapped"
)
{
bool
tapped
=
avalue
==
"1"
;
if
(
!
(
!
tapped
&&
card
->
getDoesntUntap
()
&&
allCards
))
{
emit
logSetTapped
(
name
,
card
->
getName
(),
tapped
);
card
->
setTapped
(
tapped
);
}
}
else
if
(
aname
==
"attacking"
)
card
->
setAttacking
(
avalue
==
"1"
);
else
if
(
aname
==
"facedown"
)
card
->
setFaceDown
(
avalue
==
"1"
);
else
if
(
aname
==
"counters"
)
{
int
value
=
avalue
.
toInt
();
emit
logSetCardCounters
(
name
,
card
->
getName
(),
value
,
card
->
getCounters
());
card
->
setCounters
(
value
);
}
else
if
(
aname
==
"annotation"
)
card
->
setAnnotation
(
avalue
);
else
if
(
aname
==
"doesnt_untap"
)
{
bool
value
=
(
avalue
==
"1"
);
emit
logSetDoesntUntap
(
name
,
card
->
getName
(),
value
);
card
->
setDoesntUntap
(
value
);
}
}
void
Player
::
gameEvent
(
ServerEventData
*
event
)
void
Player
::
gameEvent
(
ServerEventData
*
event
)
{
{
QStringList
data
=
event
->
getEventData
();
QStringList
data
=
event
->
getEventData
();
...
@@ -171,7 +196,7 @@ void Player::gameEvent(ServerEventData *event)
...
@@ -171,7 +196,7 @@ void Player::gameEvent(ServerEventData *event)
break
;
break
;
}
}
case
eventMoveCard
:
{
case
eventMoveCard
:
{
if
(
data
.
size
()
!=
7
)
{
if
(
data
.
size
()
!=
8
)
{
qDebug
(
"error"
);
qDebug
(
"error"
);
// XXX
// XXX
}
}
...
@@ -186,14 +211,17 @@ void Player::gameEvent(ServerEventData *event)
...
@@ -186,14 +211,17 @@ void Player::gameEvent(ServerEventData *event)
qDebug
(
QString
(
"target zone invalid: %1"
).
arg
(
data
[
4
]).
toLatin1
());
qDebug
(
QString
(
"target zone invalid: %1"
).
arg
(
data
[
4
]).
toLatin1
());
int
x
=
data
[
5
].
toInt
();
int
x
=
data
[
5
].
toInt
();
int
y
=
data
[
6
].
toInt
();
int
y
=
data
[
6
].
toInt
();
bool
facedown
=
data
[
7
].
toInt
();
// XXX Mehr Fehlerbehandlung
// XXX Mehr Fehlerbehandlung
CardItem
*
card
=
startZone
->
takeCard
(
position
,
cardId
,
cardName
);
CardItem
*
card
=
startZone
->
takeCard
(
position
,
cardId
,
cardName
);
if
(
!
card
)
// XXX
if
(
!
card
)
// XXX
qDebug
(
"
null
"
);
qDebug
(
"
moveCard: card not found
"
);
card
->
deleteDragItem
();
card
->
deleteDragItem
();
card
->
setFaceDown
(
facedown
);
// The log event has to be sent before the card is added to the target zone
// The log event has to be sent before the card is added to the target zone
// because the addCard function can modify the card object.
// because the addCard function can modify the card object.
emit
logMoveCard
(
name
,
card
->
getName
(),
startZone
->
getName
(),
targetZone
->
getName
());
emit
logMoveCard
(
name
,
card
->
getName
(),
startZone
->
getName
(),
targetZone
->
getName
());
...
@@ -227,25 +255,18 @@ void Player::gameEvent(ServerEventData *event)
...
@@ -227,25 +255,18 @@ void Player::gameEvent(ServerEventData *event)
}
}
CardZone
*
zone
=
zones
.
findZone
(
data
[
0
]);
CardZone
*
zone
=
zones
.
findZone
(
data
[
0
]);
int
cardId
=
data
[
1
].
toInt
();
int
cardId
=
data
[
1
].
toInt
();
CardItem
*
card
=
zone
->
getCard
(
cardId
,
""
);
QString
aname
=
data
[
2
];
QString
aname
=
data
[
2
];
QString
avalue
=
data
[
3
];
QString
avalue
=
data
[
3
];
// XXX Fehlerbehandlung
// XXX Fehlerbehandlung
if
(
aname
==
"tapped"
)
{
if
(
cardId
==
-
1
)
{
bool
tapped
=
avalue
==
"1"
;
CardList
*
const
cards
=
zone
->
getCards
();
emit
logSetTapped
(
name
,
card
->
getName
(),
tapped
);
for
(
int
i
=
0
;
i
<
cards
->
size
();
i
++
)
card
->
setTapped
(
tapped
);
setCardAttrHelper
(
cards
->
at
(
i
),
aname
,
avalue
,
true
);
}
else
if
(
aname
==
"attacking"
)
}
else
{
card
->
setAttacking
(
avalue
==
"1"
);
CardItem
*
card
=
zone
->
getCard
(
cardId
,
""
);
else
if
(
aname
==
"facedown"
)
setCardAttrHelper
(
card
,
aname
,
avalue
,
false
);
card
->
setFacedown
(
avalue
==
"1"
);
}
else
if
(
aname
==
"counters"
)
{
int
value
=
avalue
.
toInt
();
emit
logSetCardCounters
(
name
,
card
->
getName
(),
value
,
card
->
getCounters
());
card
->
setCounters
(
value
);
}
else
if
(
aname
==
"annotation"
)
card
->
setAnnotation
(
avalue
);
break
;
break
;
}
}
case
eventSetCounter
:
{
case
eventSetCounter
:
{
...
...
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