mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-29 23:07:48 +02:00
Unified handling of battle sides ID's
- Replaced BattleSide namespace-enum with enum class - Merged two different BattleSide enum's into one - Merged BattlePerspective enum into BattleSide enum - Changed all places that use integers to represent battle side to use BattleSide enum - Added BattleSideArray convenience wrapper for std::array that is always 2-elements in size and allows access to its elements using BattleSide enum
This commit is contained in:
@@ -387,7 +387,7 @@ void CBank::doVisit(const CGHeroInstance * hero) const
|
||||
|
||||
void CBank::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if (result.winner == 0)
|
||||
if (result.winner == BattleSide::ATTACKER)
|
||||
{
|
||||
doVisit(hero);
|
||||
}
|
||||
|
||||
@@ -480,12 +480,12 @@ void CGCreature::flee( const CGHeroInstance * h ) const
|
||||
|
||||
void CGCreature::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if(result.winner == 0)
|
||||
if(result.winner == BattleSide::ATTACKER)
|
||||
{
|
||||
giveReward(hero);
|
||||
cb->removeObject(this, hero->getOwner());
|
||||
}
|
||||
else if(result.winner > 1) // draw
|
||||
else if(result.winner == BattleSide::NONE) // draw
|
||||
{
|
||||
// guarded reward is lost forever on draw
|
||||
cb->removeObject(this, hero->getOwner());
|
||||
|
||||
@@ -510,7 +510,7 @@ void CGDwelling::heroAcceptsCreatures( const CGHeroInstance *h) const
|
||||
|
||||
void CGDwelling::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if (result.winner == 0)
|
||||
if (result.winner == BattleSide::ATTACKER)
|
||||
{
|
||||
onHeroVisit(hero);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "../StartInfo.h"
|
||||
#include "CGTownInstance.h"
|
||||
#include "../entities/faction/CTownHandler.h"
|
||||
#include "../battle/CBattleInfoEssentials.h"
|
||||
#include "../campaign/CampaignState.h"
|
||||
#include "../json/JsonBonus.h"
|
||||
#include "../pathfinder/TurnInfo.h"
|
||||
@@ -880,7 +881,7 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
|
||||
double necromancySkill = valOfBonuses(BonusType::UNDEAD_RAISE_PERCENTAGE) / 100.0;
|
||||
const ui8 necromancyLevel = valOfBonuses(BonusType::IMPROVED_NECROMANCY);
|
||||
vstd::amin(necromancySkill, 1.0); //it's impossible to raise more creatures than all...
|
||||
const std::map<CreatureID,si32> &casualties = battleResult.casualties[!battleResult.winner];
|
||||
const std::map<CreatureID,si32> &casualties = battleResult.casualties[CBattleInfoEssentials::otherSide(battleResult.winner)];
|
||||
// figure out what to raise - pick strongest creature meeting requirements
|
||||
CreatureID creatureTypeRaised = CreatureID::NONE; //now we always have IMPROVED_NECROMANCY, no need for hardcode
|
||||
int requiredCasualtyLevel = 1;
|
||||
|
||||
@@ -180,7 +180,7 @@ void CGPandoraBox::onHeroVisit(const CGHeroInstance * h) const
|
||||
|
||||
void CGPandoraBox::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if(result.winner == 0)
|
||||
if(result.winner == BattleSide::ATTACKER)
|
||||
{
|
||||
CRewardableObject::onHeroVisit(hero);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ ui32 CGMine::getProducedQuantity() const
|
||||
|
||||
void CGMine::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if(result.winner == 0) //attacker won
|
||||
if(result.winner == BattleSide::ATTACKER) //attacker won
|
||||
{
|
||||
if(isAbandoned())
|
||||
{
|
||||
@@ -344,7 +344,7 @@ void CGResource::collectRes(const PlayerColor & player) const
|
||||
|
||||
void CGResource::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if(result.winner == 0) //attacker won
|
||||
if(result.winner == BattleSide::ATTACKER) //attacker won
|
||||
collectRes(hero->getOwner());
|
||||
}
|
||||
|
||||
@@ -911,7 +911,7 @@ BattleField CGArtifact::getBattlefield() const
|
||||
|
||||
void CGArtifact::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if(result.winner == 0) //attacker won
|
||||
if(result.winner == BattleSide::ATTACKER) //attacker won
|
||||
pick(hero);
|
||||
}
|
||||
|
||||
@@ -1010,7 +1010,7 @@ bool CGGarrison::passableFor(PlayerColor player) const
|
||||
|
||||
void CGGarrison::battleFinished(const CGHeroInstance *hero, const BattleResult &result) const
|
||||
{
|
||||
if (result.winner == 0)
|
||||
if (result.winner == BattleSide::ATTACKER)
|
||||
onHeroVisit(hero);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user