1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Work in progress on BattleAI. Related changes:

* battle AIs receive ptr to CBattleCallback (not sure why it was CPlayerBattleCallback, likely mistake)
* reworked some battle callback methods to be more generic and able to handle some hypothetic scenarios
* for testing purposes in duel mode the first AI will be taken fro mconfig and the second will remain stupid ai
* minor changes
This commit is contained in:
Michał W. Urbańczyk
2012-09-20 16:55:21 +00:00
parent 871f680ccc
commit 62e63d45b1
25 changed files with 793 additions and 257 deletions

View File

@ -1155,19 +1155,6 @@ si32 CStack::magicResistance() const
return magicResistance;
}
const Bonus * CStack::getEffect( ui16 id, int turn /*= 0*/ ) const
{
BOOST_FOREACH(Bonus *it, getBonusList())
{
if(it->source == Bonus::SPELL_EFFECT && it->sid == id)
{
if(!turn || it->turnsRemain > turn)
return &(*it);
}
}
return NULL;
}
void CStack::stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse)
{
si32 power = VLC->spellh->spells[sse.sid]->powers[sse.val];
@ -1342,17 +1329,6 @@ void CStack::stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse)
}
}
ui8 CStack::howManyEffectsSet(ui16 id) const
{
ui8 ret = 0;
BOOST_FOREACH(const Bonus *it, getBonusList())
if(it->source == Bonus::SPELL_EFFECT && it->sid == id) //effect found
{
++ret;
}
return ret;
}
bool CStack::willMove(int turn /*= 0*/) const
{
return ( turn ? true : !vstd::contains(state, EBattleStackState::DEFENDING) )
@ -1374,6 +1350,14 @@ bool CStack::moved( int turn /*= 0*/ ) const
return false;
}
bool CStack::waited(int turn /*= 0*/) const
{
if(!turn)
return vstd::contains(state, EBattleStackState::WAITING);
else
return false;
}
bool CStack::doubleWide() const
{
return getCreature()->doubleWide;