This commit is contained in:
RickyRister 2026-06-20 22:56:25 -07:00 committed by GitHub
commit 86f1cc11d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 44 additions and 13 deletions

View file

@ -85,7 +85,8 @@ void CardDatabase::refreshCachedReverseRelatedCards()
for (auto *rel : card->getReverseRelatedCards()) {
if (auto target = cards.value(rel->getName())) {
auto *newRel = new CardRelation(card->getName(), rel->getAttachType(), rel->getIsCreateAllExclusion(),
rel->getIsVariable(), rel->getDefaultCount(), rel->getIsPersistent());
rel->getIsVariable(), rel->getDefaultCount(), rel->getIsPersistent(),
rel->getIsFaceDown());
target->addReverseRelatedCards2Me(newRel);
}
}

View file

@ -329,6 +329,7 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
bool exclude = false;
bool variable = false;
bool persistent = false;
bool facedown = false;
int count = 1;
QXmlStreamAttributes attrs = xml.attributes();
QString cardName = xml.readElementText(QXmlStreamReader::IncludeChildElements);
@ -360,7 +361,12 @@ void CockatriceXml4Parser::loadCardsFromXml(QXmlStreamReader &xml)
persistent = true;
}
auto *relation = new CardRelation(cardName, attachType, exclude, variable, count, persistent);
if (attrs.hasAttribute("facedown")) {
facedown = true;
}
auto *relation =
new CardRelation(cardName, attachType, exclude, variable, count, persistent, facedown);
if (xmlName == "reverse-related") {
reverseRelatedCards << relation;
} else {
@ -510,6 +516,9 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfoPtr &in
if (i->getIsPersistent()) {
xml.writeAttribute("persistent", "persistent");
}
if (i->getIsFaceDown()) {
xml.writeAttribute("facedown", "facedown");
}
if (i->getIsVariable()) {
if (1 == i->getDefaultCount()) {
xml.writeAttribute("count", "x");

View file

@ -7,8 +7,10 @@ CardRelation::CardRelation(const QString &_name,
bool _isCreateAllExclusion,
bool _isVariableCount,
int _defaultCount,
bool _isPersistent)
bool _isPersistent,
bool _isFaceDown)
: name(_name), attachType(_attachType), isCreateAllExclusion(_isCreateAllExclusion),
isVariableCount(_isVariableCount), defaultCount(_defaultCount), isPersistent(_isPersistent)
isVariableCount(_isVariableCount), defaultCount(_defaultCount), isPersistent(_isPersistent),
isFaceDown(_isFaceDown)
{
}
}

View file

@ -31,6 +31,7 @@ private:
bool isVariableCount; ///< True if the number of creations is variable.
int defaultCount; ///< Default number of cards created or involved.
bool isPersistent; ///< True if this relation persists (i.e. is not destroyed) on zone change.
bool isFaceDown; ///< True if this relation creates the tokens facedown
public:
/**
@ -42,13 +43,15 @@ public:
* @param _isVariableCount Whether the count is variable.
* @param _defaultCount Default number for creations or transformations.
* @param _isPersistent Whether the relation persists across zone changes.
* @param _isFaceDown Whether the relation creates the token face down
*/
explicit CardRelation(const QString &_name = QString(),
CardRelationType _attachType = CardRelationType::DoesNotAttach,
bool _isCreateAllExclusion = false,
bool _isVariableCount = false,
int _defaultCount = 1,
bool _isPersistent = false);
bool _isPersistent = false,
bool _isFaceDown = false);
/**
* @brief Returns the name of the related card.
@ -151,6 +154,16 @@ public:
{
return isPersistent;
}
/**
* @brief Returns whether the relation creates the token facedown.
*
* @return True if facedown, false otherwise.
*/
[[nodiscard]] bool getIsFaceDown() const
{
return isFaceDown;
}
};
#endif // COCKATRICE_CARD_RELATION_H