engine/actions/source/RangedCombatApplicabilityChecker.cpp
// Check to see if the creature is capable of doing ranged combat by
// performing a number of checks on their equipment, and the configuration
// thereof.
Check to see if the creature is capable of doing ranged combat by
performing a number of checks on their equipment, and the configuration
thereof.
Check to see if the creature is capable of doing ranged combat by performing a number of checks on their equipment and the configuration thereof .
pair<bool, string> RangedCombatApplicabilityChecker::can_creature_do_ranged_combat(CreaturePtr creature)
{
  pair<bool, string> ranged_combat_info;
  ranged_combat_info.first = false;
  bool allow_cursed_ammunition_use = Game::instance().get_settings_ref().get_setting_as_bool(Setting::ALLOW_CURSED_AMMUNITION_USE);
  if (creature != nullptr)
  {
    if (!is_current_map_type_not_world())
    {
      ranged_combat_info.second = get_ranged_combat_on_world_map_not_allowed_message();
    }
    else if (is_ammunition_cursed(creature) && !allow_cursed_ammunition_use)
    {
      ranged_combat_info.second = get_ammunition_cursed_message();
    }
    else if (!is_ranged_weapon_equipped(creature))
    {
      ranged_combat_info.second = get_ranged_weapon_not_equipped_message();
    }
    else if (!is_ranged_weapon_and_ammunition_equipped(creature))
    {
      ranged_combat_info.second = get_ammunition_not_equipped_message();
    }
    else if (!is_ranged_weapon_required_and_equipped(creature))
    {
      ranged_combat_info.second = get_ammunition_requires_ranged_weapon_message();
    }
    else if (!does_ranged_weapon_match_ammunition(creature))
    {
      ranged_combat_info.second = get_weapon_and_ammunition_mismatch_message();
    }
    else if (BurdenLevelConverter::to_burden_level(creature) == BurdenLevel::BURDEN_LEVEL_OVERBURDENED)
    {
      ranged_combat_info.second = get_overburdened_message();
    }
    else
    {
      ranged_combat_info.first = true;
    }
  }
  return ranged_combat_info;
}
pair < bool , string > RangedCombatApplicabilityChecker :: can_creature_do_ranged_combat ( CreaturePtr creature ) { pair < bool , string > ranged_combat_info ; ranged_combat_info . first = false ; bool allow_cursed_ammunition_use = Game :: instance ( ) . get_settings_ref ( ) . get_setting_as_bool ( Setting :: ALLOW_CURSED_AMMUNITION_USE ) ; if ( creature != nullptr ) { if ( ! is_current_map_type_not_world ( ) ) { ranged_combat_info . second = get_ranged_combat_on_world_map_not_allowed_message ( ) ; } else if ( is_ammunition_cursed ( creature ) && ! allow_cursed_ammunition_use ) { ranged_combat_info . second = get_ammunition_cursed_message ( ) ; } else if ( ! is_ranged_weapon_equipped ( creature ) ) { ranged_combat_info . second = get_ranged_weapon_not_equipped_message ( ) ; } else if ( ! is_ranged_weapon_and_ammunition_equipped ( creature ) ) { ranged_combat_info . second = get_ammunition_not_equipped_message ( ) ; } else if ( ! is_ranged_weapon_required_and_equipped ( creature ) ) { ranged_combat_info . second = get_ammunition_requires_ranged_weapon_message ( ) ; } else if ( ! does_ranged_weapon_match_ammunition ( creature ) ) { ranged_combat_info . second = get_weapon_and_ammunition_mismatch_message ( ) ; } else if ( BurdenLevelConverter :: to_burden_level ( creature ) == BurdenLevel :: BURDEN_LEVEL_OVERBURDENED ) { ranged_combat_info . second = get_overburdened_message ( ) ; } else { ranged_combat_info . first = true ; } } return ranged_combat_info ; }
Check to see if the creature is capable of doing ranged combat by
performing a number of checks on their equipment, and the configuration
thereof.
Check to see if the creature is capable of doing ranged combat by performing a number of checks on their equipment and the configuration thereof .
// Everything is good - update the pair so that the "success" // boolean value is true.