mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
Moved defensive stance log message building to server side.
This commit is contained in:
parent
de01a797a6
commit
1fe01b7254
@ -1358,27 +1358,8 @@ void CBattleInterface::spellCast(const BattleSpellCast *sc)
|
||||
|
||||
void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
|
||||
{
|
||||
if(sse.stacks.size() == 1 && sse.effect.size() == 2 && sse.effect.back().sid == -1)
|
||||
{
|
||||
const Bonus & bns = sse.effect.front();
|
||||
if(bns.source == Bonus::OTHER && bns.type == Bonus::PRIMARY_SKILL)
|
||||
{
|
||||
//defensive stance
|
||||
const CStack * stack = LOCPLINT->cb->battleGetStackByID(*sse.stacks.begin());
|
||||
if(stack)
|
||||
{
|
||||
BonusList defenseBonuses = *(stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE)));
|
||||
defenseBonuses.remove_if(Bonus::UntilGetsTurn); //remove bonuses gained from defensive stance
|
||||
int val = stack->Defense() - defenseBonuses.totalValue();
|
||||
|
||||
MetaString text;
|
||||
stack->addText(text, MetaString::GENERAL_TXT, 120);
|
||||
stack->addNameReplacement(text);
|
||||
text.addReplacement(val);
|
||||
console->addText(text.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
for(const MetaString & line : sse.battleLog)
|
||||
console->addText(line.toString());
|
||||
|
||||
if(activeStack != nullptr)
|
||||
redrawBackgroundWithHexes(activeStack);
|
||||
|
@ -1532,10 +1532,12 @@ struct SetStackEffect : public CPackForClient
|
||||
std::vector<Bonus> cumulativeEffects; //bonuses to apply
|
||||
std::vector<std::pair<ui32, Bonus> > cumulativeUniqueBonuses; //bonuses per single stack
|
||||
|
||||
std::vector<MetaString> battleLog;
|
||||
template <typename Handler> void serialize(Handler &h, const int version)
|
||||
{
|
||||
h & stacks & effect & uniqueBonuses;
|
||||
h & cumulativeEffects & cumulativeUniqueBonuses;
|
||||
h & battleLog;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3871,11 +3871,29 @@ bool CGameHandler::makeBattleAction(BattleAction &ba)
|
||||
}
|
||||
case Battle::DEFEND:
|
||||
{
|
||||
//defensive stance //TODO: remove this bonus when stack becomes active
|
||||
//defensive stance
|
||||
SetStackEffect sse;
|
||||
sse.effect.push_back(Bonus(Bonus::STACK_GETS_TURN, Bonus::PRIMARY_SKILL, Bonus::OTHER, 20, -1, PrimarySkill::DEFENSE, Bonus::PERCENT_TO_ALL));
|
||||
sse.effect.push_back(Bonus(Bonus::STACK_GETS_TURN, Bonus::PRIMARY_SKILL, Bonus::OTHER, gs->curB->battleGetStackByID(ba.stackNumber)->valOfBonuses(Bonus::DEFENSIVE_STANCE),
|
||||
-1, PrimarySkill::DEFENSE, Bonus::ADDITIVE_VALUE));
|
||||
Bonus bonus1(Bonus::STACK_GETS_TURN, Bonus::PRIMARY_SKILL, Bonus::OTHER, 20, -1, PrimarySkill::DEFENSE, Bonus::PERCENT_TO_ALL);
|
||||
Bonus bonus2(Bonus::STACK_GETS_TURN, Bonus::PRIMARY_SKILL, Bonus::OTHER, stack->valOfBonuses(Bonus::DEFENSIVE_STANCE),
|
||||
-1, PrimarySkill::DEFENSE, Bonus::ADDITIVE_VALUE);
|
||||
TBonusListPtr defence = stack->getBonuses(Selector::typeSubtype(Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE));
|
||||
int oldDefenceValue = defence->totalValue();
|
||||
|
||||
defence->push_back(std::make_shared<Bonus>(bonus1));
|
||||
defence->push_back(std::make_shared<Bonus>(bonus2));
|
||||
|
||||
int difference = defence->totalValue() - oldDefenceValue;
|
||||
|
||||
MetaString text;
|
||||
stack->addText(text, MetaString::GENERAL_TXT, 120);
|
||||
stack->addNameReplacement(text);
|
||||
text.addReplacement(difference);
|
||||
|
||||
sse.battleLog.push_back(text);
|
||||
|
||||
sse.effect.push_back(bonus1);
|
||||
sse.effect.push_back(bonus2);
|
||||
|
||||
sse.stacks.push_back(ba.stackNumber);
|
||||
sendAndApply(&sse);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user