Skip to content
Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
PokemonBox Class Reference

A single Pokemon record – the most property-rich object in the tree. More...

#include <pokemonbox.h>

Inheritance diagram for PokemonBox:
Collaboration diagram for PokemonBox:

Public Member Functions

 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 ~PokemonBox ()
virtual SaveFileIteratorload (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 SaveFileIteratorsave (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.
PokemonDBEntryisValid ()
 The species' DB entry, or null if not a real Pokedex species.
bool isValidBool ()
 Convenience bool form of isValid().
unsigned int levelToExp (int level=-1)
 EXP needed for level (current level if -1).
unsigned int expLevelRangeStart ()
 EXP at the start of the current level.
unsigned int expLevelRangeEnd ()
 EXP at the next level.
float expLevelRangePercent ()
 Fractional progress through the level.
int hpDV ()
int hpStat ()
int nonHpStat (PokemonStats::PokemonStats_ stat)
bool isAfflicted ()
 Has any status condition.
bool isHealed ()
 Fully healed (HP + status). (heal() performs a Pokecenter heal.).
bool isMaxHp ()
 HP equals computed max.
bool hasNickname ()
 Carries a real nickname.
bool hasTradeStatus (PlayerBasics *basics=nullptr)
 Counts as traded relative to basics.
bool hasEvolution ()
 Species can evolve.
bool hasDeEvolution ()
 Species has a pre-evolution.
bool isMaxLevel ()
 Level 100.
bool isMaxPP ()
 All moves at max PP.
bool isMaxPpUps ()
 All moves at max PP-Ups.
bool isMaxEVs ()
 All stat-exp maxed.
bool isMinEvs ()
 All stat-exp zero.
bool isMaxDVs ()
 All DVs maxed.
bool isMinDVs ()
 All DVs zero.
bool isPokemonReset ()
 Matches the reset baseline.
bool isMaxedOut ()
 Level/EV/DV/PP all maxed.
bool isCorrected ()
 Values internally consistent (see correct* slots).
int dexNum ()
 Pokedex number.
QString speciesName ()
 Species display name.
bool isShiny ()
 Shiny per the VC-era DV formula (see disclaimer above).
int getNature ()
virtual void copyFrom (PokemonBox *pkmn)
 Deep-copy another mon's values into this one.
PokemonDBEntrytoData ()
 The species' DB entry for this mon.
int atkStat ()
 Computed Attack stat.
int defStat ()
 Computed Defense stat.
int spdStat ()
 Computed Speed stat.
int spStat ()
 Computed Special stat.
int movesCount ()
 Number of non-empty move slots.
int movesMax ()
 Move-slot capacity (maxMoves).
PokemonMovemovesAt (int ind)
 Move slot ind (GC-protected return).
int dvCount ()
 Number of stored DVs (maxDV).
int dvAt (int ind)
 DV value at ind.
void dvSet (int ind, int val)
 Set DV ind.
protected::void speciesChanged ()
void hpChanged ()
void levelChanged ()
void statusChanged ()
void type1Changed ()
void type2Changed ()
void catchRateChanged ()
void otIDChanged ()
void expChanged ()
void hpExpChanged ()
void atkExpChanged ()
void defExpChanged ()
void spdExpChanged ()
void spExpChanged ()
void dvChanged ()
void otNameChanged ()
void nicknameChanged ()
void movesChanged ()
void type2ExplicitChanged ()
void expRangeChanged ()
void statChanged ()
void healedChanged ()
void hasNicknameChanged ()
void evChanged ()
void pokemonResetChanged ()
virtual void reset ()
 Blank this Pokemon.
virtual void randomize (PlayerBasics *basics=nullptr)
 Randomize this Pokemon (constrained).
void clearMoves ()
 Empty all move slots.
void resetExp ()
 Reset EXP to the current level's baseline.
virtual void update (bool resetHp=false, bool resetExp=false, bool resetType=false, bool resetCatchRate=false, bool correctMoves=false)
 Recompute derived stats.
void correctTypes ()
 Reset type1/type2 to this species' DB-default type(s) (e.g.
void heal ()
 Pokecenter heal: full HP, clear status.
void changeName (bool removeNickname=false)
 Randomize or (if true) remove the nickname.
void changeOtData (bool removeOtData=false, PlayerBasics *basics=nullptr)
 Randomize or remove OT data.
void changeTrade (bool removeTradeStatus=false, PlayerBasics *basics=nullptr)
 Toggle traded status.
void evolve ()
 Evolve to the next species.
void deEvolve ()
 Revert to the prior species.
void maxLevel ()
 Set to level 100.
void maxPpUps ()
 Max every move's PP-Ups.
void maxEVs ()
 Max all stat-exp.
void resetEVs ()
 Zero all stat-exp.
void reRollEVs ()
 Randomize stat-exp.
void maxDVs ()
 Max all DVs.
void reRollDVs ()
 Randomize DVs.
void resetDVs ()
 Zero all DVs.
void maxOut ()
 Max level/EV/DV/PP at once.
void randomizeMoves ()
 Randomize the move set.
void resetPokemon ()
 Reset to the baseline state.
void rollShiny ()
 Randomize DVs until shiny.
void rollNonShiny ()
 Randomize DVs until not shiny.
void makeShiny ()
 Force DVs to a shiny combination.
void unmakeShiny ()
 Force DVs to a non-shiny combination.
void setNature (int nature)
void cleanupMoves ()
 Remove invalid/duplicate moves.
void correctMoves ()
 Repair move/PP inconsistencies.
virtual bool isBoxMon ()
 True for a pure box mon; PokemonParty overrides to false.
void changeMove (int ind, int moveID=0, int pp=0, int ppUp=0)
 Set move slot ind.
void deleteMoveAt (int ind)
 Delete the move in slot ind, then compact so there is no gap in the move list (the slots after it slide up; empties stay parked at the bottom).
void clearMovesButFirst ()
 Remove every move except the first one (slots 1..3 cleared).
void correctMoveAt (int ind)
 Make the move in slot ind valid (PokemonMove::correctMove) THEN compact: correctMove can clear an invalid/duplicate move, which would otherwise leave a gap, so the list is reflowed so there is no hole.
void reorderMove (int from, int to)
 Reorder the filled move slots: take the move at from and re-insert it before slot to (drop-slot convention: 0..movesCount; == movesCount appends after the last move).
void manualSpeciesChanged ()
 UI hook: species edited directly.
void manualLevelChanged ()
 UI hook: level edited directly.

Static Public Member Functions

static PokemonBoxnewPokemon (PokemonRandom::PokemonRandom_ list=PokemonRandom::Random_Starters, PlayerBasics *basics=nullptr)
static PokemonBoxnewPokemon (PokemonDBEntry *pkmnData, PlayerBasics *basics=nullptr)

Public Attributes

int species
int hp
int level
int status
int type1
int type2
int catchRate
int otID
unsigned int exp
int hpExp
int atkExp
int defExp
int spdExp
int spExp
var8 dv [maxDV]
 Stored DVs (Atk/Def/Spd/Spc); HP DV is derived.
QString otName
QString nickname
PokemonMovemoves [4]
 The four move slots.
bool type2Explicit

Detailed Description

A single Pokemon record – the most property-rich object in the tree.

Models one stored Pokemon (box format by default; PokemonParty extends it with party-only stats). The stored fields are the raw save values (species, level, EXP, the four EVs/"exp" stats, DVs, OT name/ID, nickname, moves). On top of those sit a large set of computed Q_PROPERTYs the UI binds to: derived stats, validity/heal/min-max checks, evolution availability, shininess and nature, dex number and species name. Editing a raw field and calling update() recomputes the derived values.

Construction/serialisation take explicit byte offsets because a Pokemon's data is split across regions in the save (species list, the record itself, the nickname table, and the OT-name table). See load()/save().

See also
PokemonStorageBox / PokemonParty (containers), PokemonMove (move slots), PokemonDBEntry (species data), PlayerBasics (OT/trade context).

Definition at line 212 of file pokemonbox.h.

Constructor & Destructor Documentation

◆ PokemonBox()

PokemonBox::PokemonBox ( SaveFile * saveFile = nullptr,
var16 startOffset = 0,
var16 nicknameStartOffset = 0,
var16 otNameStartOffset = 0,
var8 index = 0,
var8 recordSize = 0x21 )

< Species id (raw save value).

Current HP. Level. Status-condition bits. Primary type id. Secondary type id. Catch-rate/held byte. Original-trainer ID. Experience points. HP stat-exp (EV equivalent). Attack stat-exp. Defense stat-exp. Speed stat-exp. Special stat-exp. Original-trainer name. Nickname (may be empty). How type2 is stored (see note at the field). < Is the species a real Pokedex entry? EXP at the current level's start. EXP at the next level. Progress through the current level (0..1). < Derived HP DV (from the four stored DVs). Computed max HP. < Has a status condition? Fully healed (HP + status)? HP at its computed max? Has a non-default nickname? < Can evolve further? Has a prior evolution (de-evolve)? Level 100? All moves at max PP? All moves at max PP-Ups? All stat-exp maxed? All stat-exp zero? All DVs maxed? All DVs zero? Matches a freshly-reset state? Fully maxed (level/EV/DV/PP)? Values are internally consistent? < Shiny by the VC-era DV formula (see disclaimer below). Derived nature (see PokemonNatures). < Computed Attack stat. Computed Defense stat. Computed Speed stat. Computed Special stat. < Pokedex number for the species. Species display name.

Parameters
startOffsetrecord start;
nicknameStartOffset/
otNameStartOffsetlocate the split name tables;
indexslot within the box;
recordSizeper-record byte size (box default 0x21).

Definition at line 290 of file pokemonbox.cpp.

References atkExpChanged(), defExpChanged(), dvChanged(), evChanged(), expRangeChanged(), hasNicknameChanged(), healedChanged(), hpChanged(), hpExpChanged(), levelChanged(), load(), moves, movesChanged(), nicknameChanged(), pokemonResetChanged(), PokemonMove::ppCapChanged(), spdExpChanged(), speciesChanged(), spExpChanged(), and statChanged().

Referenced by PokemonParty::convertToBox(), PokemonParty::convertToParty(), copyFrom(), PokemonParty::copyFrom(), newPokemon(), newPokemon(), and PokemonParty::toBoxData().

◆ ~PokemonBox()

PokemonBox::~PokemonBox ( )
virtual

Definition at line 353 of file pokemonbox.cpp.

References moves.

Member Function Documentation

◆ atkExpChanged()

void PokemonBox::atkExpChanged ( )

◆ atkStat()

int PokemonBox::atkStat ( )

Computed Attack stat.

Definition at line 2012 of file pokemonbox.cpp.

References PokemonStats::Attack, and nonHpStat().

Referenced by PokemonParty::regenStats().

◆ catchRateChanged()

void PokemonBox::catchRateChanged ( )

Referenced by copyFrom(), load(), reset(), and update().

◆ changeMove()

void PokemonBox::changeMove ( int ind,
int moveID = 0,
int pp = 0,
int ppUp = 0 )

Set move slot ind.

Definition at line 1745 of file pokemonbox.cpp.

References moves.

Referenced by pokemonResetChanged().

◆ changeName()

void PokemonBox::changeName ( bool removeNickname = false)

◆ changeOtData()

void PokemonBox::changeOtData ( bool removeOtData = false,
PlayerBasics * basics = nullptr )

◆ changeTrade()

void PokemonBox::changeTrade ( bool removeTradeStatus = false,
PlayerBasics * basics = nullptr )

Toggle traded status.

Definition at line 1162 of file pokemonbox.cpp.

References changeName(), and changeOtData().

Referenced by pokemonResetChanged(), and randomize().

◆ cleanupMoves()

void PokemonBox::cleanupMoves ( )

Remove invalid/duplicate moves.

Definition at line 1651 of file pokemonbox.cpp.

References moves.

Referenced by clearMovesButFirst(), correctMoveAt(), deleteMoveAt(), pokemonResetChanged(), and update().

◆ clearMoves()

void PokemonBox::clearMoves ( )

Empty all move slots.

Definition at line 799 of file pokemonbox.cpp.

References moves, and movesChanged().

Referenced by copyFrom(), pokemonResetChanged(), randomizeMoves(), reset(), and resetPokemon().

◆ clearMovesButFirst()

void PokemonBox::clearMovesButFirst ( )

Remove every move except the first one (slots 1..3 cleared).

The list is compacted first, so "first" is whatever move currently leads the list.

Definition at line 1765 of file pokemonbox.cpp.

References cleanupMoves(), maxMoves, moves, and movesChanged().

Referenced by pokemonResetChanged().

◆ copyFrom()

◆ correctMoveAt()

void PokemonBox::correctMoveAt ( int ind)

Make the move in slot ind valid (PokemonMove::correctMove) THEN compact: correctMove can clear an invalid/duplicate move, which would otherwise leave a gap, so the list is reflowed so there is no hole.

Definition at line 1785 of file pokemonbox.cpp.

References cleanupMoves(), maxMoves, moves, and movesChanged().

Referenced by pokemonResetChanged().

◆ correctMoves()

void PokemonBox::correctMoves ( )

Repair move/PP inconsistencies.

Definition at line 1692 of file pokemonbox.cpp.

References moves.

Referenced by pokemonResetChanged(), PokemonParty::specialChanged(), update(), and PokemonParty::update().

◆ correctTypes()

void PokemonBox::correctTypes ( )

Reset type1/type2 to this species' DB-default type(s) (e.g.

Fire/Flying for Charizard). Standalone so QML can call it cleanly – update() with mixed bool args is unreliable from QML (the arg-passing glitch), so don't route through it.

Definition at line 1050 of file pokemonbox.cpp.

References isValid(), type1, type1Changed(), type2, type2Changed(), type2Explicit, and type2ExplicitChanged().

Referenced by pokemonResetChanged().

◆ deEvolve()

void PokemonBox::deEvolve ( )

Revert to the prior species.

Definition at line 1222 of file pokemonbox.cpp.

References changeName(), hasDeEvolution(), hasNickname(), isValid(), species, speciesChanged(), and update().

Referenced by pokemonResetChanged().

◆ defExpChanged()

void PokemonBox::defExpChanged ( )

◆ defStat()

int PokemonBox::defStat ( )

Computed Defense stat.

Definition at line 2017 of file pokemonbox.cpp.

References PokemonStats::Defense, and nonHpStat().

Referenced by PokemonParty::regenStats().

◆ deleteMoveAt()

void PokemonBox::deleteMoveAt ( int ind)

Delete the move in slot ind, then compact so there is no gap in the move list (the slots after it slide up; empties stay parked at the bottom).

Definition at line 1750 of file pokemonbox.cpp.

References cleanupMoves(), maxMoves, moves, and movesChanged().

Referenced by pokemonResetChanged().

◆ dexNum()

int PokemonBox::dexNum ( )

Pokedex number.

Definition at line 1572 of file pokemonbox.cpp.

References isValid().

◆ dvAt()

int PokemonBox::dvAt ( int ind)

DV value at ind.

Definition at line 1991 of file pokemonbox.cpp.

References dv.

◆ dvChanged()

◆ dvCount()

int PokemonBox::dvCount ( )

Number of stored DVs (maxDV).

Definition at line 1986 of file pokemonbox.cpp.

References maxDV.

◆ dvSet()

void PokemonBox::dvSet ( int ind,
int val )

Set DV ind.

Definition at line 1996 of file pokemonbox.cpp.

References dv, and dvChanged().

◆ evChanged()

void PokemonBox::evChanged ( )

Referenced by PokemonBox().

◆ evolve()

void PokemonBox::evolve ( )

Evolve to the next species.

Definition at line 1194 of file pokemonbox.cpp.

References changeName(), hasEvolution(), hasNickname(), Random::inst(), isValid(), Random::rangeExclusive(), species, speciesChanged(), and update().

Referenced by pokemonResetChanged().

◆ expChanged()

void PokemonBox::expChanged ( )

◆ expLevelRangeEnd()

var32 PokemonBox::expLevelRangeEnd ( )

EXP at the next level.

Definition at line 879 of file pokemonbox.cpp.

References exp, isValid(), level, and levelToExp().

Referenced by expLevelRangePercent(), isMaxedOut(), and setNature().

◆ expLevelRangePercent()

float PokemonBox::expLevelRangePercent ( )

Fractional progress through the level.

Definition at line 887 of file pokemonbox.cpp.

References exp, expLevelRangeEnd(), expLevelRangeStart(), isValid(), and level.

◆ expLevelRangeStart()

var32 PokemonBox::expLevelRangeStart ( )

EXP at the start of the current level.

Definition at line 871 of file pokemonbox.cpp.

References exp, isValid(), level, and levelToExp().

Referenced by expLevelRangePercent(), resetExp(), and setNature().

◆ expRangeChanged()

void PokemonBox::expRangeChanged ( )

Referenced by PokemonBox().

◆ getNature()

int PokemonBox::getNature ( )

Definition at line 1603 of file pokemonbox.cpp.

References exp.

◆ hasDeEvolution()

bool PokemonBox::hasDeEvolution ( )

Species has a pre-evolution.

Definition at line 1181 of file pokemonbox.cpp.

References isValid().

Referenced by deEvolve().

◆ hasEvolution()

bool PokemonBox::hasEvolution ( )

Species can evolve.

Definition at line 1168 of file pokemonbox.cpp.

References isValid().

Referenced by evolve().

◆ hasNickname()

bool PokemonBox::hasNickname ( )

Carries a real nickname.

Definition at line 1108 of file pokemonbox.cpp.

References isValid(), and nickname.

Referenced by deEvolve(), and evolve().

◆ hasNicknameChanged()

void PokemonBox::hasNicknameChanged ( )

Referenced by PokemonBox().

◆ hasTradeStatus()

bool PokemonBox::hasTradeStatus ( PlayerBasics * basics = nullptr)

Counts as traded relative to basics.

Definition at line 1118 of file pokemonbox.cpp.

References otID, otName, PlayerBasics::playerID, and PlayerBasics::playerName.

◆ heal()

void PokemonBox::heal ( )

Pokecenter heal: full HP, clear status.

Definition at line 1096 of file pokemonbox.cpp.

References hp, hpChanged(), hpStat(), moves, status, and statusChanged().

Referenced by maxOut(), pokemonResetChanged(), randomize(), and resetPokemon().

◆ healedChanged()

void PokemonBox::healedChanged ( )

Referenced by PokemonBox().

◆ hpChanged()

void PokemonBox::hpChanged ( )

◆ hpDV()

int PokemonBox::hpDV ( )

Definition at line 918 of file pokemonbox.cpp.

References PokemonStats::Attack, PokemonStats::Defense, dv, PokemonStats::Special, and PokemonStats::Speed.

Referenced by hpStat().

◆ hpExpChanged()

void PokemonBox::hpExpChanged ( )

◆ hpStat()

int PokemonBox::hpStat ( )

Definition at line 937 of file pokemonbox.cpp.

References hpDV(), hpExp, isValid(), and level.

Referenced by heal(), isCorrected(), isMaxedOut(), isMaxHp(), PokemonParty::regenStats(), and update().

◆ isAfflicted()

bool PokemonBox::isAfflicted ( )

Has any status condition.

Definition at line 1083 of file pokemonbox.cpp.

References status.

Referenced by isHealed().

◆ isBoxMon()

bool PokemonBox::isBoxMon ( )
virtual

True for a pure box mon; PokemonParty overrides to false.

Reimplemented in PokemonParty.

Definition at line 1740 of file pokemonbox.cpp.

Referenced by pokemonResetChanged().

◆ isCorrected()

bool PokemonBox::isCorrected ( )

Values internally consistent (see correct* slots).

Definition at line 1523 of file pokemonbox.cpp.

References catchRate, exp, hp, hpStat(), isValid(), levelToExp(), type1, and type2.

◆ isHealed()

bool PokemonBox::isHealed ( )

Fully healed (HP + status). (heal() performs a Pokecenter heal.).

Definition at line 1078 of file pokemonbox.cpp.

References isAfflicted(), isMaxHp(), and isMaxPP().

Referenced by isPokemonReset().

◆ isMaxDVs()

bool PokemonBox::isMaxDVs ( )

All DVs maxed.

Definition at line 1301 of file pokemonbox.cpp.

References dv.

◆ isMaxedOut()

bool PokemonBox::isMaxedOut ( )

Level/EV/DV/PP all maxed.

Definition at line 1492 of file pokemonbox.cpp.

References atkExp, defExp, dv, exp, expLevelRangeEnd(), hp, hpExp, hpStat(), isMaxPP(), isMaxPpUps(), isValidBool(), level, moves, spdExp, and spExp.

◆ isMaxEVs()

bool PokemonBox::isMaxEVs ( )

All stat-exp maxed.

Definition at line 1279 of file pokemonbox.cpp.

References atkExp, defExp, hpExp, spdExp, and spExp.

◆ isMaxHp()

bool PokemonBox::isMaxHp ( )

HP equals computed max.

Definition at line 1088 of file pokemonbox.cpp.

References hp, hpStat(), and isValid().

Referenced by isHealed().

◆ isMaxLevel()

bool PokemonBox::isMaxLevel ( )

Level 100.

Definition at line 1247 of file pokemonbox.cpp.

References level.

◆ isMaxPP()

bool PokemonBox::isMaxPP ( )

All moves at max PP.

Definition at line 1252 of file pokemonbox.cpp.

References isMaxPP(), and moves.

Referenced by isHealed(), isMaxedOut(), and isMaxPP().

◆ isMaxPpUps()

bool PokemonBox::isMaxPpUps ( )

All moves at max PP-Ups.

Definition at line 1267 of file pokemonbox.cpp.

References isMaxPpUps(), and moves.

Referenced by isMaxedOut(), and isMaxPpUps().

◆ isMinDVs()

bool PokemonBox::isMinDVs ( )

All DVs zero.

Definition at line 1311 of file pokemonbox.cpp.

References dv.

◆ isMinEvs()

bool PokemonBox::isMinEvs ( )

All stat-exp zero.

Definition at line 1288 of file pokemonbox.cpp.

References atkExp, defExp, hpExp, spdExp, and spExp.

Referenced by isPokemonReset().

◆ isPokemonReset()

bool PokemonBox::isPokemonReset ( )

Matches the reset baseline.

Definition at line 1441 of file pokemonbox.cpp.

References isHealed(), isMinEvs(), isValid(), level, and moves.

◆ isShiny()

bool PokemonBox::isShiny ( )

Shiny per the VC-era DV formula (see disclaimer above).

Definition at line 1593 of file pokemonbox.cpp.

References PokemonStats::Attack, PokemonStats::Defense, dv, PokemonStats::Special, and PokemonStats::Speed.

◆ isValid()

◆ isValidBool()

bool PokemonBox::isValidBool ( )

Convenience bool form of isValid().

Definition at line 831 of file pokemonbox.cpp.

References isValid().

Referenced by isMaxedOut(), PokemonParty::regenStats(), and setNature().

◆ levelChanged()

void PokemonBox::levelChanged ( )

◆ levelToExp()

unsigned int PokemonBox::levelToExp ( int level = -1)

EXP needed for level (current level if -1).

Definition at line 836 of file pokemonbox.cpp.

References exp, isValid(), and level.

Referenced by expLevelRangeEnd(), expLevelRangeStart(), isCorrected(), and update().

◆ load()

◆ makeShiny()

void PokemonBox::makeShiny ( )

Force DVs to a shiny combination.

Definition at line 1722 of file pokemonbox.cpp.

References PokemonStats::Attack, dv, dvChanged(), and rollShiny().

Referenced by pokemonResetChanged().

◆ manualLevelChanged()

void PokemonBox::manualLevelChanged ( )

UI hook: level edited directly.

Definition at line 2007 of file pokemonbox.cpp.

References update().

Referenced by pokemonResetChanged().

◆ manualSpeciesChanged()

void PokemonBox::manualSpeciesChanged ( )

UI hook: species edited directly.

Definition at line 2002 of file pokemonbox.cpp.

References update().

Referenced by pokemonResetChanged().

◆ maxDVs()

void PokemonBox::maxDVs ( )

Max all DVs.

Definition at line 1335 of file pokemonbox.cpp.

References dv, and dvChanged().

Referenced by maxOut(), and pokemonResetChanged().

◆ maxEVs()

void PokemonBox::maxEVs ( )

Max all stat-exp.

Definition at line 1359 of file pokemonbox.cpp.

References atkExp, atkExpChanged(), defExp, defExpChanged(), hpExp, hpExpChanged(), spdExp, spdExpChanged(), spExp, spExpChanged(), and update().

Referenced by maxOut(), and pokemonResetChanged().

◆ maxLevel()

void PokemonBox::maxLevel ( )

Set to level 100.

Definition at line 1321 of file pokemonbox.cpp.

References level, levelChanged(), and update().

Referenced by maxOut(), and pokemonResetChanged().

◆ maxOut()

void PokemonBox::maxOut ( )

Max level/EV/DV/PP at once.

Definition at line 1419 of file pokemonbox.cpp.

References heal(), maxDVs(), maxEVs(), maxLevel(), maxPpUps(), and update().

Referenced by pokemonResetChanged().

◆ maxPpUps()

void PokemonBox::maxPpUps ( )

Max every move's PP-Ups.

Definition at line 1329 of file pokemonbox.cpp.

References moves.

Referenced by maxOut(), and pokemonResetChanged().

◆ movesAt()

PokemonMove * PokemonBox::movesAt ( int ind)

Move slot ind (GC-protected return).

Definition at line 1981 of file pokemonbox.cpp.

References moves, and qmlCppOwned().

◆ movesChanged()

◆ movesCount()

int PokemonBox::movesCount ( )

Number of non-empty move slots.

Definition at line 1960 of file pokemonbox.cpp.

References moves.

◆ movesMax()

int PokemonBox::movesMax ( )

Move-slot capacity (maxMoves).

Definition at line 1976 of file pokemonbox.cpp.

References maxMoves.

◆ newPokemon() [1/2]

PokemonBox * PokemonBox::newPokemon ( PokemonDBEntry * pkmnData,
PlayerBasics * basics = nullptr )
static

◆ newPokemon() [2/2]

◆ nicknameChanged()

void PokemonBox::nicknameChanged ( )

◆ nonHpStat()

◆ otIDChanged()

void PokemonBox::otIDChanged ( )

Referenced by changeOtData(), copyFrom(), load(), and reset().

◆ otNameChanged()

void PokemonBox::otNameChanged ( )

Referenced by changeOtData(), copyFrom(), load(), and reset().

◆ pokemonResetChanged()

◆ randomize()

◆ randomizeMoves()

void PokemonBox::randomizeMoves ( )

Randomize the move set.

Definition at line 1430 of file pokemonbox.cpp.

References clearMoves(), moves, and movesChanged().

Referenced by pokemonResetChanged(), and randomize().

◆ reorderMove()

void PokemonBox::reorderMove ( int from,
int to )

Reorder the filled move slots: take the move at from and re-insert it before slot to (drop-slot convention: 0..movesCount; == movesCount appends after the last move).

Only the filled prefix participates (empty slots stay parked at the bottom, per game move-list compaction). The fixed PokemonMove slot objects keep their identity – the (id/pp/ppUp) VALUES move between them – so QML's movesAt() pointers stay valid. Writes only the move bytes the reorder touches; nothing else in the save changes.

Definition at line 1798 of file pokemonbox.cpp.

References maxMoves, moves, and movesChanged().

Referenced by pokemonResetChanged().

◆ reRollDVs()

void PokemonBox::reRollDVs ( )

Randomize DVs.

Definition at line 1343 of file pokemonbox.cpp.

References dv, dvChanged(), and Random::inst().

Referenced by pokemonResetChanged(), and rollNonShiny().

◆ reRollEVs()

void PokemonBox::reRollEVs ( )

◆ reset()

◆ resetDVs()

void PokemonBox::resetDVs ( )

Zero all DVs.

Definition at line 1351 of file pokemonbox.cpp.

References dv, and dvChanged().

Referenced by pokemonResetChanged().

◆ resetEVs()

void PokemonBox::resetEVs ( )

Zero all stat-exp.

Definition at line 1379 of file pokemonbox.cpp.

References atkExp, atkExpChanged(), defExp, defExpChanged(), hpExp, hpExpChanged(), spdExp, spdExpChanged(), spExp, spExpChanged(), and update().

Referenced by pokemonResetChanged(), and resetPokemon().

◆ resetExp()

void PokemonBox::resetExp ( )

Reset EXP to the current level's baseline.

Definition at line 909 of file pokemonbox.cpp.

References exp, expChanged(), expLevelRangeStart(), and isValid().

Referenced by pokemonResetChanged(), PokemonParty::specialChanged(), update(), and PokemonParty::update().

◆ resetPokemon()

void PokemonBox::resetPokemon ( )

Reset to the baseline state.

Definition at line 1850 of file pokemonbox.cpp.

References clearMoves(), heal(), isValid(), level, levelChanged(), moves, movesChanged(), resetEVs(), and update().

Referenced by pokemonResetChanged().

◆ rollNonShiny()

void PokemonBox::rollNonShiny ( )

Randomize DVs until not shiny.

Definition at line 1714 of file pokemonbox.cpp.

References PokemonStats::Attack, dv, dvChanged(), and reRollDVs().

Referenced by pokemonResetChanged().

◆ rollShiny()

void PokemonBox::rollShiny ( )

◆ save()

SaveFileIterator * PokemonBox::save ( SaveFile * saveFile = nullptr,
var16 startOffset = 0,
svar32 speciesStartOffset = 0,
var16 nicknameStartOffset = 0,
var16 otNameStartOffset = 0,
var8 index = 0,
var8 recordSize = 0x21 )
virtual

Flatten one Pokemon back to the save.

Returns
the iterator left past this record.

Reimplemented in PokemonParty.

Definition at line 556 of file pokemonbox.cpp.

References atkExp, PokemonStats::Attack, catchRate, PokemonStats::Defense, defExp, dv, exp, hp, hpExp, SaveFile::iterator(), level, moves, nickname, SaveFileIterator::offsetTo(), otID, otName, spdExp, PokemonStats::Special, species, PokemonStats::Speed, spExp, status, SaveFile::toolset, type1, type2, and type2Explicit.

Referenced by PokemonParty::save().

◆ setNature()

void PokemonBox::setNature ( int nature)

Definition at line 1608 of file pokemonbox.cpp.

References exp, expChanged(), expLevelRangeEnd(), expLevelRangeStart(), and isValidBool().

Referenced by pokemonResetChanged().

◆ spdExpChanged()

void PokemonBox::spdExpChanged ( )

◆ spdStat()

int PokemonBox::spdStat ( )

Computed Speed stat.

Definition at line 2022 of file pokemonbox.cpp.

References nonHpStat(), and PokemonStats::Speed.

Referenced by PokemonParty::regenStats().

◆ speciesChanged()

protected::void PokemonBox::speciesChanged ( )

◆ speciesName()

QString PokemonBox::speciesName ( )

Species display name.

Definition at line 1581 of file pokemonbox.cpp.

References isValid().

◆ spExpChanged()

void PokemonBox::spExpChanged ( )

◆ spStat()

int PokemonBox::spStat ( )

Computed Special stat.

Definition at line 2027 of file pokemonbox.cpp.

References nonHpStat(), and PokemonStats::Special.

Referenced by PokemonParty::regenStats().

◆ statChanged()

void PokemonBox::statChanged ( )

◆ statusChanged()

void PokemonBox::statusChanged ( )

Referenced by copyFrom(), heal(), load(), and reset().

◆ toData()

PokemonDBEntry * PokemonBox::toData ( )

The species' DB entry for this mon.

Definition at line 1955 of file pokemonbox.cpp.

References PokemonDB::getIndAt(), PokemonDB::inst(), and species.

Referenced by changeName(), and MoveSelectModel::monFromBox().

◆ type1Changed()

void PokemonBox::type1Changed ( )

◆ type2Changed()

void PokemonBox::type2Changed ( )

◆ type2ExplicitChanged()

void PokemonBox::type2ExplicitChanged ( )

◆ unmakeShiny()

void PokemonBox::unmakeShiny ( )

Force DVs to a non-shiny combination.

Definition at line 1733 of file pokemonbox.cpp.

References PokemonStats::Attack, dv, and dvChanged().

Referenced by pokemonResetChanged().

◆ update()

void PokemonBox::update ( bool resetHp = false,
bool resetExp = false,
bool resetType = false,
bool resetCatchRate = false,
bool correctMoves = false )
virtual

Recompute derived stats.

Each flag opts into clobbering a value that would otherwise be preserved (HP/EXP) or only sometimes needs it (type/catch rate/moves).

Reimplemented in PokemonParty.

Definition at line 984 of file pokemonbox.cpp.

References catchRate, catchRateChanged(), cleanupMoves(), correctMoves(), exp, expChanged(), hp, hpChanged(), hpStat(), isValid(), levelToExp(), resetExp(), type1, type1Changed(), type2, type2Changed(), type2Explicit, and type2ExplicitChanged().

Referenced by deEvolve(), evolve(), manualLevelChanged(), manualSpeciesChanged(), maxEVs(), maxLevel(), maxOut(), pokemonResetChanged(), randomize(), reRollEVs(), resetEVs(), resetPokemon(), and PokemonParty::update().

Member Data Documentation

◆ atkExp

int PokemonBox::atkExp
See also
atkExp property.

Definition at line 511 of file pokemonbox.h.

Referenced by copyFrom(), isMaxedOut(), isMaxEVs(), isMinEvs(), load(), maxEVs(), nonHpStat(), randomize(), reRollEVs(), reset(), resetEVs(), and save().

◆ catchRate

int PokemonBox::catchRate
See also
catchRate property.

Definition at line 507 of file pokemonbox.h.

Referenced by copyFrom(), isCorrected(), load(), reset(), save(), and update().

◆ defExp

int PokemonBox::defExp
See also
defExp property.

Definition at line 512 of file pokemonbox.h.

Referenced by copyFrom(), isMaxedOut(), isMaxEVs(), isMinEvs(), load(), maxEVs(), nonHpStat(), randomize(), reRollEVs(), reset(), resetEVs(), and save().

◆ dv

var8 PokemonBox::dv[maxDV]

Stored DVs (Atk/Def/Spd/Spc); HP DV is derived.

Definition at line 515 of file pokemonbox.h.

Referenced by copyFrom(), dvAt(), dvSet(), hpDV(), isMaxDVs(), isMaxedOut(), isMinDVs(), isShiny(), load(), makeShiny(), maxDVs(), nonHpStat(), reRollDVs(), reset(), resetDVs(), rollNonShiny(), rollShiny(), save(), and unmakeShiny().

◆ exp

unsigned int PokemonBox::exp

◆ hp

int PokemonBox::hp
See also
hp property.

Definition at line 502 of file pokemonbox.h.

Referenced by copyFrom(), heal(), isCorrected(), isMaxedOut(), isMaxHp(), load(), reset(), save(), and update().

◆ hpExp

int PokemonBox::hpExp
See also
hpExp property.

Definition at line 510 of file pokemonbox.h.

Referenced by copyFrom(), hpStat(), isMaxedOut(), isMaxEVs(), isMinEvs(), load(), maxEVs(), randomize(), reRollEVs(), reset(), resetEVs(), and save().

◆ level

◆ moves

◆ nickname

QString PokemonBox::nickname
See also
nickname property.

Definition at line 517 of file pokemonbox.h.

Referenced by changeName(), copyFrom(), hasNickname(), load(), reset(), and save().

◆ otID

int PokemonBox::otID
See also
otID property.

Definition at line 508 of file pokemonbox.h.

Referenced by changeOtData(), copyFrom(), hasTradeStatus(), load(), reset(), and save().

◆ otName

QString PokemonBox::otName
See also
otName property.

Definition at line 516 of file pokemonbox.h.

Referenced by changeOtData(), copyFrom(), hasTradeStatus(), load(), reset(), and save().

◆ spdExp

int PokemonBox::spdExp
See also
spdExp property.

Definition at line 513 of file pokemonbox.h.

Referenced by copyFrom(), isMaxedOut(), isMaxEVs(), isMinEvs(), load(), maxEVs(), nonHpStat(), randomize(), reRollEVs(), reset(), resetEVs(), and save().

◆ species

int PokemonBox::species
See also
species property.

Definition at line 501 of file pokemonbox.h.

Referenced by copyFrom(), deEvolve(), evolve(), isValid(), load(), reset(), save(), and toData().

◆ spExp

int PokemonBox::spExp
See also
spExp property.

Definition at line 514 of file pokemonbox.h.

Referenced by copyFrom(), isMaxedOut(), isMaxEVs(), isMinEvs(), load(), maxEVs(), nonHpStat(), randomize(), reRollEVs(), reset(), resetEVs(), and save().

◆ status

int PokemonBox::status
See also
status property.

Definition at line 504 of file pokemonbox.h.

Referenced by copyFrom(), heal(), isAfflicted(), load(), reset(), and save().

◆ type1

int PokemonBox::type1
See also
type1 property.

Definition at line 505 of file pokemonbox.h.

Referenced by copyFrom(), correctTypes(), isCorrected(), load(), randomize(), reset(), save(), and update().

◆ type2

int PokemonBox::type2
See also
type2 property.

Definition at line 506 of file pokemonbox.h.

Referenced by copyFrom(), correctTypes(), isCorrected(), load(), randomize(), reset(), save(), and update().

◆ type2Explicit

bool PokemonBox::type2Explicit

Definition at line 530 of file pokemonbox.h.

Referenced by copyFrom(), correctTypes(), load(), randomize(), reset(), save(), and update().


The documentation for this class was generated from the following files:
  • projects/savefile/src/pse-savefile/expanded/fragments/pokemonbox.h
  • projects/savefile/src/pse-savefile/expanded/fragments/pokemonbox.cpp