Adds support for script owner to clone command.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
parent
be7a5fe6bd
commit
cb6725ab5e
|
@ -213,7 +213,7 @@ Battle* Battle::Clone() const {
|
||||||
battle->_hasEnded = _hasEnded;
|
battle->_hasEnded = _hasEnded;
|
||||||
battle->_battleResult = _battleResult;
|
battle->_battleResult = _battleResult;
|
||||||
battle->_currentTurn = _currentTurn;
|
battle->_currentTurn = _currentTurn;
|
||||||
_volatile.Clone(battle->_volatile);
|
_volatile.Clone(battle, battle->_volatile);
|
||||||
|
|
||||||
return battle;
|
return battle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ bool BattleSide::SwapPositions(u8 a, u8 b) {
|
||||||
BattleSide* BattleSide::CloneWithoutCreatures(ArbUt::BorrowedPtr<Battle> battle) const {
|
BattleSide* BattleSide::CloneWithoutCreatures(ArbUt::BorrowedPtr<Battle> battle) const {
|
||||||
auto* side = new BattleSide(_index, battle, _creaturesPerSide);
|
auto* side = new BattleSide(_index, battle, _creaturesPerSide);
|
||||||
side->_choicesSet = _choicesSet;
|
side->_choicesSet = _choicesSet;
|
||||||
_volatile.Clone(side->_volatile);
|
_volatile.Clone(side, side->_volatile);
|
||||||
side->_hasFled = _hasFled;
|
side->_hasFled = _hasFled;
|
||||||
return side;
|
return side;
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,14 +366,14 @@ namespace CreatureLib::Battling {
|
||||||
c->_battleData.OnBattleField = _battleData.OnBattleField;
|
c->_battleData.OnBattleField = _battleData.OnBattleField;
|
||||||
c->_battleData.Index = _battleData.Index;
|
c->_battleData.Index = _battleData.Index;
|
||||||
if (_activeTalent != nullptr) {
|
if (_activeTalent != nullptr) {
|
||||||
c->_activeTalent = std::unique_ptr<BattleScript>(_activeTalent->Clone());
|
c->_activeTalent = std::unique_ptr<BattleScript>(_activeTalent->Clone(c));
|
||||||
}
|
}
|
||||||
c->_hasOverridenTalent = _hasOverridenTalent;
|
c->_hasOverridenTalent = _hasOverridenTalent;
|
||||||
c->_overridenTalentName = _overridenTalentName;
|
c->_overridenTalentName = _overridenTalentName;
|
||||||
if (_status != nullptr) {
|
if (_status != nullptr) {
|
||||||
c->_status = std::unique_ptr<BattleScript>(_status->Clone());
|
c->_status = std::unique_ptr<BattleScript>(_status->Clone(c));
|
||||||
}
|
}
|
||||||
_volatile.Clone(c->_volatile);
|
_volatile.Clone(c, c->_volatile);
|
||||||
c->_types = std::vector<u8>(_types);
|
c->_types = std::vector<u8>(_types);
|
||||||
c->RecalculateFlatStats();
|
c->RecalculateFlatStats();
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,14 @@ namespace CreatureLib::Battling {
|
||||||
ArbUt::OptionalBorrowedPtr<void> _owner;
|
ArbUt::OptionalBorrowedPtr<void> _owner;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BattleScript(ArbUt::OptionalBorrowedPtr<void> owner) { _owner = owner; };
|
BattleScript(const ArbUt::OptionalBorrowedPtr<void>& owner) { _owner = owner; };
|
||||||
NO_COPY_OR_MOVE(BattleScript);
|
NO_COPY_OR_MOVE(BattleScript);
|
||||||
|
|
||||||
inline ArbUt::OptionalBorrowedPtr<void> GetOwner() const noexcept { return _owner; }
|
inline ArbUt::OptionalBorrowedPtr<void> GetOwner() const noexcept { return _owner; }
|
||||||
|
|
||||||
virtual ~BattleScript() = default;
|
virtual ~BattleScript() = default;
|
||||||
|
|
||||||
virtual BattleScript* Clone() = 0;
|
virtual BattleScript* Clone(const ArbUt::OptionalBorrowedPtr<void>& owner) = 0;
|
||||||
|
|
||||||
virtual void Stack(){};
|
virtual void Stack(){};
|
||||||
virtual void OnRemove(){};
|
virtual void OnRemove(){};
|
||||||
|
|
|
@ -15,9 +15,9 @@ namespace CreatureLib::Battling {
|
||||||
static constexpr size_t defaultCapacity = 8;
|
static constexpr size_t defaultCapacity = 8;
|
||||||
ScriptSet() : _scripts(defaultCapacity), _lookup(defaultCapacity){};
|
ScriptSet() : _scripts(defaultCapacity), _lookup(defaultCapacity){};
|
||||||
|
|
||||||
void Clone(ScriptSet& s) const {
|
void Clone(const ArbUt::OptionalBorrowedPtr<void>& owner, ScriptSet& s) const {
|
||||||
for (auto* script : _scripts) {
|
for (auto* script : _scripts) {
|
||||||
s.Add(script->Clone());
|
s.Add(script->Clone(owner));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
|
|
||||||
void TestMethod(int& runCount) { runCount++; }
|
void TestMethod(int& runCount) { runCount++; }
|
||||||
|
|
||||||
BattleScript* Clone() override { return new TestScript(_name); }
|
BattleScript* Clone(const ArbUt::OptionalBorrowedPtr<void>&) override { return new TestScript(_name); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_CASE("Script Aggregator properly iterates containing script.") {
|
TEST_CASE("Script Aggregator properly iterates containing script.") {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
explicit TestScript(const ArbUt::StringView& name) : BattleScript(nullptr), _name(name){};
|
explicit TestScript(const ArbUt::StringView& name) : BattleScript(nullptr), _name(name){};
|
||||||
const ArbUt::StringView& GetName() const noexcept override { return _name; }
|
const ArbUt::StringView& GetName() const noexcept override { return _name; }
|
||||||
|
|
||||||
BattleScript* Clone() override { return new TestScript(_name); }
|
BattleScript* Clone(const ArbUt::OptionalBorrowedPtr<void>&) override { return new TestScript(_name); }
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_CASE("Empty script set count == 0") {
|
TEST_CASE("Empty script set count == 0") {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
const ArbUt::StringView& GetName() const noexcept override { return _name; }
|
const ArbUt::StringView& GetName() const noexcept override { return _name; }
|
||||||
|
|
||||||
void TestMethod(int& runCount) { runCount++; }
|
void TestMethod(int& runCount) { runCount++; }
|
||||||
BattleScript* Clone() override { return new TestScript(_name); }
|
BattleScript* Clone(const ArbUt::OptionalBorrowedPtr<void>&) override { return new TestScript(_name); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ScriptSourceWithScriptPtr : public ScriptSource {
|
class ScriptSourceWithScriptPtr : public ScriptSource {
|
||||||
|
|
Loading…
Reference in New Issue