Refactor: Represent cardName + providerId with CardRef struct (#6039)

* card_ref.h

* update CardDatabase signatures

* make everything compile

* rename methods

* add docs

* mark stuff const

* set cardRef in CardItem

* cleanup

* fix build failure

* Fix builds on mac

---------

Co-authored-by: ZeldaZach <zahalpern+github@gmail.com>
This commit is contained in:
RickyRister 2025-07-15 19:14:02 -07:00 committed by GitHub
parent e05dad4267
commit a9b3be33e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 328 additions and 305 deletions

View file

@ -20,6 +20,7 @@
#ifndef SERVER_CARD_H
#define SERVER_CARD_H
#include "card_ref.h"
#include "pb/card_attributes.pb.h"
#include "pb/serverinfo_card.pb.h"
#include "server_arrowtarget.h"
@ -38,8 +39,7 @@ private:
Server_CardZone *zone;
int id;
int coord_x, coord_y;
QString name;
QString provider_id;
CardRef cardRef;
QMap<int, int> counters;
bool tapped;
bool attacking;
@ -55,12 +55,7 @@ private:
Server_Card *stashedCard;
public:
Server_Card(QString _name,
QString _provider_id,
int _id,
int _coord_x,
int _coord_y,
Server_CardZone *_zone = nullptr);
Server_Card(const CardRef &cardRef, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone = nullptr);
~Server_Card() override;
Server_CardZone *getZone() const
@ -76,9 +71,13 @@ public:
{
return id;
}
CardRef getCardRef() const
{
return cardRef;
}
QString getProviderId() const
{
return provider_id;
return cardRef.providerId;
}
int getX() const
{
@ -90,7 +89,7 @@ public:
}
QString getName() const
{
return name;
return cardRef.name;
}
const QMap<int, int> &getCounters() const
{
@ -150,9 +149,9 @@ public:
coord_x = x;
coord_y = y;
}
void setName(const QString &_name)
void setCardRef(const CardRef &_cardRef)
{
name = _name;
cardRef = _cardRef;
}
void setCounter(int _id, int value, Event_SetCardCounter *event = nullptr);
void setTapped(bool _tapped)