MCPcopy Create free account
hub / github.com/EasyRPG/Player / AreConditionsMet

Method AreConditionsMet

src/game_event.cpp:242–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242bool Game_Event::AreConditionsMet(const lcf::rpg::EventPage& page) {
243 // First switch (A)
244 if (page.condition.flags.switch_a && !Main_Data::game_switches->Get(page.condition.switch_a_id)) {
245 return false;
246 }
247
248 // Second switch (B)
249 if (page.condition.flags.switch_b && !Main_Data::game_switches->Get(page.condition.switch_b_id)) {
250 return false;
251 }
252
253 // Variable
254 if (Player::IsRPG2k()) {
255 if (page.condition.flags.variable && !(Main_Data::game_variables->Get(page.condition.variable_id) >= page.condition.variable_value)) {
256 return false;
257 }
258 } else {
259 if (page.condition.flags.variable && page.condition.compare_operator >= 0 && page.condition.compare_operator <= 5) {
260 if (!Game_Interpreter_Shared::CheckOperator(Main_Data::game_variables->Get(page.condition.variable_id), page.condition.variable_value, page.condition.compare_operator))
261 return false;
262 }
263 }
264
265 // Item in possession?
266 if (page.condition.flags.item && !(Main_Data::game_party->GetItemCount(page.condition.item_id)
267 + Main_Data::game_party->GetEquippedItemCount(page.condition.item_id))) {
268 return false;
269 }
270
271 // Actor in party?
272 if (page.condition.flags.actor) {
273 if (!Main_Data::game_party->IsActorInParty(page.condition.actor_id)) {
274 return false;
275 }
276 }
277
278 // Timer
279 if (page.condition.flags.timer) {
280 int secs = Main_Data::game_party->GetTimerSeconds(Main_Data::game_party->Timer1);
281 if (secs > page.condition.timer_sec)
282 return false;
283 }
284
285 // Timer2
286 if (page.condition.flags.timer2 && Player::IsRPG2k3Commands()) {
287 int secs = Main_Data::game_party->GetTimerSeconds(Main_Data::game_party->Timer2);
288 if (secs > page.condition.timer2_sec)
289 return false;
290 }
291
292 // All conditions met :D
293 return true;
294}
295
296int Game_Event::GetId() const {
297 return data()->ID;

Callers

nothing calls this directly

Calls 5

GetEquippedItemCountMethod · 0.80
IsActorInPartyMethod · 0.80
GetTimerSecondsMethod · 0.80
GetMethod · 0.45
GetItemCountMethod · 0.45

Tested by

no test coverage detected