Added lots of security using asserts.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -14,6 +14,9 @@ Battling::Creature::Creature(const BattleLibrary* library, const Library::Creatu
|
||||
: _library(library), _species(species), _variant(variant), _level(level), _experience(experience),
|
||||
_uniqueIdentifier(uid), _gender(gender), _coloring(coloring), _heldItem(heldItem), _nickname(std::move(nickname)),
|
||||
_talentIndex(talent), _hasOverridenTalent(false), _attacks(std::move(attacks)) {
|
||||
AssertNotNull(library)
|
||||
AssertNotNull(species)
|
||||
AssertNotNull(variant)
|
||||
|
||||
_activeTalent = _library->LoadScript(ScriptCategory::Talent, GetActiveTalent());
|
||||
if (_nickname.empty()) {
|
||||
@@ -84,7 +87,7 @@ Battling::Battle* Battling::Creature::GetBattle() const { return _battle; }
|
||||
|
||||
Battling::BattleSide* Battling::Creature::GetBattleSide() const { return _side; }
|
||||
|
||||
bool Battling::Creature::IsFainted() const { return this->_currentHealth <= 0; }
|
||||
bool Battling::Creature::IsFainted() const noexcept { return this->_currentHealth <= 0; }
|
||||
|
||||
void Battling::Creature::OnFaint() {
|
||||
// HOOK: On Faint
|
||||
@@ -140,12 +143,12 @@ void Battling::Creature::OverrideActiveTalent(const ConstString& talent) {
|
||||
_activeTalent = this->_library->LoadScript(ScriptCategory::Talent, talent);
|
||||
}
|
||||
|
||||
const std::vector<uint8_t>& Battling::Creature::GetTypes() const {
|
||||
const std::vector<uint8_t>& Battling::Creature::GetTypes() const noexcept {
|
||||
// HOOK: override types.
|
||||
return this->_variant->GetTypes();
|
||||
}
|
||||
|
||||
bool Battling::Creature::HasType(uint8_t type) const {
|
||||
bool Battling::Creature::HasType(uint8_t type) const noexcept {
|
||||
auto t = GetTypes();
|
||||
return std::find(t.begin(), t.end(), type) != t.end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user