mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +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.
This commit is contained in:
@ -35,6 +35,7 @@ protected:
|
||||
void SetUp() override
|
||||
{
|
||||
EffectFixture::setUp();
|
||||
EffectFixture::setupEffect(JsonNode());
|
||||
}
|
||||
};
|
||||
|
||||
@ -86,6 +87,7 @@ protected:
|
||||
|
||||
TEST_F(DamageApplyTest, DoesDamageToAliveUnit)
|
||||
{
|
||||
EffectFixture::setupEffect(JsonNode());
|
||||
using namespace ::battle;
|
||||
|
||||
const int64_t effectValue = 123;
|
||||
@ -106,34 +108,38 @@ TEST_F(DamageApplyTest, DoesDamageToAliveUnit)
|
||||
std::shared_ptr<CUnitState> targetUnitState = std::make_shared<CUnitStateDetached>(&targetUnit, &targetUnit);
|
||||
targetUnitState->localInit(&unitEnvironmentMock);
|
||||
EXPECT_CALL(targetUnit, acquireState()).WillOnce(Return(targetUnitState));
|
||||
|
||||
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId),_, Lt(0))).Times(1);
|
||||
EXPECT_CALL(serverMock, apply(Matcher<StacksInjured *>(_))).Times(1);
|
||||
EXPECT_CALL(serverMock, describeChanges()).WillRepeatedly(Return(false));
|
||||
|
||||
setupDefaultRNG();
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&targetUnit, BattleHex());
|
||||
|
||||
subject->apply(battleProxy.get(), rngMock, &mechanicsMock, target);
|
||||
subject->apply(&serverMock, &mechanicsMock, target);
|
||||
|
||||
EXPECT_EQ(targetUnitState->getCount(), unitAmount - 1);
|
||||
}
|
||||
|
||||
TEST_F(DamageApplyTest, IgnoresDeadUnit)
|
||||
{
|
||||
EffectFixture::setupEffect(JsonNode());
|
||||
using namespace ::battle;
|
||||
|
||||
auto & targetUnit = unitsFake.add(BattleSide::ATTACKER);
|
||||
|
||||
EXPECT_CALL(targetUnit, alive()).WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(targetUnit, acquireState()).Times(0);
|
||||
|
||||
EXPECT_CALL(*battleFake, setUnitState(_,_,_)).Times(0);
|
||||
EXPECT_CALL(serverMock, describeChanges()).WillRepeatedly(Return(false));
|
||||
|
||||
setupDefaultRNG();
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&targetUnit, BattleHex());
|
||||
|
||||
subject->apply(battleProxy.get(), rngMock, &mechanicsMock, target);
|
||||
subject->apply(&serverMock, &mechanicsMock, target);
|
||||
}
|
||||
|
||||
TEST_F(DamageApplyTest, DoesDamageByPercent)
|
||||
@ -168,13 +174,15 @@ TEST_F(DamageApplyTest, DoesDamageByPercent)
|
||||
EXPECT_CALL(targetUnit, acquireState()).WillOnce(Return(targetUnitState));
|
||||
|
||||
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId),_, Lt(0))).Times(1);
|
||||
EXPECT_CALL(serverMock, apply(Matcher<StacksInjured *>(_))).Times(1);
|
||||
EXPECT_CALL(serverMock, describeChanges()).WillRepeatedly(Return(false));
|
||||
|
||||
setupDefaultRNG();
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&targetUnit, BattleHex());
|
||||
|
||||
subject->apply(battleProxy.get(), rngMock, &mechanicsMock, target);
|
||||
subject->apply(&serverMock, &mechanicsMock, target);
|
||||
|
||||
EXPECT_EQ(targetUnitState->getCount(), unitAmount - (unitAmount * effectValue / 100));
|
||||
}
|
||||
@ -210,13 +218,15 @@ TEST_F(DamageApplyTest, DoesDamageByCount)
|
||||
EXPECT_CALL(targetUnit, acquireState()).WillOnce(Return(targetUnitState));
|
||||
|
||||
EXPECT_CALL(*battleFake, setUnitState(Eq(unitId), _, Lt(0))).Times(1);
|
||||
EXPECT_CALL(serverMock, apply(Matcher<StacksInjured *>(_))).Times(1);
|
||||
EXPECT_CALL(serverMock, describeChanges()).WillRepeatedly(Return(false));
|
||||
|
||||
setupDefaultRNG();
|
||||
|
||||
EffectTarget target;
|
||||
target.emplace_back(&targetUnit, BattleHex());
|
||||
|
||||
subject->apply(battleProxy.get(), rngMock, &mechanicsMock, target);
|
||||
subject->apply(&serverMock, &mechanicsMock, target);
|
||||
|
||||
EXPECT_EQ(targetUnitState->getCount(), unitAmount - effectValue);
|
||||
}
|
||||
|
Reference in New Issue
Block a user