Cockatrice 2026-06-01-Development-3.1.0-beta.3
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
CardItem Class Reference

#include <card_item.h>

Inheritance diagram for CardItem:
[legend]
Collaboration diagram for CardItem:
[legend]

Public Types

enum  { Type = typeCard }
Public Types inherited from AbstractCardItem
enum  { Type = typeCard }

Public Slots

void deleteLater ()
Public Slots inherited from AbstractCardItem
void refreshCardInfo ()

Public Member Functions

int type () const override
 CardItem (PlayerLogic *_owner, QGraphicsItem *parent=nullptr, const CardRef &cardRef={}, int _cardid=-1, CardZoneLogic *_zone=nullptr)
void retranslateUi ()
CardStategetState () const
CardZoneLogicgetZone () const
void setZone (CardZoneLogic *_zone)
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
QPoint getGridPoint () const
void setGridPoint (const QPoint &_gridPoint)
QPoint getGridPos () const
PlayerLogicgetOwner () const
void setOwner (PlayerLogic *_owner)
bool getAttacking () const
void setAttacking (bool _attacking)
const QMap< int, int > & getCounters () const
void setCounter (int _id, int _value)
QString getAnnotation () const
void setAnnotation (const QString &_annotation)
bool getDoesntUntap () const
void setDoesntUntap (bool _doesntUntap)
QString getPT () const
void setPT (const QString &_pt)
bool getDestroyOnZoneChange () const
void setDestroyOnZoneChange (bool _destroy)
CardItemgetAttachedTo () const
void setAttachedTo (CardItem *_attachedTo)
void addAttachedCard (CardItem *card)
void removeAttachedCard (CardItem *card)
const QList< CardItem * > & getAttachedCards () const
void resetState (bool keepAnnotations=false)
 Resets the fields that should be reset after a zone transition.
void processCardInfo (const ServerInfo_Card &_info)
bool animationEvent ()
CardDragItemcreateDragItem (int _id, const QPointF &_pos, const QPointF &_scenePos, bool forceFaceDown)
void deleteDragItem ()
void drawArrow (const QColor &arrowColor)
void drawAttachArrow ()
void playCard (bool faceDown)
Public Member Functions inherited from AbstractCardItem
int type () const override
 AbstractCardItem (QGraphicsItem *parent=nullptr, const CardRef &cardRef={}, PlayerLogic *_owner=nullptr, int _id=-1)
 ~AbstractCardItem () override
QRectF boundingRect () const override
QPainterPath shape () const override
QSizeF getTranslatedSize (QPainter *painter) const
void paintPicture (QPainter *painter, const QSizeF &translatedSize, int angle)
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
ExactCard getCard () const
const CardInfogetCardInfo () const
int getId () const
void setId (int _id)
QString getName () const
QString getProviderId () const
void setCardRef (const CardRef &_cardRef)
CardRef getCardRef () const
qreal getRealZValue () const
void setRealZValue (qreal _zValue)
void setHovered (bool _hovered)
bool getIsHovered () const
QString getColor () const
void setColor (const QString &_color)
bool getTapped () const
void setTapped (bool _tapped, bool canAnimate=false)
bool getFaceDown () const
void setFaceDown (bool _facedown)
void processHoverEvent ()
void deleteCardInfoPopup ()
Public Member Functions inherited from ArrowTarget
 ArrowTarget (PlayerLogic *_owner, QGraphicsItem *parent=nullptr)
 ~ArrowTarget () override=default
PlayerLogicgetOwner () const
void setBeingPointedAt (bool _beingPointedAt)
bool getBeingPointedAt () const
Public Member Functions inherited from AbstractGraphicsItem
 AbstractGraphicsItem (QGraphicsItem *parent=nullptr)

Static Public Member Functions

static QVariantList parsePT (const QString &pt)
 Parses a string representing a p/t in order to extract the values from it.

Protected Member Functions

void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
Protected Member Functions inherited from AbstractCardItem
void transformPainter (QPainter *painter, const QSizeF &translatedSize, int angle)
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
QVariant itemChange (QGraphicsItem::GraphicsItemChange change, const QVariant &value) override
void cacheBgColor ()
Protected Member Functions inherited from ArrowTarget
QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
Protected Member Functions inherited from AbstractGraphicsItem
void paintNumberEllipse (int number, int radius, const QColor &color, int position, int count, QPainter *painter)

Private Member Functions

void prepareDelete ()
void handleClickedToPlay (bool shiftHeld)

Private Attributes

CardStatestate
QPoint gridPoint
CardDragItemdragItem
QList< CardItem * > attachedCards

Additional Inherited Members

Signals inherited from AbstractCardItem
void hovered (AbstractCardItem *card)
void showCardInfoPopup (const QPoint &pos, const CardRef &cardRef)
void deleteCardInfoPopup (QString cardName)
void sigPixmapUpdated ()
void cardShiftClicked (QString cardName)
Signals inherited from ArrowTarget
void scenePositionChanged ()
Protected Attributes inherited from AbstractCardItem
ExactCard exactCard
int id
CardRef cardRef
bool tapped
bool facedown
int tapAngle
QString color
QColor bgColor
Protected Attributes inherited from ArrowTarget
PlayerLogicowner

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Constructor & Destructor Documentation

◆ CardItem()

CardItem::CardItem ( PlayerLogic * _owner,
QGraphicsItem * parent = nullptr,
const CardRef & cardRef = {},
int _cardid = -1,
CardZoneLogic * _zone = nullptr )
explicit
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ addAttachedCard()

