Skip to main content

bodyguard

Function bodyguard 

Source
pub fn bodyguard(
    tables: &StartposTables,
    faction: &FactionEntry,
    naval: bool,
) -> Result<Option<Bodyguard>>
Expand description

Returns the default bodyguard of a faction’s generals, or the flagship of its admirals.

The candidates are the commander_unit_permissions units of the faction, of its subculture (rows without faction) and of its culture (rows without faction and subculture), allowed for the faction’s military group and naval only for flagships. The bodyguard is the candidate no other candidate upgrades into (technology_unit_upgrades), that is, the start of the upgrade chain; the first one in table order if there are several.

§Arguments

  • tables - Tables with commander_unit_permissions, units_to_groupings_military_permissions, technology_unit_upgrades and main_units.
  • faction - The faction.
  • naval - Look for a flagship instead of a land bodyguard.

§Returns

The bodyguard, or None if the faction has no candidate.

§Errors

Returns an error if a table or column is missing.