1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

Attempt to fix 2293

This commit is contained in:
AlexVinS
2016-03-01 13:24:46 +03:00
parent e3e27b9bfe
commit 3873e5047e
2 changed files with 14 additions and 13 deletions

View File

@@ -647,16 +647,18 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
break;
case ESpellCastProblem::ANOTHER_ELEMENTAL_SUMMONED:
{
std::string text = CGI->generaltexth->allTexts[538], summoner, elemental, caster;
std::vector<const CStack *> stacks = owner->myInt->cb->battleGetStacks();
std::string text = CGI->generaltexth->allTexts[538], elemental, caster;
const PlayerColor player = owner->myInt->playerID;
const TStacks stacks = owner->myInt->cb->battleGetStacksIf([player](const CStack * s)
{
return s->owner == player
&& vstd::contains(s->state, EBattleStackState::SUMMONED)
&& !vstd::contains(s->state, EBattleStackState::CLONED);
});
for(const CStack * s : stacks)
{
if(vstd::contains(s->state, EBattleStackState::SUMMONED))
{
elemental = s->getCreature()->namePl;
summoner = owner->myInt->cb->battleGetHeroInfo(!s->attackerOwned).name;
break;
}
elemental = s->getCreature()->namePl;
}
if (owner->myHero->type->sex)
{ //female
@@ -666,8 +668,9 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
{ //male
caster = CGI->generaltexth->allTexts[539];
}
text = boost::str(boost::format(text) % summoner % elemental % caster);
std::string summoner = owner->myHero->name;
text = boost::str(boost::format(text) % summoner % elemental % caster);
owner->myInt->showInfoDialog(text);
}

View File

@@ -637,13 +637,11 @@ ESpellCastProblem::ESpellCastProblem SpecialRisingSpellMechanics::isImmuneByStac
///SummonMechanics
ESpellCastProblem::ESpellCastProblem SummonMechanics::canBeCast(const CBattleInfoCallback * cb, PlayerColor player) const
{
const ui8 side = cb->playerToSide(player);
//check if there are summoned elementals of other type
auto otherSummoned = cb->battleGetStacksIf([side, this](const CStack * st)
auto otherSummoned = cb->battleGetStacksIf([player, this](const CStack * st)
{
return (st->attackerOwned == !side)
return (st->owner == player)
&& (vstd::contains(st->state, EBattleStackState::SUMMONED))
&& (!vstd::contains(st->state, EBattleStackState::CLONED))
&& (st->getCreature()->idNumber != creatureToSummon);