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
35};
36
40constexpr bool IsLockedType(ObjectType type)
41{
42 return type >= ObjectType::LOCKED_UP &&
44}
45
49constexpr bool IsTextType(ObjectType type)
50{
51 return type < ObjectType::ICON_TYPE || IsLockedType(type);
52}
53
57constexpr bool IsNounType(ObjectType type)
58{
59 return (type > ObjectType::NOUN_TYPE && type < ObjectType::OP_TYPE);
60}
61
65constexpr bool IsOpType(ObjectType type)
66{
67 return (type > ObjectType::OP_TYPE && type < ObjectType::PROPERTY_TYPE);
68}
69
73constexpr bool IsVerbType(ObjectType type)
74{
75 return (type == ObjectType::IS || type == ObjectType::HAS ||
76 type == ObjectType::MAKE);
77}
78
82constexpr bool IsPropertyType(ObjectType type)
83{
84 return (type > ObjectType::PROPERTY_TYPE &&
85 type < ObjectType::ICON_TYPE) ||
86 IsLockedType(type);
87}
88
92constexpr bool IsIconType(ObjectType type)
93{
94 return type > ObjectType::ICON_TYPE && type <= ObjectType::ICON_WATER;
95}
96
101{
102 const auto typeVal = static_cast<int>(type);
103 const auto iconTypeVal = static_cast<int>(ObjectType::ICON_TYPE);
104
105 if (!IsIconType(type))
106 {
107 return type;
108 }
109
110 const int convertedVal = typeVal - iconTypeVal;
111 return static_cast<ObjectType>(convertedVal);
112}
113
118{
119 const auto typeVal = static_cast<int>(type);
120 const auto iconTypeVal = static_cast<int>(ObjectType::ICON_TYPE);
121
122 if (!IsNounType(type))
123 {
124 return type;
125 }
126
127 const int convertedVal = typeVal + iconTypeVal;
128 return static_cast<ObjectType>(convertedVal);
129}
130
132enum class PlayState
133{
134 INVALID,
135 PLAYING,
136 WON,
137 LOST
138};
139
141enum class Direction
142{
143 NONE,
144 UP,
145 DOWN,
146 LEFT,
147 RIGHT
148};
149} // namespace baba_is_auto
150
151#endif // BABA_IS_AUTO_WORD_ENUMS_HPP
Definition IAgent.hpp:14
constexpr bool IsTextType(ObjectType type)
Definition GameEnums.hpp:49
constexpr bool IsOpType(ObjectType type)
Definition GameEnums.hpp:65
constexpr bool IsVerbType(ObjectType type)
Definition GameEnums.hpp:73
ObjectType
An enumerator for identifying the object.
Definition GameEnums.hpp:14
constexpr bool IsPropertyType(ObjectType type)
Definition GameEnums.hpp:82
constexpr ObjectType ConvertIconToText(ObjectType type)
Definition GameEnums.hpp:100
constexpr ObjectType ConvertTextToIcon(ObjectType type)
Definition GameEnums.hpp:117
constexpr bool IsIconType(ObjectType type)
Definition GameEnums.hpp:92
PlayState
An enumerator for identifying the play state.
Definition GameEnums.hpp:133
constexpr bool IsNounType(ObjectType type)
Definition GameEnums.hpp:57
Direction
An enumerator for identifying the direction.
Definition GameEnums.hpp:142
constexpr bool IsLockedType(ObjectType type)
Definition GameEnums.hpp:40