52 if(saveFile ==
nullptr) {
58 auto toolset = saveFile->
toolset;
61 playerName = toolset->getStr(0x2598, 0xB, 7+1);
67 money = toolset->getBCD(0x25F3, 3);
70 coins = toolset->getBCD(0x2850, 2);
89 for(
var8 i = 0; i < 8; i++)
102 auto toolset = saveFile->
toolset;
106 toolset->setBCD(0x25F3, 3,
money);
107 toolset->setBCD(0x2850, 2,
coins);
131 for(
var8 i = 0; i < 8; i++)
161 for(
var8 i = 0; i < 8; i++)
169 for(
var8 i = 0; i < badgesEarned; i++)
217 it->setBit(1, 1,
badges[1]);
218 it->setBit(1, 2,
badges[2]);
219 it->setBit(1, 3,
badges[3]);
220 it->setBit(1, 4,
badges[4]);
221 it->setBit(1, 5,
badges[5]);
222 it->setBit(1, 6,
badges[6]);
223 it->setBit(1, 7,
badges[7]);
318 return QVector<PokemonBox*>();
321 QVector<PokemonBox*> monsToFix;
324 for(
auto el :
file->dataExpanded->player->pokemon->pokemon) {
325 if(!el->hasTradeStatus(
this))
326 monsToFix.append(el);
333 auto box =
file->dataExpanded->storage->boxAt(i);
338 for(
auto el : box->pokemon) {
339 if(!el->hasTradeStatus(
this))
340 monsToFix.append(el);
350 el->changeOtData(
true,
this);
QString randomExample()
A random string from the list.
NamesPlayer * player() const
The player-name source (backs player).
static Names * inst()
< Random player-name source.
void save(SaveFile *saveFile)
Flatten the trainer basics back to the save.
void randomizeMoney()
Randomize just the money.
QString getPlayerName()
Current trainer name (backs the property READ).
void fullSetPlayerName(QString val)
Set name AND fix non-trade mons' OT name.
void randomize()
Randomize the trainer basics (constrained).
QVector< PokemonBox * > getNonTradeMons()
All party/box mons whose OT is this trainer (not traded in).
unsigned int money
Money value.
int playerID
Trainer ID (backs the property).
SaveFile * file
Owning save (used by the full-set helpers to reach the mons).
int getPlayerId()
Current trainer ID (backs the property READ).
QString playerName
Trainer name (backs the property).
void randomizeStarter()
Randomize just the starter.
void randomizeCoins()
Randomize just the coin count.
bool badgeAt(int ind)
Is badge ind set?
void playerStarterChanged()
int badgeCount()
How many badges are set.
void fullSetPlayerId(int id)
Set ID AND fix non-trade mons' OT ID.
PlayerBasics(SaveFile *saveFile=nullptr)
< Trainer name; writing it full-sets non-trade mons (see note above).
void reset()
Blank the trainer basics.
protected::void playerNameChanged()
void fixNonTradeMons(QVector< PokemonBox * > mons)
Rewrite those mons' OT name/ID to match this trainer.
void badgeSet(int ind, bool val)
Set/clear badge ind.
void randomizeID()
Randomize just the trainer ID.
int playerStarter
Chosen starter species.
void load(SaveFile *saveFile=nullptr)
Expand the trainer basics from the save.
void setBadges(SaveFile *saveFile, var16 offset)
Write the badge bits at offset.
bool badges[maxBadges]
Per-badge owned flags, indexed by Badges::Badges_.
PokemonDBEntry * toStarter()
Resolve playerStarter to its DB entry.
static PokemonDB * inst()
< Number of species.
PokemonDBEntry * getIndAt(const QString &key) const
Species by name key (for QML).
int rangeInclusive(const int start, const int end) const
Random integer in the closed interval [start, end].
static Random * inst()
< Convenience 50% coin flip (integer path), readable from QML.
int rangeExclusive(const int start, const int end) const
Random integer in the half-open interval [start, end).
void setBit(var8 size, var8 bit, bool value, bool reverse=false)
Set a bit at the cursor.
SaveFileIterator * offsetTo(var16 val)
Move the cursor to an absolute offset. Returns this for chaining.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
SaveFileToolset * toolset
Tools to operate directly on the raw sav file data.
SaveFileIterator * iterator()
Returns a unique iterator that's setup to iterate over the raw sav file data.
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
var16e var16
Everyday 16-bit alias. Exact width to avoid the "fastest" widening bug.
constexpr var8 maxBadges
Number of Gym badges.
constexpr var8 maxPokemonBoxes
Total PC boxes (12).
One species' complete static data – the richest entry in the db layer.
var8 ind
Internal species index.