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

A party Pokemon: a PokemonBox plus the five pre-generated battle stats. More...

#include <pokemonparty.h>

Inheritance diagram for PokemonParty:
Collaboration diagram for PokemonParty:

Public Member Functions

 PokemonParty (SaveFile *saveFile=nullptr, var16 offset=0, var16 nicknameStartOffset=0, var16 otNameStartOffset=0, var8 index=0)
 < Stored max HP.
virtual ~PokemonParty ()
virtual SaveFileIteratorload (SaveFile *saveFile=nullptr, var16 offset=0, var16 nicknameStartOffset=0, var16 otNameStartOffset=0, var8 index=0, var8 recordSize=0x2C) override
 Expand a party record (record size defaults to the party's 0x2C).
virtual SaveFileIteratorsave (SaveFile *saveFile, var16 offset, svar32 speciesStartOffset, var16 nicknameStartOffset, var16 otNameStartOffset, var8 index, var8 recordSize=0x2C) override
 Flatten a party record back to the save.
virtual void copyFrom (PokemonBox *pkmn) override
 Copy values from another mon (box or party).
PokemonBoxtoBoxData ()
 This mon as a plain box record.
protected::void maxHPChanged ()
void attackChanged ()
void defenseChanged ()
void speedChanged ()
void specialChanged ()
virtual void reset () override
 Blank, including stored stats.
virtual void randomize (PlayerBasics *basics=nullptr) override
 Randomize, then regen stats.
virtual void update (bool resetHp=false, bool resetExp=false, bool resetType=false, bool resetCatchRate=false, bool correctMoves=false) override
 Recompute; also refreshes stored stats.
virtual bool isBoxMon () override
 False – this is a party mon.
void regenStats ()
 Recompute the five stored stats from species/level/DVs/EVs.
Public Member Functions inherited from 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).
virtual ~PokemonBox ()
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 ()
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 ()
void clearMoves ()
 Empty all move slots.
void resetExp ()
 Reset EXP to the current level's baseline.
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.
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 PokemonBoxconvertToBox (PokemonParty *data)
 New box record from a party mon (drops stored stats).
static PokemonPartyconvertToParty (PokemonBox *data)
 New party mon from a box record (regenerates stats).
Static Public Member Functions inherited from PokemonBox
static PokemonBoxnewPokemon (PokemonRandom::PokemonRandom_ list=PokemonRandom::Random_Starters, PlayerBasics *basics=nullptr)
static PokemonBoxnewPokemon (PokemonDBEntry *pkmnData, PlayerBasics *basics=nullptr)

Public Attributes

int maxHP
int attack
int defense
int speed
int special
Public Attributes inherited from PokemonBox
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 party Pokemon: a PokemonBox plus the five pre-generated battle stats.

Box records don't store final stats (they're recomputed), but party records DO carry them on disk, so PokemonParty extends PokemonBox with maxHP / attack / defense / speed / special and a larger record size (0x2C vs the box 0x21). It overrides load()/save()/update()/reset()/randomize() to handle those extra stat bytes, and provides conversions to/from a plain box record (e.g. when moving a mon between the party and a PC box).

See also
PokemonBox (base), PlayerPokemon (the party container), PokemonStorageBox.

Definition at line 35 of file pokemonparty.h.

Constructor & Destructor Documentation

◆ PokemonParty()

PokemonParty::PokemonParty ( SaveFile * saveFile = nullptr,
var16 offset = 0,
var16 nicknameStartOffset = 0,
var16 otNameStartOffset = 0,
var8 index = 0 )

< Stored max HP.

Stored Attack stat. Stored Defense stat. Stored Speed stat. Stored Special stat.

Definition at line 27 of file pokemonparty.cpp.

References load(), regenStats(), and PokemonBox::statChanged().

Referenced by convertToBox(), and convertToParty().

◆ ~PokemonParty()

PokemonParty::~PokemonParty ( )
virtual

Definition at line 37 of file pokemonparty.cpp.

Member Function Documentation

◆ attackChanged()

void PokemonParty::attackChanged ( )

Referenced by load(), regenStats(), and reset().

◆ convertToBox()

PokemonBox * PokemonParty::convertToBox ( PokemonParty * data)
static

New box record from a party mon (drops stored stats).

Definition at line 182 of file pokemonparty.cpp.

References PokemonBox::PokemonBox(), and PokemonParty().

◆ convertToParty()

PokemonParty * PokemonParty::convertToParty ( PokemonBox * data)
static

New party mon from a box record (regenerates stats).

Definition at line 191 of file pokemonparty.cpp.

References PokemonBox::PokemonBox(), and PokemonParty().

