mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
refactor CardInfo
This commit is contained in:
parent
827f22ed37
commit
5734f51f3f
2 changed files with 30 additions and 54 deletions
|
|
@ -26,13 +26,9 @@ CardInfo::CardInfo(const QString &_name,
|
|||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
SetToPrintingsMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
bool _upsideDownArt)
|
||||
const UiAttributes _uiAttributes)
|
||||
: name(_name), text(_text), isToken(_isToken), properties(std::move(_properties)), relatedCards(_relatedCards),
|
||||
reverseRelatedCards(_reverseRelatedCards), setsToPrintings(std::move(_sets)), cipt(_cipt),
|
||||
landscapeOrientation(_landscapeOrientation), tableRow(_tableRow), upsideDownArt(_upsideDownArt)
|
||||
reverseRelatedCards(_reverseRelatedCards), setsToPrintings(std::move(_sets)), uiAttributes(_uiAttributes)
|
||||
{
|
||||
simpleName = CardInfo::simplifyName(name);
|
||||
|
||||
|
|
@ -41,8 +37,7 @@ CardInfo::CardInfo(const QString &_name,
|
|||
|
||||
CardInfoPtr CardInfo::newInstance(const QString &_name)
|
||||
{
|
||||
return newInstance(_name, QString(), false, QVariantHash(), QList<CardRelation *>(), QList<CardRelation *>(),
|
||||
SetToPrintingsMap(), false, false, 0, false);
|
||||
return newInstance(_name, "", false, {}, {}, {}, {}, {});
|
||||
}
|
||||
|
||||
CardInfoPtr CardInfo::newInstance(const QString &_name,
|
||||
|
|
@ -52,13 +47,10 @@ CardInfoPtr CardInfo::newInstance(const QString &_name,
|
|||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
SetToPrintingsMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
bool _upsideDownArt)
|
||||
const UiAttributes _uiAttributes)
|
||||
{
|
||||
CardInfoPtr ptr(new CardInfo(_name, _text, _isToken, std::move(_properties), _relatedCards, _reverseRelatedCards,
|
||||
_sets, _cipt, _landscapeOrientation, _tableRow, _upsideDownArt));
|
||||
_sets, _uiAttributes));
|
||||
ptr->setSmartPointer(ptr);
|
||||
|
||||
for (const auto &printings : _sets) {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,21 @@ class CardInfo : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @class CardInfo::UiAttributes
|
||||
* @ingroup Cards
|
||||
*
|
||||
* @brief Attributes of the card that affect display and game logic.
|
||||
*/
|
||||
struct UiAttributes
|
||||
{
|
||||
bool cipt = false; ///< Positioning flag used by UI.
|
||||
bool landscapeOrientation = false; ///< Orientation flag for rendering.
|
||||
int tableRow = 0; ///< Row index in a table or visual representation.
|
||||
bool upsideDownArt = false; ///< Whether artwork is flipped for visual purposes.
|
||||
};
|
||||
|
||||
private:
|
||||
/** @name Private Card Properties
|
||||
* @anchor PrivateCardProperties
|
||||
|
|
@ -63,10 +78,7 @@ private:
|
|||
QList<CardRelation *> reverseRelatedCardsToMe; ///< Cards that consider this card as related.
|
||||
SetToPrintingsMap setsToPrintings; ///< Mapping from set names to printing variations.
|
||||
QString setsNames; ///< Cached, human-readable list of set names.
|
||||
bool cipt; ///< Positioning flag used by UI.
|
||||
bool landscapeOrientation; ///< Orientation flag for rendering.
|
||||
int tableRow; ///< Row index in a table or visual representation.
|
||||
bool upsideDownArt; ///< Whether artwork is flipped for visual purposes.
|
||||
UiAttributes uiAttributes; ///< Attributes that affect display and game logic
|
||||
///@}
|
||||
|
||||
public:
|
||||
|
|
@ -80,10 +92,7 @@ public:
|
|||
* @param _relatedCards Forward references to related cards.
|
||||
* @param _reverseRelatedCards Backward references to related cards.
|
||||
* @param _sets Map of set names to printing information.
|
||||
* @param _cipt UI positioning flag.
|
||||
* @param _landscapeOrientation UI rendering orientation.
|
||||
* @param _tableRow Row index for table placement.
|
||||
* @param _upsideDownArt Whether the artwork should be displayed upside down.
|
||||
* @param _uiAttributes Attributes that affect display and game logic
|
||||
*/
|
||||
explicit CardInfo(const QString &_name,
|
||||
const QString &_text,
|
||||
|
|
@ -92,10 +101,7 @@ public:
|
|||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
SetToPrintingsMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
bool _upsideDownArt);
|
||||
UiAttributes _uiAttributes);
|
||||
|
||||
/**
|
||||
* @brief Copy constructor for CardInfo.
|
||||
|
|
@ -108,8 +114,7 @@ public:
|
|||
: QObject(other.parent()), name(other.name), simpleName(other.simpleName), text(other.text),
|
||||
isToken(other.isToken), properties(other.properties), relatedCards(other.relatedCards),
|
||||
reverseRelatedCards(other.reverseRelatedCards), reverseRelatedCardsToMe(other.reverseRelatedCardsToMe),
|
||||
setsToPrintings(other.setsToPrintings), setsNames(other.setsNames), cipt(other.cipt),
|
||||
landscapeOrientation(other.landscapeOrientation), tableRow(other.tableRow), upsideDownArt(other.upsideDownArt)
|
||||
setsToPrintings(other.setsToPrintings), setsNames(other.setsNames), uiAttributes(other.uiAttributes)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -133,10 +138,7 @@ public:
|
|||
* @param _relatedCards Forward relationships.
|
||||
* @param _reverseRelatedCards Reverse relationships.
|
||||
* @param _sets Printing information per set.
|
||||
* @param _cipt UI positioning flag.
|
||||
* @param _landscapeOrientation UI rendering orientation.
|
||||
* @param _tableRow Row index for table placement.
|
||||
* @param _upsideDownArt Artwork orientation flag.
|
||||
* @param _uiAttributes Attributes that affect display and game logic
|
||||
* @return Shared pointer to the new CardInfo instance.
|
||||
*/
|
||||
static CardInfoPtr newInstance(const QString &_name,
|
||||
|
|
@ -146,10 +148,7 @@ public:
|
|||
const QList<CardRelation *> &_relatedCards,
|
||||
const QList<CardRelation *> &_reverseRelatedCards,
|
||||
SetToPrintingsMap _sets,
|
||||
bool _cipt,
|
||||
bool _landscapeOrientation,
|
||||
int _tableRow,
|
||||
bool _upsideDownArt);
|
||||
UiAttributes _uiAttributes);
|
||||
|
||||
/**
|
||||
* @brief Clones the current CardInfo instance.
|
||||
|
|
@ -254,29 +253,14 @@ public:
|
|||
//@}
|
||||
|
||||
/** @name UI Positioning */ //@{
|
||||
bool getCipt() const
|
||||
const UiAttributes &getUiAttributes() const
|
||||
{
|
||||
return cipt;
|
||||
return uiAttributes;
|
||||
}
|
||||
bool getLandscapeOrientation() const
|
||||
{
|
||||
return landscapeOrientation;
|
||||
}
|
||||
int getTableRow() const
|
||||
{
|
||||
return tableRow;
|
||||
}
|
||||
void setTableRow(int _tableRow)
|
||||
{
|
||||
tableRow = _tableRow;
|
||||
}
|
||||
bool getUpsideDownArt() const
|
||||
{
|
||||
return upsideDownArt;
|
||||
}
|
||||
const QChar getColorChar() const;
|
||||
//@}
|
||||
|
||||
const QChar getColorChar() const;
|
||||
|
||||
/** @name Legacy/Convenience Property Accessors */ //@{
|
||||
const QString getCardType() const;
|
||||
void setCardType(const QString &value);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue