forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_interpreter_battle.h
125 lines (102 loc) · 4.05 KB
/
game_interpreter_battle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_GAME_INTERPRETER_BATTLE_H
#define EP_GAME_INTERPRETER_BATTLE_H
// Headers
#include <map>
#include <string>
#include <vector>
#include <cassert>
#include "game_character.h"
#include <lcf/rpg/eventcommand.h>
#include <lcf/rpg/trooppagecondition.h>
#include "system.h"
#include "game_interpreter.h"
class Game_Enemy;
class Game_Event;
class Game_CommonEvent;
/**
* Game_Interpreter_Battle class.
*/
class Game_Interpreter_Battle : public Game_Interpreter
{
public:
explicit Game_Interpreter_Battle(Span<const lcf::rpg::TroopPage> pages);
int GetNumPages() const;
bool IsValidPage(int page_id) const;
bool HasPageExecuted(int page_id) const;
static bool AreConditionsMet(const lcf::rpg::TroopPageCondition& condition, Game_Battler* source);
int ScheduleNextPage(Game_Battler* source);
int ScheduleNextPage(lcf::rpg::TroopPageCondition::Flags required_conditions, Game_Battler* source);
void ResetPagesExecuted();
void SetCurrentEnemyTargetIndex(int idx);
void SetCurrentActionTargetsSingleEnemy(bool value);
void SetCurrentActingActorId(int id);
bool IsForceFleeEnabled() const;
bool ExecuteCommand(lcf::rpg::EventCommand const& com) override;
private:
bool CommandCallCommonEvent(lcf::rpg::EventCommand const& com);
bool CommandForceFlee(lcf::rpg::EventCommand const& com);
bool CommandEnableCombo(lcf::rpg::EventCommand const& com);
bool CommandChangeMonsterHP(lcf::rpg::EventCommand const& com);
bool CommandChangeMonsterMP(lcf::rpg::EventCommand const& com);
bool CommandChangeMonsterCondition(lcf::rpg::EventCommand const& com);
bool CommandShowHiddenMonster(lcf::rpg::EventCommand const& com);
bool CommandChangeBattleBG(lcf::rpg::EventCommand const& com);
bool CommandShowBattleAnimation(lcf::rpg::EventCommand const& com);
bool CommandTerminateBattle(lcf::rpg::EventCommand const& com);
bool CommandConditionalBranchBattle(lcf::rpg::EventCommand const& com);
bool CommandElseBranchBattle(lcf::rpg::EventCommand const& com);
bool CommandEndBranchBattle(lcf::rpg::EventCommand const& com);
bool CommandManiacControlBattle(lcf::rpg::EventCommand const& com);
bool CommandManiacControlAtbGauge(lcf::rpg::EventCommand const& com);
bool CommandManiacChangeBattleCommandEx(lcf::rpg::EventCommand const& com);
bool CommandManiacGetBattleInfo(lcf::rpg::EventCommand const& com);
private:
Span<const lcf::rpg::TroopPage> pages;
std::vector<bool> executed;
int target_enemy_index = -1;
int current_actor_id = 0;
bool targets_single_enemy = false;
bool force_flee_enabled = false;
};
inline int Game_Interpreter_Battle::GetNumPages() const {
return static_cast<int>(pages.size());
}
inline bool Game_Interpreter_Battle::IsValidPage(int page_id) const {
return page_id >= 1 && page_id <= GetNumPages();
}
inline bool Game_Interpreter_Battle::HasPageExecuted(int page_id) const {
assert(IsValidPage(page_id));
return executed[page_id - 1];
}
inline void Game_Interpreter_Battle::ResetPagesExecuted() {
std::fill(executed.begin(), executed.end(), false);
}
inline void Game_Interpreter_Battle::SetCurrentEnemyTargetIndex(int idx) {
target_enemy_index = idx;
}
inline void Game_Interpreter_Battle::SetCurrentActionTargetsSingleEnemy(bool value) {
targets_single_enemy = value;
}
inline void Game_Interpreter_Battle::SetCurrentActingActorId(int id) {
current_actor_id = id;
}
inline bool Game_Interpreter_Battle::IsForceFleeEnabled() const {
return force_flee_enabled;
}
#endif