mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-14 19:18:55 -07:00
Remove isView flag from CardZone (#5728)
* Remove `isView` flag from CardZone
This flag is used for two purposes:
1. It is used as a check for casting to a zone to a `ZoneViewZone`;
2. Non-view zones are added to the player's zones on construction
This patch removes the `isView` flag and instead:
1. We directly cast zones to `ZoneViewZone` using a dynamic (qobject)
cast and use the result of the cast instead of the `isView` flag to
detect if we are a view zone or not;
2. The player records its own zones when they are created, simplifying
control flow.
* Review
This commit is contained in:
parent
6fd1e9a4c4
commit
1409dcc2e8
8 changed files with 30 additions and 47 deletions
|
|
@ -336,8 +336,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() <
|
||||
2 * QApplication::startDragDistance())
|
||||
return;
|
||||
if (zone->getIsView()) {
|
||||
const ZoneViewZone *view = static_cast<const ZoneViewZone *>(zone);
|
||||
if (const ZoneViewZone *view = qobject_cast<const ZoneViewZone *>(zone)) {
|
||||
if (view->getRevealZone() && !view->getWriteableRevealZone())
|
||||
return;
|
||||
} else if (!owner->getLocalOrJudge())
|
||||
|
|
@ -394,10 +393,8 @@ void CardItem::playCard(bool faceDown)
|
|||
*/
|
||||
static bool isUnwritableRevealZone(CardZone *zone)
|
||||
{
|
||||
if (zone && zone->getIsView()) {
|
||||
if (auto *view = static_cast<ZoneViewZone *>(zone)) {
|
||||
return view->getRevealZone() && !view->getWriteableRevealZone();
|
||||
}
|
||||
if (auto *view = qobject_cast<ZoneViewZone *>(zone)) {
|
||||
return view->getRevealZone() && !view->getWriteableRevealZone();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue