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

Method IsSkillUsable

src/game_battler.cpp:119–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool Game_Battler::IsSkillUsable(int skill_id) const {
120 const lcf::rpg::Skill* skill = lcf::ReaderUtil::GetElement(lcf::Data::skills, skill_id);
121
122 if (!skill) {
123 Output::Warning("IsSkillUsable: Invalid skill ID {}", skill_id);
124 return false;
125 }
126
127 if (CalculateSkillCost(skill_id) > GetSp() || CalculateSkillHpCost(skill_id) >= GetHp()) {
128 return false;
129 }
130
131 for (auto state_id: GetInflictedStates()) {
132 const auto* state = lcf::ReaderUtil::GetElement(lcf::Data::states, state_id);
133 if (state) {
134 if (state->restrict_skill && skill->physical_rate >= state->restrict_skill_level && !skill->easyrpg_ignore_restrict_skill) {
135 return false;
136 }
137 if (state->restrict_magic && skill->magical_rate >= state->restrict_magic_level && !skill->easyrpg_ignore_restrict_magic) {
138 return false;
139 }
140 }
141 }
142
143 return Algo::IsSkillUsable(*skill, true);
144}
145
146bool Game_Battler::UseItem(int item_id, const Game_Battler* source) {
147 const lcf::rpg::Item* item = lcf::ReaderUtil::GetElement(lcf::Data::items, item_id);

Callers

nothing calls this directly

Calls 1

IsSkillUsableFunction · 0.85

Tested by

no test coverage detected