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

[programming challenge]

* stupid AI will print more info
* proper handling of too long processing of battle end calls
* doxygenized some comments
This commit is contained in:
Michał W. Urbańczyk
2011-12-03 23:40:56 +00:00
parent 3fbaaac6d9
commit 85588b6bda
17 changed files with 371 additions and 130 deletions

View File

@ -33,6 +33,7 @@
#include "../lib/JsonNode.h"
#include <boost/algorithm/string/predicate.hpp>
#include "BattleAction.h"
//#include <windows.h>
boost::rand48 ran;
class CGObjectInstance;
@ -967,10 +968,14 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
CArmedInstance *obj = NULL;
if(dp.sides[i].heroId >= 0)
{
const DuelParameters::SideSettings &ss = dp.sides[i];
CGHeroInstance *h = new CGHeroInstance();
armies[i] = heroes[i] = h;
obj = h;
h->subID = dp.sides[i].heroId;
h->subID = ss.heroId;
for(int i = 0; i < ss.heroPrimSkills.size(); i++)
h->pushPrimSkill(i, ss.heroPrimSkills[i]);
h->initHero(h->subID);
obj->initObj();
}
@ -2812,7 +2817,23 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
i++;
}
ss.heroId = n["heroid"].Float();
if(n["heroid"].getType() == JsonNode::DATA_FLOAT)
ss.heroId = n["heroid"].Float();
else
ss.heroId = -1;
// int msgboxID = MessageBox(
// NULL,
// "Resource not available\nDo you want to try again?",
// "Account Details",
// MB_ICONWARNING | MB_CANCELTRYCONTINUE | MB_DEFBUTTON2
// );
BOOST_FOREACH(const JsonNode &n, n["heroPrimSkills"].Vector())
ss.heroPrimSkills.push_back(n.Float());
assert(ss.heroPrimSkills.empty() || ss.heroPrimSkills.size() == PRIMARY_SKILLS);
if(ss.heroId != -1)
BOOST_FOREACH(const JsonNode &spell, n["spells"].Vector())
ss.spells.insert(spell.Float());