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_SKILL_H
13 #define LCF_RPG_SKILL_H
14 
15 // Headers
16 #include <stdint.h>
17 #include <vector>
18 #include "lcf/dbbitarray.h"
19 #include "lcf/dbstring.h"
20 #include "lcf/enum_tags.h"
21 #include "lcf/rpg/battleranimationitemskill.h"
22 #include "lcf/rpg/sound.h"
23 #include "lcf/context.h"
24 #include <ostream>
25 #include <type_traits>
26 
27 /**
28  * rpg::Skill class.
29  */
30 namespace lcf {
31 namespace rpg {
32 	class Skill {
33 	public:
34 		// Sentinel name used to denote that the default skill start message should be used.
35 		static constexpr const char* kDefaultMessage = "default_message";
36 
37 		enum Type {
38 			Type_normal = 0,
39 			Type_teleport = 1,
40 			Type_escape = 2,
41 			Type_switch = 3,
42 			Type_subskill = 4
43 		};
44 		static constexpr auto kTypeTags = lcf::makeEnumTags<Type>(
45 			"normal",
46 			"teleport",
47 			"escape",
48 			"switch",
49 			"subskill"
50 		);
51 		enum SpType {
52 			SpType_cost = 0,
53 			SpType_percent = 1
54 		};
55 		static constexpr auto kSpTypeTags = lcf::makeEnumTags<SpType>(
56 			"cost",
57 			"percent"
58 		);
59 		enum Scope {
60 			Scope_enemy = 0,
61 			Scope_enemies = 1,
62 			Scope_self = 2,
63 			Scope_ally = 3,
64 			Scope_party = 4
65 		};
66 		static constexpr auto kScopeTags = lcf::makeEnumTags<Scope>(
67 			"enemy",
68 			"enemies",
69 			"self",
70 			"ally",
71 			"party"
72 		);
73 
74 		int ID = 0;
75 		DBString name;
76 		DBString description;
77 		DBString using_message1;
78 		DBString using_message2;
79 		int32_t failure_message = 0;
80 		int32_t type = 0;
81 		int32_t sp_type = 0;
82 		int32_t sp_percent = 0;
83 		int32_t sp_cost = 0;
84 		int32_t scope = 0;
85 		int32_t switch_id = 1;
86 		int32_t animation_id = 1;
87 		Sound sound_effect;
88 		bool occasion_field = true;
89 		bool occasion_battle = false;
90 		bool reverse_state_effect = false;
91 		int32_t physical_rate = 0;
92 		int32_t magical_rate = 3;
93 		int32_t variance = 4;
94 		int32_t power = 0;
95 		int32_t hit = 100;
96 		bool affect_hp = false;
97 		bool affect_sp = false;
98 		bool affect_attack = false;
99 		bool affect_defense = false;
100 		bool affect_spirit = false;
101 		bool affect_agility = false;
102 		bool absorb_damage = false;
103 		bool ignore_defense = false;
104 		DBBitArray state_effects;
105 		DBBitArray attribute_effects;
106 		bool affect_attr_defence = false;
107 		int32_t battler_animation = -1;
108 		std::vector<BattlerAnimationItemSkill> battler_animation_data;
109 		DBString easyrpg_battle2k3_message = DBString(kDefaultMessage);
110 		bool easyrpg_ignore_reflect = false;
111 		int32_t easyrpg_state_hit = -1;
112 		int32_t easyrpg_attribute_hit = -1;
113 		bool easyrpg_ignore_restrict_skill = false;
114 		bool easyrpg_ignore_restrict_magic = false;
115 		bool easyrpg_enable_stat_absorbing = false;
116 	};
117 	inline std::ostream& operator<<(std::ostream& os, Skill::Type code) {
118 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
119 		return os;
120 	}
121 	inline std::ostream& operator<<(std::ostream& os, Skill::SpType code) {
122 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
123 		return os;
124 	}
125 	inline std::ostream& operator<<(std::ostream& os, Skill::Scope code) {
126 		os << static_cast<std::underlying_type_t<decltype(code)>>(code);
127 		return os;
128 	}
129 
130 	inline bool operator==(const Skill& l, const Skill& r) {
131 		return l.name == r.name
132 		&& l.description == r.description
133 		&& l.using_message1 == r.using_message1
134 		&& l.using_message2 == r.using_message2
135 		&& l.failure_message == r.failure_message
136 		&& l.type == r.type
137 		&& l.sp_type == r.sp_type
138 		&& l.sp_percent == r.sp_percent
139 		&& l.sp_cost == r.sp_cost
140 		&& l.scope == r.scope
141 		&& l.switch_id == r.switch_id
142 		&& l.animation_id == r.animation_id
143 		&& l.sound_effect == r.sound_effect
144 		&& l.occasion_field == r.occasion_field
145 		&& l.occasion_battle == r.occasion_battle
146 		&& l.reverse_state_effect == r.reverse_state_effect
147 		&& l.physical_rate == r.physical_rate
148 		&& l.magical_rate == r.magical_rate
149 		&& l.variance == r.variance
150 		&& l.power == r.power
151 		&& l.hit == r.hit
152 		&& l.affect_hp == r.affect_hp
153 		&& l.affect_sp == r.affect_sp
154 		&& l.affect_attack == r.affect_attack
155 		&& l.affect_defense == r.affect_defense
156 		&& l.affect_spirit == r.affect_spirit
157 		&& l.affect_agility == r.affect_agility
158 		&& l.absorb_damage == r.absorb_damage
159 		&& l.ignore_defense == r.ignore_defense
160 		&& l.state_effects == r.state_effects
161 		&& l.attribute_effects == r.attribute_effects
162 		&& l.affect_attr_defence == r.affect_attr_defence
163 		&& l.battler_animation == r.battler_animation
164 		&& l.battler_animation_data == r.battler_animation_data
165 		&& l.easyrpg_battle2k3_message == r.easyrpg_battle2k3_message
166 		&& l.easyrpg_ignore_reflect == r.easyrpg_ignore_reflect
167 		&& l.easyrpg_state_hit == r.easyrpg_state_hit
168 		&& l.easyrpg_attribute_hit == r.easyrpg_attribute_hit
169 		&& l.easyrpg_ignore_restrict_skill == r.easyrpg_ignore_restrict_skill
170 		&& l.easyrpg_ignore_restrict_magic == r.easyrpg_ignore_restrict_magic
171 		&& l.easyrpg_enable_stat_absorbing == r.easyrpg_enable_stat_absorbing;
172 	}
173 
174 	inline bool operator!=(const Skill& l, const Skill& r) {
175 		return !(l == r);
176 	}
177 
178 	std::ostream& operator<<(std::ostream& os, const Skill& obj);
179 
180 	template <typename F, typename ParentCtx = Context<void,void>>
181 	void ForEachString(Skill& obj, const F& f, const ParentCtx* parent_ctx = nullptr) {
182 		const auto ctx1 = Context<Skill, ParentCtx>{ "name", -1, &obj, parent_ctx };
183 		f(obj.name, ctx1);
184 		const auto ctx2 = Context<Skill, ParentCtx>{ "description", -1, &obj, parent_ctx };
185 		f(obj.description, ctx2);
186 		const auto ctx3 = Context<Skill, ParentCtx>{ "using_message1", -1, &obj, parent_ctx };
187 		f(obj.using_message1, ctx3);
188 		const auto ctx4 = Context<Skill, ParentCtx>{ "using_message2", -1, &obj, parent_ctx };
189 		f(obj.using_message2, ctx4);
190 		const auto ctx13 = Context<Skill, ParentCtx>{ "sound_effect", -1, &obj, parent_ctx };
191 		ForEachString(obj.sound_effect, f, &ctx13);
192 		const auto ctx35 = Context<Skill, ParentCtx>{ "easyrpg_battle2k3_message", -1, &obj, parent_ctx };
193 		f(obj.easyrpg_battle2k3_message, ctx35);
194 		(void)obj;
195 		(void)f;
196 		(void)parent_ctx;
197 	}
198 
199 } // namespace rpg
200 } // namespace lcf
201 
202 #endif
203