Skip to content

Commit

Permalink
rename get_..._bool method to has_.. method
Browse files Browse the repository at this point in the history
  • Loading branch information
newfrenchy83 authored and Pentarctagon committed Mar 26, 2021
1 parent 56cfa32 commit 6b40f8a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
24 changes: 12 additions & 12 deletions src/actions/attack.cpp
Expand Up @@ -143,19 +143,19 @@ battle_context_unit_stats::battle_context_unit_stats(nonempty_unit_const_ptr up,
opp_ctx.emplace(opp_weapon->specials_context(oppp, up, opp_loc, u_loc, !attacking, weapon));
}

slows = weapon->get_special_and_abilities_bool("slow");
drains = !opp.get_state("undrainable") && weapon->get_special_and_abilities_bool("drains");
petrifies = weapon->get_special_and_abilities_bool("petrifies");
poisons = !opp.get_state("unpoisonable") && weapon->get_special_and_abilities_bool("poison") && !opp.get_state(unit::STATE_POISONED);
slows = weapon->has_special_and_abilities("slow");
drains = !opp.get_state("undrainable") && weapon->has_special_and_abilities("drains");
petrifies = weapon->has_special_and_abilities("petrifies");
poisons = !opp.get_state("unpoisonable") && weapon->has_special_and_abilities("poison") && !opp.get_state(unit::STATE_POISONED);
backstab_pos = is_attacker && backstab_check(u_loc, opp_loc, units, resources::gameboard->teams());
rounds = weapon->get_specials_and_abilities("berserk").highest("value", 1).first;

firststrike = weapon->get_special_and_abilities_bool("firststrike");
firststrike = weapon->has_special_and_abilities("firststrike");

{
const int distance = distance_between(u_loc, opp_loc);
const bool out_of_range = distance > weapon->max_range() || distance < weapon->min_range();
disable = weapon->get_special_bool("disable") || out_of_range;
disable = weapon->has_special("disable") || out_of_range;
}

// Handle plague.
Expand Down Expand Up @@ -305,13 +305,13 @@ battle_context_unit_stats::battle_context_unit_stats(const unit_type* u_type,
opp_ctx.emplace(opp_weapon->specials_context(*opp_type, map_location::null_location(), !attacking));
}

slows = weapon->get_special_bool("slow");
drains = !opp_type->musthave_status("undrainable") && weapon->get_special_bool("drains");
petrifies = weapon->get_special_bool("petrifies");
poisons = !opp_type->musthave_status("unpoisonable") && weapon->get_special_bool("poison");
slows = weapon->has_special("slow");
drains = !opp_type->musthave_status("undrainable") && weapon->has_special("drains");
petrifies = weapon->has_special("petrifies");
poisons = !opp_type->musthave_status("unpoisonable") && weapon->has_special("poison");
rounds = weapon->get_specials("berserk").highest("value", 1).first;
firststrike = weapon->get_special_bool("firststrike");
disable = weapon->get_special_bool("disable");
firststrike = weapon->has_special("firststrike");
disable = weapon->has_special("disable");

