mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Simplify statements
-Simplify return statements across the code
This commit is contained in:
parent
ec536e613c
commit
ac6b477aa2
@ -205,14 +205,7 @@ bool isSafeToVisit(HeroPtr h, uint64_t dangerStrength)
|
|||||||
|
|
||||||
if(dangerStrength)
|
if(dangerStrength)
|
||||||
{
|
{
|
||||||
if(heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength)
|
return heroStrength / SAFE_ATTACK_CONSTANT > dangerStrength;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; //there's no danger
|
return true; //there's no danger
|
||||||
@ -314,8 +307,6 @@ bool compareArtifacts(const CArtifactInstance * a1, const CArtifactInstance * a2
|
|||||||
|
|
||||||
if(art1->price == art2->price)
|
if(art1->price == art2->price)
|
||||||
return art1->valOfBonuses(Bonus::PRIMARY_SKILL) > art2->valOfBonuses(Bonus::PRIMARY_SKILL);
|
return art1->valOfBonuses(Bonus::PRIMARY_SKILL) > art2->valOfBonuses(Bonus::PRIMARY_SKILL);
|
||||||
else if(art1->price > art2->price)
|
|
||||||
return true;
|
|
||||||
else
|
else
|
||||||
return false;
|
return art1->price > art2->price;
|
||||||
}
|
}
|
||||||
|
@ -225,10 +225,7 @@ bool BuildingManager::getBuildingOptions(const CGTownInstance * t)
|
|||||||
if (buildingInfo.first > 43)
|
if (buildingInfo.first > 43)
|
||||||
extraBuildings.push_back(buildingInfo.first);
|
extraBuildings.push_back(buildingInfo.first);
|
||||||
}
|
}
|
||||||
if (tryBuildAnyStructure(t, extraBuildings))
|
return tryBuildAnyStructure(t, extraBuildings);
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BuildingID BuildingManager::getMaxPossibleGoldBuilding(const CGTownInstance * t)
|
BuildingID BuildingManager::getMaxPossibleGoldBuilding(const CGTownInstance * t)
|
||||||
|
@ -1282,10 +1282,7 @@ bool VCAI::isGoodForVisit(const CGObjectInstance * obj, HeroPtr h, const AIPath
|
|||||||
const CGObjectInstance * topObj = cb->getVisitableObjs(obj->visitablePos()).back(); //it may be hero visiting this obj
|
const CGObjectInstance * topObj = cb->getVisitableObjs(obj->visitablePos()).back(); //it may be hero visiting this obj
|
||||||
//we don't try visiting object on which allied or owned hero stands
|
//we don't try visiting object on which allied or owned hero stands
|
||||||
// -> it will just trigger exchange windows and AI will be confused that obj behind doesn't get visited
|
// -> it will just trigger exchange windows and AI will be confused that obj behind doesn't get visited
|
||||||
if (topObj->ID == Obj::HERO && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != PlayerRelations::ENEMIES)
|
return !(topObj->ID == Obj::HERO && cb->getPlayerRelations(h->tempOwner, topObj->tempOwner) != PlayerRelations::ENEMIES); //all of the following is met
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true; //all of the following is met
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VCAI::isTileNotReserved(const CGHeroInstance * h, int3 t) const
|
bool VCAI::isTileNotReserved(const CGHeroInstance * h, int3 t) const
|
||||||
|
@ -308,14 +308,7 @@ bool CStack::unitHasAmmoCart(const battle::Unit * unit) const
|
|||||||
{
|
{
|
||||||
if(battle->battleMatchOwner(st, unit, true) && st->getCreature()->idNumber == CreatureID::AMMO_CART)
|
if(battle->battleMatchOwner(st, unit, true) && st->getCreature()->idNumber == CreatureID::AMMO_CART)
|
||||||
{
|
{
|
||||||
if(st->alive())
|
return st->alive();
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//ammo cart works during creature bank battle while not on battlefield
|
//ammo cart works during creature bank battle while not on battlefield
|
||||||
|
@ -876,10 +876,7 @@ void BattleInfo::setUnitState(uint32_t id, const JsonNode & data, int64_t health
|
|||||||
auto selector = [](const Bonus * b)
|
auto selector = [](const Bonus * b)
|
||||||
{
|
{
|
||||||
//Special case: DISRUPTING_RAY is absolutely permanent
|
//Special case: DISRUPTING_RAY is absolutely permanent
|
||||||
if(b->source == Bonus::SPELL_EFFECT)
|
return b->source == Bonus::SPELL_EFFECT && b->sid != SpellID::DISRUPTING_RAY;
|
||||||
return b->sid != SpellID::DISRUPTING_RAY;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
changedStack->removeBonusesRecursive(selector);
|
changedStack->removeBonusesRecursive(selector);
|
||||||
}
|
}
|
||||||
|
@ -577,11 +577,8 @@ bool CBattleInfoCallback::battleCanAttack(const CStack * stack, const CStack * t
|
|||||||
auto &id = stack->getCreature()->idNumber;
|
auto &id = stack->getCreature()->idNumber;
|
||||||
if (id == CreatureID::FIRST_AID_TENT || id == CreatureID::CATAPULT)
|
if (id == CreatureID::FIRST_AID_TENT || id == CreatureID::CATAPULT)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!target->alive())
|
return target->alive();
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBattleInfoCallback::battleCanShoot(const battle::Unit * attacker, BattleHex dest) const
|
bool CBattleInfoCallback::battleCanShoot(const battle::Unit * attacker, BattleHex dest) const
|
||||||
@ -610,12 +607,11 @@ bool CBattleInfoCallback::battleCanShoot(const battle::Unit * attacker, BattleHe
|
|||||||
if(attacker->creatureIndex() == CreatureID::CATAPULT && defender) //catapult cannot attack creatures
|
if(attacker->creatureIndex() == CreatureID::CATAPULT && defender) //catapult cannot attack creatures
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(attacker->canShoot()
|
return attacker->canShoot()
|
||||||
&& battleMatchOwner(attacker, defender)
|
&& battleMatchOwner(attacker, defender)
|
||||||
&& defender->alive()
|
&& defender->alive()
|
||||||
&& (!battleIsUnitBlocked(attacker) || attacker->hasBonusOfType(Bonus::FREE_SHOOTING)))
|
&& (!battleIsUnitBlocked(attacker)
|
||||||
return true;
|
|| attacker->hasBonusOfType(Bonus::FREE_SHOOTING));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo & info) const
|
TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo & info) const
|
||||||
|
@ -422,8 +422,5 @@ bool CBattleInfoEssentials::battleMatchOwner(const PlayerColor & attacker, const
|
|||||||
|
|
||||||
PlayerColor initialOwner = getBattle()->getSidePlayer(defender->unitSide());
|
PlayerColor initialOwner = getBattle()->getSidePlayer(defender->unitSide());
|
||||||
|
|
||||||
if(boost::logic::indeterminate(positivness))
|
return boost::logic::indeterminate(positivness) || (attacker == initialOwner) == (bool)positivness;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return (attacker == initialOwner) == (bool)positivness;
|
|
||||||
}
|
}
|
||||||
|
@ -721,10 +721,7 @@ bool CUnitState::canMove(int turn) const
|
|||||||
|
|
||||||
bool CUnitState::defended(int turn) const
|
bool CUnitState::defended(int turn) const
|
||||||
{
|
{
|
||||||
if(!turn)
|
return !turn && defending;
|
||||||
return defending;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CUnitState::moved(int turn) const
|
bool CUnitState::moved(int turn) const
|
||||||
|
@ -165,7 +165,7 @@ si64 CCompressedStream::readMore(ui8 *data, si64 size)
|
|||||||
throw std::runtime_error(std::string("Decompression error: ") + inflateState->msg);
|
throw std::runtime_error(std::string("Decompression error: ") + inflateState->msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (endLoop == false && inflateState->avail_out != 0 );
|
while (!endLoop && inflateState->avail_out != 0 );
|
||||||
|
|
||||||
decompressed = inflateState->total_out - decompressed;
|
decompressed = inflateState->total_out - decompressed;
|
||||||
|
|
||||||
|
@ -859,9 +859,7 @@ bool CGTownInstance::passableFor(PlayerColor color) const
|
|||||||
if ( tempOwner == PlayerColor::NEUTRAL )//neutral guarded - no one can visit
|
if ( tempOwner == PlayerColor::NEUTRAL )//neutral guarded - no one can visit
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (cb->getPlayerRelations(tempOwner, color) != PlayerRelations::ENEMIES)
|
return cb->getPlayerRelations(tempOwner, color) != PlayerRelations::ENEMIES;
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGTownInstance::getOutOffsets( std::vector<int3> &offsets ) const
|
void CGTownInstance::getOutOffsets( std::vector<int3> &offsets ) const
|
||||||
|
@ -65,9 +65,7 @@ bool CTownInstanceConstructor::objectFilter(const CGObjectInstance * object, con
|
|||||||
return town->hasBuilt(id);
|
return town->hasBuilt(id);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (filters.count(templ.stringID))
|
return filters.count(templ.stringID) != 0 && filters.at(templ.stringID).test(buildTest);
|
||||||
return filters.at(templ.stringID).test(buildTest);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGObjectInstance * CTownInstanceConstructor::create(const ObjectTemplate & tmpl) const
|
CGObjectInstance * CTownInstanceConstructor::create(const ObjectTemplate & tmpl) const
|
||||||
|
@ -1279,12 +1279,8 @@ void CGWhirlpool::teleportDialogAnswered(const CGHeroInstance *hero, ui32 answer
|
|||||||
|
|
||||||
bool CGWhirlpool::isProtected(const CGHeroInstance * h)
|
bool CGWhirlpool::isProtected(const CGHeroInstance * h)
|
||||||
{
|
{
|
||||||
if(h->hasBonusOfType(Bonus::WHIRLPOOL_PROTECTION) ||
|
return h->hasBonusOfType(Bonus::WHIRLPOOL_PROTECTION)
|
||||||
(h->stacksCount() == 1 && h->Slots().begin()->second->count == 1)) //we can't remove last unit
|
|| (h->stacksCount() == 1 && h->Slots().begin()->second->count == 1);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGArtifact::initObj(CRandomGenerator & rand)
|
void CGArtifact::initObj(CRandomGenerator & rand)
|
||||||
|
@ -44,9 +44,7 @@ static bool isOnVisitableFromTopList(int identifier, int type)
|
|||||||
Obj::QUEST_GUARD,
|
Obj::QUEST_GUARD,
|
||||||
Obj::CORPSE
|
Obj::CORPSE
|
||||||
};
|
};
|
||||||
if (vstd::find_pos(visitableFromTop, identifier) != -1)
|
return vstd::find_pos(visitableFromTop, identifier) != -1;
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectTemplate::ObjectTemplate():
|
ObjectTemplate::ObjectTemplate():
|
||||||
@ -430,30 +428,22 @@ bool ObjectTemplate::isWithin(si32 X, si32 Y) const
|
|||||||
{
|
{
|
||||||
if (X < 0 || Y < 0)
|
if (X < 0 || Y < 0)
|
||||||
return false;
|
return false;
|
||||||
if (X >= getWidth() || Y >= getHeight())
|
return !(X >= getWidth() || Y >= getHeight());
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectTemplate::isVisitableAt(si32 X, si32 Y) const
|
bool ObjectTemplate::isVisitableAt(si32 X, si32 Y) const
|
||||||
{
|
{
|
||||||
if (isWithin(X, Y))
|
return isWithin(X, Y) && usedTiles[Y][X] & VISITABLE;
|
||||||
return usedTiles[Y][X] & VISITABLE;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectTemplate::isVisibleAt(si32 X, si32 Y) const
|
bool ObjectTemplate::isVisibleAt(si32 X, si32 Y) const
|
||||||
{
|
{
|
||||||
if (isWithin(X, Y))
|
return isWithin(X, Y) && usedTiles[Y][X] & VISIBLE;
|
||||||
return usedTiles[Y][X] & VISIBLE;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ObjectTemplate::isBlockedAt(si32 X, si32 Y) const
|
bool ObjectTemplate::isBlockedAt(si32 X, si32 Y) const
|
||||||
{
|
{
|
||||||
if (isWithin(X, Y))
|
return isWithin(X, Y) && usedTiles[Y][X] & BLOCKED;
|
||||||
return usedTiles[Y][X] & BLOCKED;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<int3> ObjectTemplate::getBlockedOffsets() const
|
std::set<int3> ObjectTemplate::getBlockedOffsets() const
|
||||||
|
@ -309,16 +309,7 @@ CDrawRoadsOperation::ValidationResult CDrawRoadsOperation::validateTile(const Ro
|
|||||||
|
|
||||||
int3 currentPos(cx, cy, pos.z);
|
int3 currentPos(cx, cy, pos.z);
|
||||||
|
|
||||||
bool hasSomething;
|
bool hasSomething = !map->isInTheMap(currentPos) || tileHasSomething(currentPos);
|
||||||
|
|
||||||
if(!map->isInTheMap(currentPos))
|
|
||||||
{
|
|
||||||
hasSomething = true; //road/river can go out of map
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hasSomething = tileHasSomething(currentPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ruleIsSomething(flipped.data[i]))
|
if(ruleIsSomething(flipped.data[i]))
|
||||||
{
|
{
|
||||||
|
@ -617,10 +617,7 @@ void CMapGenerator::createConnections2()
|
|||||||
boost::set_intersection(tilesA, tilesB, std::back_inserter(commonTiles), [](const int3 &lhs, const int3 &rhs) -> bool
|
boost::set_intersection(tilesA, tilesB, std::back_inserter(commonTiles), [](const int3 &lhs, const int3 &rhs) -> bool
|
||||||
{
|
{
|
||||||
//ignore z coordinate
|
//ignore z coordinate
|
||||||
if (lhs.x < rhs.x)
|
return lhs.x < rhs.x || lhs.y < rhs.y;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return lhs.y < rhs.y;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
vstd::erase_if(commonTiles, [](const int3 &tile) -> bool
|
vstd::erase_if(commonTiles, [](const int3 &tile) -> bool
|
||||||
|
@ -594,10 +594,7 @@ CSpell::TargetInfo::TargetInfo(const CSpell * spell, const int level, spells::Mo
|
|||||||
bool DLL_LINKAGE isInScreenRange(const int3 & center, const int3 & pos)
|
bool DLL_LINKAGE isInScreenRange(const int3 & center, const int3 & pos)
|
||||||
{
|
{
|
||||||
int3 diff = pos - center;
|
int3 diff = pos - center;
|
||||||
if(diff.x >= -9 && diff.x <= 9 && diff.y >= -8 && diff.y <= 8)
|
return diff.x >= -9 && diff.x <= 9 && diff.y >= -8 && diff.y <= 8;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///CSpellHandler
|
///CSpellHandler
|
||||||
|
@ -57,11 +57,7 @@ public:
|
|||||||
bool isReceptive(const Mechanics * m, const battle::Unit * target) const override
|
bool isReceptive(const Mechanics * m, const battle::Unit * target) const override
|
||||||
{
|
{
|
||||||
bool result = check(m, target);
|
bool result = check(m, target);
|
||||||
|
return inverted != result;
|
||||||
if(inverted)
|
|
||||||
return !result;
|
|
||||||
else
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -120,10 +116,10 @@ protected:
|
|||||||
cachingStr << "type_" << Bonus::LEVEL_SPELL_IMMUNITY << "addInfo_1";
|
cachingStr << "type_" << Bonus::LEVEL_SPELL_IMMUNITY << "addInfo_1";
|
||||||
|
|
||||||
TBonusListPtr levelImmunities = target->getBonuses(Selector::type(Bonus::LEVEL_SPELL_IMMUNITY).And(Selector::info(1)), cachingStr.str());
|
TBonusListPtr levelImmunities = target->getBonuses(Selector::type(Bonus::LEVEL_SPELL_IMMUNITY).And(Selector::info(1)), cachingStr.str());
|
||||||
|
|
||||||
if(levelImmunities->size() > 0 && levelImmunities->totalValue() >= m->getSpellLevel() && m->getSpellLevel() > 0)
|
return !(levelImmunities->size() > 0
|
||||||
return false;
|
&& levelImmunities->totalValue() >= m->getSpellLevel()
|
||||||
return true;
|
&& m->getSpellLevel() > 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -141,9 +137,7 @@ protected:
|
|||||||
{
|
{
|
||||||
std::stringstream cachingStr;
|
std::stringstream cachingStr;
|
||||||
cachingStr << "type_" << Bonus::SPELL_IMMUNITY << "subtype_" << m->getSpellIndex() << "addInfo_1";
|
cachingStr << "type_" << Bonus::SPELL_IMMUNITY << "subtype_" << m->getSpellIndex() << "addInfo_1";
|
||||||
if(target->hasBonus(Selector::typeSubtypeInfo(Bonus::SPELL_IMMUNITY, m->getSpellIndex(), 1), cachingStr.str()))
|
return !target->hasBonus(Selector::typeSubtypeInfo(Bonus::SPELL_IMMUNITY, m->getSpellIndex(), 1), cachingStr.str());
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -197,10 +191,9 @@ protected:
|
|||||||
bool check(const Mechanics * m, const battle::Unit * target) const override
|
bool check(const Mechanics * m, const battle::Unit * target) const override
|
||||||
{
|
{
|
||||||
TBonusListPtr levelImmunities = target->getBonuses(Selector::type(Bonus::LEVEL_SPELL_IMMUNITY));
|
TBonusListPtr levelImmunities = target->getBonuses(Selector::type(Bonus::LEVEL_SPELL_IMMUNITY));
|
||||||
|
return !(levelImmunities->size() > 0 &&
|
||||||
if(levelImmunities->size() > 0 && levelImmunities->totalValue() >= m->getSpellLevel() && m->getSpellLevel() > 0)
|
levelImmunities->totalValue() >= m->getSpellLevel() &&
|
||||||
return false;
|
m->getSpellLevel() > 0);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -236,10 +229,7 @@ protected:
|
|||||||
int64_t subjectHealth = target->getAvailableHealth();
|
int64_t subjectHealth = target->getAvailableHealth();
|
||||||
//apply 'damage' bonus for hypnotize, including hero specialty
|
//apply 'damage' bonus for hypnotize, including hero specialty
|
||||||
auto maxHealth = m->applySpellBonus(m->getEffectValue(), target);
|
auto maxHealth = m->applySpellBonus(m->getEffectValue(), target);
|
||||||
if(subjectHealth > maxHealth)
|
return subjectHealth <= maxHealth;
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -426,11 +416,7 @@ bool TargetCondition::isReceptive(const Mechanics * m, const battle::Unit * targ
|
|||||||
if(item->isReceptive(m, target))
|
if(item->isReceptive(m, target))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return check(normal, m, target);
|
||||||
if(!check(normal, m, target))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetCondition::serializeJson(JsonSerializeFormat & handler, const ItemFactory * itemFactory)
|
void TargetCondition::serializeJson(JsonSerializeFormat & handler, const ItemFactory * itemFactory)
|
||||||
@ -488,11 +474,7 @@ bool TargetCondition::check(const ItemVector & condition, const Mechanics * m, c
|
|||||||
nonExclusiveExits = true;
|
nonExclusiveExits = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return !nonExclusiveExits || nonExclusiveCheck;
|
||||||
if(nonExclusiveExits)
|
|
||||||
return nonExclusiveCheck;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetCondition::loadConditions(const JsonNode & source, bool exclusive, bool inverted, const ItemFactory * itemFactory)
|
void TargetCondition::loadConditions(const JsonNode & source, bool exclusive, bool inverted, const ItemFactory * itemFactory)
|
||||||
|
@ -59,11 +59,8 @@ bool Catapult::applicable(Problem & problem, const Mechanics * m) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto attackableBattleHexes = m->cb->getAttackableBattleHexes();
|
const auto attackableBattleHexes = m->cb->getAttackableBattleHexes();
|
||||||
|
|
||||||
if(attackableBattleHexes.empty())
|
return !attackableBattleHexes.empty() || m->adaptProblem(ESpellCastProblem::NO_APPROPRIATE_TARGET, problem);
|
||||||
return m->adaptProblem(ESpellCastProblem::NO_APPROPRIATE_TARGET, problem);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics * m, const EffectTarget & /* eTarget */) const
|
void Catapult::apply(BattleStateProxy * battleState, RNG & rng, const Mechanics * m, const EffectTarget & /* eTarget */) const
|
||||||
|
@ -102,9 +102,7 @@ bool Dispel::mainSelector(const Bonus * bonus)
|
|||||||
if(sourceSpell->id == SpellID::CLONE)
|
if(sourceSpell->id == SpellID::CLONE)
|
||||||
return false;
|
return false;
|
||||||
//stack may have inherited effects
|
//stack may have inherited effects
|
||||||
if(sourceSpell->isAdventureSpell())
|
return !sourceSpell->isAdventureSpell();
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
//not spell effect
|
//not spell effect
|
||||||
return false;
|
return false;
|
||||||
|
@ -110,11 +110,8 @@ bool Sacrifice::applicable(Problem & problem, const Mechanics * m, const EffectT
|
|||||||
auto victim = target.at(1).unitValue;
|
auto victim = target.at(1).unitValue;
|
||||||
if(!victim)
|
if(!victim)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!victim->alive() || !getStackFilter(m, false, victim) || !isReceptive(m, victim))
|
return !(!victim->alive() || !getStackFilter(m, false, victim) || !isReceptive(m, victim));
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -93,13 +93,7 @@ EffectTarget UnitEffect::filterTarget(const Mechanics * m, const EffectTarget &
|
|||||||
EffectTarget res;
|
EffectTarget res;
|
||||||
vstd::copy_if(target, std::back_inserter(res), [this, m](const Destination & d)
|
vstd::copy_if(target, std::back_inserter(res), [this, m](const Destination & d)
|
||||||
{
|
{
|
||||||
if(!d.unitValue)
|
return d.unitValue && isValidTarget(m, d.unitValue) && isReceptive(m, d.unitValue);
|
||||||
return false;
|
|
||||||
if(!isValidTarget(m, d.unitValue))
|
|
||||||
return false;
|
|
||||||
if(!isReceptive(m, d.unitValue))
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
});
|
});
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -271,10 +265,7 @@ bool UnitEffect::isReceptive(const Mechanics * m, const battle::Unit * unit) con
|
|||||||
//SPELL_IMMUNITY absolute case
|
//SPELL_IMMUNITY absolute case
|
||||||
std::stringstream cachingStr;
|
std::stringstream cachingStr;
|
||||||
cachingStr << "type_" << Bonus::SPELL_IMMUNITY << "subtype_" << m->getSpellIndex() << "addInfo_1";
|
cachingStr << "type_" << Bonus::SPELL_IMMUNITY << "subtype_" << m->getSpellIndex() << "addInfo_1";
|
||||||
if(unit->hasBonus(Selector::typeSubtypeInfo(Bonus::SPELL_IMMUNITY, m->getSpellIndex(), 1), cachingStr.str()))
|
return !unit->hasBonus(Selector::typeSubtypeInfo(Bonus::SPELL_IMMUNITY, m->getSpellIndex(), 1), cachingStr.str());
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user