1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00
This commit is contained in:
AlexVinS 2015-06-21 21:27:58 +03:00
parent f81116e04d
commit e27516a0b5

View File

@ -4213,12 +4213,17 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
} }
BonusList bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTER))); BonusList bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTER)));
int side = gs->curB->whatSide(st->owner); int side = gs->curB->whatSide(st->owner);
if (bl.size() && st->casts && !gs->curB->sides.at(side).enchanterCounter) if (st->casts && !gs->curB->sides.at(side).enchanterCounter)
{
bool casted = false;
while (!bl.empty() and !casted)
{ {
auto bonus = *RandomGeneratorUtil::nextItem(bl, gs->getRandomGenerator()); auto bonus = *RandomGeneratorUtil::nextItem(bl, gs->getRandomGenerator());
auto spellID = SpellID(bonus->subtype); auto spellID = SpellID(bonus->subtype);
const CSpell * spell = SpellID(spellID).toSpell(); const CSpell * spell = SpellID(spellID).toSpell();
if (gs->curB->battleCanCastThisSpell(st->owner, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK) //TODO: select another available? bl.remove_if([&bonus](Bonus * b){return b==bonus;});
if (gs->curB->battleCanCastThisSpell(st->owner, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK)
{ {
BattleSpellCastParameters parameters(gs->curB); BattleSpellCastParameters parameters(gs->curB);
parameters.spellLvl = bonus->val; parameters.spellLvl = bonus->val;
@ -4240,7 +4245,10 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
ssp.val = bonus->additionalInfo; //increase cooldown counter ssp.val = bonus->additionalInfo; //increase cooldown counter
ssp.stackID = st->ID; ssp.stackID = st->ID;
sendAndApply(&ssp); sendAndApply(&ssp);
casted = true;
} }
};
} }
bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTED))); bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTED)));
for (auto b : bl) for (auto b : bl)