baba-is-auto
C++17 Baba Is You simulator
Loading...
Searching...
No Matches
GameEnums.hpp
Go to the documentation of this file.
1// Copyright (c) 2020-2026 Chris Ohk
2
3// I am making my contributions/submissions to this project solely in our
4// personal capacity and am not conveying any rights to any intellectual
5// property of any third parties.
6
7#ifndef BABA_IS_AUTO_GAME_ENUMS_HPP
8#define BABA_IS_AUTO_GAME_ENUMS_HPP
9
10namespace baba_is_auto
11{
13enum class ObjectType
14{
16#define X(a) a,
17#include "NounType.def"
18#undef X
19 OP_TYPE,
20#define X(a) a,
21#include "OpType.def"
22#undef X
24#define X(a) a,
25#include "PropertyType.def"
26#undef X
28#define X(a) a,
29#include "IconType.def"
30#undef X
31};
32
36constexpr bool IsTextType(ObjectType type)
37{
38 return type < ObjectType::ICON_TYPE;
39}
40
44constexpr bool IsNounType(ObjectType type)
45{
46 return (type > ObjectType::NOUN_TYPE && type < ObjectType::OP_TYPE);
47}
48
52constexpr bool IsOpType(ObjectType type)
53{
54 return (type > ObjectType::OP_TYPE && type < ObjectType::PROPERTY_TYPE);
55}
56
60constexpr bool IsVerbType(ObjectType type)
61{
62 return (type == ObjectType::IS || type == ObjectType::HAS ||
63 type == ObjectType::MAKE);
64}
65
69constexpr bool IsPropertyType(ObjectType type)
70{
71 return (type > ObjectType::PROPERTY_TYPE && type < ObjectType::ICON_TYPE);
72}
73
78{
79 const auto typeVal = static_cast<int>(type);
80 const auto iconTypeVal = static_cast<int>(ObjectType::ICON_TYPE);
81
82 if (typeVal <= iconTypeVal)
83 {
84 return type;
85 }
86
87 const int convertedVal = typeVal - iconTypeVal;
88 return static_cast<ObjectType>(convertedVal);
89}
90
95{
96 const auto typeVal = static_cast<int>(type);
97 const auto iconTypeVal = static_cast<int>(ObjectType::ICON_TYPE);
98
99 if (typeVal > iconTypeVal)
100 {
101 return type;
102 }
103
104 const int convertedVal = typeVal + iconTypeVal;
105 return static_cast<ObjectType>(convertedVal);
106}
107
109enum class PlayState
110{
111 INVALID,
112 PLAYING,
113 WON,
114 LOST
115};
116
118enum class Direction
119{
120 NONE,
121 UP,
122 DOWN,
123 LEFT,
124 RIGHT
125};
126} // namespace baba_is_auto
127
128#endif // BABA_IS_AUTO_WORD_ENUMS_HPP
Definition IAgent.hpp:14
constexpr bool IsTextType(ObjectType type)
Definition GameEnums.hpp:36
constexpr bool IsOpType(ObjectType type)
Definition GameEnums.hpp:52
constexpr bool IsVerbType(ObjectType type)
Definition GameEnums.hpp:60
ObjectType
An enumerator for identifying the object.
Definition GameEnums.hpp:14
constexpr bool IsPropertyType(ObjectType type)
Definition GameEnums.hpp:69
constexpr ObjectType ConvertIconToText(ObjectType type)
Definition GameEnums.hpp:77
constexpr ObjectType ConvertTextToIcon(ObjectType type)
Definition GameEnums.hpp:94
PlayState
An enumerator for identifying the play state.
Definition GameEnums.hpp:110
constexpr bool IsNounType(ObjectType type)
Definition GameEnums.hpp:44
Direction
An enumerator for identifying the direction.
Definition GameEnums.hpp:119