1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

Merge branch 'develop' of https://github.com/vcmi/vcmi into develop

This commit is contained in:
DjWarmonger
2016-11-28 10:12:01 +01:00
81 changed files with 456 additions and 390 deletions

View File

@ -13,30 +13,11 @@
#include "EnemyInfo.h"
#include "../../lib/spells/CSpellHandler.h"
/*
//
// //set has its own order, so remove_if won't work. TODO - reuse for map
// template<typename Elem, typename Predicate>
// void erase_if(std::set<Elem> &setContainer, Predicate pred)
// {
// auto itr = setContainer.begin();
// auto endItr = setContainer.end();
// while(itr != endItr)
// {
// auto tmpItr = itr++;
// if(pred(*tmpItr))
// setContainer.erase(tmpItr);
// }
// }
*/
#define LOGL(text) print(text)
#define LOGFL(text, formattingEl) print(boost::str(boost::format(text) % formattingEl))
CBattleAI::CBattleAI(void)
: side(-1)
: side(-1), wasWaitingForRealize(false), wasUnlockingGs(false)
{
}
@ -82,8 +63,8 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
return BattleAction::makeHeal(stack, woundHpToStack.rbegin()->second); //last element of the woundHpToStack is the most wounded stack
}
if(cb->battleCanCastSpell())
attemptCastingSpell();
attemptCastingSpell();
if(auto ret = getCbc()->battleIsFinished())
{
//spellcast may finish battle
@ -201,8 +182,14 @@ SpellTypes spellType(const CSpell *spell)
void CBattleAI::attemptCastingSpell()
{
auto hero = cb->battleGetMyHero();
if(!hero)
return;
if(!cb->battleCanCastSpell())
return;
LOGL("Casting spells sounds like fun. Let's see...");
auto hero = cb->battleGetMyHero(); //auto known = cb->battleGetFightingHero(side);
//Get all spells we can cast
std::vector<const CSpell*> possibleSpells;
vstd::copy_if(VLC->spellh->objects, std::back_inserter(possibleSpells), [this] (const CSpell *s) -> bool

View File

@ -297,6 +297,7 @@ ui64 evaluateDanger(const CGObjectInstance *obj)
return cre->getArmyStrength();
}
case Obj::CREATURE_GENERATOR1:
case Obj::CREATURE_GENERATOR4:
{
const CGDwelling *d = dynamic_cast<const CGDwelling*>(obj);
return d->getArmyStrength();

View File

@ -83,6 +83,7 @@ struct SectorMap
Sector()
{
id = -1;
water = false;
}
};