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
d2b71a15
Commit
d2b71a15
authored
Jun 27, 2015
by
Zach
Browse files
Merge pull request #1166 from ctrlaltca/fix_232
Support <tablerow> for tokens; fix #232
parents
08d7f8e9
f84d6fec
Changes
4
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/player.cpp
View file @
d2b71a15
...
@@ -102,6 +102,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
...
@@ -102,6 +102,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
shortcutsActive
(
false
),
shortcutsActive
(
false
),
defaultNumberTopCards
(
1
),
defaultNumberTopCards
(
1
),
lastTokenDestroy
(
true
),
lastTokenDestroy
(
true
),
lastTokenTableRow
(
0
),
id
(
_id
),
id
(
_id
),
active
(
false
),
active
(
false
),
local
(
_local
),
local
(
_local
),
...
@@ -1035,6 +1036,7 @@ void Player::actCreateToken()
...
@@ -1035,6 +1036,7 @@ void Player::actCreateToken()
lastTokenPT
=
dlg
.
getPT
();
lastTokenPT
=
dlg
.
getPT
();
if
(
CardInfo
*
correctedCard
=
db
->
getCardBySimpleName
(
lastTokenName
,
false
))
{
if
(
CardInfo
*
correctedCard
=
db
->
getCardBySimpleName
(
lastTokenName
,
false
))
{
lastTokenName
=
correctedCard
->
getName
();
lastTokenName
=
correctedCard
->
getName
();
lastTokenTableRow
=
table
->
clampValidTableRow
(
2
-
correctedCard
->
getTableRow
());
if
(
lastTokenPT
.
isEmpty
())
if
(
lastTokenPT
.
isEmpty
())
lastTokenPT
=
correctedCard
->
getPowTough
();
lastTokenPT
=
correctedCard
->
getPowTough
();
}
}
...
@@ -1056,7 +1058,7 @@ void Player::actCreateAnotherToken()
...
@@ -1056,7 +1058,7 @@ void Player::actCreateAnotherToken()
cmd
.
set_annotation
(
lastTokenAnnotation
.
toStdString
());
cmd
.
set_annotation
(
lastTokenAnnotation
.
toStdString
());
cmd
.
set_destroy_on_zone_change
(
lastTokenDestroy
);
cmd
.
set_destroy_on_zone_change
(
lastTokenDestroy
);
cmd
.
set_x
(
-
1
);
cmd
.
set_x
(
-
1
);
cmd
.
set_y
(
0
);
cmd
.
set_y
(
lastTokenTableRow
);
sendGameCommand
(
cmd
);
sendGameCommand
(
cmd
);
}
}
...
@@ -1070,6 +1072,7 @@ void Player::actCreatePredefinedToken()
...
@@ -1070,6 +1072,7 @@ void Player::actCreatePredefinedToken()
lastTokenColor
=
cardInfo
->
getColors
().
isEmpty
()
?
QString
()
:
cardInfo
->
getColors
().
first
().
toLower
();
lastTokenColor
=
cardInfo
->
getColors
().
isEmpty
()
?
QString
()
:
cardInfo
->
getColors
().
first
().
toLower
();
lastTokenPT
=
cardInfo
->
getPowTough
();
lastTokenPT
=
cardInfo
->
getPowTough
();
lastTokenAnnotation
=
cardInfo
->
getText
();
lastTokenAnnotation
=
cardInfo
->
getText
();
lastTokenTableRow
=
table
->
clampValidTableRow
(
2
-
cardInfo
->
getTableRow
());
lastTokenDestroy
=
true
;
lastTokenDestroy
=
true
;
aCreateAnotherToken
->
setEnabled
(
true
);
aCreateAnotherToken
->
setEnabled
(
true
);
...
@@ -1657,7 +1660,7 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
...
@@ -1657,7 +1660,7 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
cmd
.
set_y
(
0
);
cmd
.
set_y
(
0
);
}
else
{
}
else
{
int
tableRow
=
faceDown
?
2
:
ci
->
getTableRow
();
int
tableRow
=
faceDown
?
2
:
ci
->
getTableRow
();
QPoint
gridPoint
=
QPoint
(
-
1
,
2
-
tableRow
);
QPoint
gridPoint
=
QPoint
(
-
1
,
table
->
clampValidTableRow
(
2
-
tableRow
)
)
;
cardToMove
->
set_face_down
(
faceDown
);
cardToMove
->
set_face_down
(
faceDown
);
cardToMove
->
set_pt
(
ci
->
getPowTough
().
toStdString
());
cardToMove
->
set_pt
(
ci
->
getPowTough
().
toStdString
());
cardToMove
->
set_tapped
(
faceDown
?
false
:
tapped
);
cardToMove
->
set_tapped
(
faceDown
?
false
:
tapped
);
...
...
cockatrice/src/player.h
View file @
d2b71a15
...
@@ -185,6 +185,7 @@ private:
...
@@ -185,6 +185,7 @@ private:
int
defaultNumberTopCards
;
int
defaultNumberTopCards
;
QString
lastTokenName
,
lastTokenColor
,
lastTokenPT
,
lastTokenAnnotation
;
QString
lastTokenName
,
lastTokenColor
,
lastTokenPT
,
lastTokenAnnotation
;
bool
lastTokenDestroy
;
bool
lastTokenDestroy
;
int
lastTokenTableRow
;
ServerInfo_User
*
userInfo
;
ServerInfo_User
*
userInfo
;
int
id
;
int
id
;
bool
active
;
bool
active
;
...
...
cockatrice/src/tablezone.cpp
View file @
d2b71a15
...
@@ -31,7 +31,7 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
...
@@ -31,7 +31,7 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
updateBgPixmap
();
updateBgPixmap
();
height
=
2
*
BOX_LINE_WIDTH
+
3
*
(
CARD_HEIGHT
+
20
)
+
2
*
PADDING_Y
;
height
=
2
*
BOX_LINE_WIDTH
+
TABLEROWS
*
(
CARD_HEIGHT
+
20
)
+
2
*
PADDING_Y
;
width
=
MIN_WIDTH
+
2
*
MARGIN_X
+
2
*
BOX_LINE_WIDTH
;
width
=
MIN_WIDTH
+
2
*
MARGIN_X
+
2
*
BOX_LINE_WIDTH
;
currentMinimumWidth
=
MIN_WIDTH
;
currentMinimumWidth
=
MIN_WIDTH
;
...
@@ -311,7 +311,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
...
@@ -311,7 +311,7 @@ QPointF TableZone::mapFromGrid(QPoint gridPoint) const
if
(
isInverted
())
if
(
isInverted
())
gridPoint
.
setY
(
2
-
gridPoint
.
y
());
gridPoint
.
setY
(
2
-
gridPoint
.
y
());
y
=
BOX_LINE_WIDTH
+
gridPoint
.
y
()
*
(
CARD_HEIGHT
+
PADDING_Y
+
20
)
+
(
gridPoint
.
x
()
%
3
)
*
10
;
y
=
BOX_LINE_WIDTH
+
gridPoint
.
y
()
*
(
CARD_HEIGHT
+
PADDING_Y
+
20
)
+
(
gridPoint
.
x
()
%
TABLEROWS
)
*
10
;
/*
/*
if (isInverted())
if (isInverted())
y = height - CARD_HEIGHT - y;
y = height - CARD_HEIGHT - y;
...
@@ -339,7 +339,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
...
@@ -339,7 +339,7 @@ QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
int
resultY
=
round
(
y
/
(
CARD_HEIGHT
+
PADDING_Y
+
20
));
int
resultY
=
round
(
y
/
(
CARD_HEIGHT
+
PADDING_Y
+
20
));
if
(
isInverted
())
if
(
isInverted
())
resultY
=
2
-
resultY
;
resultY
=
TABLEROWS
-
1
-
resultY
;
int
baseX
=
-
1
;
int
baseX
=
-
1
;
qreal
oldTempX
=
0
,
tempX
=
0
;
qreal
oldTempX
=
0
,
tempX
=
0
;
...
@@ -365,3 +365,12 @@ QPointF TableZone::closestGridPoint(const QPointF &point)
...
@@ -365,3 +365,12 @@ QPointF TableZone::closestGridPoint(const QPointF &point)
gridPoint
.
setX
(
gridPoint
.
x
()
+
1
);
gridPoint
.
setX
(
gridPoint
.
x
()
+
1
);
return
mapFromGrid
(
gridPoint
);
return
mapFromGrid
(
gridPoint
);
}
}
int
TableZone
::
clampValidTableRow
(
const
int
row
)
{
if
(
row
<
0
)
return
0
;
if
(
row
>=
TABLEROWS
)
return
TABLEROWS
-
1
;
return
row
;
}
cockatrice/src/tablezone.h
View file @
d2b71a15
...
@@ -25,6 +25,7 @@ private:
...
@@ -25,6 +25,7 @@ private:
static
const
int
PADDING_Y
=
10
;
static
const
int
PADDING_Y
=
10
;
static
const
int
MARGIN_X
=
20
;
static
const
int
MARGIN_X
=
20
;
static
const
int
MIN_WIDTH
=
10
*
CARD_WIDTH
/
2
;
static
const
int
MIN_WIDTH
=
10
*
CARD_WIDTH
/
2
;
static
const
int
TABLEROWS
=
3
;
/*
/*
Default background color, inactive mask and boarder gradient
Default background color, inactive mask and boarder gradient
...
@@ -117,6 +118,8 @@ public:
...
@@ -117,6 +118,8 @@ public:
QPoint
mapToGrid
(
const
QPointF
&
mapPoint
)
const
;
QPoint
mapToGrid
(
const
QPointF
&
mapPoint
)
const
;
QPointF
closestGridPoint
(
const
QPointF
&
point
);
QPointF
closestGridPoint
(
const
QPointF
&
point
);
int
clampValidTableRow
(
const
int
row
);
/**
/**
Removes a card from view.
Removes a card from view.
...
...
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