2017-07-20 06:08:49 +02:00
|
|
|
/*
|
|
|
|
* SummonTest.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "EffectFixture.h"
|
|
|
|
|
|
|
|
#include <vstd/RNG.h>
|
|
|
|
|
2018-02-20 07:08:34 +02:00
|
|
|
#include "../../../lib/CCreatureHandler.h"
|
2024-02-11 23:09:01 +02:00
|
|
|
#include "../../../lib/json/JsonNode.h"
|
2018-02-20 07:08:34 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
namespace test
|
|
|
|
{
|
|
|
|
using namespace ::spells;
|
|
|
|
using namespace ::spells::effects;
|
|
|
|
using namespace ::testing;
|
|
|
|
|
|
|
|
static const CreatureID creature1(CreatureID::AIR_ELEMENTAL);
|
|
|
|
static const CreatureID creature2(CreatureID::FIRE_ELEMENTAL);
|
|
|
|
|
2018-03-03 19:37:49 +02:00
|
|
|
class SummonTest : public TestWithParam<::testing::tuple<CreatureID, bool, bool>>, public EffectFixture
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
CreatureID toSummon;
|
|
|
|
CreatureID otherSummoned;
|
2018-03-03 19:37:49 +02:00
|
|
|
bool exclusive;
|
|
|
|
bool summonSameUnit;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
const battle::Unit * otherSummonedUnit;
|
|
|
|
|
|
|
|
SummonTest()
|
|
|
|
: EffectFixture("core:summon"),
|
|
|
|
otherSummonedUnit(nullptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void addOtherSummoned(bool expectAlive)
|
|
|
|
{
|
|
|
|
auto & unit = unitsFake.add(BattleSide::ATTACKER);
|
|
|
|
|
|
|
|
EXPECT_CALL(unit, unitOwner()).WillRepeatedly(Return(PlayerColor(5)));
|
|
|
|
EXPECT_CALL(unit, isClone()).WillRepeatedly(Return(false));
|
|
|
|
EXPECT_CALL(unit, creatureId()).WillRepeatedly(Return(otherSummoned));
|
|
|
|
EXPECT_CALL(unit, isValidTarget(Eq(false))).WillRepeatedly(Return(true));
|
|
|
|
EXPECT_CALL(unit, getPosition()).WillRepeatedly(Return(BattleHex(5,5)));
|
|
|
|
EXPECT_CALL(unit, doubleWide()).WillRepeatedly(Return(false));
|
|
|
|
EXPECT_CALL(unit, unitSide()).Times(AnyNumber());
|
|
|
|
EXPECT_CALL(unit, unitSlot()).WillRepeatedly(Return(SlotID::SUMMONED_SLOT_PLACEHOLDER));
|
|
|
|
|
|
|
|
if(expectAlive)
|
|
|
|
EXPECT_CALL(unit, alive()).WillRepeatedly(Return(true));
|
|
|
|
else
|
|
|
|
EXPECT_CALL(unit, alive()).Times(0);
|
|
|
|
|
|
|
|
otherSummonedUnit = &unit;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
EffectFixture::setUp();
|
|
|
|
|
2018-03-03 19:37:49 +02:00
|
|
|
otherSummoned = ::testing::get<0>(GetParam());
|
|
|
|
exclusive = ::testing::get<1>(GetParam());
|
|
|
|
summonSameUnit = ::testing::get<2>(GetParam());
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
toSummon = creature1;
|
|
|
|
|
2024-02-13 14:34:16 +02:00
|
|
|
JsonNode options;
|
2017-07-20 06:08:49 +02:00
|
|
|
options["id"].String() = "airElemental";
|
|
|
|
options["exclusive"].Bool() = exclusive;
|
2018-03-03 19:37:49 +02:00
|
|
|
options["summonSameUnit"].Bool() = summonSameUnit;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
EffectFixture::setupEffect(options);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-01-03 02:26:15 +02:00
|
|
|
TEST_P(SummonTest, DISABLED_Applicable)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
const bool expectedApplicable = !exclusive || otherSummoned == CreatureID() || otherSummoned == toSummon;
|
|
|
|
|
|
|
|
if(otherSummoned != CreatureID())
|
|
|
|
addOtherSummoned(false);
|
|
|
|
|
|
|
|
if(otherSummoned != CreatureID() && !expectedApplicable)
|
|
|
|
EXPECT_CALL(problemMock, add(_));
|
|
|
|
|
|
|
|
if(exclusive)
|
|
|
|
EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(AtLeast(1));
|
|
|
|
else
|
|
|
|
EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(0);
|
|
|
|
|
|
|
|
EXPECT_CALL(mechanicsMock, getCasterColor()).WillRepeatedly(Return(PlayerColor(5)));
|
|
|
|
|
|
|
|
EXPECT_EQ(expectedApplicable, subject->applicable(problemMock, &mechanicsMock));
|
|
|
|
}
|
|
|
|
|
2024-01-03 02:26:15 +02:00
|
|
|
TEST_P(SummonTest, DISABLED_Transform)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
if(otherSummoned != CreatureID())
|
|
|
|
addOtherSummoned(true);
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
battleFake->setupEmptyBattlefield();
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_CALL(*battleFake, getUnitsIf(_)).Times(AtLeast(1));
|
|
|
|
|
|
|
|
EXPECT_CALL(mechanicsMock, getCasterColor()).WillRepeatedly(Return(PlayerColor(5)));
|
|
|
|
|
|
|
|
EffectTarget transformed = subject->transformTarget(&mechanicsMock, Target(), Target());
|
|
|
|
|
|
|
|
EffectTarget expected;
|
|
|
|
|
2018-03-03 19:37:49 +02:00
|
|
|
if(otherSummoned == toSummon && summonSameUnit)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
expected.emplace_back(otherSummonedUnit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expected.emplace_back(BattleHex(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_THAT(transformed, ContainerEq(expected));
|
|
|
|
}
|
|
|
|
|
2023-02-28 13:29:35 +02:00
|
|
|
INSTANTIATE_TEST_SUITE_P
|
2017-07-20 06:08:49 +02:00
|
|
|
(
|
|
|
|
ByConfig,
|
|
|
|
SummonTest,
|
|
|
|
Combine
|
|
|
|
(
|
2018-03-03 19:37:49 +02:00
|
|
|
Values(CreatureID(), creature1, creature2),
|
2017-07-20 06:08:49 +02:00
|
|
|
Values(false, true),
|
2018-03-03 19:37:49 +02:00
|
|
|
Values(false, true)
|
2017-07-20 06:08:49 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2018-02-20 07:08:34 +02:00
|
|
|
class SummonApplyTest : public TestWithParam<::testing::tuple<bool, bool>>, public EffectFixture
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
public:
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
const CreatureID toSummon = CreatureID::AIR_ELEMENTAL;
|
2017-07-20 06:08:49 +02:00
|
|
|
bool permanent = false;
|
2018-02-20 07:08:34 +02:00
|
|
|
bool summonByHealth = false;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2018-02-20 07:08:34 +02:00
|
|
|
const uint32_t unitId = 42;
|
2017-07-20 06:08:49 +02:00
|
|
|
const int32_t unitAmount = 123;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
const int32_t unitHealth = 479;
|
|
|
|
const int64_t unitTotalHealth = unitAmount * unitHealth;
|
2018-02-20 07:08:34 +02:00
|
|
|
|
|
|
|
const BattleHex unitPosition = BattleHex(5,5);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
std::shared_ptr<::battle::UnitInfo> unitAddInfo;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
std::shared_ptr<battle::UnitFake> acquired;
|
|
|
|
|
|
|
|
StrictMock<CreatureMock> toSummonType;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
SummonApplyTest()
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
: EffectFixture("core:summon")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2024-06-24 03:23:26 +02:00
|
|
|
void setDefaultExpectations()
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
EXPECT_CALL(mechanicsMock, creatures()).Times(AnyNumber());
|
|
|
|
EXPECT_CALL(creatureServiceMock, getById(Eq(toSummon))).WillRepeatedly(Return(&toSummonType));
|
|
|
|
EXPECT_CALL(toSummonType, getMaxHealth()).WillRepeatedly(Return(unitHealth));
|
|
|
|
|
|
|
|
expectAmountCalculation();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void expectAmountCalculation()
|
|
|
|
{
|
|
|
|
InSequence local;
|
|
|
|
EXPECT_CALL(mechanicsMock, getEffectPower()).WillOnce(Return(38));
|
|
|
|
EXPECT_CALL(mechanicsMock, calculateRawEffectValue(Eq(0), Eq(38))).WillOnce(Return(567));
|
2018-02-20 07:08:34 +02:00
|
|
|
|
|
|
|
if(summonByHealth)
|
|
|
|
{
|
|
|
|
EXPECT_CALL(mechanicsMock, applySpecificSpellBonus(Eq(567))).WillOnce(Return(unitTotalHealth));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EXPECT_CALL(mechanicsMock, applySpecificSpellBonus(Eq(567))).WillOnce(Return(unitAmount));
|
|
|
|
}
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void onUnitAdded(uint32_t id, const JsonNode & data)
|
|
|
|
{
|
|
|
|
unitAddInfo->load(id, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SetUp() override
|
|
|
|
{
|
|
|
|
EffectFixture::setUp();
|
|
|
|
|
2018-02-20 07:08:34 +02:00
|
|
|
permanent = ::testing::get<0>(GetParam());
|
|
|
|
summonByHealth = ::testing::get<1>(GetParam());
|
2017-07-20 06:08:49 +02:00
|
|
|
|
2024-02-13 14:34:16 +02:00
|
|
|
JsonNode options;
|
2017-07-20 06:08:49 +02:00
|
|
|
options["id"].String() = "airElemental";
|
|
|
|
options["permanent"].Bool() = permanent;
|
2018-02-20 07:08:34 +02:00
|
|
|
options["summonByHealth"].Bool() = summonByHealth;
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
EffectFixture::setupEffect(options);
|
|
|
|
|
|
|
|
unitAddInfo = std::make_shared<::battle::UnitInfo>();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TearDown() override
|
|
|
|
{
|
|
|
|
acquired.reset();
|
2018-02-20 07:08:34 +02:00
|
|
|
unitAddInfo.reset();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-01-03 02:26:15 +02:00
|
|
|
TEST_P(SummonApplyTest, DISABLED_SpawnsNewUnit)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2024-06-24 03:23:26 +02:00
|
|
|
setDefaultExpectations();
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
EXPECT_CALL(*battleFake, nextUnitId()).WillOnce(Return(unitId));
|
|
|
|
EXPECT_CALL(*battleFake, addUnit(Eq(unitId), _)).WillOnce(Invoke(this, &SummonApplyTest::onUnitAdded));
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
EXPECT_CALL(serverMock, apply(Matcher<BattleUnitsChanged *>(_))).Times(1);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
EffectTarget target;
|
2018-02-20 07:08:34 +02:00
|
|
|
target.emplace_back(unitPosition);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
subject->apply(&serverMock, &mechanicsMock, target);
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
EXPECT_EQ(unitAddInfo->count, unitAmount);
|
|
|
|
EXPECT_EQ(unitAddInfo->id, unitId);
|
2018-02-20 07:08:34 +02:00
|
|
|
EXPECT_EQ(unitAddInfo->position, unitPosition);
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_EQ(unitAddInfo->side, mechanicsMock.casterSide);
|
|
|
|
EXPECT_EQ(unitAddInfo->summoned, !permanent);
|
|
|
|
EXPECT_EQ(unitAddInfo->type, toSummon);
|
|
|
|
}
|
|
|
|
|
2024-01-03 02:26:15 +02:00
|
|
|
TEST_P(SummonApplyTest, DISABLED_UpdatesOldUnit)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2024-06-24 03:23:26 +02:00
|
|
|
setDefaultExpectations();
|
2017-07-20 06:08:49 +02:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
acquired = std::make_shared<battle::UnitFake>();
|
2023-10-21 13:50:42 +02:00
|
|
|
acquired->addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHealth, BonusSourceID()));
|
2017-07-20 06:08:49 +02:00
|
|
|
acquired->redirectBonusesToFake();
|
|
|
|
acquired->expectAnyBonusSystemCall();
|
|
|
|
|
|
|
|
auto & unit = unitsFake.add(BattleSide::ATTACKER);
|
2023-10-21 13:50:42 +02:00
|
|
|
unit.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, unitHealth, BonusSourceID()));
|
2017-07-20 06:08:49 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
EXPECT_CALL(unit, acquire()).WillOnce(Return(acquired));
|
2018-02-20 07:08:34 +02:00
|
|
|
EXPECT_CALL(*acquired, heal(Eq(unitTotalHealth), Eq(EHealLevel::OVERHEAL), Eq(permanent ? EHealPower::PERMANENT : EHealPower::ONE_BATTLE)));
|
2017-07-20 06:08:49 +02:00
|
|
|
EXPECT_CALL(*acquired, save(_));
|
|
|
|
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId), _, _));
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_CALL(unit, unitId()).WillOnce(Return(unitId));
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
EXPECT_CALL(serverMock, apply(Matcher<BattleUnitsChanged *>(_))).Times(1);
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
unitsFake.setDefaultBonusExpectations();
|
|
|
|
|
|
|
|
EffectTarget target;
|
|
|
|
target.emplace_back(&unit, BattleHex());
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
subject->apply(&serverMock, &mechanicsMock, target);
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2023-02-28 13:29:35 +02:00
|
|
|
INSTANTIATE_TEST_SUITE_P
|
2017-07-20 06:08:49 +02:00
|
|
|
(
|
|
|
|
ByConfig,
|
|
|
|
SummonApplyTest,
|
2018-02-20 07:08:34 +02:00
|
|
|
Combine
|
|
|
|
(
|
|
|
|
Values(false, true),
|
|
|
|
Values(false, true)
|
|
|
|
)
|
2017-07-20 06:08:49 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
}
|