mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
Summon effect fixes.
This commit is contained in:
parent
44d653b835
commit
5ea1888a14
@ -37,7 +37,8 @@ Summon::Summon()
|
||||
creature(),
|
||||
permanent(false),
|
||||
exclusive(true),
|
||||
summonByHealth(false)
|
||||
summonByHealth(false),
|
||||
summonSameUnit(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -162,6 +163,7 @@ void Summon::serializeJsonEffect(JsonSerializeFormat & handler)
|
||||
handler.serializeBool("permanent", permanent, false);
|
||||
handler.serializeBool("exclusive", exclusive, true);
|
||||
handler.serializeBool("summonByHealth", summonByHealth, false);
|
||||
handler.serializeBool("summonSameUnit", summonSameUnit, false);
|
||||
}
|
||||
|
||||
EffectTarget Summon::transformTarget(const Mechanics * m, const Target & aimPoint, const Target & spellTarget) const
|
||||
@ -177,7 +179,7 @@ EffectTarget Summon::transformTarget(const Mechanics * m, const Target & aimPoin
|
||||
|
||||
EffectTarget effectTarget;
|
||||
|
||||
if(sameSummoned.empty())
|
||||
if(sameSummoned.empty() || !summonSameUnit)
|
||||
{
|
||||
BattleHex hex = m->cb->getAvaliableHex(creature, m->casterSide);
|
||||
if(!hex.isValid())
|
||||
@ -193,6 +195,5 @@ EffectTarget Summon::transformTarget(const Mechanics * m, const Target & aimPoin
|
||||
return effectTarget;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
bool permanent;
|
||||
bool exclusive;
|
||||
bool summonByHealth;
|
||||
bool summonSameUnit;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -24,12 +24,13 @@ using namespace ::testing;
|
||||
static const CreatureID creature1(CreatureID::AIR_ELEMENTAL);
|
||||
static const CreatureID creature2(CreatureID::FIRE_ELEMENTAL);
|
||||
|
||||
class SummonTest : public TestWithParam<::testing::tuple<bool, CreatureID>>, public EffectFixture
|
||||
class SummonTest : public TestWithParam<::testing::tuple<CreatureID, bool, bool>>, public EffectFixture
|
||||
{
|
||||
public:
|
||||
bool exclusive;
|
||||
CreatureID toSummon;
|
||||
CreatureID otherSummoned;
|
||||
bool exclusive;
|
||||
bool summonSameUnit;
|
||||
|
||||
const battle::Unit * otherSummonedUnit;
|
||||
|
||||
@ -65,14 +66,16 @@ protected:
|
||||
{
|
||||
EffectFixture::setUp();
|
||||
|
||||
exclusive = ::testing::get<0>(GetParam());
|
||||
otherSummoned = ::testing::get<1>(GetParam());
|
||||
otherSummoned = ::testing::get<0>(GetParam());
|
||||
exclusive = ::testing::get<1>(GetParam());
|
||||
summonSameUnit = ::testing::get<2>(GetParam());
|
||||
|
||||
toSummon = creature1;
|
||||
|
||||
JsonNode options(JsonNode::JsonType::DATA_STRUCT);
|
||||
options["id"].String() = "airElemental";
|
||||
options["exclusive"].Bool() = exclusive;
|
||||
options["summonSameUnit"].Bool() = summonSameUnit;
|
||||
|
||||
EffectFixture::setupEffect(options);
|
||||
}
|
||||
@ -112,7 +115,7 @@ TEST_P(SummonTest, Transform)
|
||||
|
||||
EffectTarget expected;
|
||||
|
||||
if(otherSummoned == toSummon)
|
||||
if(otherSummoned == toSummon && summonSameUnit)
|
||||
{
|
||||
expected.emplace_back(otherSummonedUnit);
|
||||
}
|
||||
@ -130,8 +133,9 @@ INSTANTIATE_TEST_CASE_P
|
||||
SummonTest,
|
||||
Combine
|
||||
(
|
||||
Values(CreatureID(), creature1, creature2),
|
||||
Values(false, true),
|
||||
Values(CreatureID(), creature1, creature2)
|
||||
Values(false, true)
|
||||
)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user