Adds functions to add, remove, and get volatile scripts from a BattleSide.
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:
@@ -132,3 +132,18 @@ BattleSide* BattleSide::CloneWithoutCreatures(ArbUt::BorrowedPtr<Battle> battle)
|
||||
side->_hasFled = _hasFled;
|
||||
return side;
|
||||
}
|
||||
|
||||
BattleScript* BattleSide::AddVolatileScript(const ArbUt::StringView& key) {
|
||||
auto script = _volatile.Get(key);
|
||||
if (script.HasValue()) {
|
||||
script.GetValue()->Stack();
|
||||
return script.GetValue();
|
||||
}
|
||||
script = _battle->GetLibrary()->LoadScript(ScriptCategory::Battle, key);
|
||||
if (!script.HasValue()) {
|
||||
THROW("Invalid volatile script requested for battle: '" << key.c_str() << "'.");
|
||||
}
|
||||
return _volatile.Add(script.GetValue());
|
||||
}
|
||||
BattleScript* BattleSide::AddVolatileScript(BattleScript* script) { return _volatile.Add(script); }
|
||||
void BattleSide::RemoveVolatileScript(BattleScript* script) { _volatile.Remove(script->GetName()); }
|
||||
|
||||
Reference in New Issue
Block a user