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
continuous-integration/drone/push Build is passing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
b84db6aa2d
commit
152ac7e407
|
@ -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.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue