mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
TargetCondition: units with 100% MR is immune
Spells should not consider units with 100% MR as valid targets.
This commit is contained in:
parent
c216292f1e
commit
3d46ee3182
@ -89,6 +89,18 @@ private:
|
|||||||
si32 maxVal = std::numeric_limits<si32>::max();
|
si32 maxVal = std::numeric_limits<si32>::max();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ResistanceCondition : public TargetConditionItemBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
bool check(const Mechanics * m, const battle::Unit * target) const override
|
||||||
|
{
|
||||||
|
if(m->isPositiveSpell()) //Always pass on positive
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return target->magicResistance() < 100;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class CreatureCondition : public TargetConditionItemBase
|
class CreatureCondition : public TargetConditionItemBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -319,6 +331,12 @@ public:
|
|||||||
return elementalCondition;
|
return elementalCondition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Object createResistance() const override
|
||||||
|
{
|
||||||
|
static auto elementalCondition = std::make_shared<ResistanceCondition>();
|
||||||
|
return elementalCondition;
|
||||||
|
}
|
||||||
|
|
||||||
Object createNormalLevel() const override
|
Object createNormalLevel() const override
|
||||||
{
|
{
|
||||||
static std::shared_ptr<TargetConditionItem> nlCondition = std::make_shared<NormalLevelCondition>();
|
static std::shared_ptr<TargetConditionItem> nlCondition = std::make_shared<NormalLevelCondition>();
|
||||||
@ -451,6 +469,7 @@ void TargetCondition::serializeJson(JsonSerializeFormat & handler, const ItemFac
|
|||||||
absolute.push_back(itemFactory->createAbsoluteSpell());
|
absolute.push_back(itemFactory->createAbsoluteSpell());
|
||||||
absolute.push_back(itemFactory->createAbsoluteLevel());
|
absolute.push_back(itemFactory->createAbsoluteLevel());
|
||||||
normal.push_back(itemFactory->createElemental());
|
normal.push_back(itemFactory->createElemental());
|
||||||
|
normal.push_back(itemFactory->createResistance());
|
||||||
normal.push_back(itemFactory->createNormalLevel());
|
normal.push_back(itemFactory->createNormalLevel());
|
||||||
normal.push_back(itemFactory->createNormalSpell());
|
normal.push_back(itemFactory->createNormalSpell());
|
||||||
negation.push_back(itemFactory->createReceptiveFeature());
|
negation.push_back(itemFactory->createReceptiveFeature());
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
virtual Object createElemental() const = 0;
|
virtual Object createElemental() const = 0;
|
||||||
virtual Object createNormalLevel() const = 0;
|
virtual Object createNormalLevel() const = 0;
|
||||||
virtual Object createNormalSpell() const = 0;
|
virtual Object createNormalSpell() const = 0;
|
||||||
|
virtual Object createResistance() const = 0;
|
||||||
|
|
||||||
virtual Object createConfigurable(std::string scope, std::string type, std::string identifier) const = 0;
|
virtual Object createConfigurable(std::string scope, std::string type, std::string identifier) const = 0;
|
||||||
virtual Object createFromJsonStruct(const JsonNode & jsonStruct) const = 0;
|
virtual Object createFromJsonStruct(const JsonNode & jsonStruct) const = 0;
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
MOCK_CONST_METHOD0(createAbsoluteLevel, Object());
|
MOCK_CONST_METHOD0(createAbsoluteLevel, Object());
|
||||||
MOCK_CONST_METHOD0(createAbsoluteSpell, Object());
|
MOCK_CONST_METHOD0(createAbsoluteSpell, Object());
|
||||||
MOCK_CONST_METHOD0(createElemental, Object());
|
MOCK_CONST_METHOD0(createElemental, Object());
|
||||||
|
MOCK_CONST_METHOD0(createResistance, Object());
|
||||||
MOCK_CONST_METHOD0(createNormalLevel, Object());
|
MOCK_CONST_METHOD0(createNormalLevel, Object());
|
||||||
MOCK_CONST_METHOD0(createNormalSpell, Object());
|
MOCK_CONST_METHOD0(createNormalSpell, Object());
|
||||||
MOCK_CONST_METHOD1(createFromJsonStruct, Object(const JsonNode &));
|
MOCK_CONST_METHOD1(createFromJsonStruct, Object(const JsonNode &));
|
||||||
@ -74,6 +75,7 @@ public:
|
|||||||
ON_CALL(factoryMock, createAbsoluteLevel()).WillByDefault(Return(itemStub));
|
ON_CALL(factoryMock, createAbsoluteLevel()).WillByDefault(Return(itemStub));
|
||||||
ON_CALL(factoryMock, createAbsoluteSpell()).WillByDefault(Return(itemStub));
|
ON_CALL(factoryMock, createAbsoluteSpell()).WillByDefault(Return(itemStub));
|
||||||
ON_CALL(factoryMock, createElemental()).WillByDefault(Return(itemStub));
|
ON_CALL(factoryMock, createElemental()).WillByDefault(Return(itemStub));
|
||||||
|
ON_CALL(factoryMock, createResistance()).WillByDefault(Return(itemStub));
|
||||||
ON_CALL(factoryMock, createNormalLevel()).WillByDefault(Return(itemStub));
|
ON_CALL(factoryMock, createNormalLevel()).WillByDefault(Return(itemStub));
|
||||||
ON_CALL(factoryMock, createNormalSpell()).WillByDefault(Return(itemStub));
|
ON_CALL(factoryMock, createNormalSpell()).WillByDefault(Return(itemStub));
|
||||||
|
|
||||||
@ -139,6 +141,7 @@ TEST_F(TargetConditionTest, CreatesSpecialConditions)
|
|||||||
EXPECT_CALL(factoryMock, createAbsoluteLevel()).Times(1);
|
EXPECT_CALL(factoryMock, createAbsoluteLevel()).Times(1);
|
||||||
EXPECT_CALL(factoryMock, createAbsoluteSpell()).Times(1);
|
EXPECT_CALL(factoryMock, createAbsoluteSpell()).Times(1);
|
||||||
EXPECT_CALL(factoryMock, createElemental()).Times(1);
|
EXPECT_CALL(factoryMock, createElemental()).Times(1);
|
||||||
|
EXPECT_CALL(factoryMock, createResistance()).Times(1);
|
||||||
EXPECT_CALL(factoryMock, createNormalLevel()).Times(1);
|
EXPECT_CALL(factoryMock, createNormalLevel()).Times(1);
|
||||||
EXPECT_CALL(factoryMock, createNormalSpell()).Times(1);
|
EXPECT_CALL(factoryMock, createNormalSpell()).Times(1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user