Referenced by PokemonStorageModel::checkedTransfer(), ItemMarketEntryGCPokemon::checkout(), PokemonStorageModel::dragTransfer(), and PlayerPokemon::pokemonNew().

◆ copyFrom()

void PokemonParty::copyFrom ( PokemonBox * pkmn)
overridevirtual

Copy values from another mon (box or party).

Reimplemented from PokemonBox.

Definition at line 171 of file pokemonparty.cpp.

References PokemonBox::copyFrom(), PokemonBox::PokemonBox(), and regenStats().

◆ defenseChanged()

void PokemonParty::defenseChanged ( )

Referenced by load(), regenStats(), and reset().

◆ isBoxMon()

bool PokemonParty::isBoxMon ( )
overridevirtual

False – this is a party mon.

Reimplemented from PokemonBox.

Definition at line 177 of file pokemonparty.cpp.

◆ load()

SaveFileIterator * PokemonParty::load ( SaveFile * saveFile = nullptr,
var16 offset = 0,
var16 nicknameStartOffset = 0,
var16 otNameStartOffset = 0,
var8 index = 0,
var8 recordSize = 0x2C )
overridevirtual

Expand a party record (record size defaults to the party's 0x2C).

Reimplemented from PokemonBox.

Definition at line 39 of file pokemonparty.cpp.

References attack, attackChanged(), defense, defenseChanged(), PokemonBox::level, PokemonBox::levelChanged(), PokemonBox::load(), maxHP, maxHPChanged(), reset(), special, specialChanged(), speed, and speedChanged().

Referenced by PokemonParty().

◆ maxHPChanged()

protected::void PokemonParty::maxHPChanged ( )

Referenced by load(), regenStats(), and reset().

◆ randomize()

void PokemonParty::randomize ( PlayerBasics * basics = nullptr)
overridevirtual

Randomize, then regen stats.

Reimplemented from PokemonBox.

Definition at line 134 of file pokemonparty.cpp.

References PokemonBox::randomize(), and regenStats().

◆ regenStats()

◆ reset()

void PokemonParty::reset ( )
overridevirtual

Blank, including stored stats.

Reimplemented from PokemonBox.

Definition at line 114 of file pokemonparty.cpp.

References attack, attackChanged(), defense, defenseChanged(), maxHP, maxHPChanged(), PokemonBox::reset(), special, specialChanged(), speed, and speedChanged().

Referenced by load().

◆ save()

SaveFileIterator * PokemonParty::save ( SaveFile * saveFile,
var16 offset,
svar32 speciesStartOffset,
var16 nicknameStartOffset,
var16 otNameStartOffset,
var8 index,
var8 recordSize = 0x2C )
overridevirtual

Flatten a party record back to the save.

Reimplemented from PokemonBox.

Definition at line 83 of file pokemonparty.cpp.

References attack, defense, PokemonBox::level, maxHP, PokemonBox::save(), special, and speed.

◆ specialChanged()

void PokemonParty::specialChanged ( )

◆ speedChanged()

void PokemonParty::speedChanged ( )

Referenced by load(), regenStats(), and reset().

◆ toBoxData()

PokemonBox * PokemonParty::toBoxData ( )

This mon as a plain box record.

Definition at line 200 of file pokemonparty.cpp.

References PokemonBox::PokemonBox().

◆ update()

void PokemonParty::update ( bool resetHp = false,
bool resetExp = false,
bool resetType = false,
bool resetCatchRate = false,
bool correctMoves = false )
overridevirtual

Recompute; also refreshes stored stats.

Reimplemented from PokemonBox.

Definition at line 165 of file pokemonparty.cpp.

References PokemonBox::correctMoves(), regenStats(), PokemonBox::resetExp(), and PokemonBox::update().

Member Data Documentation

◆ attack

int PokemonParty::attack
See also
attack property.

Definition at line 99 of file pokemonparty.h.

Referenced by load(), regenStats(), reset(), and save().

◆ defense

int PokemonParty::defense
See also
defense property.

Definition at line 100 of file pokemonparty.h.

Referenced by load(), regenStats(), reset(), and save().

◆ maxHP

int PokemonParty::maxHP
See also
maxHP property.

Definition at line 98 of file pokemonparty.h.

Referenced by load(), regenStats(), reset(), and save().

◆ special

int PokemonParty::special
See also
special property.

Definition at line 102 of file pokemonparty.h.

Referenced by load(), regenStats(), reset(), and save().

◆ speed

int PokemonParty::speed
See also
speed property.

Definition at line 101 of file pokemonparty.h.

Referenced by load(), regenStats(), reset(), and save().


The documentation for this class was generated from the following files: