New has_variation(id) method
This method is used for querying if a unit has a certain subtype. If the unit is a variation itself it checks the siblings.
This commit is contained in:
parent
c0a24dc4b7
commit
7e95aa90bb
2 changed files with 10 additions and 0 deletions
|
@ -1033,6 +1033,10 @@ std::vector<std::string> unit_type::variations() const
|
|||
return retval;
|
||||
}
|
||||
|
||||
bool unit_type::has_variation(const std::string& variation_id) const
|
||||
{
|
||||
return variations_.find(variation_id) != variations_.end();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates (and returns) a trimmed config suitable for use with units.
|
||||
|
|
|
@ -246,6 +246,12 @@ public:
|
|||
/// to the HELP_INDEX status.
|
||||
const std::vector<unit_race::GENDER>& genders() const { return genders_; }
|
||||
std::vector<std::string> variations() const;
|
||||
|
||||
/**
|
||||
* @param variation_id The id of the variation we search for.
|
||||
* @return Iff one of the type's variations' (or the sibling's if the unit_type is a variation itself) id matches @variation_id.
|
||||
*/
|
||||
bool has_variation(const std::string& variation_id) const;
|
||||
|
||||
/// Returns the ID of this type's race without the need to build the type.
|
||||
std::string race_id() const { return cfg_["race"]; } //race_->id(); }
|
||||
|
|
Loading…
Add table
Reference in a new issue