2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2007-06-10 21:04:15 +03:00
|
|
|
#include "CBuildingHandler.h"
|
2011-12-14 00:23:17 +03:00
|
|
|
|
2010-08-02 17:29:30 +03:00
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
|
|
|
* CBuildingHandler.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-11 22:11:34 +03:00
|
|
|
BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
|
2010-08-02 17:29:30 +03:00
|
|
|
{
|
|
|
|
using namespace boost::assign;
|
2013-02-13 17:21:11 +03:00
|
|
|
static const std::vector<BuildingID> campToERMU = list_of(BuildingID::TOWN_HALL)(BuildingID::CITY_HALL)
|
|
|
|
(BuildingID::CAPITOL)(BuildingID::FORT)(BuildingID::CITADEL)(BuildingID::CASTLE)(BuildingID::TAVERN)
|
|
|
|
(BuildingID::BLACKSMITH)(BuildingID::MARKETPLACE)(BuildingID::RESOURCE_SILO)(BuildingID::NONE)
|
|
|
|
(BuildingID::MAGES_GUILD_1)(BuildingID::MAGES_GUILD_2)(BuildingID::MAGES_GUILD_3)(BuildingID::MAGES_GUILD_4)
|
|
|
|
(BuildingID::MAGES_GUILD_5)
|
|
|
|
(BuildingID::SHIPYARD)(BuildingID::GRAIL)
|
|
|
|
(BuildingID::SPECIAL_1)(BuildingID::SPECIAL_2)(BuildingID::SPECIAL_3)(BuildingID::SPECIAL_4)
|
2010-08-02 17:29:30 +03:00
|
|
|
; //creature generators with banks - handled separately
|
|
|
|
if (camp < campToERMU.size())
|
|
|
|
{
|
2013-02-13 17:21:11 +03:00
|
|
|
return campToERMU[camp];
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
|
2011-12-14 00:23:17 +03:00
|
|
|
static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2),
|
2010-08-02 17:29:30 +03:00
|
|
|
list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)};
|
|
|
|
|
|
|
|
int curPos = campToERMU.size();
|
|
|
|
for (int i=0; i<7; ++i)
|
|
|
|
{
|
|
|
|
if(camp == curPos) //non-upgraded
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID(30 + i);
|
2010-08-02 17:29:30 +03:00
|
|
|
curPos++;
|
|
|
|
if(camp == curPos) //upgraded
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID(37 + i);
|
2010-08-02 17:29:30 +03:00
|
|
|
curPos++;
|
|
|
|
//horde building
|
|
|
|
if (vstd::contains(hordeLvlsPerTType[townType], i))
|
|
|
|
{
|
|
|
|
if (camp == curPos)
|
|
|
|
{
|
|
|
|
if (hordeLvlsPerTType[townType][0] == i)
|
|
|
|
{
|
2010-08-03 14:36:52 +03:00
|
|
|
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][0])) //if upgraded dwelling is built
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID::HORDE_1_UPGR;
|
2010-08-03 14:36:52 +03:00
|
|
|
else //upgraded dwelling not presents
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID::HORDE_1;
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-08-03 14:36:52 +03:00
|
|
|
if(hordeLvlsPerTType[townType].size() > 1)
|
|
|
|
{
|
|
|
|
if(vstd::contains(builtBuildings, 37 + hordeLvlsPerTType[townType][1])) //if upgraded dwelling is built
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID::HORDE_2_UPGR;
|
2010-08-03 14:36:52 +03:00
|
|
|
else //upgraded dwelling not presents
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID::HORDE_2;
|
2010-08-03 14:36:52 +03:00
|
|
|
}
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-02-13 17:21:11 +03:00
|
|
|
curPos++;
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
assert(0);
|
2013-02-11 22:11:34 +03:00
|
|
|
return BuildingID::NONE; //not found
|
2010-08-02 17:29:30 +03:00
|
|
|
}
|
|
|
|
|