2017-06-24 15:51:07 +02:00
|
|
|
/*
|
|
|
|
* CPlayerBattleCallback.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
|
|
|
|
*
|
|
|
|
*/
|
2017-07-01 20:05:10 +02:00
|
|
|
#include "StdInc.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
#include "CPlayerBattleCallback.h"
|
2017-06-29 01:02:05 +02:00
|
|
|
#include "../CStack.h"
|
|
|
|
#include "../CGameState.h"
|
2017-06-24 15:51:07 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2017-06-24 15:51:07 +02:00
|
|
|
bool CPlayerBattleCallback::battleCanFlee() const
|
|
|
|
{
|
|
|
|
RETURN_IF_NOT_BATTLE(false);
|
|
|
|
ASSERT_IF_CALLED_WITH_PLAYER
|
|
|
|
return CBattleInfoEssentials::battleCanFlee(*player);
|
|
|
|
}
|
|
|
|
|
2017-07-15 13:08:20 +02:00
|
|
|
TStacks CPlayerBattleCallback::battleGetStacks(EStackOwnership whose, bool onlyAlive) const
|
2017-06-24 15:51:07 +02:00
|
|
|
{
|
|
|
|
if(whose != MINE_AND_ENEMY)
|
|
|
|
{
|
|
|
|
ASSERT_IF_CALLED_WITH_PLAYER
|
|
|
|
}
|
|
|
|
|
|
|
|
return battleGetStacksIf([=](const CStack * s){
|
|
|
|
const bool ownerMatches = (whose == MINE_AND_ENEMY)
|
2023-04-27 19:43:20 +02:00
|
|
|
|| (whose == ONLY_MINE && s->unitOwner() == player)
|
|
|
|
|| (whose == ONLY_ENEMY && s->unitOwner() != player);
|
2017-06-24 15:51:07 +02:00
|
|
|
|
|
|
|
return ownerMatches && s->isValidTarget(!onlyAlive);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPlayerBattleCallback::battleGetSurrenderCost() const
|
|
|
|
{
|
|
|
|
RETURN_IF_NOT_BATTLE(-3)
|
|
|
|
ASSERT_IF_CALLED_WITH_PLAYER
|
|
|
|
return CBattleInfoCallback::battleGetSurrenderCost(*player);
|
|
|
|
}
|
|
|
|
|
|
|
|
const CGHeroInstance * CPlayerBattleCallback::battleGetMyHero() const
|
|
|
|
{
|
|
|
|
return CBattleInfoEssentials::battleGetFightingHero(battleGetMySide());
|
|
|
|
}
|
|
|
|
|
|
|
|
InfoAboutHero CPlayerBattleCallback::battleGetEnemyHero() const
|
|
|
|
{
|
|
|
|
return battleGetHeroInfo(!battleGetMySide());
|
|
|
|
}
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|