Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
pokemonparty.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 "./pokemonbox.h"
18#include <pse-common/types.h>
20
21class SaveFile;
22
36{
37 Q_OBJECT
38
39 Q_PROPERTY(int maxHP MEMBER maxHP NOTIFY maxHPChanged)
40 Q_PROPERTY(int attack MEMBER attack NOTIFY attackChanged)
41 Q_PROPERTY(int defense MEMBER defense NOTIFY defenseChanged)
42 Q_PROPERTY(int speed MEMBER speed NOTIFY speedChanged)
43 Q_PROPERTY(int special MEMBER special NOTIFY specialChanged)
44
45public:
46 PokemonParty(SaveFile* saveFile = nullptr,
47 var16 offset = 0,
48 var16 nicknameStartOffset = 0,
49 var16 otNameStartOffset = 0,
50 var8 index = 0);
51
52 virtual ~PokemonParty();
53
55 virtual SaveFileIterator* load(SaveFile* saveFile = nullptr,
56 var16 offset = 0,
57 var16 nicknameStartOffset = 0,
58 var16 otNameStartOffset = 0,
59 var8 index = 0,
60 var8 recordSize = 0x2C) override;
61
63 virtual SaveFileIterator* save(SaveFile* saveFile,
64 var16 offset,
65 svar32 speciesStartOffset,
66 var16 nicknameStartOffset,
67 var16 otNameStartOffset,
68 var8 index,
69 var8 recordSize = 0x2C) override;
70
71 virtual void copyFrom(PokemonBox* pkmn) override;
72
73 static PokemonBox* convertToBox(PokemonParty* data);
76
77signals:
83
84public slots:
85 virtual void reset() override;
86 virtual void randomize(PlayerBasics* basics = nullptr) override;
87 virtual void update(bool resetHp = false,
88 bool resetExp = false,
89 bool resetType = false,
90 bool resetCatchRate = false,
91 bool correctMoves = false) override;
92 virtual bool isBoxMon() override;
93
94 void regenStats();
95
96public:
97 // Pre-generated stats when not in box
98 int maxHP;
99 int attack;
101 int speed;
103};
The trainer's headline values: name, ID, money, coins, badges, starter.
virtual void randomize(PlayerBasics *basics=nullptr)
Randomize this Pokemon (constrained).
virtual void update(bool resetHp=false, bool resetExp=false, bool resetType=false, bool resetCatchRate=false, bool correctMoves=false)
Recompute derived stats.
virtual SaveFileIterator * save(SaveFile *saveFile=nullptr, var16 startOffset=0, svar32 speciesStartOffset=0, var16 nicknameStartOffset=0, var16 otNameStartOffset=0, var8 index=0, var8 recordSize=0x21)
Flatten one Pokemon back to the save.
void resetExp()
Reset EXP to the current level's baseline.
void correctMoves()
Repair move/PP inconsistencies.
virtual SaveFileIterator * load(SaveFile *saveFile=nullptr, var16 startOffset=0, var16 nicknameStartOffset=0, var16 otNameStartOffset=0, var8 index=0, var8 recordSize=0x21)
Expand one Pokemon from the save.
virtual void copyFrom(PokemonBox *pkmn)
Deep-copy another mon's values into this one.
virtual bool isBoxMon()
True for a pure box mon; PokemonParty overrides to false.
PokemonBox(SaveFile *saveFile=nullptr, var16 startOffset=0, var16 nicknameStartOffset=0, var16 otNameStartOffset=0, var8 index=0, var8 recordSize=0x21)
< Species id (raw save value).
virtual void reset()
Blank this Pokemon.
PokemonParty(SaveFile *saveFile=nullptr, var16 offset=0, var16 nicknameStartOffset=0, var16 otNameStartOffset=0, var8 index=0)
< Stored max HP.
void defenseChanged()
PokemonBox * toBoxData()
This mon as a plain box record.
static PokemonParty * convertToParty(PokemonBox *data)
New party mon from a box record (regenerates stats).
static PokemonBox * convertToBox(PokemonParty *data)
New box record from a party mon (drops stored stats).
void regenStats()
Recompute the five stored stats from species/level/DVs/EVs.
void attackChanged()
void speedChanged()
void specialChanged()
protected::void maxHPChanged()
A moving cursor over a SaveFile, layering auto-advancing reads/writes on top of SaveFileToolset.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
Project-wide fixed-width integer aliases (var8, var16, ...).
svar32e svar32
Signed, exactly 32-bit (shorthand for svar32e).
Definition types.h:111
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition types.h:124
var16e var16
Everyday 16-bit alias. Exact width to avoid the "fastest" widening bug.
Definition types.h:125
Import/export macro for the savefile library, plus the central list of QObject types kept deliberatel...
#define SAVEFILE_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.