1 /* !!!! GENERATED FILE - DO NOT EDIT !!!!
2  * --------------------------------------
3  *
4  * This file is part of liblcf. Copyright (c) 2021 liblcf authors.
5  * https://github.com/EasyRPG/liblcf - https://easyrpg.org
6  *
7  * liblcf is Free/Libre Open Source Software, released under the MIT License.
8  * For the full copyright and license information, please view the COPYING
9  * file that was distributed with this source code.
10  */
11 
12 #ifndef LCF_RPG_STATE_H
13 #define LCF_RPG_STATE_H
14 
15 // Headers
16 #include <stdint.h>
17 #include "lcf/dbstring.h"
18 #include "lcf/enum_tags.h"
19 #include "lcf/context.h"
20 #include <ostream>
21 #include <type_traits>
22 
23 /**
24  * rpg::State class.
25  */
26 namespace lcf {
27 namespace rpg {
28 	class State {
29 	public:
30 		// The ID of the special death state
31 		static constexpr int kDeathID = 1;
32 
33 		enum Persistence {
34 			Persistence_ends = 0,
35 			Persistence_persists = 1
36 		};
37 		static constexpr auto kPersistenceTags = lcf::makeEnumTags<Persistence>(
38 			"ends",
39 			"persists"
40 		);
41 		enum Restriction {
42 			Restriction_normal = 0,
43 			Restriction_do_nothing = 1,
44 			Restriction_attack_enemy = 2,
45 			Restriction_attack_ally = 3
46 		};
47 		static constexpr auto kRestrictionTags = lcf::makeEnumTags<Restriction>(
48 			"normal",
49 			"do_nothing",
50 			"attack_enemy",
51 			"attack_ally"
52 		);
53 		enum AffectType {
54 			AffectType_half = 0,
55 			AffectType_double = 1,
56 			AffectType_nothing = 2
57 		};
58 		static constexpr auto kAffectTypeTags = lcf::makeEnumTags<AffectType>(
59 			"half",
60 			"double",
61 			"nothing"
62 		);
63 		enum ChangeType {
64 			ChangeType_lose = 0,
65 			ChangeType_gain = 1,
66 			ChangeType_nothing = 2
67 		};
68 		static constexpr auto kChangeTypeTags = lcf::makeEnumTags<ChangeType>(
69 			"lose",
70 			"gain",
71 			"nothing"
72 		);
73 
74 		int ID = 0;
75 		DBString name;
76 		int32_t type = 0;
77 		int32_t color = 6;
78 		int32_t priority = 50;
79 		int32_t restriction = 0;
80 		int32_t a_rate = 100;
81 		int32_t b_rate = 80;
82 		int32_t c_rate = 60;
83 		int32_t d_rate = 30;
84 		int32_t e_rate = 0;
85 		int32_t hold_turn = 0;
86 		int32_t auto_release_prob = 0;
87 		int32_t release_by_damage = 0;
88 		int32_t affect_type = 0;
89 		bool affect_attack = false;
90 		bool affect_defense = false;
91 		bool affect_spirit = false;
92 		bool affect_agility = false;
93 		int32_t reduce_hit_ratio = 100;
94 		bool avoid_attacks = false;
95 		bool reflect_magic = false;
96 		bool cursed = false;
97 		int32_t battler_animation_id = 100;
98 		bool restrict_skill = false;
99 		int32_t restrict_skill_level = 0;
100 		bool restrict_magic = false;
101 		int32_t restrict_magic_level = 0;
102 		int32_t hp_change_type = 0;
103 		int32_t sp_change_type = 0;
104 		DBString message_actor;
105 		DBString message_enemy;
106 		DBString message_already;
107 		DBString message_affected;
108 		DBString message_recovery;
109 		int32_t hp_change_max = 0;
110 		int32_t hp_change_val = 0;
111 		int32_t hp_change_map_steps = 0;
112 		int32_t hp_change_map_val = 0;
113 		int32_t sp_change_max = 0;
114 		int32_t sp_change_val = 0;
115 		int32_t sp_change_map_steps = 0;
116 		int32_t sp_change_map_val = 0;
117 	};
118 	inline std::ostream& operator<<(std::ostream& os, State::Persistence code) {
119 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
120 		return os;
121 	}
122 	inline std::ostream& operator<<(std::ostream& os, State::Restriction code) {
123 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
124 		return os;
125 	}
126 	inline std::ostream& operator<<(std::ostream& os, State::AffectType code) {
127 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
128 		return os;
129 	}
130 	inline std::ostream& operator<<(std::ostream& os, State::ChangeType code) {
131 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
132 		return os;
133 	}
134 
135 	inline bool operator==(const State& l, const State& r) {
136 		return l.name == r.name
137 		&& l.type == r.type
138 		&& l.color == r.color
139 		&& l.priority == r.priority
140 		&& l.restriction == r.restriction
141 		&& l.a_rate == r.a_rate
142 		&& l.b_rate == r.b_rate
143 		&& l.c_rate == r.c_rate
144 		&& l.d_rate == r.d_rate
145 		&& l.e_rate == r.e_rate
146 		&& l.hold_turn == r.hold_turn
147 		&& l.auto_release_prob == r.auto_release_prob
148 		&& l.release_by_damage == r.release_by_damage
149 		&& l.affect_type == r.affect_type
150 		&& l.affect_attack == r.affect_attack
151 		&& l.affect_defense == r.affect_defense
152 		&& l.affect_spirit == r.affect_spirit
153 		&& l.affect_agility == r.affect_agility
154 		&& l.reduce_hit_ratio == r.reduce_hit_ratio
155 		&& l.avoid_attacks == r.avoid_attacks
156 		&& l.reflect_magic == r.reflect_magic
157 		&& l.cursed == r.cursed
158 		&& l.battler_animation_id == r.battler_animation_id
159 		&& l.restrict_skill == r.restrict_skill
160 		&& l.restrict_skill_level == r.restrict_skill_level
161 		&& l.restrict_magic == r.restrict_magic
162 		&& l.restrict_magic_level == r.restrict_magic_level
163 		&& l.hp_change_type == r.hp_change_type
164 		&& l.sp_change_type == r.sp_change_type
165 		&& l.message_actor == r.message_actor
166 		&& l.message_enemy == r.message_enemy
167 		&& l.message_already == r.message_already
168 		&& l.message_affected == r.message_affected
169 		&& l.message_recovery == r.message_recovery
170 		&& l.hp_change_max == r.hp_change_max
171 		&& l.hp_change_val == r.hp_change_val
172 		&& l.hp_change_map_steps == r.hp_change_map_steps
173 		&& l.hp_change_map_val == r.hp_change_map_val
174 		&& l.sp_change_max == r.sp_change_max
175 		&& l.sp_change_val == r.sp_change_val
176 		&& l.sp_change_map_steps == r.sp_change_map_steps
177 		&& l.sp_change_map_val == r.sp_change_map_val;
178 	}
179 
180 	inline bool operator!=(const State& l, const State& r) {
181 		return !(l == r);
182 	}
183 
184 	std::ostream& operator<<(std::ostream& os, const State& obj);
185 
186 	template <typename F, typename ParentCtx = Context<void,void>>
187 	void ForEachString(State& obj, const F& f, const ParentCtx* parent_ctx = nullptr) {
188 		const auto ctx1 = Context<State, ParentCtx>{ "name", -1, &obj, parent_ctx };
189 		f(obj.name, ctx1);
190 		const auto ctx30 = Context<State, ParentCtx>{ "message_actor", -1, &obj, parent_ctx };
191 		f(obj.message_actor, ctx30);
192 		const auto ctx31 = Context<State, ParentCtx>{ "message_enemy", -1, &obj, parent_ctx };
193 		f(obj.message_enemy, ctx31);
194 		const auto ctx32 = Context<State, ParentCtx>{ "message_already", -1, &obj, parent_ctx };
195 		f(obj.message_already, ctx32);
196 		const auto ctx33 = Context<State, ParentCtx>{ "message_affected", -1, &obj, parent_ctx };
197 		f(obj.message_affected, ctx33);
198 		const auto ctx34 = Context<State, ParentCtx>{ "message_recovery", -1, &obj, parent_ctx };
199 		f(obj.message_recovery, ctx34);
200 		(void)obj;
201 		(void)f;
202 		(void)parent_ctx;
203 	}
204 
205 } // namespace rpg
206 } // namespace lcf
207 
208 #endif
209