Skip to content

Commit

Permalink
add a error message
Browse files Browse the repository at this point in the history
  • Loading branch information
newfrenchy83 committed Dec 8, 2023
1 parent 153fefe commit 9f0a884
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/units/unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "game_events/manager.hpp" // for add_events
#include "game_version.hpp"
#include "gettext.hpp" // for N_
#include "gui/dialogs/message.hpp"
#include "lexical_cast.hpp"
#include "log.hpp" // for LOG_STREAM, logger, etc
#include "map/map.hpp" // for gamemap
Expand Down Expand Up @@ -1791,9 +1792,16 @@ int unit::resistance_against(const std::string& damage_name,bool attacker,const
int res = opp_weapon ? movement_type_.resistance_against(*opp_weapon) : movement_type_.resistance_against(damage_name);

unit_ability_list resistance_abilities = get_abilities_weapons("resistance",loc, weapon, opp_weapon);
bool error_message = false;
utils::erase_if(resistance_abilities, [&](const unit_ability& i) {
if(!error_message && (*i.ability_cfg)["max_value"].empty()){
error_message = true;
}
return ((*i.ability_cfg)["max_value"].empty() || !resistance_filter_matches(*i.ability_cfg, attacker, damage_name, 100-res));
});
if(error_message){
gui2::show_error_message(_("One of [resistance] abilities don't have max_value attribute and is not valid."));
}

if(!resistance_abilities.empty()) {
unit_abilities::effect resist_effect(resistance_abilities, 100-res);
Expand Down

0 comments on commit 9f0a884

Please sign in to comment.