Don't show Attack dialog if all attacker weapons are disabled

This commit is contained in:
Charles Dang 2016-09-08 11:11:40 +11:00
parent 276047ce96
commit a0453ad5d7

View file

@ -967,7 +967,13 @@ int mouse_handler::show_attack_dialog(const map_location& attacker_loc, const ma
return -1; // abort, click will do nothing
}
if ((*attacker).attacks().empty()) {
auto attacker_weapons = (*attacker).attacks();
const bool all_disabled = std::all_of(attacker_weapons.begin(), attacker_weapons.end(), [](attack_type& attack) {
return attack.get_special_bool("disable");
});
if(attacker_weapons.empty() || all_disabled) {
gui2::show_transient_message(gui_->video(), "No Attacks",
_("This unit has no usable weapons."));