unit_ability_list plague_specials = weapon->get_specials("plague");
plagues = !opp_type->musthave_status("unplagueable") && !plague_specials.empty() &&
Expand Down
4 changes: 2 additions & 2 deletions src/ai/default/aspect_attacks.cpp
Expand Up @@ -168,11 +168,11 @@ void aspect_attacks_base::do_attack_analysis(const map_location& loc,
bool backstab = false, slow = false;
for(const attack_type& a : unit_itor->attacks()) {
// For speed, just assume these specials will be active if they are present.
if(a.get_special_bool("backstab", true)) {
if(a.has_special("backstab", true)) {
backstab = true;
}

if(a.get_special_bool("slow", true)) {
if(a.has_special("slow", true)) {
slow = true;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/units/abilities.cpp
Expand Up @@ -693,7 +693,7 @@ namespace {
* active in the current context (see set_specials_context), including
* specials obtained from the opponent's attack.
*/
bool attack_type::get_special_bool(const std::string& special, bool simple_check, bool special_id, bool special_tags) const
bool attack_type::has_special(const std::string& special, bool simple_check, bool special_id, bool special_tags) const
{
{
std::vector<special_match> special_tag_matches;
Expand Down Expand Up @@ -1261,7 +1261,7 @@ bool attack_type::check_adj_abilities_impl(const_attack_ptr self_attack, const_a
* active in the current context (see set_specials_context), including
* specials obtained from the opponent's attack.
*/
bool attack_type::get_weapon_ability_bool(const std::string& special, bool special_id, bool special_tags) const
bool attack_type::has_weapon_ability(const std::string& special, bool special_id, bool special_tags) const
{
assert(display::get_singleton());
const unit_map& units = display::get_singleton()->get_units();
Expand Down Expand Up @@ -1359,9 +1359,9 @@ bool attack_type::get_weapon_ability_bool(const std::string& special, bool speci
return false;
}

bool attack_type::get_special_and_abilities_bool(const std::string& special, bool special_id, bool special_tags) const
bool attack_type::has_special_and_abilities(const std::string& special, bool special_id, bool special_tags) const
{
return (get_special_bool(special, false, special_id, special_tags) || get_weapon_ability_bool(special, special_id, special_tags));
return (has_special(special, false, special_id, special_tags) || has_weapon_ability(special, special_id, special_tags));
}
//end of emulate weapon special functions.

Expand Down Expand Up @@ -1456,7 +1456,7 @@ bool attack_type::special_active_impl(const_attack_ptr self_attack, const_attack
return false;
}
if (tag_name == "firststrike" && !is_attacker && other_attack &&
other_attack->get_special_and_abilities_bool("firststrike")) {
other_attack->has_special_and_abilities("firststrike")) {
return false;
}

Expand Down
12 changes: 6 additions & 6 deletions src/units/attack_type.cpp
Expand Up @@ -142,7 +142,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
deprecated_message("special=", DEP_LEVEL::PREEMPTIVE, {1, 17, 0}, "Please use special_id or special_type instead");
bool found = false;
for(auto& special : filter_special) {
if(attack.get_special_bool(special, true)) {
if(attack.has_special(special, true)) {
found = true;
break;
}
Expand All @@ -154,7 +154,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
if(!filter_special_id.empty()) {
bool found = false;
for(auto& special : filter_special_id) {
if(attack.get_special_bool(special, true, true, false)) {
if(attack.has_special(special, true, true, false)) {
found = true;
break;
}
Expand All @@ -168,7 +168,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
deprecated_message("special_active=", DEP_LEVEL::PREEMPTIVE, {1, 17, 0}, "Please use special_id_active or special_type_active instead");
bool found = false;
for(auto& special : filter_special_active) {
if(attack.get_special_bool(special, false)) {
if(attack.has_special(special, false)) {
found = true;
break;
}
Expand All @@ -180,7 +180,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
if(!filter_special_id_active.empty()) {
bool found = false;
for(auto& special : filter_special_id_active) {
if(attack.get_special_and_abilities_bool(special, true, false)) {
if(attack.has_special_and_abilities(special, true, false)) {
found = true;
break;
}
Expand All @@ -192,7 +192,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
if(!filter_special_type.empty()) {
bool found = false;
for(auto& special : filter_special_type) {
if(attack.get_special_bool(special, true, false)) {
if(attack.has_special(special, true, false)) {
found = true;
break;
}
Expand All @@ -204,7 +204,7 @@ static bool matches_simple_filter(const attack_type & attack, const config & fil
if(!filter_special_type_active.empty()) {
bool found = false;
for(auto& special : filter_special_type_active) {
if(attack.get_special_and_abilities_bool(special, false)) {
if(attack.has_special_and_abilities(special, false)) {
found = true;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/units/attack_type.hpp
Expand Up @@ -78,7 +78,7 @@ class attack_type : public std::enable_shared_from_this<attack_type>
* @param special_id If true, match @a special against the @c id of special tags.
* @param special_tags If true, match @a special against the tag name of special tags.
*/
bool get_special_bool(const std::string& special, bool simple_check=false, bool special_id=true, bool special_tags=true) const;
bool has_special(const std::string& special, bool simple_check=false, bool special_id=true, bool special_tags=true) const;
unit_ability_list get_specials(const std::string& special) const;
std::vector<std::pair<t_string, t_string>> special_tooltips(boost::dynamic_bitset<>* active_list = nullptr) const;
std::string weapon_specials(bool only_active=false, bool is_backstab=false) const;
Expand All @@ -98,14 +98,14 @@ class attack_type : public std::enable_shared_from_this<attack_type>
* @param special_id If true, match @a special against the @c id of special tags.
* @param special_tags If true, match @a special against the tag name of special tags.
*/
bool get_weapon_ability_bool(const std::string& special, bool special_id=true, bool special_tags=true) const;
bool has_weapon_ability(const std::string& special, bool special_id=true, bool special_tags=true) const;
/** used for abilities used like weapon and true specials
* @return True if the ability @a special is active.
* @param special The special being checked.
* @param special_id If true, match @a special against the @c id of special tags.
* @param special_tags If true, match @a special against the tag name of special tags.
*/
bool get_special_and_abilities_bool(const std::string& special, bool special_id=true, bool special_tags=true) const;
bool has_special_and_abilities(const std::string& special, bool special_id=true, bool special_tags=true) const;

// In unit_types.cpp:

Expand Down

0 comments on commit 6b40f8a

Please sign in to comment.