Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
player.cpp
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
22#include "player.h"
23#include "../../savefile.h"
24#include "./playerbasics.h"
25#include "./playerpokedex.h"
26#include "./playerpokemon.h"
28
30{
31 basics = new PlayerBasics;
32 items = new ItemStorageBox(true, 20); // Max 20 items, mark this is a bag
35
36 load(saveFile);
37}
38
40{
41 basics->deleteLater();
42 items->deleteLater();
43 pokedex->deleteLater();
44 pokemon->deleteLater();
45}
46
47void Player::load(SaveFile* saveFile)
48{
49 if(saveFile == nullptr)
50 return reset();
51
52 basics->load(saveFile);
53 items->load(saveFile, 0x25C9);
54 pokedex->load(saveFile);
55 pokemon->load(saveFile);
56}
57
58void Player::save(SaveFile* saveFile)
59{
60 basics->save(saveFile);
61 items->save(saveFile, 0x25C9);
62 pokedex->save(saveFile);
63 pokemon->save(saveFile);
64}
65
67{
68 basics->reset();
69 items->reset();
70 pokedex->reset();
71 pokemon->reset();
72}
73
75{
76 basics->randomize();
77 items->randomize();
78 pokedex->randomize();
79 pokemon->randomize(basics);
80}
A container of Items – either the trainer's bag or a PC item box.
The trainer's headline values: name, ID, money, coins, badges, starter.
The player's Pokedex: a seen flag and an owned flag per species.
The player's active party – a specialized PokemonStorageBox.
PlayerBasics * basics
Definition player.h:68
void load(SaveFile *saveFile=nullptr)
Expand the player regions from the save.
Definition player.cpp:47
void reset()
Blank all player regions.
Definition player.cpp:66
PlayerPokemon * pokemon
Definition player.h:71
Player(SaveFile *saveFile=nullptr)
< Name, ID, money, coins, badges, starter.
Definition player.cpp:29
void randomize()
Randomize all player regions (constrained).
Definition player.cpp:74
void save(SaveFile *saveFile)
Flatten the player regions back to the save.
Definition player.cpp:58
virtual ~Player()
Definition player.cpp:39
ItemStorageBox * items
Definition player.h:69
PlayerPokedex * pokedex
Definition player.h:70
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46