void CardItem::addAttachedCard ( CardItem * card)
inline
Here is the call graph for this function:

◆ animationEvent()

bool CardItem::animationEvent ( )
Here is the call graph for this function:

◆ createDragItem()

CardDragItem * CardItem::createDragItem ( int _id,
const QPointF & _pos,
const QPointF & _scenePos,
bool forceFaceDown )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deleteDragItem()

void CardItem::deleteDragItem ( )
Here is the caller graph for this function:

◆ deleteLater

void CardItem::deleteLater ( )
slot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawArrow()

void CardItem::drawArrow ( const QColor & arrowColor)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawAttachArrow()

void CardItem::drawAttachArrow ( )
Here is the call graph for this function:

◆ getAnnotation()

QString CardItem::getAnnotation ( ) const
inlinenodiscard

◆ getAttachedCards()

const QList< CardItem * > & CardItem::getAttachedCards ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getAttachedTo()

CardItem * CardItem::getAttachedTo ( ) const
inlinenodiscard
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAttacking()

bool CardItem::getAttacking ( ) const
inlinenodiscard

◆ getCounters()

const QMap< int, int > & CardItem::getCounters ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getDestroyOnZoneChange()

bool CardItem::getDestroyOnZoneChange ( ) const
inlinenodiscard

◆ getDoesntUntap()

bool CardItem::getDoesntUntap ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getGridPoint()

QPoint CardItem::getGridPoint ( ) const
inlinenodiscard

◆ getGridPos()

QPoint CardItem::getGridPos ( ) const
inlinenodiscard

◆ getOwner()

PlayerLogic * CardItem::getOwner ( ) const
inlinenodiscard

◆ getPT()

QString CardItem::getPT ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getState()

CardState * CardItem::getState ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getZone()

CardZoneLogic * CardItem::getZone ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ handleClickedToPlay()

void CardItem::handleClickedToPlay ( bool shiftHeld)
private

This method is called when a "click to play" is done on the card. This is either triggered by a single click or double click, depending on the settings.

Parameters
shiftHeldif the shift key was held during the click
Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemChange()

QVariant CardItem::itemChange ( GraphicsItemChange change,
const QVariant & value )
overrideprotected
Here is the call graph for this function:

◆ mouseDoubleClickEvent()

void CardItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ mouseMoveEvent()

void CardItem::mouseMoveEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ mouseReleaseEvent()

void CardItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event)
overrideprotected
Here is the call graph for this function:

◆ paint()

void CardItem::paint ( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget )
override
Here is the call graph for this function:

◆ parsePT()

QVariantList CardItem::parsePT ( const QString & pt)
static

Parses a string representing a p/t in order to extract the values from it.

If the string contains '/', the string will be split at the '/' and each side will be parsed separately, which means the result list will have two elements.

If '/' is not found, then the entire string is parsed together, which means the result list will have a single element.

If either side of the split is empty, there will also only be a single element in the result list.

This function will attempt to parse each substring as an int first, handling plus and minus prefixes. If successful, it will put the parsed value into the QVariant as an int. If failed, it will just put the substring into the QVariant as a QString.

Parameters
ptThe p/t string
Returns
A QVariantList that can contain one or two elements, where each QVariant can be either int or QString
Here is the caller graph for this function:

◆ playCard()

void CardItem::playCard ( bool faceDown)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ prepareDelete()

void CardItem::prepareDelete ( )
private
Here is the caller graph for this function:

◆ processCardInfo()

void CardItem::processCardInfo ( const ServerInfo_Card & _info)
Here is the call graph for this function:

◆ removeAttachedCard()

void CardItem::removeAttachedCard ( CardItem * card)
inline
Here is the call graph for this function:

◆ resetState()

void CardItem::resetState ( bool keepAnnotations = false)

Resets the fields that should be reset after a zone transition.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ retranslateUi()

void CardItem::retranslateUi ( )

◆ setAnnotation()

void CardItem::setAnnotation ( const QString & _annotation)
Here is the caller graph for this function:

◆ setAttachedTo()

void CardItem::setAttachedTo ( CardItem * _attachedTo)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAttacking()

void CardItem::setAttacking ( bool _attacking)
Here is the caller graph for this function:

◆ setCounter()

void CardItem::setCounter ( int _id,
int _value )
Here is the caller graph for this function:

◆ setDestroyOnZoneChange()

void CardItem::setDestroyOnZoneChange ( bool _destroy)
inline
Here is the caller graph for this function:

◆ setDoesntUntap()

void CardItem::setDoesntUntap ( bool _doesntUntap)
Here is the caller graph for this function:

◆ setGridPoint()

void CardItem::setGridPoint ( const QPoint & _gridPoint)
inline
Here is the caller graph for this function:

◆ setOwner()

void CardItem::setOwner ( PlayerLogic * _owner)
inline
Here is the caller graph for this function:

◆ setPT()

void CardItem::setPT ( const QString & _pt)
Here is the caller graph for this function:

◆ setZone()

void CardItem::setZone ( CardZoneLogic * _zone)
Here is the caller graph for this function:

◆ type()

int CardItem::type ( ) const
inlinenodiscardoverride

Member Data Documentation

◆ attachedCards

QList<CardItem *> CardItem::attachedCards
private

◆ dragItem

CardDragItem* CardItem::dragItem
private

◆ gridPoint

QPoint CardItem::gridPoint
private

◆ state

CardState* CardItem::state
private

The documentation for this class was generated from the following files: