Adds status handling functions
All checks were successful
continuous-integration/drone/push Build is passing

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
2021-07-09 15:33:30 +02:00
parent 9303ec53e0
commit 08120d5433
6 changed files with 57 additions and 2 deletions

View File

@@ -371,4 +371,24 @@ namespace CreatureLib::Battling {
return c;
}
}
void CreatureLib::Battling::Creature::SetStatus(const ArbUt::StringView& name) {
if (_status != nullptr) {
_status->OnRemove();
}
_status = std::unique_ptr<CreatureLib::Battling::BattleScript>(_library->LoadScript(ScriptCategory::Status, name));
if (_battleData.Battle.HasValue()) {
_battleData.Battle.GetValue()->TriggerEventListener<StatusChangeEvent>(this, name);
}
}
void CreatureLib::Battling::Creature::ClearStatus() {
if (_status == nullptr) {
return;
}
_status->OnRemove();
_status = nullptr;
if (_battleData.Battle.HasValue()) {
_battleData.Battle.GetValue()->TriggerEventListener<StatusChangeEvent>(this, ""_cnc);
}
}

View File

@@ -179,6 +179,14 @@ namespace CreatureLib::Battling {
void ReplaceAttack(size_t index, LearnedAttack* attack);
void SwapAttacks(size_t a, size_t b) { _attacks.Swap(a, b); }
void SetStatus(const ArbUt::StringView& name);
void ClearStatus();
const ArbUt::StringView& GetStatusName() noexcept {
if (_status == nullptr)
return ArbUt::StringView::EmptyString();
return _status->GetName();
}
// region Stat APIs
bool ChangeStatBoost(Library::Statistic stat, int8_t diffAmount);