3 #include <BLIB/Util/FileUtil.hpp>
12 const std::string InvalidStr =
"<INVALID>";
13 std::vector<Id> allIds;
15 void refreshIds(std::unordered_map<Id, std::string>* names) {
17 allIds.reserve(names->size());
18 for (
const auto& p : *names) { allIds.emplace_back(p.first); }
19 std::sort(allIds.begin(), allIds.end());
22 const std::pair<std::string, std::string> abilityTexts[43] = {
23 std::make_pair(
"No Ability",
"This Peoplemon has no special talents to speak of"),
24 std::make_pair(
"Board Game Master",
"The opposing Peoplemon cannot switch out"),
25 std::make_pair(
"Chillaxed",
"Cannot receive critical hits"),
26 std::make_pair(
"Classy",
"Cannot be Frustrated"),
27 std::make_pair(
"Goon",
"Enemy Peoplemon take damage when they attack physically"),
28 std::make_pair(
"Quick Draw",
"Attacks first on the first turn of every battle"),
29 std::make_pair(
"Always Friendly",
"Is cured of all ailments when switched out"),
30 std::make_pair(
"Skipped Slot",
"Id #7 is missing, it's Chris' fault"),
31 std::make_pair(
"Impulse Buy",
"May purchase items at random in stores"),
32 std::make_pair(
"Run Away",
"Always able to get away from battle"),
33 std::make_pair(
"Mr. Extra",
"Occasionally finds items when exploring and pockets them"),
34 std::make_pair(
"Beefed Up",
"Athletic type moves do more damage when below 25% HP"),
35 std::make_pair(
"Reserved",
"Quiet type moves do more damage when below 25% HP"),
36 std::make_pair(
"Duke of Jokes",
"Joke based moves do 50% more damage"),
39 "Moves that otherwise would not affect enemy Peoplemon become Not Very Effective instead"),
40 std::make_pair(
"Snack Share",
"Chance to give inflicted ailments to the attacker as well"),
41 std::make_pair(
"Derp Derp",
"Chance to Confuse opponent when taking damage"),
42 std::make_pair(
"Klutz",
43 "Chance to drop hold item before battle, making it unusable for the battle"),
44 std::make_pair(
"Gender Bend",
"Changes the gender of enemy Peoplemon"),
45 std::make_pair(
"Garbage",
"This Peoplemon is garbage and has no special skills"),
46 std::make_pair(
"Bike Mechanic",
"Can fix broken bikes"),
47 std::make_pair(
"Sidetrack Teach",
"Teach based moves have a chance to Distract opponents"),
48 std::make_pair(
"No Joke Teach",
49 "Takes no damage from Joke based moves if a Teach based move was used"),
50 std::make_pair(
"Fiery Teach",
"Teach based moves have a chance to raise Special Attack"),
51 std::make_pair(
"Experienced Teach",
"Cannot be K.O'd if a Teach based move was used"),
52 std::make_pair(
"New Teach",
53 "Teach based moves used on the first turn of a battle have higher speed"),
54 std::make_pair(
"Doze Off",
55 "Teach based moves have a chance to make this Peoplemon fall asleep"),
56 std::make_pair(
"Douse Flames",
57 "Has a chance to reduce opponent Attack after taking physical damage"),
58 std::make_pair(
"Flirty",
59 "Has a chance to reduce opponent Special Attack after taking special damage"),
60 std::make_pair(
"Undying Faith",
"Has a chance to survive a lethal attack"),
61 std::make_pair(
"Too Cool",
"Cannot be Stunned"),
62 std::make_pair(
"Fake Study",
63 "If an attack misses the move used is not revealed to the opponent"),
64 std::make_pair(
"Alcoholic",
"Consumes Alcohol based items at the beginning of each turn"),
65 std::make_pair(
"Total Bro",
"Increases Bro Power of other Bros in your party"),
66 std::make_pair(
"Total Mom",
"Restores some PP of the next Peoplemon when K.O'd"),
67 std::make_pair(
"Can't Swim",
68 "Has a chance to decrease opponents Attack when hit with a physical move"),
69 std::make_pair(
"All Nighter",
"Cannot be put to sleep"),
70 std::make_pair(
"Ailment Saturated",
"Can only ever have one Ailment at a time"),
71 std::make_pair(
"Adamant",
"Can't be forced to switch out of battle by an opponent"),
72 std::make_pair(
"Absolute Pitch",
"Super Effective moves do additional damage, but Not Very "
73 "Effective moves do even less damage"),
74 std::make_pair(
"GameMaker Virus",
"Eliminates half of the PP of any moves that it gets hit by"),
75 std::make_pair(
"Snapshot",
76 "Cannot take Super Effective damage from the same move twice in a row"),
77 std::make_pair(
"Get Baked",
"Automatically self-destructs if at 20% or less HP")};
80 std::unordered_map<Id, std::string>* Peoplemon::names =
nullptr;
81 std::unordered_map<Id, std::string>* Peoplemon::descriptions =
nullptr;
82 std::unordered_map<Id, Type>* Peoplemon::types =
nullptr;
83 std::unordered_map<Id, SpecialAbility>* Peoplemon::abilities =
nullptr;
84 std::unordered_map<Id, Stats>* Peoplemon::stats =
nullptr;
85 std::unordered_map<Id, std::unordered_set<MoveId>>* Peoplemon::validMoves =
nullptr;
86 std::unordered_map<Id, std::unordered_map<unsigned int, MoveId>>* Peoplemon::learnedMoves =
nullptr;
87 std::unordered_map<Id, unsigned int>* Peoplemon::evolveLevels =
nullptr;
88 std::unordered_map<Id, Id>* Peoplemon::evolveIds =
nullptr;
89 std::unordered_map<Id, Stats>* Peoplemon::evAwards =
nullptr;
90 std::unordered_map<Id, unsigned int>* Peoplemon::xpGroups =
nullptr;
91 std::unordered_map<Id, int>* Peoplemon::xpMults =
nullptr;
92 std::unordered_map<Id, int>* Peoplemon::catchRates =
nullptr;
113 const Id r =
static_cast<Id>(id);
114 if (names !=
nullptr && names->find(r) == names->end())
return Id::Unknown;
119 #ifdef PEOPLEMON_DEBUG
127 const auto it = names->find(
id);
128 return it != names->end() ? it->second : InvalidStr;
132 const auto it = descriptions->find(
id);
133 return it != descriptions->end() ? it->second : InvalidStr;
137 const auto it = types->find(
id);
138 return it != types->end() ? it->second :
Type::None;
142 const auto it = abilities->find(
id);
147 static const Stats Zero;
148 const auto it = stats->find(
id);
149 return it != stats->end() ? it->second : Zero;
153 const auto it = validMoves->find(
id);
154 return it != validMoves->end() ? it->second.find(move) != it->second.end() :
false;
158 const auto it = learnedMoves->find(
id);
159 if (it != learnedMoves->end()) {
160 const auto jit = it->second.find(level);
167 const auto it = evolveLevels->find(
id);
168 return it != evolveLevels->end() ? it->second : 101;
172 const auto it = evolveIds->find(
id);
173 return it != evolveIds->end() ? it->second :
Id::Unknown;
177 static const Stats Zero;
178 const auto it = evAwards->find(
id);
179 return it != evAwards->end() ? it->second : Zero;
183 const auto it = xpMults->find(
id);
184 return it != xpMults->end() ? it->second : 1;
188 const auto it = xpGroups->find(
id);
189 if (it == xpGroups->end())
return std::numeric_limits<unsigned int>::max();
190 switch (it->second) {
192 return 5 * level * level * level / 4;
194 return level * level * level;
196 return 4 * level * level * level / 5;
198 BL_LOG_ERROR <<
"Invalid xp group " << it->second <<
" for peoplemon "
199 <<
static_cast<unsigned int>(id);
200 return std::numeric_limits<unsigned int>::max();
205 for (
const auto& p : *evolveIds) {
206 if (p.second ==
id)
return p.first;
212 static const std::string missingno =
214 const std::string f = bl::util::FileUtil::joinPath(
216 return bl::util::FileUtil::exists(f) ? f : missingno;
220 static const std::string rd =
222 static const std::string missingno = bl::util::FileUtil::joinPath(rd,
"0.png");
223 const std::string img =
224 bl::util::FileUtil::joinPath(rd, std::to_string(
static_cast<unsigned int>(
id)) +
".png");
225 return bl::util::FileUtil::exists(img) ? img : missingno;
229 static const std::string rd =
231 static const std::string missingno = bl::util::FileUtil::joinPath(rd,
"0.png");
232 const std::string img =
233 bl::util::FileUtil::joinPath(rd, std::to_string(
static_cast<unsigned int>(
id)) +
".png");
234 return bl::util::FileUtil::exists(img) ? img : missingno;
238 const auto it = catchRates->find(
id);
239 return it != catchRates->end() ?
static_cast<float>(it->second) : 48.f;
264 const unsigned int i =
static_cast<unsigned int>(ability);
265 return i < std::size(abilityTexts) ? abilityTexts[i].first : InvalidStr;
269 const unsigned int i =
static_cast<unsigned int>(ability);
270 return i < std::size(abilityTexts) ? abilityTexts[i].second : InvalidStr;
Ailment
Represents an ailment that a Peoplemon can have.
Type
Represents a type that a move or Peoplemon can be. Types may be combined.
SpecialAbility
Represents a special ability that a Peoplemon may have.
Core classes and functionality for both the editor and game.
Data structure that holds the underlaying data for all the peoplemon.
std::unordered_map< pplmn::Id, int > catchRates
std::unordered_map< pplmn::Id, pplmn::Id > evolveIds
std::unordered_map< pplmn::Id, pplmn::SpecialAbility > abilities
std::unordered_map< pplmn::Id, int > xpMults
std::unordered_map< pplmn::Id, pplmn::Type > types
std::unordered_map< pplmn::Id, std::unordered_set< pplmn::MoveId > > validMoves
std::unordered_map< pplmn::Id, unsigned int > xpGroups
std::unordered_map< pplmn::Id, pplmn::Stats > stats
std::unordered_map< pplmn::Id, unsigned int > evolveLevels
std::unordered_map< pplmn::Id, pplmn::Stats > evAwards
std::unordered_map< pplmn::Id, std::string > descriptions
std::unordered_map< pplmn::Id, std::unordered_map< unsigned int, pplmn::MoveId > > learnedMoves
std::unordered_map< pplmn::Id, std::string > names
static bool canClone(Id id)
Returns whether or not the given Peoplemon may be cloned.
static unsigned int evolveLevel(Id id)
Returns the minimum level that the given peoplemon will evolve at.
static std::string playerImage(Id id)
Returns the full path to the image to use in battle for the player peoplemon.
static void setDataSource(file::PeoplemonDB &data)
Sets the data source for all peoplemon. Must remain in scope.
static MoveId moveLearnedAtLevel(Id ppl, unsigned int level)
Returns the move the peoplemon learns at the given level, if any.
static float catchRate(Id id)
Returns the base catch rate for the given peoplemon.
static SpecialAbility specialAbility(Id id)
Returns the ability of the given peoplemon, if any.
static std::string opponentImage(Id id)
Returns the full path to the image to use in battle for the opponent peoplemon.
static int xpYieldMultiplier(Id id)
Returns the multiplier used when computing the XP award for defeating the given peoplemon.
static const std::string & abilityDescription(SpecialAbility ability)
Returns the description of the given special ability.
static Id evolvesInto(Id orig)
Returns what the given peoplemon will evolve into.
static Id evolvesFrom(Id evolved)
Returns what the given Peoplemon evolved from. This is expensive.
static const std::string & description(Id id)
Returns the description of the given Peoplemon.
static bool canLearnMove(Id ppl, MoveId move)
Returns whether or not the given Peoplemon can learn the given move.
static std::string ailmentString(Ailment ailment)
Returns the name of the given ailment as a string.
static unsigned int levelUpXp(Id id, unsigned int level)
Returns the XP required to level up the given peoplemon.
static const std::vector< Id > & validIds()
Returtns the list of all valid ids.
static const Stats & baseStats(Id id)
Returns the base stats for the given peoplemon.
static const std::string & name(Id id)
Returns the name of the given Peoplemon.
static const Stats & evAward(Id id)
Returns the ev points awarded for defeating the given peoplemon.
static Type type(Id id)
Returns the type of the Peoplemon.
static const std::string & abilityName(SpecialAbility ability)
Returns the name of the given special ability.
static Id cast(unsigned int id)
Casts an integer to a validated id. Returns Unknown if the id is invalid.
static std::string thumbnailImage(Id id)
Returns the path of the image to render as the peoplemon thumbnail.
Stats for Peoplemon. This struct is used for base stats, EVs, IVs, battle increases/decreases,...
static const std::string & ImagePath()
static const std::string & PeoplemonImageFolder()