Don't throw an exception when teaching an attack when we don't have the max amount of attacks yet.
continuous-integration/drone/push Build is passing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2021-08-29 17:16:36 +02:00
parent b84db6aa2d
commit 152ac7e407
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 2 additions and 1 deletions

View File

@ -302,13 +302,14 @@ namespace CreatureLib::Battling {
bool Creature::HasVolatileScript(const ArbUt::BasicStringView& name) const { return _volatile.Has(name); }
void Creature::AddAttack(LearnedAttack* attack) {
for (size_t i = 0; i < _attacks.Count(); i++) {
if (_attacks[i] == nullptr) {
if (!_attacks[i].HasValue()) {
_attacks.Set(i, attack);
return;
}
}
if (_attacks.Count() < _library->GetStaticLib()->GetSettings()->GetMaximalAttacks()) {
_attacks.Append(attack);
return;
}
THROW("Can't add attack. The creature already has the maximum amount of attacks.");
}