Auto-lint was disabled and my pre-commit hook didn't fire. Oh well.

Took 3 minutes
This commit is contained in:
Lukas Brübach 2025-10-01 00:19:35 +02:00
parent b1a3be681e
commit 66dfa05445
7 changed files with 132 additions and 47 deletions

View file

@ -36,7 +36,6 @@ typedef QHash<QString, CardSetPtr> SetNameMap;
Q_DECLARE_METATYPE(CardInfoPtr)
class CardInfo : public QObject
{
Q_OBJECT

View file

@ -1,9 +1,10 @@
#ifndef COCKATRICE_CARD_RELATION_H
#define COCKATRICE_CARD_RELATION_H
#include "card_relation_type.h"
#include <QObject>
#include <QString>
#include "card_relation_type.h"
class CardRelation : public QObject
{
@ -25,19 +26,48 @@ public:
int _defaultCount = 1,
bool _isPersistent = false);
const QString &getName() const { return name; }
CardRelationType getAttachType() const { return attachType; }
bool getDoesAttach() const { return attachType != CardRelationType::DoesNotAttach; }
bool getDoesTransform() const { return attachType == CardRelationType::TransformInto; }
const QString &getName() const
{
return name;
}
CardRelationType getAttachType() const
{
return attachType;
}
bool getDoesAttach() const
{
return attachType != CardRelationType::DoesNotAttach;
}
bool getDoesTransform() const
{
return attachType == CardRelationType::TransformInto;
}
QString getAttachTypeAsString() const { return cardAttachTypeToString(attachType); }
QString getAttachTypeAsString() const
{
return cardAttachTypeToString(attachType);
}
bool getCanCreateAnother() const { return !getDoesAttach(); }
bool getIsCreateAllExclusion() const { return isCreateAllExclusion; }
bool getIsVariable() const { return isVariableCount; }
int getDefaultCount() const { return defaultCount; }
bool getIsPersistent() const { return isPersistent; }
bool getCanCreateAnother() const
{
return !getDoesAttach();
}
bool getIsCreateAllExclusion() const
{
return isCreateAllExclusion;
}
bool getIsVariable() const
{
return isVariableCount;
}
int getDefaultCount() const
{
return defaultCount;
}
bool getIsPersistent() const
{
return isPersistent;
}
};
#endif // COCKATRICE_CARD_RELATION_H

View file

@ -6,20 +6,24 @@
/**
* Represents how a card relates to another (attach, transform, etc.).
*/
enum class CardRelationType {
enum class CardRelationType
{
DoesNotAttach = 0,
AttachTo = 1,
TransformInto = 2,
};
// Optional helper
inline QString cardAttachTypeToString(CardRelationType type) {
inline QString cardAttachTypeToString(CardRelationType type)
{
switch (type) {
case CardRelationType::AttachTo: return "attach";
case CardRelationType::TransformInto: return "transform";
default: return "";
case CardRelationType::AttachTo:
return "attach";
case CardRelationType::TransformInto:
return "transform";
default:
return "";
}
}
#endif // COCKATRICE_CARD_RELATION_TYPE_H

View file

@ -3,8 +3,8 @@
#include <QDate>
#include <QList>
#include <QString>
#include <QSharedPointer>
#include <QString>
class CardInfo;
using CardInfoPtr = QSharedPointer<CardInfo>;
@ -15,7 +15,8 @@ using CardSetPtr = QSharedPointer<CardSet>;
class CardSet : public QList<CardInfoPtr>
{
public:
enum Priority {
enum Priority
{
PriorityFallback = 0,
PriorityPrimary = 10,
PrioritySecondary = 20,
@ -33,6 +34,7 @@ private:
QString setType;
Priority priority;
bool enabled, isknown;
public:
explicit CardSet(const QString &_shortName = QString(),
const QString &_longName = QString(),
@ -48,28 +50,65 @@ public:
QString getCorrectedShortName() const;
QString getShortName() const { return shortName; }
QString getLongName() const { return longName; }
QString getSetType() const { return setType; }
QDate getReleaseDate() const { return releaseDate; }
Priority getPriority() const { return priority; }
QString getShortName() const
{
return shortName;
}
QString getLongName() const
{
return longName;
}
QString getSetType() const
{
return setType;
}
QDate getReleaseDate() const
{
return releaseDate;
}
Priority getPriority() const
{
return priority;
}
void setLongName(const QString &_longName) { longName = _longName; }
void setSetType(const QString &_setType) { setType = _setType; }
void setReleaseDate(const QDate &_releaseDate) { releaseDate = _releaseDate; }
void setPriority(const Priority _priority) { priority = _priority; }
void setLongName(const QString &_longName)
{
longName = _longName;
}
void setSetType(const QString &_setType)
{
setType = _setType;
}
void setReleaseDate(const QDate &_releaseDate)
{
releaseDate = _releaseDate;
}
void setPriority(const Priority _priority)
{
priority = _priority;
}
void loadSetOptions();
int getSortKey() const { return sortKey; }
int getSortKey() const
{
return sortKey;
}
void setSortKey(unsigned int _sortKey);
bool getEnabled() const { return enabled; }
bool getEnabled() const
{
return enabled;
}
void setEnabled(bool _enabled);
bool getIsKnown() const { return isknown; }
bool getIsKnown() const
{
return isknown;
}
void setIsKnown(bool _isknown);
bool getIsKnownIgnored() const {
bool getIsKnownIgnored() const
{
return longName.length() + setType.length() + releaseDate.toString().length() == 0;
}
};

View file

@ -6,7 +6,7 @@ public:
inline bool operator()(const CardSetPtr &a, const CardSetPtr &b) const
{
if (a.isNull() || b.isNull()) {
//qCWarning(CardInfoLog) << "SetList::KeyCompareFunctor a or b is null";
// qCWarning(CardInfoLog) << "SetList::KeyCompareFunctor a or b is null";
return false;
}
@ -74,7 +74,7 @@ void CardSetList::enableAll()
CardSetPtr set = at(i);
if (set == nullptr) {
//qCWarning(CardInfoLog) << "enabledAll has null";
// qCWarning(CardInfoLog) << "enabledAll has null";
continue;
}
@ -105,7 +105,7 @@ void CardSetList::guessSortKeys()
for (int i = 0; i < size(); ++i) {
CardSetPtr set = at(i);
if (set.isNull()) {
//qCWarning(CardInfoLog) << "guessSortKeys set is null";
// qCWarning(CardInfoLog) << "guessSortKeys set is null";
continue;
}
set->setSortKey(i);

View file

@ -2,6 +2,7 @@
#define COCKATRICE_CARD_SET_LIST_H
#include "card_set.h"
#include <QList>
#include <QStringList>
@ -22,5 +23,4 @@ public:
void defaultSort();
};
#endif // COCKATRICE_CARD_SET_LIST_H

View file

@ -2,10 +2,11 @@
#define COCKATRICE_PRINTING_INFO_H
#include "card_set.h"
#include <QVariant>
#include <QStringList>
#include <QMap>
#include <QList>
#include <QMap>
#include <QStringList>
#include <QVariant>
class PrintingInfo;
@ -20,7 +21,8 @@ public:
explicit PrintingInfo(const CardSetPtr &_set = nullptr);
~PrintingInfo() = default;
bool operator==(const PrintingInfo &other) const {
bool operator==(const PrintingInfo &other) const
{
return this->set == other.set && this->properties == other.properties;
}
@ -30,14 +32,25 @@ private:
QVariantHash properties;
public:
CardSetPtr getSet() const { return set; }
CardSetPtr getSet() const
{
return set;
}
QStringList getProperties() const { return properties.keys(); }
QString getProperty(const QString &propertyName) const { return properties.value(propertyName).toString(); }
void setProperty(const QString &_name, const QString &_value) { properties.insert(_name, _value); }
QStringList getProperties() const
{
return properties.keys();
}
QString getProperty(const QString &propertyName) const
{
return properties.value(propertyName).toString();
}
void setProperty(const QString &_name, const QString &_value)
{
properties.insert(_name, _value);
}
QString getUuid() const;
};
#endif // COCKATRICE_PRINTING_INFO_H