1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-04 09:42:40 +02:00
vcmi/lib/battle/BattleProxy.cpp
Ivan Savenko 2a05fbdd50 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
2024-08-11 20:54:44 +00:00

125 lines
2.5 KiB
C++

/*
* BattleProxy.cpp, part of VCMI engine
*
* Authors: listed in file AUTHORS in main folder
*
* License: GNU General Public License v2.0 or later
* Full text of license available in license.txt file, in main folder
*
*/
#include "StdInc.h"
#include "BattleProxy.h"
#include "Unit.h"
VCMI_LIB_NAMESPACE_BEGIN
///BattleProxy
BattleProxy::BattleProxy(Subject subject_):
subject(std::move(subject_))
{}
BattleProxy::~BattleProxy() = default;
const IBattleInfo * BattleProxy::getBattle() const
{
return this;
}
std::optional<PlayerColor> BattleProxy::getPlayerID() const
{
return subject->getPlayerID();
}
int32_t BattleProxy::getActiveStackID() const
{
const auto * ret = subject->battleActiveUnit();
if(ret)
return ret->unitId();
else
return -1;
}
TStacks BattleProxy::getStacksIf(const TStackFilter & predicate) const
{
return subject->battleGetStacksIf(predicate);
}
battle::Units BattleProxy::getUnitsIf(const battle::UnitFilter & predicate) const
{
return subject->battleGetUnitsIf(predicate);
}
BattleField BattleProxy::getBattlefieldType() const
{
return subject->battleGetBattlefieldType();
}
TerrainId BattleProxy::getTerrainType() const
{
return subject->battleTerrainType();
}
IBattleInfo::ObstacleCList BattleProxy::getAllObstacles() const
{
return subject->battleGetAllObstacles();
}
PlayerColor BattleProxy::getSidePlayer(BattleSide side) const
{
return subject->sideToPlayer(side);
}
const CArmedInstance * BattleProxy::getSideArmy(BattleSide side) const
{
return subject->battleGetArmyObject(side);
}
const CGHeroInstance * BattleProxy::getSideHero(BattleSide side) const
{
return subject->battleGetFightingHero(side);
}
ui8 BattleProxy::getTacticDist() const
{
return subject->battleTacticDist();
}
BattleSide BattleProxy::getTacticsSide() const
{
return subject->battleGetTacticsSide();
}
const CGTownInstance * BattleProxy::getDefendedTown() const
{
return subject->battleGetDefendedTown();
}
EWallState BattleProxy::getWallState(EWallPart partOfWall) const
{
return subject->battleGetWallState(partOfWall);
}
EGateState BattleProxy::getGateState() const
{
return subject->battleGetGateState();
}
uint32_t BattleProxy::getCastSpells(BattleSide side) const
{
return subject->battleCastSpells(side);
}
int32_t BattleProxy::getEnchanterCounter(BattleSide side) const
{
return subject->battleGetEnchanterCounter(side);
}
const IBonusBearer * BattleProxy::getBonusBearer() const
{
return subject->getBonusBearer();
}
VCMI_LIB_NAMESPACE_END