Peoplemon  0.1.0
Peoplemon 3 game source documentation
Type.hpp
Go to the documentation of this file.
1 #ifndef CORE_PEOPLEMON_TYPE_HPP
2 #define CORE_PEOPLEMON_TYPE_HPP
3 
4 #include <cstdint>
5 #include <string>
6 #include <utility>
7 
8 namespace core
9 {
10 namespace pplmn
11 {
18 enum struct Type : std::uint8_t {
19  None = 0,
20  Normal = 0x1 << 0,
21  Intelligent = 0x1 << 1,
22  Funny = 0x1 << 2,
23  Athletic = 0x1 << 3,
24  Quiet = 0x1 << 4,
25  Awkward = 0x1 << 5,
26  PartyAnimal = 0x1 << 6
27 };
28 
36 inline Type operator&(Type l, Type r) {
37  return static_cast<Type>(static_cast<std::uint8_t>(l) & static_cast<std::uint8_t>(r));
38 }
39 
47 inline Type operator|(Type l, Type r) {
48  return static_cast<Type>(static_cast<std::uint8_t>(l) | static_cast<std::uint8_t>(r));
49 }
50 
57 struct TypeUtil {
65  static float getSuperMult(Type moveType, Type defenderType);
66 
74  static float getStab(Type moveType, Type userType);
75 
82  static Type legacyTypeToNew(unsigned int ogType);
83 
91  static inline bool isType(Type type, Type check) { return (type & check) == check; }
92 
99  static std::pair<Type, Type> getTypes(Type type);
100 
107  static std::string getTypeString(Type type);
108 };
109 
110 } // namespace pplmn
111 } // namespace core
112 
113 #endif
Type
Represents a type that a move or Peoplemon can be. Types may be combined.
Definition: Type.hpp:18
Core classes and functionality for both the editor and game.
Type operator&(Type l, Type r)
Binary AND for Type values.
Definition: Type.hpp:36
Type operator|(Type l, Type r)
Binary OR for Type values.
Definition: Type.hpp:47
Contains a collection of helper methods for types.
Definition: Type.hpp:57
static std::pair< Type, Type > getTypes(Type type)
Returns the primary and secondary type of the given composite type.
Definition: Type.cpp:153
static std::string getTypeString(Type type)
Returns the type as a user-facing text string.
Definition: Type.cpp:169
static float getStab(Type moveType, Type userType)
Returns the STAB multiplier for a move.
Definition: Type.cpp:112
static float getSuperMult(Type moveType, Type defenderType)
Returns the multiplier for if/when a move is super effective.
Definition: Type.cpp:114
static bool isType(Type type, Type check)
Checks whether the given type contains the type to check.
Definition: Type.hpp:91
static Type legacyTypeToNew(unsigned int ogType)
Helper method to convert old type ids to the new.
Definition: Type.cpp:123