Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
itemdbentry.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QObject>
18#include <QString>
19#include <QVector>
20#include <QJsonValue>
21#include "../db_autoport.h"
22
23// as property types without requiring full includes (avoids circular deps).
24struct MoveDBEntry;
27struct PokemonDBEntry;
29class QQmlEngine;
30class ItemsDB;
31
32
46struct DB_AUTOPORT ItemDBEntry : public QObject {
47 Q_OBJECT
48 Q_PROPERTY(QString getName READ getName CONSTANT)
49 Q_PROPERTY(int getInd READ getInd CONSTANT)
50 Q_PROPERTY(bool getOnce READ getOnce CONSTANT)
51 Q_PROPERTY(bool getGlitch READ getGlitch CONSTANT)
52 Q_PROPERTY(QString getReadable READ getReadable CONSTANT)
53 Q_PROPERTY(int getTm READ getTm CONSTANT)
54 Q_PROPERTY(int getHm READ getHm CONSTANT)
55 Q_PROPERTY(int getPrice READ getPrice CONSTANT)
56 Q_PROPERTY(QString getInfo READ getInfo CONSTANT)
57 Q_PROPERTY(int buyPriceMoney READ buyPriceMoney CONSTANT)
58 Q_PROPERTY(int buyPriceCoins READ buyPriceCoins CONSTANT)
59 Q_PROPERTY(int sellPriceMoney READ sellPriceMoney CONSTANT)
60 Q_PROPERTY(int sellPriceCoins READ sellPriceCoins CONSTANT)
61 Q_PROPERTY(bool canSell READ canSell CONSTANT)
62 Q_PROPERTY(bool isGameCornerExclusive READ isGameCornerExclusive CONSTANT)
63 Q_PROPERTY(MoveDBEntry* getToMove READ getToMove CONSTANT)
64 Q_PROPERTY(GameCornerDBEntry* getToGameCorner READ getToGameCorner CONSTANT)
65 // Indexed list properties exposed via size + Q_INVOKABLE accessor (not direct property)
66 Q_PROPERTY(int getToMapSpriteItemSize READ getToMapSpriteItemSize CONSTANT)
67 Q_PROPERTY(int getToEvolvePokemonSize READ getToEvolvePokemonSize CONSTANT)
68 Q_PROPERTY(int getToTeachPokemonSize READ getToTeachPokemonSize CONSTANT)
69
70public:
71 QString getName() const;
72 int getInd() const;
73 bool getOnce() const;
74 bool getGlitch() const;
75 QString getReadable() const;
76 int getTm() const;
77 int getHm() const;
78 int getPrice() const;
79 QString getInfo() const;
80 int buyPriceMoney() const;
81 int buyPriceCoins() const;
82 int sellPriceMoney() const;
83 int sellPriceCoins() const;
84 bool canSell() const;
85 bool isGameCornerExclusive() const;
86
87 MoveDBEntry* getToMove() const;
89
90 const QVector<MapDBEntrySpriteItem*> getToMapSpriteItem() const;
91 int getToMapSpriteItemSize() const;
92 Q_INVOKABLE MapDBEntrySpriteItem* getToMapSpriteItemAt(int ind) const;
93
94 const QVector<PokemonDBEntryEvolution*> getToEvolvePokemon() const;
95 int getToEvolvePokemonSize() const;
96 Q_INVOKABLE PokemonDBEntryEvolution* getToEvolvePokemonAt(int ind) const;
97
98 const QVector<PokemonDBEntry*> getToTeachPokemon() const;
99 int getToTeachPokemonSize() const;
100 Q_INVOKABLE PokemonDBEntry* getToTeachPokemonAt(int ind) const;
101
102public slots:
103 void qmlProtect(const QQmlEngine* const engine) const;
104
105protected:
106 ItemDBEntry();
107 ItemDBEntry(const QJsonValue& data);
108 void deepLink();
109 void qmlRegister() const;
110
111 QString name = "";
112 int ind = -1;
113 bool once = false;
114 bool glitch = false;
115 QString readable = "";
116 int tm = -1;
117 int hm = -1;
118 int price = -1;
119 QString info = "";
120
121 MoveDBEntry* toMove = nullptr;
123 QVector<MapDBEntrySpriteItem*> toMapSpriteItem;
124 QVector<PokemonDBEntryEvolution*> toEvolvePokemon;
125 QVector<PokemonDBEntry*> toTeachPokemon;
126
127 friend class ItemsDB;
128 friend struct MapDBEntrySpriteItem;
129 friend struct GameCornerDBEntry; // writes toGameCorner in GameCornerDBEntry::deepLink
130 friend struct PokemonDBEntry; // writes toTeachPokemon in PokemonDBEntry::deepLink
131 friend struct PokemonDBEntryEvolution; // writes toEvolvePokemon in PokemonDBEntryEvolution::deepLink
132};
The items database – every item (with prices), keyed by name.
Definition itemsdb.h:36
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37
One Game Corner prize: a Pokemon or item, its coin price, and level.
int getPrice() const
int sellPriceMoney() const
QString info
Backing field (read via getInfo()); optional "info" in items.json.
int sellPriceCoins() const
MapDBEntrySpriteItem * getToMapSpriteItemAt(int ind) const
Map-sprite-item ind (for QML).
void deepLink()
Resolve the move/Game-Corner links.
GameCornerDBEntry * getToGameCorner() const
QString readable
Backing field (read via getReadable()).
QString name
Backing field (read via getName()).
MoveDBEntry * toMove
Resolved taught move (deepLink).
friend struct PokemonDBEntry
bool isGameCornerExclusive() const
void qmlRegister() const
Register with QML.
bool canSell() const
int getToMapSpriteItemSize() const
int getToTeachPokemonSize() const
QString getReadable() const
int tm
Backing field (read via getTm()).
int buyPriceMoney() const
PokemonDBEntry * getToTeachPokemonAt(int ind) const
Taught Pokemon ind (for QML).
int getTm() const
int getToEvolvePokemonSize() const
bool getGlitch() const
GameCornerDBEntry * toGameCorner
Resolved Game Corner entry (deepLink).
int buyPriceCoins() const
const QVector< PokemonDBEntryEvolution * > getToEvolvePokemon() const
Evolutions triggered by this item.
QVector< PokemonDBEntryEvolution * > toEvolvePokemon
Evolutions using this (back-ref).
bool glitch
Backing field (read via getGlitch()).
QVector< MapDBEntrySpriteItem * > toMapSpriteItem
Map sprites dropping this (back-ref).
QVector< PokemonDBEntry * > toTeachPokemon
Pokemon this teaches (back-ref).
ItemDBEntry()
Empty entry (built by ItemsDB).
QString getName() const
< Internal item name.
QString getInfo() const
PokemonDBEntryEvolution * getToEvolvePokemonAt(int ind) const
Evolution ind (for QML).
int hm
Backing field (read via getHm()).
const QVector< PokemonDBEntry * > getToTeachPokemon() const
Pokemon this TM/HM teaches.
int ind
Backing field (read via getInd()).
bool once
Backing field (read via getOnce()).
bool getOnce() const
MoveDBEntry * getToMove() const
int price
Backing field (read via getPrice()).
friend class ItemsDB
Owning DB constructs/populates entries.
int getInd() const
int getHm() const
friend struct MapDBEntrySpriteItem
Writes toMapSpriteItem.
const QVector< MapDBEntrySpriteItem * > getToMapSpriteItem() const
Map sprites that drop this item.
friend struct PokemonDBEntryEvolution
friend struct GameCornerDBEntry
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
A map sprite that is a pick-up item (type ITEM).
One move's static data (type, power, accuracy, PP, TM/HM), with links.
Definition moves.h:46
One evolution edge of a species: how it evolves (and de-evolves).
Definition pokemon.h:52
One species' complete static data – the richest entry in the db layer.
Definition pokemon.h:98