Cockatrice 2026-06-27-Development-3.1.0-beta.3
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
arrow_registry.h
Go to the documentation of this file.
1#ifndef COCKATRICE_ARROW_REGISTRY_H
2#define COCKATRICE_ARROW_REGISTRY_H
3
4#include "board/arrow_data.h"
5
6#include <QMap>
7#include <QSet>
8#include <QSharedPointer>
9
10class ArrowItem;
11
13{
16
17 bool operator<(const ArrowKey &other) const
18 {
19 if (creatorId != other.creatorId) {
20 return creatorId < other.creatorId;
21 }
22 return arrowId < other.arrowId;
23 }
24};
25
27{
28public:
29 void insert(QSharedPointer<ArrowData> data, ArrowItem *arrow);
30 ArrowItem *take(int creatorId, int arrowId);
31
32 [[nodiscard]] ArrowItem *get(int creatorId, int arrowId) const;
33 [[nodiscard]] bool contains(int creatorId, int arrowId) const;
34 [[nodiscard]] QSet<int> idsForPlayer(int playerId) const;
35 [[nodiscard]] QList<ArrowItem *> all() const;
36
37private:
38 QMap<ArrowKey, QSharedPointer<ArrowData>> dataStore;
39 QMap<ArrowKey, ArrowItem *> items;
40 QMap<int, QSet<int>> byPlayer;
41};
42
43#endif
Definition arrow_item.h:16
Definition arrow_registry.h:27
QMap< ArrowKey, QSharedPointer< ArrowData > > dataStore
Definition arrow_registry.h:38
QMap< int, QSet< int > > byPlayer
Definition arrow_registry.h:40
QSet< int > idsForPlayer(int playerId) const
Definition arrow_registry.cpp:40
QList< ArrowItem * > all() const
Definition arrow_registry.cpp:45
QMap< ArrowKey, ArrowItem * > items
Definition arrow_registry.h:39
ArrowItem * get(int creatorId, int arrowId) const
Definition arrow_registry.cpp:30
void insert(QSharedPointer< ArrowData > data, ArrowItem *arrow)
Definition arrow_registry.cpp:5
bool contains(int creatorId, int arrowId) const
Definition arrow_registry.cpp:35
ArrowItem * take(int creatorId, int arrowId)
Definition arrow_registry.cpp:18
Definition arrow_registry.h:13
bool operator<(const ArrowKey &other) const
Definition arrow_registry.h:17
int arrowId
Definition arrow_registry.h:15
int creatorId
Definition arrow_registry.h:14