Peoplemon  0.1.0
Peoplemon 3 game source documentation
Item.hpp
Go to the documentation of this file.
1 #ifndef CORE_ITEMS_ITEM_HPP
2 #define CORE_ITEMS_ITEM_HPP
3 
5 #include <Core/Files/ItemDB.hpp>
7 #include <Core/Items/Id.hpp>
8 #include <Core/Items/Type.hpp>
12 #include <Core/Player/State.hpp>
13 #include <vector>
14 
15 namespace core
16 {
17 namespace item
18 {
25 struct Item {
32  static Id cast(unsigned int id);
33 
39  static void setDataSource(file::ItemDB& source);
40 
47  static Category getCategory(Id item);
48 
55  static Type getType(Id item);
56 
63  static const std::string& getName(item::Id item);
64 
71  static const std::string& getDescription(item::Id item);
72 
79  static int getValue(item::Id item);
80 
85  static const std::vector<Id>& validIds();
86 
93  static bool canUseInBattle(Id item);
94 
102  static bool hasEffectOnPeoplemon(Id item, const pplmn::OwnedPeoplemon& ppl);
103 
112  static bool hasEffectOnPeoplemon(Id item, const pplmn::BattlePeoplemon& ppl,
113  const battle::Battler& battler);
114 
123  static void useOnPeoplemon(Id item, pplmn::OwnedPeoplemon& ppl,
124  std::vector<pplmn::OwnedPeoplemon>* team = nullptr,
125  std::vector<pplmn::BattlePeoplemon>* battleTeam = nullptr);
126 
134  static void useOnPeoplemon(Id item, pplmn::BattlePeoplemon& ppl, battle::Battler& battler);
135 
143  static std::string getUseLine(Id item, const pplmn::OwnedPeoplemon& ppl);
144 
152  static bool hasEffectOnPlayer(Id item, const player::State& state);
153 
160  static void useOnPlayer(Id item, player::State& state);
161 
168  static std::string getUseLine(Id item);
169 
176  static pplmn::MoveId getTmMove(Id tm);
177 
187  static float getPeopleballRate(Id ball, pplmn::Id ppl, int turnNumber, float levelRatio);
188 
189 private:
190  static std::unordered_map<Id, std::string>* names;
191  static std::unordered_map<Id, std::string>* descriptions;
192  static std::unordered_map<Id, int>* values;
193 };
194 
195 } // namespace item
196 } // namespace core
197 
198 #endif
Type
The type classification of an item. This is used to determine when an item may be used and how to use...
Definition: Type.hpp:17
Category
Represents a category that an item can belong to. Used for bag sorting.
Definition: Category.hpp:16
Id
Represents an item in its simplist form.
Definition: Id.hpp:24
MoveId
The id of a move.
Definition: MoveId.hpp:16
Id
The id of a peoplemon.
Definition: Id.hpp:16
Core classes and functionality for both the editor and game.
Base class for battlers in the game. This provides storage for peoplemon and turn choices.
Definition: Battler.hpp:23
Loads and stores metadata surrounding items in the game.
Definition: ItemDB.hpp:24
Collection of static methods centered around items.
Definition: Item.hpp:25
static std::string getUseLine(Id item, const pplmn::OwnedPeoplemon &ppl)
Returns the text to display when the item is used on the given peoplemon.
Definition: Item.cpp:327
static void setDataSource(file::ItemDB &source)
Set the data source for the item methods.
Definition: Item.cpp:41
static const std::string & getDescription(item::Id item)
Returns the description of the given item.
Definition: Item.cpp:105
static Category getCategory(Id item)
Returns the category of the given item.
Definition: Item.cpp:49
static pplmn::MoveId getTmMove(Id tm)
Returns the move taught by the TM.
Definition: Item.cpp:418
static void useOnPlayer(Id item, player::State &state)
Uses the given item on the player.
Definition: Item.cpp:391
static const std::string & getName(item::Id item)
Returns the name of the given item.
Definition: Item.cpp:91
static bool canUseInBattle(Id item)
Returns whether or not the item can be used in battle.
Definition: Item.cpp:133
static Type getType(Id item)
Returns the type of the given item.
Definition: Item.cpp:76
static void useOnPeoplemon(Id item, pplmn::OwnedPeoplemon &ppl, std::vector< pplmn::OwnedPeoplemon > *team=nullptr, std::vector< pplmn::BattlePeoplemon > *battleTeam=nullptr)
Applies the given item to the peoplemon.
Definition: Item.cpp:222
static float getPeopleballRate(Id ball, pplmn::Id ppl, int turnNumber, float levelRatio)
Returns the catch rate for the given peopleball.
Definition: Item.cpp:426
static const std::vector< Id > & validIds()
Returns the list of valid item ids.
Definition: Item.cpp:125
static int getValue(item::Id item)
Returns the value of the given item.
Definition: Item.cpp:119
static Id cast(unsigned int id)
Helper function to cast a raw id to an item Id.
Definition: Item.cpp:31
static bool hasEffectOnPeoplemon(Id item, const pplmn::OwnedPeoplemon &ppl)
Returns whether or not the given item will affect the peoplemon.
Definition: Item.cpp:144
static bool hasEffectOnPlayer(Id item, const player::State &state)
Returns whether or not the given item will affect the player.
Definition: Item.cpp:380
Represents a Peoplemon in battle. Stores some extra state that only exists in battle....
Represents an instance of a peoplemon. Can be a wild peoplemon, trainer, or player peoplemon....
Stores all player state.
Definition: State.hpp:21