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

Function GetSignificantRestriction

src/state.cpp:118–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118lcf::rpg::State::Restriction GetSignificantRestriction(const StateVec& states) {
119 // Priority is nomove > attack enemy > attack ally > normal
120
121 lcf::rpg::State::Restriction sig_res = lcf::rpg::State::Restriction_normal;
122
123 for (int i = 0; i < (int)states.size(); ++i) {
124 auto state_id = i + 1;
125
126 if (!Has(state_id, states)) {
127 continue;
128 }
129
130 auto* state = lcf::ReaderUtil::GetElement(lcf::Data::states, state_id);
131 if (state == nullptr) {
132 Output::Warning("State::GetSignificantRestriction: Can't remove state with invalid ID {}", state_id);
133 continue;
134 }
135
136 switch (state->restriction) {
137 case lcf::rpg::State::Restriction_normal:
138 break;
139 case lcf::rpg::State::Restriction_do_nothing:
140 return lcf::rpg::State::Restriction_do_nothing;
141 case lcf::rpg::State::Restriction::Restriction_attack_enemy:
142 if (sig_res == lcf::rpg::State::Restriction::Restriction_attack_ally
143 || sig_res == lcf::rpg::State::Restriction_normal) {
144 sig_res = lcf::rpg::State::Restriction_attack_enemy;
145 }
146 break;
147 case lcf::rpg::State::Restriction::Restriction_attack_ally:
148 if (sig_res == lcf::rpg::State::Restriction_normal) {
149 sig_res = lcf::rpg::State::Restriction_attack_ally;
150 }
151 break;
152 }
153 }
154
155 return sig_res;
156
157}
158const lcf::rpg::State* GetSignificantState(const StateVec& states) {
159 int priority = 0;
160 const lcf::rpg::State* sig_state = NULL;

Callers 3

IsControllableMethod · 0.85
AddStateMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected