Return nullptr from LearnableAttacks when trying to retrieve from empty.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b286d1726d
commit
680f949df8
|
@ -33,6 +33,9 @@ namespace CreatureLib::Library {
|
|||
const List<const AttackData*>& GetAttacksForLevel(uint8_t level) const;
|
||||
|
||||
virtual const AttackData* GetRandomAttack(Arbutils::Random rand = Arbutils::Random()) const {
|
||||
if (_distinctAttacks.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto val = rand.Get(_distinctAttacks.size());
|
||||
return *std::next(_distinctAttacks.begin(), val);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue