mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
* [Refactor] Move game logic into libcockatrice_game * [Refactor] Include card_state.h in player_actions.h * [Game] Inject settings providers into libcockatrice_game, drop Widgets * [Game] Follow base rename to createCardRequested after rebase * [Game] Drop unused CardItem forward declaration * [Game] Fix includes after moving game logic into libcockatrice_game --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
44 lines
No EOL
1 KiB
C++
44 lines
No EOL
1 KiB
C++
#ifndef COCKATRICE_ARROW_REGISTRY_H
|
|
#define COCKATRICE_ARROW_REGISTRY_H
|
|
|
|
#include <QList>
|
|
#include <QMap>
|
|
#include <QSet>
|
|
#include <libcockatrice/game/board/arrow_data.h>
|
|
|
|
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 |