Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
moves.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 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
18#include <QObject>
19#include <QJsonValue>
20#include <QVector>
21#include <QString>
22#include <QHash>
23#include <optional>
24
25#include <pse-common/types.h>
26#include "./db_autoport.h"
27
28struct TypeDBEntry;
29struct ItemDBEntry;
31struct PokemonDBEntry;
32class QQmlEngine;
33
47 MoveDBEntry();
48 MoveDBEntry(QJsonValue& data);
49 void deepLink();
50
51 QString name;
52 var8 ind = 0;
53 bool glitch = false;
54 QString type;
55 QString readable;
56
57 std::optional<var8> power;
58 std::optional<var8> accuracy;
59 std::optional<var8> pp;
60 std::optional<var8> tm;
61 std::optional<var8> hm;
62
63 TypeDBEntry* toType = nullptr;
64 ItemDBEntry* toItem = nullptr;
65
66 // Back-references populated during PokemonDB deep-link
67 QVector<struct PokemonDBEntryMove*> toPokemonLearned;
68 QVector<struct PokemonDBEntry*> toPokemonInitial;
69 QVector<struct PokemonDBEntry*> toPokemonTmHm;
70};
71
81class DB_AUTOPORT MovesDB : public QObject
82{
83 Q_OBJECT
84 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
85
86public:
87 static MovesDB* inst();
88
89 [[nodiscard]] const QVector<MoveDBEntry*> getStore() const;
90 [[nodiscard]] const QHash<QString, MoveDBEntry*> getInd() const;
91 [[nodiscard]] int getStoreSize() const;
92
93 Q_INVOKABLE MoveDBEntry* getStoreAt(int idx) const;
94 Q_INVOKABLE MoveDBEntry* getIndAt(const QString& key) const;
95
96public slots:
97 void load();
98 void index();
99 void deepLink();
100 void qmlProtect(const QQmlEngine* const engine) const;
101
102private slots:
103 void qmlRegister() const;
104
105private:
106 MovesDB();
107
108 QVector<MoveDBEntry*> store;
109 QHash<QString, MoveDBEntry*> ind;
110};
void load()
Load moves from JSON.
Definition moves.cpp:93
void deepLink()
Resolve every move's cross-DB links.
Definition moves.cpp:117
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition moves.cpp:126
int getStoreSize() const
Move count.
Definition moves.cpp:80
const QHash< QString, MoveDBEntry * > getInd() const
Name->entry index.
Definition moves.cpp:79
void index()
Build the name->entry index.
Definition moves.cpp:103
MoveDBEntry * getStoreAt(int idx) const
Move by store index (for QML).
Definition moves.cpp:82
const QVector< MoveDBEntry * > getStore() const
All moves, in load order.
Definition moves.cpp:78
MoveDBEntry * getIndAt(const QString &key) const
Move by name key (for QML).
Definition moves.cpp:88
static MovesDB * inst()
< Number of moves.
Definition moves.cpp:72
Project-wide fixed-width integer aliases (var8, var16, ...).
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition types.h:124
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 item's static data: name/flags, pricing, and where it's used.
Definition itemdbentry.h:46
One move's static data (type, power, accuracy, PP, TM/HM), with links.
Definition moves.h:46
std::optional< var8 > hm
HM number teaching this move, if any.
Definition moves.h:61
QVector< struct PokemonDBEntryMove * > toPokemonLearned
Mons that learn this by level-up.
Definition moves.h:67
QString type
Type name (resolved to toType).
Definition moves.h:54
ItemDBEntry * toItem
Resolved TM/HM item entry (deepLink).
Definition moves.h:64
QVector< struct PokemonDBEntry * > toPokemonInitial
Mons that start with this move.
Definition moves.h:68
std::optional< var8 > pp
Base PP, if any.
Definition moves.h:59
std::optional< var8 > accuracy
Accuracy, if any.
Definition moves.h:58
void deepLink()
Resolve cross-DB links (type, item) after load.
Definition moves.cpp:51
TypeDBEntry * toType
Resolved type entry (deepLink).
Definition moves.h:63
var8 ind
Move index/id.
Definition moves.h:52
std::optional< var8 > power
Base power, if any.
Definition moves.h:57
QVector< struct PokemonDBEntry * > toPokemonTmHm
Mons that can learn it via TM/HM.
Definition moves.h:69
QString readable
Human-readable display name.
Definition moves.h:55
std::optional< var8 > tm
TM number teaching this move, if any.
Definition moves.h:60
QString name
Internal move name (key).
Definition moves.h:51
bool glitch
Whether this is a glitch move.
Definition moves.h:53
MoveDBEntry()
Empty entry.
Definition moves.cpp:35
One learnable move of a species, with the level it's learned at.
Definition pokemon.h:74
One species' complete static data – the richest entry in the db layer.
Definition pokemon.h:98
One elemental type: its name plus the moves and Pokemon of that type.
Definition types.h:39