Peoplemon  0.1.0
Peoplemon 3 game source documentation
PeoplemonDB.hpp
Go to the documentation of this file.
1 #ifndef CORE_FILES_PEOPLEMONDB_HPP
2 #define CORE_FILES_PEOPLEMONDB_HPP
3 
4 #include <BLIB/Resources.hpp>
5 #include <BLIB/Serialization/Binary.hpp>
6 #include <BLIB/Util/NonCopyable.hpp>
7 #include <unordered_map>
8 #include <unordered_set>
9 
10 #include <Core/Peoplemon/Id.hpp>
13 #include <Core/Peoplemon/Stats.hpp>
14 #include <Core/Peoplemon/Type.hpp>
15 
16 namespace core
17 {
18 namespace file
19 {
26 struct PeoplemonDB : private bl::util::NonCopyable {
31  bool save() const;
32 
37  bool load();
38 
45  bool loadDev(std::istream& input);
46 
53  bool loadProd(bl::serial::binary::InputStream& input);
54 
62  bool saveBundle(bl::serial::binary::OutputStream& output,
63  bl::resource::bundle::FileHandlerContext& ctx) const;
64 
65  std::unordered_map<pplmn::Id, std::string> names;
66  std::unordered_map<pplmn::Id, std::string> descriptions;
67  std::unordered_map<pplmn::Id, pplmn::Type> types;
68  std::unordered_map<pplmn::Id, pplmn::SpecialAbility> abilities;
69  std::unordered_map<pplmn::Id, pplmn::Stats> stats;
70  std::unordered_map<pplmn::Id, std::unordered_set<pplmn::MoveId>> validMoves;
71  std::unordered_map<pplmn::Id, std::unordered_map<unsigned int, pplmn::MoveId>> learnedMoves;
72  std::unordered_map<pplmn::Id, unsigned int> evolveLevels;
73  std::unordered_map<pplmn::Id, pplmn::Id> evolveIds;
74  std::unordered_map<pplmn::Id, pplmn::Stats> evAwards;
75  std::unordered_map<pplmn::Id, unsigned int> xpGroups;
76  std::unordered_map<pplmn::Id, int> xpMults;
77  std::unordered_map<pplmn::Id, int> catchRates;
78 };
79 
80 } // namespace file
81 } // namespace core
82 
83 namespace bl
84 {
85 namespace serial
86 {
87 template<>
88 struct SerializableObject<core::file::PeoplemonDB> : public SerializableObjectBase {
91 
92  SerializableField<1, DB, std::unordered_map<Id, std::string>> names;
93  SerializableField<2, DB, std::unordered_map<Id, std::string>> descriptions;
94  SerializableField<3, DB, std::unordered_map<Id, core::pplmn::Type>> types;
95  SerializableField<4, DB, std::unordered_map<Id, core::pplmn::SpecialAbility>> abilities;
96  SerializableField<5, DB, std::unordered_map<Id, core::pplmn::Stats>> stats;
97  SerializableField<6, DB, std::unordered_map<Id, std::unordered_set<core::pplmn::MoveId>>>
99  SerializableField<7, DB,
100  std::unordered_map<Id, std::unordered_map<unsigned int, core::pplmn::MoveId>>>
102  SerializableField<8, DB, std::unordered_map<Id, unsigned int>> evolveLevels;
103  SerializableField<9, DB, std::unordered_map<Id, Id>> evolveIds;
104  SerializableField<10, DB, std::unordered_map<Id, core::pplmn::Stats>> evAwards;
105  SerializableField<11, DB, std::unordered_map<Id, unsigned int>> xpGroups;
106  SerializableField<12, DB, std::unordered_map<Id, int>> xpMults;
107  SerializableField<13, DB, std::unordered_map<Id, int>> catchRates;
108 
110  : SerializableObjectBase("PeoplemonDB")
111  , names("names", *this, &DB::names, SerializableFieldBase::Required{})
112  , descriptions("descs", *this, &DB::descriptions, SerializableFieldBase::Required{})
113  , types("types", *this, &DB::types, SerializableFieldBase::Required{})
114  , abilities("abilities", *this, &DB::abilities, SerializableFieldBase::Required{})
115  , stats("stats", *this, &DB::stats, SerializableFieldBase::Required{})
116  , validMoves("validMoves", *this, &DB::validMoves, SerializableFieldBase::Required{})
117  , learnedMoves("learnMoves", *this, &DB::learnedMoves, SerializableFieldBase::Required{})
118  , evolveLevels("evolveLevels", *this, &DB::evolveLevels, SerializableFieldBase::Required{})
119  , evolveIds("evolveIds", *this, &DB::evolveIds, SerializableFieldBase::Required{})
120  , evAwards("evAwards", *this, &DB::evAwards, SerializableFieldBase::Required{})
121  , xpGroups("xpGroups", *this, &DB::xpGroups, SerializableFieldBase::Required{})
122  , xpMults("xpMults", *this, &DB::xpMults, SerializableFieldBase::Required{})
123  , catchRates("catchRates", *this, &DB::catchRates, SerializableFieldBase::Required{}) {}
124 };
125 
126 } // namespace serial
127 } // namespace bl
128 
129 #endif
Id
The id of a peoplemon.
Definition: Id.hpp:16
Core classes and functionality for both the editor and game.
Data structure that holds the underlaying data for all the peoplemon.
Definition: PeoplemonDB.hpp:26
bool load()
Loads the database data from the save file.
Definition: PeoplemonDB.cpp:12
std::unordered_map< pplmn::Id, int > catchRates
Definition: PeoplemonDB.hpp:77
std::unordered_map< pplmn::Id, pplmn::Id > evolveIds
Definition: PeoplemonDB.hpp:73
bool save() const
Saves the database data to the save file.
Definition: PeoplemonDB.cpp:24
std::unordered_map< pplmn::Id, pplmn::SpecialAbility > abilities
Definition: PeoplemonDB.hpp:68
std::unordered_map< pplmn::Id, int > xpMults
Definition: PeoplemonDB.hpp:76
std::unordered_map< pplmn::Id, pplmn::Type > types
Definition: PeoplemonDB.hpp:67
std::unordered_map< pplmn::Id, std::unordered_set< pplmn::MoveId > > validMoves
Definition: PeoplemonDB.hpp:70
std::unordered_map< pplmn::Id, unsigned int > xpGroups
Definition: PeoplemonDB.hpp:75
std::unordered_map< pplmn::Id, pplmn::Stats > stats
Definition: PeoplemonDB.hpp:69
bool loadProd(bl::serial::binary::InputStream &input)
Loads the database from its json format.
Definition: PeoplemonDB.cpp:20
std::unordered_map< pplmn::Id, unsigned int > evolveLevels
Definition: PeoplemonDB.hpp:72
std::unordered_map< pplmn::Id, pplmn::Stats > evAwards
Definition: PeoplemonDB.hpp:74
std::unordered_map< pplmn::Id, std::string > descriptions
Definition: PeoplemonDB.hpp:66
std::unordered_map< pplmn::Id, std::unordered_map< unsigned int, pplmn::MoveId > > learnedMoves
Definition: PeoplemonDB.hpp:71
bool saveBundle(bl::serial::binary::OutputStream &output, bl::resource::bundle::FileHandlerContext &ctx) const
Saves the data from this object to the given bundle and registers depency files if any.
Definition: PeoplemonDB.cpp:29
std::unordered_map< pplmn::Id, std::string > names
Definition: PeoplemonDB.hpp:65
bool loadDev(std::istream &input)
Loads the database from its json format.
Definition: PeoplemonDB.cpp:16
SerializableField< 4, DB, std::unordered_map< Id, core::pplmn::SpecialAbility > > abilities
Definition: PeoplemonDB.hpp:95
SerializableField< 9, DB, std::unordered_map< Id, Id > > evolveIds
SerializableField< 2, DB, std::unordered_map< Id, std::string > > descriptions
Definition: PeoplemonDB.hpp:93
SerializableField< 1, DB, std::unordered_map< Id, std::string > > names
Definition: PeoplemonDB.hpp:92
SerializableField< 6, DB, std::unordered_map< Id, std::unordered_set< core::pplmn::MoveId > > > validMoves
Definition: PeoplemonDB.hpp:98
SerializableField< 8, DB, std::unordered_map< Id, unsigned int > > evolveLevels
SerializableField< 13, DB, std::unordered_map< Id, int > > catchRates
SerializableField< 5, DB, std::unordered_map< Id, core::pplmn::Stats > > stats
Definition: PeoplemonDB.hpp:96
SerializableField< 11, DB, std::unordered_map< Id, unsigned int > > xpGroups
SerializableField< 7, DB, std::unordered_map< Id, std::unordered_map< unsigned int, core::pplmn::MoveId > > > learnedMoves
SerializableField< 12, DB, std::unordered_map< Id, int > > xpMults
SerializableField< 3, DB, std::unordered_map< Id, core::pplmn::Type > > types
Definition: PeoplemonDB.hpp:94
SerializableField< 10, DB, std::unordered_map< Id, core::pplmn::Stats > > evAwards