mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
fix mantiss #2210
This commit is contained in:
parent
f81116e04d
commit
e27516a0b5
@ -4213,34 +4213,42 @@ 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)
|
||||||
{
|
{
|
||||||
auto bonus = *RandomGeneratorUtil::nextItem(bl, gs->getRandomGenerator());
|
bool casted = false;
|
||||||
auto spellID = SpellID(bonus->subtype);
|
while (!bl.empty() and !casted)
|
||||||
const CSpell * spell = SpellID(spellID).toSpell();
|
|
||||||
if (gs->curB->battleCanCastThisSpell(st->owner, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK) //TODO: select another available?
|
|
||||||
{
|
{
|
||||||
BattleSpellCastParameters parameters(gs->curB);
|
auto bonus = *RandomGeneratorUtil::nextItem(bl, gs->getRandomGenerator());
|
||||||
parameters.spellLvl = bonus->val;
|
auto spellID = SpellID(bonus->subtype);
|
||||||
parameters.destination = BattleHex::INVALID;
|
const CSpell * spell = SpellID(spellID).toSpell();
|
||||||
parameters.casterSide = side;
|
bl.remove_if([&bonus](Bonus * b){return b==bonus;});
|
||||||
parameters.casterColor = st->owner;
|
|
||||||
parameters.caster = nullptr;
|
|
||||||
parameters.secHero = gs->curB->getHero(gs->curB->theOtherPlayer(st->owner));
|
|
||||||
parameters.usedSpellPower = 0;
|
|
||||||
parameters.mode = ECastingMode::ENCHANTER_CASTING;
|
|
||||||
parameters.casterStack = st;
|
|
||||||
parameters.selectedStack = nullptr;
|
|
||||||
|
|
||||||
spell->battleCast(spellEnv, parameters);
|
if (gs->curB->battleCanCastThisSpell(st->owner, spell, ECastingMode::ENCHANTER_CASTING) == ESpellCastProblem::OK)
|
||||||
|
{
|
||||||
|
BattleSpellCastParameters parameters(gs->curB);
|
||||||
|
parameters.spellLvl = bonus->val;
|
||||||
|
parameters.destination = BattleHex::INVALID;
|
||||||
|
parameters.casterSide = side;
|
||||||
|
parameters.casterColor = st->owner;
|
||||||
|
parameters.caster = nullptr;
|
||||||
|
parameters.secHero = gs->curB->getHero(gs->curB->theOtherPlayer(st->owner));
|
||||||
|
parameters.usedSpellPower = 0;
|
||||||
|
parameters.mode = ECastingMode::ENCHANTER_CASTING;
|
||||||
|
parameters.casterStack = st;
|
||||||
|
parameters.selectedStack = nullptr;
|
||||||
|
|
||||||
|
spell->battleCast(spellEnv, parameters);
|
||||||
|
|
||||||
BattleSetStackProperty ssp;
|
BattleSetStackProperty ssp;
|
||||||
ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER;
|
ssp.which = BattleSetStackProperty::ENCHANTER_COUNTER;
|
||||||
ssp.absolute = false;
|
ssp.absolute = false;
|
||||||
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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user