Cute Chess  0.1
Public Types | Public Member Functions | List of all members
GraphicsPieceReserve Class Reference

A graphical reserve for captured chess pieces. More...

#include <graphicspiecereserve.h>

Inheritance diagram for GraphicsPieceReserve:
QGraphicsItem

Public Types

enum  { Type = UserType + 3 }
 
- Public Types inherited from QGraphicsItem
enum  CacheMode
 
enum  Extension
 
enum  GraphicsItemFlag
 

Public Member Functions

void addPiece (GraphicsPiece *piece)
 
virtual QRectF boundingRect () const
 
 GraphicsPieceReserve (qreal squareSize, QGraphicsItem *parent=nullptr)
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr)
 
GraphicsPiecepiece (const Chess::Piece &piece) const
 
int pieceCount (const Chess::Piece &piece) const
 
GraphicsPiecetakePiece (const Chess::Piece &piece)
 
virtual int type () const
 

Detailed Description

A graphical reserve for captured chess pieces.

Some chess variants like Crazyhouse have a reserve for captured pieces which can be brought back to the game. This class acts as a kind of separate chessboard for the piece reserve.

Member Enumeration Documentation

anonymous enum

The type value returned by type().

Constructor & Destructor Documentation

GraphicsPieceReserve::GraphicsPieceReserve ( qreal  squareSize,
QGraphicsItem parent = nullptr 
)
explicit

Creates a new piece reserve.

Each "square" has a width and height of squareSize, and squares are automatically added and removed when needed.

Member Function Documentation

void GraphicsPieceReserve::addPiece ( GraphicsPiece piece)

Adds piece to the reserve. This object becomes the parent item and container of piece.

GraphicsPiece * GraphicsPieceReserve::piece ( const Chess::Piece piece) const

Returns a GraphicsPiece object of type piece. Returns 0 if no pieces of type piece exist.

int GraphicsPieceReserve::pieceCount ( const Chess::Piece piece) const

Returns the number of pieces of type piece.

GraphicsPiece * GraphicsPieceReserve::takePiece ( const Chess::Piece piece)

Removes a GraphicsPiece of type piece and returns it. Returns 0 if no pieces of type exist.


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