mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 12:03:25 -08:00
[Refactor] Move ArrowRegistry out of game/ into game_graphics/board (#7423)
Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
3ccd44155d
commit
85fd052fdb
5 changed files with 11 additions and 5 deletions
|
|
@ -1,43 +0,0 @@
|
|||
#ifndef COCKATRICE_ARROW_REGISTRY_H
|
||||
#define COCKATRICE_ARROW_REGISTRY_H
|
||||
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
class ArrowItem;
|
||||
struct ArrowData;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct ArrowKey
|
||||
{
|
||||
int creatorId;
|
||||
int arrowId;
|
||||
|
||||
bool operator<(const ArrowKey &other) const
|
||||
{
|
||||
if (creatorId != other.creatorId) {
|
||||
return creatorId < other.creatorId;
|
||||
}
|
||||
return arrowId < other.arrowId;
|
||||
}
|
||||
};
|
||||
|
||||
class ArrowRegistry
|
||||
{
|
||||
public:
|
||||
void insert(QSharedPointer<ArrowData> data, ArrowItem *arrow);
|
||||
ArrowItem *take(int creatorId, int arrowId);
|
||||
|
||||
[[nodiscard]] ArrowItem *get(int creatorId, int arrowId) const;
|
||||
[[nodiscard]] bool contains(int creatorId, int arrowId) const;
|
||||
[[nodiscard]] QSet<int> idsForPlayer(int playerId) const;
|
||||
[[nodiscard]] QList<ArrowItem *> all() const;
|
||||
|
||||
private:
|
||||
QMap<ArrowKey, QSharedPointer<ArrowData>> dataStore;
|
||||
QMap<ArrowKey, ArrowItem *> items;
|
||||
QMap<int, QSet<int>> byPlayer;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue