Adds status handling functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user