2011-12-13 21:23:17 +00:00
#include "StdInc.h"
2007-06-08 14:58:04 +00:00
#include "CHeroHandler.h"
2011-12-13 21:23:17 +00:00
2012-08-25 08:44:51 +00:00
#include "CGeneralTextHandler.h"
2012-08-01 12:02:54 +00:00
#include "Filesystem/CResourceLoader.h"
2012-08-25 08:44:51 +00:00
#include "VCMI_Lib.h"
#include "JsonNode.h"
2012-12-14 15:32:53 +00:00
#include "StringConstants.h"
2012-04-23 19:56:37 +00:00
#include "BattleHex.h"
2012-12-03 16:00:17 +00:00
#include "CModHandler.h"
2012-12-15 08:47:02 +00:00
#include "CTownHandler.h"
2013-01-19 17:38:37 +00:00
#include "CObjectHandler.h" //for hero specialty
2009-08-31 15:57:15 +00:00
2009-04-15 14:03:31 +00:00
/*
* CHeroHandler.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
*
*/
2013-02-04 19:43:16 +00:00
SecondarySkill :: SecondarySkill CHeroClass :: chooseSecSkill ( const std :: set < SecondarySkill :: SecondarySkill > & possibles ) const //picks secondary skill out from given possibilities
2008-08-04 15:56:36 +00:00
{
if ( possibles . size () == 1 )
return * possibles . begin ();
int totalProb = 0 ;
2013-02-04 19:43:16 +00:00
for ( auto i = possibles . begin (); i != possibles . end (); i ++ )
2008-08-04 15:56:36 +00:00
{
2012-12-14 15:32:53 +00:00
totalProb += secSkillProbability [ * i ];
2008-08-04 15:56:36 +00:00
}
int ran = rand () % totalProb ;
2013-02-04 19:43:16 +00:00
for ( auto i = possibles . begin (); i != possibles . end (); i ++ )
2008-08-04 15:56:36 +00:00
{
2012-12-14 15:32:53 +00:00
ran -= secSkillProbability [ * i ];
2008-08-04 15:56:36 +00:00
if ( ran < 0 )
return * i ;
}
2012-04-22 07:32:45 +00:00
throw std :: runtime_error ( "Cannot pick secondary skill!" );
2008-08-04 15:56:36 +00:00
}
2012-09-23 18:01:04 +00:00
EAlignment :: EAlignment CHeroClass :: getAlignment () const
2010-07-20 06:05:45 +00:00
{
2012-12-14 15:32:53 +00:00
return EAlignment :: EAlignment ( VLC -> townh -> factions [ faction ]. alignment );
2010-07-20 06:05:45 +00:00
}
2011-12-22 13:05:19 +00:00
std :: vector < BattleHex > CObstacleInfo :: getBlocked ( BattleHex hex ) const
2009-02-09 14:50:32 +00:00
{
2011-12-22 13:05:19 +00:00
std :: vector < BattleHex > ret ;
2012-04-23 19:56:37 +00:00
if ( isAbsoluteObstacle )
2009-02-09 14:50:32 +00:00
{
2012-04-23 19:56:37 +00:00
assert ( ! hex . isValid ());
range :: copy ( blockedTiles , std :: back_inserter ( ret ));
return ret ;
2009-02-09 14:50:32 +00:00
}
2012-04-23 19:56:37 +00:00
BOOST_FOREACH ( int offset , blockedTiles )
{
BattleHex toBlock = hex + offset ;
if (( hex . getY () & 1 ) && ! ( toBlock . getY () & 1 ))
toBlock += BattleHex :: LEFT ;
if ( ! toBlock . isValid ())
tlog1 << "Misplaced obstacle! \n " ;
else
ret . push_back ( toBlock );
}
2009-02-09 14:50:32 +00:00
return ret ;
}
2013-02-03 21:05:44 +00:00
bool CObstacleInfo :: isAppropriate ( ETerrainType :: ETerrainType terrainType , int specialBattlefield /*= -1*/ ) const
2009-09-25 11:38:18 +00:00
{
2012-04-23 19:56:37 +00:00
if ( specialBattlefield != - 1 )
return vstd :: contains ( allowedSpecialBfields , specialBattlefield );
return vstd :: contains ( allowedTerrains , terrainType );
2009-09-25 11:38:18 +00:00
}
2012-12-14 15:32:53 +00:00
void CHeroClassHandler :: load ()
{
CLegacyConfigParser parser ( "DATA/HCTRAITS.TXT" );
parser . endLine (); // header
parser . endLine ();
do
{
CHeroClass * hc = new CHeroClass ;
hc -> name = parser . readString ();
hc -> aggression = parser . readNumber ();
hc -> id = heroClasses . size ();
hc -> primarySkillInitial = parser . readNumArray < int > ( GameConstants :: PRIMARY_SKILLS );
hc -> primarySkillLowLevel = parser . readNumArray < int > ( GameConstants :: PRIMARY_SKILLS );
hc -> primarySkillHighLevel = parser . readNumArray < int > ( GameConstants :: PRIMARY_SKILLS );
hc -> secSkillProbability = parser . readNumArray < int > ( GameConstants :: SKILL_QUANTITY );
for ( int dd = 0 ; dd < GameConstants :: F_NUMBER ; ++ dd )
{
hc -> selectionProbability [ dd ] = parser . readNumber ();
}
VLC -> modh -> identifiers . requestIdentifier ( "faction." + ETownType :: names [ heroClasses . size () / 2 ],
[ = ]( si32 faction )
{
hc -> faction = faction ;
});
heroClasses . push_back ( hc );
VLC -> modh -> identifiers . registerObject ( "heroClass." + GameConstants :: HERO_CLASSES_NAMES [ hc -> id ], hc -> id );
}
while ( parser . endLine () && ! parser . isNextEntryEmpty ());
2012-12-16 13:47:53 +00:00
const JsonNode & heroGraphics = JsonNode ( ResourceID ( "config/heroClasses.json" ));
for ( size_t i = 0 ; i < heroClasses . size (); i ++ )
{
const JsonNode & battle = heroGraphics [ "heroBattleAnim" ]. Vector ()[ i / 2 ];
heroClasses [ i ] -> imageBattleFemale = battle [ "female" ]. String ();
heroClasses [ i ] -> imageBattleMale = battle [ "male" ]. String ();
const JsonNode & map = heroGraphics [ "heroMapAnim" ]. Vector ()[ i ];
heroClasses [ i ] -> imageMapMale = map . String ();
heroClasses [ i ] -> imageMapFemale = map . String ();
}
2012-12-14 15:32:53 +00:00
}
void CHeroClassHandler :: load ( const JsonNode & classes )
{
2012-12-16 13:47:53 +00:00
BOOST_FOREACH ( auto & entry , classes . Struct ())
{
if ( ! entry . second . isNull ()) // may happens if mod removed creature by setting json entry to null
{
CHeroClass * heroClass = loadClass ( entry . second );
heroClass -> identifier = entry . first ;
heroClass -> id = heroClasses . size ();
heroClasses . push_back ( heroClass );
2013-01-16 14:28:49 +00:00
tlog5 << "Added hero class: " << entry . first << " \n " ;
2012-12-16 13:47:53 +00:00
VLC -> modh -> identifiers . registerObject ( "heroClass." + heroClass -> identifier , heroClass -> id );
}
}
2012-12-14 15:32:53 +00:00
}
2012-12-16 13:47:53 +00:00
CHeroClass * CHeroClassHandler :: loadClass ( const JsonNode & node )
2012-12-14 15:32:53 +00:00
{
2012-12-16 13:47:53 +00:00
CHeroClass * heroClass = new CHeroClass ;
heroClass -> imageBattleFemale = node [ "animation" ][ "battle" ][ "female" ]. String ();
heroClass -> imageBattleMale = node [ "animation" ][ "battle" ][ "male" ]. String ();
heroClass -> imageMapFemale = node [ "animation" ][ "map" ][ "female" ]. String ();
heroClass -> imageMapMale = node [ "animation" ][ "map" ][ "male" ]. String ();
heroClass -> name = node [ "name" ]. String ();
BOOST_FOREACH ( const std :: string & pSkill , PrimarySkill :: names )
{
heroClass -> primarySkillInitial . push_back ( node [ "primarySkills" ][ pSkill ]. Float ());
heroClass -> primarySkillLowLevel . push_back ( node [ "lowLevelChance" ][ pSkill ]. Float ());
heroClass -> primarySkillHighLevel . push_back ( node [ "highLevelChance" ][ pSkill ]. Float ());
}
BOOST_FOREACH ( const std :: string & secSkill , SecondarySkill :: names )
{
heroClass -> secSkillProbability . push_back ( node [ "secondarySkills" ][ secSkill ]. Float ());
}
BOOST_FOREACH ( auto & tavern , node [ "tavern" ]. Struct ())
{
int value = tavern . second . Float ();
VLC -> modh -> identifiers . requestIdentifier ( "faction." + tavern . first ,
[ = ]( si32 factionID )
{
heroClass -> selectionProbability [ factionID ] = value ;
});
}
VLC -> modh -> identifiers . requestIdentifier ( "faction." + node [ "faction" ]. String (),
[ = ]( si32 factionID )
{
heroClass -> faction = factionID ;
});
return heroClass ;
2012-12-14 15:32:53 +00:00
}
CHeroClassHandler ::~ CHeroClassHandler ()
{
BOOST_FOREACH ( auto heroClass , heroClasses )
{
delete heroClass . get ();
}
}
2007-07-19 23:38:11 +00:00
CHeroHandler ::~ CHeroHandler ()
2009-01-10 22:08:18 +00:00
{
2012-12-14 15:32:53 +00:00
BOOST_FOREACH ( auto hero , heroes )
delete hero . get ();
2009-01-10 22:08:18 +00:00
}
CHeroHandler :: CHeroHandler ()
2012-12-26 09:46:09 +00:00
{
}
2009-01-10 22:08:18 +00:00
2012-12-16 13:47:53 +00:00
void CHeroHandler :: load ( const JsonNode & input )
2012-12-15 08:47:02 +00:00
{
2012-12-16 13:47:53 +00:00
BOOST_FOREACH ( auto & entry , input . Struct ())
{
if ( ! entry . second . isNull ()) // may happens if mod removed creature by setting json entry to null
{
CHero * hero = loadHero ( entry . second );
hero -> ID = heroes . size ();
heroes . push_back ( hero );
2013-01-16 14:28:49 +00:00
tlog5 << "Added hero: " << entry . first << " \n " ;
2012-12-16 13:47:53 +00:00
VLC -> modh -> identifiers . registerObject ( "hero." + entry . first , hero -> ID );
}
}
2012-12-15 08:47:02 +00:00
}
2012-12-16 13:47:53 +00:00
CHero * CHeroHandler :: loadHero ( const JsonNode & node )
2012-12-15 08:47:02 +00:00
{
2012-12-16 13:47:53 +00:00
CHero * hero = new CHero ;
hero -> name = node [ "texts" ][ "name" ]. String ();
hero -> biography = node [ "texts" ][ "biography" ]. String ();
hero -> specName = node [ "texts" ][ "specialty" ][ "name" ]. String ();
hero -> specTooltip = node [ "texts" ][ "specialty" ][ "tooltip" ]. String ();
hero -> specDescr = node [ "texts" ][ "specialty" ][ "description" ]. String ();
hero -> imageIndex = node [ "images" ][ "index" ]. Float ();
hero -> iconSpecSmall = node [ "images" ][ "specialtySmall" ]. String ();
hero -> iconSpecLarge = node [ "images" ][ "specialtyLarge" ]. String ();
hero -> portraitSmall = node [ "images" ][ "small" ]. String ();
hero -> portraitLarge = node [ "images" ][ "large" ]. String ();
assert ( node [ "army" ]. Vector (). size () <= 3 ); // anything bigger is useless - army initialization uses up to 3 slots
hero -> initialArmy . resize ( node [ "army" ]. Vector (). size ());
for ( size_t i = 0 ; i < hero -> initialArmy . size (); i ++ )
{
const JsonNode & source = node [ "army" ]. Vector ()[ i ];
hero -> initialArmy [ i ]. minAmount = source [ "min" ]. Float ();
hero -> initialArmy [ i ]. maxAmount = source [ "max" ]. Float ();
assert ( hero -> initialArmy [ i ]. minAmount <= hero -> initialArmy [ i ]. maxAmount );
VLC -> modh -> identifiers . requestIdentifier ( std :: string ( "creature." ) + source [ "creature" ]. String (), [ = ]( si32 creature )
{
hero -> initialArmy [ i ]. creature = creature ;
});
}
loadHeroJson ( hero , node );
return hero ;
}
void CHeroHandler :: loadHeroJson ( CHero * hero , const JsonNode & node )
{
// sex: 0=male, 1=female
2012-12-17 12:55:29 +00:00
hero -> sex = node [ "female" ]. Bool ();
hero -> special = node [ "special" ]. Bool ();
2012-12-16 13:47:53 +00:00
BOOST_FOREACH ( const JsonNode & set , node [ "skills" ]. Vector ())
{
2013-02-04 19:43:16 +00:00
SecondarySkill :: SecondarySkill skillID = static_cast < SecondarySkill :: SecondarySkill > (
boost :: range :: find ( SecondarySkill :: names , set [ "skill" ]. String ()) - boost :: begin ( SecondarySkill :: names ));
2012-12-16 13:47:53 +00:00
int skillLevel = boost :: range :: find ( SecondarySkill :: levels , set [ "level" ]. String ()) - boost :: begin ( SecondarySkill :: levels );
hero -> secSkillsInit . push_back ( std :: make_pair ( skillID , skillLevel ));
}
BOOST_FOREACH ( const JsonNode & spell , node [ "spellbook" ]. Vector ())
{
hero -> spells . insert ( spell . Float ());
}
2013-01-19 17:38:37 +00:00
//deprecated, used only for original spciealties
2012-12-16 13:47:53 +00:00
BOOST_FOREACH ( const JsonNode & specialty , node [ "specialties" ]. Vector ())
{
SSpecialtyInfo spec ;
spec . type = specialty [ "type" ]. Float ();
spec . val = specialty [ "val" ]. Float ();
spec . subtype = specialty [ "subtype" ]. Float ();
spec . additionalinfo = specialty [ "info" ]. Float ();
hero -> spec . push_back ( spec ); //put a copy of dummy
}
2013-01-19 17:38:37 +00:00
//new format, using bonus system
BOOST_FOREACH ( const JsonNode & specialty , node [ "specialty" ]. Vector ())
{
SSpecialtyBonus hs ;
hs . growsWithLevel = specialty [ "growsWithLevel" ]. Bool ();
BOOST_FOREACH ( const JsonNode & bonus , specialty [ "bonuses" ]. Vector ())
{
auto b = JsonUtils :: parseBonus ( bonus );
hs . bonuses . push_back ( b );
}
hero -> specialty . push_back ( hs ); //now, how to get CGHeroInstance from it?
}
2012-12-16 13:47:53 +00:00
VLC -> modh -> identifiers . requestIdentifier ( "heroClass." + node [ "class" ]. String (),
[ = ]( si32 classID )
{
hero -> heroClass = classes . heroClasses [ classID ];
});
2012-12-15 08:47:02 +00:00
}
2012-12-14 15:32:53 +00:00
void CHeroHandler :: load ()
{
2013-01-24 21:03:01 +00:00
for ( int i = 0 ; i < GameConstants :: SKILL_QUANTITY ; ++ i )
{
VLC -> modh -> identifiers . registerObject ( "skill." + SecondarySkill :: names [ i ], i );
}
2012-12-14 15:32:53 +00:00
classes . load ();
loadHeroes ();
2012-12-16 13:47:53 +00:00
loadHeroTexts ();
2012-12-14 15:32:53 +00:00
loadObstacles ();
2012-12-15 08:47:02 +00:00
loadTerrains ();
loadBallistics ();
loadExperience ();
}
void CHeroHandler :: loadExperience ()
{
expPerLevel . push_back ( 0 );
expPerLevel . push_back ( 1000 );
expPerLevel . push_back ( 2000 );
expPerLevel . push_back ( 3200 );
expPerLevel . push_back ( 4600 );
expPerLevel . push_back ( 6200 );
expPerLevel . push_back ( 8000 );
expPerLevel . push_back ( 10000 );
expPerLevel . push_back ( 12200 );
expPerLevel . push_back ( 14700 );
expPerLevel . push_back ( 17500 );
expPerLevel . push_back ( 20600 );
expPerLevel . push_back ( 24320 );
expPerLevel . push_back ( 28784 );
expPerLevel . push_back ( 34140 );
while ( expPerLevel [ expPerLevel . size () - 1 ] > expPerLevel [ expPerLevel . size () - 2 ])
{
int i = expPerLevel . size () - 1 ;
expPerLevel . push_back ( expPerLevel [ i ] + ( expPerLevel [ i ] - expPerLevel [ i - 1 ]) * 1.2 );
}
expPerLevel . pop_back (); //last value is broken
2012-12-14 15:32:53 +00:00
}
2009-02-07 16:07:29 +00:00
void CHeroHandler :: loadObstacles ()
{
2012-04-23 19:56:37 +00:00
auto loadObstacles = []( const JsonNode & node , bool absolute , std :: map < int , CObstacleInfo > & out )
{
2013-02-04 21:58:42 +00:00
BOOST_FOREACH ( const JsonNode & obs , node . Vector ())
2012-04-23 19:56:37 +00:00
{
int ID = obs [ "id" ]. Float ();
CObstacleInfo & obi = out [ ID ];
obi . ID = ID ;
obi . defName = obs [ "defname" ]. String ();
obi . width = obs [ "width" ]. Float ();
obi . height = obs [ "height" ]. Float ();
2013-02-03 21:05:44 +00:00
obi . allowedTerrains = obs [ "allowedTerrain" ]. convertTo < std :: vector < ETerrainType :: ETerrainType > > ();
obi . allowedSpecialBfields = obs [ "specialBattlefields" ]. convertTo < std :: vector < BFieldType :: BFieldType > > ();
2012-12-02 12:21:44 +00:00
obi . blockedTiles = obs [ "blockedTiles" ]. convertTo < std :: vector < si16 > > ();
2012-04-23 19:56:37 +00:00
obi . isAbsoluteObstacle = absolute ;
}
};
2012-08-02 11:03:26 +00:00
const JsonNode config ( ResourceID ( "config/obstacles.json" ));
2012-04-23 19:56:37 +00:00
loadObstacles ( config [ "obstacles" ], false , obstacles );
loadObstacles ( config [ "absoluteObstacles" ], true , absoluteObstacles );
2012-05-18 20:50:16 +00:00
//loadObstacles(config["moats"], true, moats);
2009-02-07 16:07:29 +00:00
}
2007-06-08 14:58:04 +00:00
void CHeroHandler :: loadHeroes ()
{
2008-06-30 00:06:41 +00:00
VLC -> heroh = this ;
2012-08-25 08:44:51 +00:00
CLegacyConfigParser parser ( "DATA/HOTRAITS.TXT" );
2007-08-04 19:01:22 +00:00
2012-08-25 08:44:51 +00:00
parser . endLine (); //ignore header
parser . endLine ();
2007-07-16 10:03:54 +00:00
2011-12-13 21:23:17 +00:00
for ( int i = 0 ; i < GameConstants :: HEROES_QUANTITY ; i ++ )
2007-06-08 14:58:04 +00:00
{
2012-08-25 08:44:51 +00:00
CHero * hero = new CHero ;
hero -> name = parser . readString ();
2007-08-04 19:01:22 +00:00
2012-12-16 13:47:53 +00:00
hero -> initialArmy . resize ( 3 );
2008-05-03 15:30:11 +00:00
for ( int x = 0 ; x < 3 ; x ++ )
{
2012-12-03 16:00:17 +00:00
hero -> initialArmy [ x ]. minAmount = parser . readNumber ();
hero -> initialArmy [ x ]. maxAmount = parser . readNumber ();
std :: string refName = parser . readString ();
boost :: algorithm :: replace_all ( refName , " " , "" ); //remove spaces
2012-12-22 16:47:12 +00:00
refName [ 0 ] = std :: tolower ( refName [ 0 ]); // to camelCase
2012-12-03 16:00:17 +00:00
VLC -> modh -> identifiers . requestIdentifier ( std :: string ( "creature." ) + refName , [ = ]( si32 creature )
{
hero -> initialArmy [ x ]. creature = creature ;
});
2008-05-03 15:30:11 +00:00
}
2012-08-25 08:44:51 +00:00
parser . endLine ();
hero -> ID = heroes . size ();
2012-12-16 13:47:53 +00:00
hero -> imageIndex = hero -> ID ;
2012-08-25 08:44:51 +00:00
heroes . push_back ( hero );
2007-06-08 14:58:04 +00:00
}
2011-08-27 15:53:45 +00:00
// Load heroes information
2012-08-02 11:03:26 +00:00
const JsonNode config ( ResourceID ( "config/heroes.json" ));
2012-12-15 13:40:22 +00:00
BOOST_FOREACH ( const JsonNode & hero , config [ "heroes" ]. Vector ())
{
2012-12-16 13:47:53 +00:00
loadHeroJson ( heroes [ hero [ "id" ]. Float ()], hero );
2008-09-29 11:03:30 +00:00
}
2012-12-15 08:47:02 +00:00
}
2008-09-29 11:03:30 +00:00
2012-12-16 13:47:53 +00:00
void CHeroHandler :: loadHeroTexts ()
{
CLegacyConfigParser parser ( "DATA/HEROSPEC.TXT" );
CLegacyConfigParser bioParser ( "DATA/HEROBIOS.TXT" );
//skip header
parser . endLine ();
parser . endLine ();
int i = 0 ;
do
{
CHero * hero = heroes [ i ++ ];
hero -> specName = parser . readString ();
hero -> specTooltip = parser . readString ();
hero -> specDescr = parser . readString ();
hero -> biography = bioParser . readString ();
}
2012-12-17 12:55:29 +00:00
while ( parser . endLine () && bioParser . endLine () && heroes . size () > i );
2012-12-16 13:47:53 +00:00
}
2012-12-15 08:47:02 +00:00
void CHeroHandler :: loadBallistics ()
{
2012-08-25 08:44:51 +00:00
CLegacyConfigParser ballParser ( "DATA/BALLIST.TXT" );
ballParser . endLine (); //header
ballParser . endLine ();
do
2009-02-06 14:15:45 +00:00
{
2012-08-25 08:44:51 +00:00
ballParser . readString ();
ballParser . readString ();
2009-02-06 14:15:45 +00:00
CHeroHandler :: SBallisticsLevelInfo bli ;
2012-08-25 08:44:51 +00:00
bli . keep = ballParser . readNumber ();
bli . tower = ballParser . readNumber ();
bli . gate = ballParser . readNumber ();
bli . wall = ballParser . readNumber ();
bli . shots = ballParser . readNumber ();
bli . noDmg = ballParser . readNumber ();
bli . oneDmg = ballParser . readNumber ();
bli . twoDmg = ballParser . readNumber ();
bli . sum = ballParser . readNumber ();
2009-02-06 14:15:45 +00:00
ballistics . push_back ( bli );
}
2012-08-25 08:44:51 +00:00
while ( ballParser . endLine ());
2007-06-09 13:28:03 +00:00
}
2011-08-27 17:33:07 +00:00
2011-12-13 21:23:17 +00:00
ui32 CHeroHandler :: level ( ui64 experience ) const
2007-08-12 17:48:05 +00:00
{
2012-12-15 13:40:22 +00:00
return boost :: range :: upper_bound ( expPerLevel , experience ) - boost :: begin ( expPerLevel );
2008-01-27 16:07:27 +00:00
}
2011-12-13 21:23:17 +00:00
ui64 CHeroHandler :: reqExp ( ui32 level ) const
2008-01-27 16:07:27 +00:00
{
2009-07-20 03:30:48 +00:00
if ( ! level )
return 0 ;
2009-10-28 10:45:45 +00:00
if ( level <= expPerLevel . size ())
2009-07-20 03:30:48 +00:00
{
2009-10-28 10:45:45 +00:00
return expPerLevel [ level - 1 ];
2009-07-20 03:30:48 +00:00
}
2008-01-27 16:07:27 +00:00
else
2007-09-14 13:11:10 +00:00
{
2010-08-16 09:54:09 +00:00
tlog3 << "A hero has reached unsupported amount of experience \n " ;
return expPerLevel [ expPerLevel . size () - 1 ];
2007-09-14 13:11:10 +00:00
}
2007-08-12 17:48:05 +00:00
}
2011-09-02 03:39:49 +00:00
void CHeroHandler :: loadTerrains ()
2007-08-15 15:13:11 +00:00
{
2012-08-02 11:03:26 +00:00
const JsonNode config ( ResourceID ( "config/terrains.json" ));
2009-06-30 12:28:22 +00:00
2012-09-05 12:49:23 +00:00
terrCosts . reserve ( GameConstants :: TERRAIN_TYPES );
BOOST_FOREACH ( const std :: string & name , GameConstants :: TERRAIN_NAMES )
2012-12-10 14:28:27 +00:00
terrCosts . push_back ( config [ name ][ "moveCost" ]. Float ());
2009-06-30 12:28:22 +00:00
}
2009-07-03 18:40:36 +00:00
2013-02-04 21:58:42 +00:00
std :: vector < bool > CHeroHandler :: getDefaultAllowedHeroes () const
2012-11-20 17:53:45 +00:00
{
// Look Data/HOTRAITS.txt for reference
2013-02-04 21:58:42 +00:00
std :: vector < bool > allowedHeroes ;
2012-12-17 12:55:29 +00:00
allowedHeroes . reserve ( heroes . size ());
BOOST_FOREACH ( const CHero * hero , heroes )
2012-11-20 17:53:45 +00:00
{
2012-12-17 12:55:29 +00:00
allowedHeroes . push_back ( ! hero -> special );
2012-11-20 17:53:45 +00:00
}
2012-12-17 12:55:29 +00:00
2012-11-20 17:53:45 +00:00
return allowedHeroes ;
2012-12-17 12:55:29 +00:00
}
2013-01-06 19:30:12 +00:00
2013-02-04 21:58:42 +00:00
std :: vector < bool > CHeroHandler :: getDefaultAllowedAbilities () const
2013-01-06 19:30:12 +00:00
{
2013-02-04 21:58:42 +00:00
std :: vector < bool > allowedAbilities ;
allowedAbilities . resize ( GameConstants :: SKILL_QUANTITY , true );
2013-01-06 19:30:12 +00:00
return allowedAbilities ;
}