mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
initializer lists part1
This commit is contained in:
parent
463b9e46b3
commit
66b022f93e
@ -108,7 +108,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
|
|||||||
if(stack->type->idNumber == CreatureID::CATAPULT)
|
if(stack->type->idNumber == CreatureID::CATAPULT)
|
||||||
{
|
{
|
||||||
BattleAction attack;
|
BattleAction attack;
|
||||||
static const std::vector<int> wallHexes = boost::assign::list_of(50)(183)(182)(130)(62)(29)(12)(95);
|
static const std::vector<int> wallHexes = {50, 183, 182, 130, 62, 29, 12, 95};
|
||||||
|
|
||||||
attack.destinationTile = *RandomGeneratorUtil::nextItem(wallHexes, CRandomGenerator::getDefault());
|
attack.destinationTile = *RandomGeneratorUtil::nextItem(wallHexes, CRandomGenerator::getDefault());
|
||||||
attack.actionType = Battle::CATAPULT;
|
attack.actionType = Battle::CATAPULT;
|
||||||
|
@ -27,7 +27,6 @@ class FuzzyEngine;
|
|||||||
class InputLVar;
|
class InputLVar;
|
||||||
class CGTownInstance;
|
class CGTownInstance;
|
||||||
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace vstd;
|
using namespace vstd;
|
||||||
//using namespace Goals;
|
//using namespace Goals;
|
||||||
|
|
||||||
@ -118,9 +117,6 @@ void FuzzyHelper::initTacticalAdvantage()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//Tactical advantage calculation
|
|
||||||
std::vector<fl::InputLVar*> helper;
|
|
||||||
|
|
||||||
ta.ourShooters = new fl::InputLVar("OurShooters");
|
ta.ourShooters = new fl::InputLVar("OurShooters");
|
||||||
ta.ourWalkers = new fl::InputLVar("OurWalkers");
|
ta.ourWalkers = new fl::InputLVar("OurWalkers");
|
||||||
ta.ourFlyers = new fl::InputLVar("OurFlyers");
|
ta.ourFlyers = new fl::InputLVar("OurFlyers");
|
||||||
@ -128,7 +124,11 @@ void FuzzyHelper::initTacticalAdvantage()
|
|||||||
ta.enemyWalkers = new fl::InputLVar("EnemyWalkers");
|
ta.enemyWalkers = new fl::InputLVar("EnemyWalkers");
|
||||||
ta.enemyFlyers = new fl::InputLVar("EnemyFlyers");
|
ta.enemyFlyers = new fl::InputLVar("EnemyFlyers");
|
||||||
|
|
||||||
helper += ta.ourShooters, ta.ourWalkers, ta.ourFlyers, ta.enemyShooters, ta.enemyWalkers, ta.enemyFlyers;
|
//Tactical advantage calculation
|
||||||
|
std::vector<fl::InputLVar*> helper =
|
||||||
|
{
|
||||||
|
ta.ourShooters, ta.ourWalkers, ta.ourFlyers, ta.enemyShooters, ta.enemyWalkers, ta.enemyFlyers
|
||||||
|
};
|
||||||
|
|
||||||
for (auto val : helper)
|
for (auto val : helper)
|
||||||
{
|
{
|
||||||
@ -136,12 +136,11 @@ void FuzzyHelper::initTacticalAdvantage()
|
|||||||
val->addTerm (new fl::ShoulderTerm("FEW", 0, 0.6, true));
|
val->addTerm (new fl::ShoulderTerm("FEW", 0, 0.6, true));
|
||||||
val->addTerm (new fl::ShoulderTerm("MANY", 0.4, 1, false));
|
val->addTerm (new fl::ShoulderTerm("MANY", 0.4, 1, false));
|
||||||
}
|
}
|
||||||
helper.clear();
|
|
||||||
|
|
||||||
ta.ourSpeed = new fl::InputLVar("OurSpeed");
|
ta.ourSpeed = new fl::InputLVar("OurSpeed");
|
||||||
ta.enemySpeed = new fl::InputLVar("EnemySpeed");
|
ta.enemySpeed = new fl::InputLVar("EnemySpeed");
|
||||||
|
|
||||||
helper += ta.ourSpeed, ta.enemySpeed;
|
helper = {ta.ourSpeed, ta.enemySpeed};
|
||||||
|
|
||||||
for (auto val : helper)
|
for (auto val : helper)
|
||||||
{
|
{
|
||||||
@ -334,15 +333,13 @@ void FuzzyHelper::initVisitTile()
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::vector<fl::InputLVar*> helper;
|
|
||||||
|
|
||||||
vt.strengthRatio = new fl::InputLVar("strengthRatio"); //hero must be strong enough to defeat guards
|
vt.strengthRatio = new fl::InputLVar("strengthRatio"); //hero must be strong enough to defeat guards
|
||||||
vt.heroStrength = new fl::InputLVar("heroStrength"); //we want to use weakest possible hero
|
vt.heroStrength = new fl::InputLVar("heroStrength"); //we want to use weakest possible hero
|
||||||
vt.turnDistance = new fl::InputLVar("turnDistance"); //we want to use hero who is near
|
vt.turnDistance = new fl::InputLVar("turnDistance"); //we want to use hero who is near
|
||||||
vt.missionImportance = new fl::InputLVar("lockedMissionImportance"); //we may want to preempt hero with low-priority mission
|
vt.missionImportance = new fl::InputLVar("lockedMissionImportance"); //we may want to preempt hero with low-priority mission
|
||||||
vt.value = new fl::OutputLVar("Value");
|
vt.value = new fl::OutputLVar("Value");
|
||||||
|
|
||||||
helper += vt.strengthRatio, vt.heroStrength, vt.turnDistance, vt.missionImportance;
|
std::vector<fl::InputLVar*> helper = {vt.strengthRatio, vt.heroStrength, vt.turnDistance, vt.missionImportance};
|
||||||
for (auto val : helper)
|
for (auto val : helper)
|
||||||
{
|
{
|
||||||
engine.addInputLVar(val);
|
engine.addInputLVar(val);
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
#define VCMI_SOUND_NAME(x)
|
#define VCMI_SOUND_NAME(x)
|
||||||
#define VCMI_SOUND_FILE(y) #y,
|
#define VCMI_SOUND_FILE(y) #y,
|
||||||
|
|
||||||
@ -88,18 +86,26 @@ CSoundHandler::CSoundHandler():
|
|||||||
listener(std::bind(&CSoundHandler::onVolumeChange, this, _1));
|
listener(std::bind(&CSoundHandler::onVolumeChange, this, _1));
|
||||||
|
|
||||||
// Vectors for helper(s)
|
// Vectors for helper(s)
|
||||||
pickupSounds += soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
|
pickupSounds =
|
||||||
soundBase::pickup04, soundBase::pickup05, soundBase::pickup06, soundBase::pickup07;
|
{
|
||||||
|
soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
|
||||||
|
soundBase::pickup04, soundBase::pickup05, soundBase::pickup06, soundBase::pickup07
|
||||||
|
};
|
||||||
|
|
||||||
horseSounds += // must be the same order as terrains (see ETerrainType);
|
horseSounds = // must be the same order as terrains (see ETerrainType);
|
||||||
|
{
|
||||||
soundBase::horseDirt, soundBase::horseSand, soundBase::horseGrass,
|
soundBase::horseDirt, soundBase::horseSand, soundBase::horseGrass,
|
||||||
soundBase::horseSnow, soundBase::horseSwamp, soundBase::horseRough,
|
soundBase::horseSnow, soundBase::horseSwamp, soundBase::horseRough,
|
||||||
soundBase::horseSubterranean, soundBase::horseLava,
|
soundBase::horseSubterranean, soundBase::horseLava,
|
||||||
soundBase::horseWater, soundBase::horseRock;
|
soundBase::horseWater, soundBase::horseRock
|
||||||
|
};
|
||||||
|
|
||||||
battleIntroSounds += soundBase::battle00, soundBase::battle01,
|
battleIntroSounds =
|
||||||
|
{
|
||||||
|
soundBase::battle00, soundBase::battle01,
|
||||||
soundBase::battle02, soundBase::battle03, soundBase::battle04,
|
soundBase::battle02, soundBase::battle03, soundBase::battle04,
|
||||||
soundBase::battle05, soundBase::battle06, soundBase::battle07;
|
soundBase::battle05, soundBase::battle06, soundBase::battle07
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void CSoundHandler::init()
|
void CSoundHandler::init()
|
||||||
|
@ -71,7 +71,6 @@
|
|||||||
return; \
|
return; \
|
||||||
RETURN_IF_QUICK_COMBAT
|
RETURN_IF_QUICK_COMBAT
|
||||||
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace CSDL_Ext;
|
using namespace CSDL_Ext;
|
||||||
|
|
||||||
void processCommand(const std::string &message, CClient *&client);
|
void processCommand(const std::string &message, CClient *&client);
|
||||||
@ -1438,7 +1437,7 @@ void CPlayerInterface::initializeHeroTownList()
|
|||||||
|
|
||||||
for (auto & allHeroe : allHeroes)
|
for (auto & allHeroe : allHeroes)
|
||||||
if (!allHeroe->inTownGarrison)
|
if (!allHeroe->inTownGarrison)
|
||||||
wanderingHeroes += allHeroe;
|
wanderingHeroes.push_back(allHeroe);
|
||||||
|
|
||||||
std::vector<const CGTownInstance*> allTowns = cb->getTownsInfo();
|
std::vector<const CGTownInstance*> allTowns = cb->getTownsInfo();
|
||||||
/*
|
/*
|
||||||
|
@ -306,11 +306,11 @@ void CMenuScreen::switchToTab(size_t index)
|
|||||||
//funciton for std::string -> std::function conversion for main menu
|
//funciton for std::string -> std::function conversion for main menu
|
||||||
static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::string> menuType, const std::string &string)
|
static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::string> menuType, const std::string &string)
|
||||||
{
|
{
|
||||||
static const std::vector<std::string> commandType = boost::assign::list_of
|
static const std::vector<std::string> commandType =
|
||||||
("to")("campaigns")("start")("load")("exit")("highscores");
|
{"to", "campaigns", "start", "load", "exit", "highscores"};
|
||||||
|
|
||||||
static const std::vector<std::string> gameType = boost::assign::list_of
|
static const std::vector<std::string> gameType =
|
||||||
("single")("multi")("campaign")("tutorial");
|
{"single", "multi", "campaign", "tutorial"};
|
||||||
|
|
||||||
std::list<std::string> commands;
|
std::list<std::string> commands;
|
||||||
boost::split(commands, string, boost::is_any_of("\t "));
|
boost::split(commands, string, boost::is_any_of("\t "));
|
||||||
@ -1624,13 +1624,12 @@ CRandomMapTab::CRandomMapTab()
|
|||||||
mapSizeBtnGroup = new CToggleGroup(0);
|
mapSizeBtnGroup = new CToggleGroup(0);
|
||||||
mapSizeBtnGroup->pos.y += 81;
|
mapSizeBtnGroup->pos.y += 81;
|
||||||
mapSizeBtnGroup->pos.x += 158;
|
mapSizeBtnGroup->pos.x += 158;
|
||||||
const std::vector<std::string> mapSizeBtns = boost::assign::list_of("RANSIZS")("RANSIZM")("RANSIZL")("RANSIZX");
|
const std::vector<std::string> mapSizeBtns = {"RANSIZS", "RANSIZM","RANSIZL","RANSIZX"};
|
||||||
addButtonsToGroup(mapSizeBtnGroup, mapSizeBtns, 0, 3, 47, 198);
|
addButtonsToGroup(mapSizeBtnGroup, mapSizeBtns, 0, 3, 47, 198);
|
||||||
mapSizeBtnGroup->setSelected(1);
|
mapSizeBtnGroup->setSelected(1);
|
||||||
mapSizeBtnGroup->addCallback([&](int btnId)
|
mapSizeBtnGroup->addCallback([&](int btnId)
|
||||||
{
|
{
|
||||||
const std::vector<int> mapSizeVal = boost::assign::list_of(CMapHeader::MAP_SIZE_SMALL)(CMapHeader::MAP_SIZE_MIDDLE)
|
const std::vector<int> mapSizeVal = {CMapHeader::MAP_SIZE_SMALL,CMapHeader::MAP_SIZE_MIDDLE,CMapHeader::MAP_SIZE_LARGE,CMapHeader::MAP_SIZE_XLARGE};
|
||||||
(CMapHeader::MAP_SIZE_LARGE)(CMapHeader::MAP_SIZE_XLARGE);
|
|
||||||
mapGenOptions.setWidth(mapSizeVal[btnId]);
|
mapGenOptions.setWidth(mapSizeVal[btnId]);
|
||||||
mapGenOptions.setHeight(mapSizeVal[btnId]);
|
mapGenOptions.setHeight(mapSizeVal[btnId]);
|
||||||
updateMapInfo();
|
updateMapInfo();
|
||||||
@ -1706,7 +1705,7 @@ CRandomMapTab::CRandomMapTab()
|
|||||||
waterContentGroup = new CToggleGroup(0);
|
waterContentGroup = new CToggleGroup(0);
|
||||||
waterContentGroup->pos.y += 419;
|
waterContentGroup->pos.y += 419;
|
||||||
waterContentGroup->pos.x += BTNS_GROUP_LEFT_MARGIN;
|
waterContentGroup->pos.x += BTNS_GROUP_LEFT_MARGIN;
|
||||||
const std::vector<std::string> waterContentBtns = boost::assign::list_of("RANNONE")("RANNORM")("RANISLD");
|
const std::vector<std::string> waterContentBtns = {"RANNONE","RANNORM","RANISLD"};
|
||||||
addButtonsWithRandToGroup(waterContentGroup, waterContentBtns, 0, 2, WIDE_BTN_WIDTH, 243, 246);
|
addButtonsWithRandToGroup(waterContentGroup, waterContentBtns, 0, 2, WIDE_BTN_WIDTH, 243, 246);
|
||||||
waterContentGroup->addCallback([&](int btnId)
|
waterContentGroup->addCallback([&](int btnId)
|
||||||
{
|
{
|
||||||
@ -1717,7 +1716,7 @@ CRandomMapTab::CRandomMapTab()
|
|||||||
monsterStrengthGroup = new CToggleGroup(0);
|
monsterStrengthGroup = new CToggleGroup(0);
|
||||||
monsterStrengthGroup->pos.y += 485;
|
monsterStrengthGroup->pos.y += 485;
|
||||||
monsterStrengthGroup->pos.x += BTNS_GROUP_LEFT_MARGIN;
|
monsterStrengthGroup->pos.x += BTNS_GROUP_LEFT_MARGIN;
|
||||||
const std::vector<std::string> monsterStrengthBtns = boost::assign::list_of("RANWEAK")("RANNORM")("RANSTRG");
|
const std::vector<std::string> monsterStrengthBtns = {"RANWEAK","RANNORM","RANSTRG"};
|
||||||
addButtonsWithRandToGroup(monsterStrengthGroup, monsterStrengthBtns, 0, 2, WIDE_BTN_WIDTH, 248, 251);
|
addButtonsWithRandToGroup(monsterStrengthGroup, monsterStrengthBtns, 0, 2, WIDE_BTN_WIDTH, 248, 251);
|
||||||
monsterStrengthGroup->addCallback([&](int btnId)
|
monsterStrengthGroup->addCallback([&](int btnId)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "../lib/CStopWatch.h"
|
#include "../lib/CStopWatch.h"
|
||||||
#include "../lib/mapObjects/CObjectClassesHandler.h"
|
#include "../lib/mapObjects/CObjectClassesHandler.h"
|
||||||
|
|
||||||
using namespace boost::assign;
|
|
||||||
using namespace CSDL_Ext;
|
using namespace CSDL_Ext;
|
||||||
#ifdef min
|
#ifdef min
|
||||||
#undef min
|
#undef min
|
||||||
@ -157,9 +156,12 @@ Graphics::Graphics()
|
|||||||
|
|
||||||
void Graphics::loadHeroAnims()
|
void Graphics::loadHeroAnims()
|
||||||
{
|
{
|
||||||
std::vector<std::pair<int,int> > rotations; //first - group number to be rotated1, second - group number after rotation1
|
//first - group number to be rotated1, second - group number after rotation1
|
||||||
rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12), std::make_pair(1,13),
|
std::vector<std::pair<int,int> > rotations =
|
||||||
std::make_pair(2,14), std::make_pair(3,15);
|
{
|
||||||
|
{6,10}, {7,11}, {8,12}, {1,13},
|
||||||
|
{2,14}, {3,15}
|
||||||
|
};
|
||||||
|
|
||||||
for(auto & elem : CGI->heroh->classes.heroClasses)
|
for(auto & elem : CGI->heroh->classes.heroClasses)
|
||||||
{
|
{
|
||||||
@ -216,8 +218,12 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
|
|||||||
{
|
{
|
||||||
for(int i=0;i<8;i++)
|
for(int i=0;i<8;i++)
|
||||||
(this->*pr.first).push_back(CDefHandler::giveDefEss(pr.second[i]));
|
(this->*pr.first).push_back(CDefHandler::giveDefEss(pr.second[i]));
|
||||||
std::vector<std::pair<int,int> > rotations; //first - group number to be rotated1, second - group number after rotation1
|
//first - group number to be rotated1, second - group number after rotation1
|
||||||
rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12);
|
std::vector<std::pair<int,int> > rotations =
|
||||||
|
{
|
||||||
|
{6,10}, {7,11}, {8,12}
|
||||||
|
};
|
||||||
|
|
||||||
for(int q=0; q<8; ++q)
|
for(int q=0; q<8; ++q)
|
||||||
{
|
{
|
||||||
std::vector<Cimage> &curImgs = (this->*pr.first)[q]->ourImages;
|
std::vector<Cimage> &curImgs = (this->*pr.first)[q]->ourImages;
|
||||||
@ -269,21 +275,32 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
|
|||||||
|
|
||||||
void Graphics::loadHeroFlags()
|
void Graphics::loadHeroFlags()
|
||||||
{
|
{
|
||||||
using namespace boost::assign;
|
|
||||||
CStopWatch th;
|
CStopWatch th;
|
||||||
std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4];
|
std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4] =
|
||||||
pr[0].first = &Graphics::flags1;
|
{
|
||||||
pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"),
|
{
|
||||||
("ABF01P.DEF"),("ABF01W.DEF"),("ABF01K.DEF");
|
&Graphics::flags1,
|
||||||
pr[1].first = &Graphics::flags2;
|
{"ABF01L.DEF","ABF01G.DEF","ABF01R.DEF","ABF01D.DEF","ABF01B.DEF",
|
||||||
pr[1].second+=("ABF02L.DEF"),("ABF02G.DEF"),("ABF02R.DEF"),("ABF02D.DEF"),("ABF02B.DEF"),
|
"ABF01P.DEF","ABF01W.DEF","ABF01K.DEF"}
|
||||||
("ABF02P.DEF"),("ABF02W.DEF"),("ABF02K.DEF");
|
},
|
||||||
pr[2].first = &Graphics::flags3;
|
{
|
||||||
pr[2].second+=("ABF03L.DEF"),("ABF03G.DEF"),("ABF03R.DEF"),("ABF03D.DEF"),("ABF03B.DEF"),
|
&Graphics::flags2,
|
||||||
("ABF03P.DEF"),("ABF03W.DEF"),("ABF03K.DEF");
|
{"ABF02L.DEF","ABF02G.DEF","ABF02R.DEF","ABF02D.DEF","ABF02B.DEF",
|
||||||
pr[3].first = &Graphics::flags4;
|
"ABF02P.DEF","ABF02W.DEF","ABF02K.DEF"}
|
||||||
pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"),
|
|
||||||
("AF05.DEF"),("AF06.DEF"),("AF07.DEF");
|
},
|
||||||
|
{
|
||||||
|
&Graphics::flags3,
|
||||||
|
{"ABF03L.DEF","ABF03G.DEF","ABF03R.DEF","ABF03D.DEF","ABF03B.DEF",
|
||||||
|
"ABF03P.DEF","ABF03W.DEF","ABF03K.DEF"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
&Graphics::flags4,
|
||||||
|
{"AF00.DEF","AF01.DEF","AF02.DEF","AF03.DEF","AF04.DEF",
|
||||||
|
"AF05.DEF","AF06.DEF","AF07.DEF"}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
boost::thread_group grupa;
|
boost::thread_group grupa;
|
||||||
for(int g=3; g>=0; --g)
|
for(int g=3; g>=0; --g)
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include "../../lib/NetPacks.h"
|
#include "../../lib/NetPacks.h"
|
||||||
#include "../../lib/UnlockGuard.h"
|
#include "../../lib/UnlockGuard.h"
|
||||||
|
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CBattleInterface.cpp, part of VCMI engine
|
* CBattleInterface.cpp, part of VCMI engine
|
||||||
@ -1737,7 +1736,8 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
|
|||||||
possibleActions.clear();
|
possibleActions.clear();
|
||||||
if (tacticsMode)
|
if (tacticsMode)
|
||||||
{
|
{
|
||||||
possibleActions += MOVE_TACTICS, CHOOSE_TACTICS_STACK;
|
possibleActions.push_back(MOVE_TACTICS);
|
||||||
|
possibleActions.push_back(CHOOSE_TACTICS_STACK);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -692,8 +692,6 @@ CArtifactsOfHero::CArtifactsOfHero(std::vector<CArtPlace *> ArtWorn, std::vector
|
|||||||
CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart /*= false*/)
|
CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart /*= false*/)
|
||||||
: curHero(nullptr), backpackPos(0), commonInfo(nullptr), updateState(false), allowedAssembling(true), highlightModeCallback(nullptr)
|
: curHero(nullptr), backpackPos(0), commonInfo(nullptr), updateState(false), allowedAssembling(true), highlightModeCallback(nullptr)
|
||||||
{
|
{
|
||||||
using namespace boost::assign;
|
|
||||||
|
|
||||||
if(createCommonPart)
|
if(createCommonPart)
|
||||||
{
|
{
|
||||||
commonInfo = new CArtifactsOfHero::SCommonPart;
|
commonInfo = new CArtifactsOfHero::SCommonPart;
|
||||||
@ -704,14 +702,16 @@ CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart
|
|||||||
pos += position;
|
pos += position;
|
||||||
artWorn.resize(19);
|
artWorn.resize(19);
|
||||||
|
|
||||||
std::vector<Point> slotPos;
|
std::vector<Point> slotPos =
|
||||||
slotPos += Point(509,30), Point(567,240), Point(509,80),
|
{
|
||||||
Point(383,68), Point(564,183), Point(509,130),
|
Point(509,30), Point(567,240), Point(509,80),
|
||||||
Point(431,68), Point(610,183), Point(515,295),
|
Point(383,68), Point(564,183), Point(509,130),
|
||||||
Point(383,143), Point(399,194), Point(415,245),
|
Point(431,68), Point(610,183), Point(515,295),
|
||||||
Point(431,296), Point(564,30), Point(610,30),
|
Point(383,143), Point(399,194), Point(415,245),
|
||||||
Point(610,76), Point(610,122), Point(610,310),
|
Point(431,296), Point(564,30), Point(610,30),
|
||||||
Point(381,296);
|
Point(610,76), Point(610,122), Point(610,310),
|
||||||
|
Point(381,296)
|
||||||
|
};
|
||||||
|
|
||||||
// Create slots for worn artifacts.
|
// Create slots for worn artifacts.
|
||||||
for (size_t g = 0; g < GameConstants::BACKPACK_START ; g++)
|
for (size_t g = 0; g < GameConstants::BACKPACK_START ; g++)
|
||||||
|
@ -761,18 +761,20 @@ shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) cons
|
|||||||
|
|
||||||
BattlefieldBI::BattlefieldBI BattleInfo::battlefieldTypeToBI(BFieldType bfieldType)
|
BattlefieldBI::BattlefieldBI BattleInfo::battlefieldTypeToBI(BFieldType bfieldType)
|
||||||
{
|
{
|
||||||
static const std::map<BFieldType, BattlefieldBI::BattlefieldBI> theMap = boost::assign::map_list_of
|
static const std::map<BFieldType, BattlefieldBI::BattlefieldBI> theMap =
|
||||||
(BFieldType::CLOVER_FIELD, BattlefieldBI::CLOVER_FIELD)
|
{
|
||||||
(BFieldType::CURSED_GROUND, BattlefieldBI::CURSED_GROUND)
|
{BFieldType::CLOVER_FIELD, BattlefieldBI::CLOVER_FIELD},
|
||||||
(BFieldType::EVIL_FOG, BattlefieldBI::EVIL_FOG)
|
{BFieldType::CURSED_GROUND, BattlefieldBI::CURSED_GROUND},
|
||||||
(BFieldType::FAVOURABLE_WINDS, BattlefieldBI::NONE)
|
{BFieldType::EVIL_FOG, BattlefieldBI::EVIL_FOG},
|
||||||
(BFieldType::FIERY_FIELDS, BattlefieldBI::FIERY_FIELDS)
|
{BFieldType::FAVOURABLE_WINDS, BattlefieldBI::NONE},
|
||||||
(BFieldType::HOLY_GROUND, BattlefieldBI::HOLY_GROUND)
|
{BFieldType::FIERY_FIELDS, BattlefieldBI::FIERY_FIELDS},
|
||||||
(BFieldType::LUCID_POOLS, BattlefieldBI::LUCID_POOLS)
|
{BFieldType::HOLY_GROUND, BattlefieldBI::HOLY_GROUND},
|
||||||
(BFieldType::MAGIC_CLOUDS, BattlefieldBI::MAGIC_CLOUDS)
|
{BFieldType::LUCID_POOLS, BattlefieldBI::LUCID_POOLS},
|
||||||
(BFieldType::MAGIC_PLAINS, BattlefieldBI::MAGIC_PLAINS)
|
{BFieldType::MAGIC_CLOUDS, BattlefieldBI::MAGIC_CLOUDS},
|
||||||
(BFieldType::ROCKLANDS, BattlefieldBI::ROCKLANDS)
|
{BFieldType::MAGIC_PLAINS, BattlefieldBI::MAGIC_PLAINS},
|
||||||
(BFieldType::SAND_SHORE, BattlefieldBI::COASTAL);
|
{BFieldType::ROCKLANDS, BattlefieldBI::ROCKLANDS},
|
||||||
|
{BFieldType::SAND_SHORE, BattlefieldBI::COASTAL}
|
||||||
|
};
|
||||||
|
|
||||||
auto itr = theMap.find(bfieldType);
|
auto itr = theMap.find(bfieldType);
|
||||||
if(itr != theMap.end())
|
if(itr != theMap.end())
|
||||||
|
@ -45,7 +45,7 @@ using namespace boost::assign;
|
|||||||
ART_POS(RIGHT_HAND) \
|
ART_POS(RIGHT_HAND) \
|
||||||
ART_POS(NECK) \
|
ART_POS(NECK) \
|
||||||
ART_POS(SHOULDERS) \
|
ART_POS(SHOULDERS) \
|
||||||
ART_POS(HEAD);
|
ART_POS(HEAD)
|
||||||
|
|
||||||
const std::string & CArtifact::Name() const
|
const std::string & CArtifact::Name() const
|
||||||
{
|
{
|
||||||
@ -157,12 +157,12 @@ std::vector<JsonNode> CArtHandler::loadLegacyData(size_t dataSize)
|
|||||||
std::vector<JsonNode> h3Data;
|
std::vector<JsonNode> h3Data;
|
||||||
h3Data.reserve(dataSize);
|
h3Data.reserve(dataSize);
|
||||||
|
|
||||||
#define ART_POS(x) ( #x)
|
#define ART_POS(x) #x ,
|
||||||
const std::vector<std::string> artSlots = boost::assign::list_of ART_POS_LIST;
|
const std::vector<std::string> artSlots = { ART_POS_LIST };
|
||||||
#undef ART_POS
|
#undef ART_POS
|
||||||
|
|
||||||
static std::map<char, std::string> classes =
|
static std::map<char, std::string> classes =
|
||||||
map_list_of('S',"SPECIAL")('T',"TREASURE")('N',"MINOR")('J',"MAJOR")('R',"RELIC");
|
{{'S',"SPECIAL"}, {'T',"TREASURE"},{'N',"MINOR"},{'J',"MAJOR"},{'R',"RELIC"},};
|
||||||
|
|
||||||
CLegacyConfigParser parser("DATA/ARTRAITS.TXT");
|
CLegacyConfigParser parser("DATA/ARTRAITS.TXT");
|
||||||
CLegacyConfigParser events("DATA/ARTEVENT.TXT");
|
CLegacyConfigParser events("DATA/ARTEVENT.TXT");
|
||||||
@ -264,8 +264,8 @@ CArtifact * CArtHandler::loadFromJson(const JsonNode & node)
|
|||||||
|
|
||||||
ArtifactPosition CArtHandler::stringToSlot(std::string slotName)
|
ArtifactPosition CArtHandler::stringToSlot(std::string slotName)
|
||||||
{
|
{
|
||||||
#define ART_POS(x) ( #x, ArtifactPosition::x )
|
#define ART_POS(x) { #x, ArtifactPosition::x },
|
||||||
static const std::map<std::string, ArtifactPosition> artifactPositionMap = boost::assign::map_list_of ART_POS_LIST;
|
static const std::map<std::string, ArtifactPosition> artifactPositionMap = { ART_POS_LIST };
|
||||||
#undef ART_POS
|
#undef ART_POS
|
||||||
auto it = artifactPositionMap.find (slotName);
|
auto it = artifactPositionMap.find (slotName);
|
||||||
if (it != artifactPositionMap.end())
|
if (it != artifactPositionMap.end())
|
||||||
@ -309,12 +309,14 @@ void CArtHandler::loadSlots(CArtifact * art, const JsonNode & node)
|
|||||||
|
|
||||||
CArtifact::EartClass CArtHandler::stringToClass(std::string className)
|
CArtifact::EartClass CArtHandler::stringToClass(std::string className)
|
||||||
{
|
{
|
||||||
static const std::map<std::string, CArtifact::EartClass> artifactClassMap = boost::assign::map_list_of
|
static const std::map<std::string, CArtifact::EartClass> artifactClassMap =
|
||||||
("TREASURE", CArtifact::ART_TREASURE)
|
{
|
||||||
("MINOR", CArtifact::ART_MINOR)
|
{"TREASURE", CArtifact::ART_TREASURE},
|
||||||
("MAJOR", CArtifact::ART_MAJOR)
|
{"MINOR", CArtifact::ART_MINOR},
|
||||||
("RELIC", CArtifact::ART_RELIC)
|
{"MAJOR", CArtifact::ART_MAJOR},
|
||||||
("SPECIAL", CArtifact::ART_SPECIAL);
|
{"RELIC", CArtifact::ART_RELIC},
|
||||||
|
{"SPECIAL", CArtifact::ART_SPECIAL}
|
||||||
|
};
|
||||||
|
|
||||||
auto it = artifactClassMap.find (className);
|
auto it = artifactClassMap.find (className);
|
||||||
if (it != artifactClassMap.end())
|
if (it != artifactClassMap.end())
|
||||||
@ -331,8 +333,8 @@ void CArtHandler::loadClass(CArtifact * art, const JsonNode & node)
|
|||||||
|
|
||||||
void CArtHandler::loadType(CArtifact * art, const JsonNode & node)
|
void CArtHandler::loadType(CArtifact * art, const JsonNode & node)
|
||||||
{
|
{
|
||||||
#define ART_BEARER(x) ( #x, ArtBearer::x )
|
#define ART_BEARER(x) { #x, ArtBearer::x },
|
||||||
static const std::map<std::string, int> artifactBearerMap = boost::assign::map_list_of ART_BEARER_LIST;
|
static const std::map<std::string, int> artifactBearerMap = { ART_BEARER_LIST };
|
||||||
#undef ART_BEARER
|
#undef ART_BEARER
|
||||||
|
|
||||||
for (const JsonNode & b : node["type"].Vector())
|
for (const JsonNode & b : node["type"].Vector())
|
||||||
|
@ -15,21 +15,26 @@
|
|||||||
BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
|
BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
|
||||||
{
|
{
|
||||||
using namespace boost::assign;
|
using namespace boost::assign;
|
||||||
static const std::vector<BuildingID> campToERMU = list_of(BuildingID::TOWN_HALL)(BuildingID::CITY_HALL)
|
static const std::vector<BuildingID> campToERMU =
|
||||||
(BuildingID::CAPITOL)(BuildingID::FORT)(BuildingID::CITADEL)(BuildingID::CASTLE)(BuildingID::TAVERN)
|
{
|
||||||
(BuildingID::BLACKSMITH)(BuildingID::MARKETPLACE)(BuildingID::RESOURCE_SILO)(BuildingID::NONE)
|
BuildingID::TOWN_HALL, BuildingID::CITY_HALL,
|
||||||
(BuildingID::MAGES_GUILD_1)(BuildingID::MAGES_GUILD_2)(BuildingID::MAGES_GUILD_3)(BuildingID::MAGES_GUILD_4)
|
BuildingID::CAPITOL, BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::TAVERN,
|
||||||
(BuildingID::MAGES_GUILD_5)
|
BuildingID::BLACKSMITH, BuildingID::MARKETPLACE, BuildingID::RESOURCE_SILO, BuildingID::NONE,
|
||||||
(BuildingID::SHIPYARD)(BuildingID::GRAIL)
|
BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3, BuildingID::MAGES_GUILD_4,
|
||||||
(BuildingID::SPECIAL_1)(BuildingID::SPECIAL_2)(BuildingID::SPECIAL_3)(BuildingID::SPECIAL_4)
|
BuildingID::MAGES_GUILD_5,
|
||||||
; //creature generators with banks - handled separately
|
BuildingID::SHIPYARD, BuildingID::GRAIL,
|
||||||
|
BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3, BuildingID::SPECIAL_4
|
||||||
|
}; //creature generators with banks - handled separately
|
||||||
|
|
||||||
if (camp < campToERMU.size())
|
if (camp < campToERMU.size())
|
||||||
{
|
{
|
||||||
return campToERMU[camp];
|
return campToERMU[camp];
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2),
|
static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] =
|
||||||
list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)};
|
{
|
||||||
|
{2}, {1}, {1,4}, {0,2}, {0}, {0}, {0}, {0}, {0}
|
||||||
|
};
|
||||||
|
|
||||||
int curPos = campToERMU.size();
|
int curPos = campToERMU.size();
|
||||||
for (int i=0; i<GameConstants::CREATURES_PER_TOWN; ++i)
|
for (int i=0; i<GameConstants::CREATURES_PER_TOWN; ++i)
|
||||||
|
@ -232,22 +232,23 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const std::map<std::string, JsonNode> abilityMap =
|
static const std::map<std::string, JsonNode> abilityMap =
|
||||||
boost::assign::map_list_of
|
{
|
||||||
("FLYING_ARMY", makeBonusNode("FLYING"))
|
{"FLYING_ARMY", makeBonusNode("FLYING")},
|
||||||
("SHOOTING_ARMY", makeBonusNode("SHOOTER"))
|
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
|
||||||
("SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON"))
|
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
|
||||||
("const_free_attack", makeBonusNode("BLOCKS_RETALIATION"))
|
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
|
||||||
("IS_UNDEAD", makeBonusNode("UNDEAD"))
|
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
|
||||||
("const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY"))
|
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
|
||||||
("const_jousting", makeBonusNode("JOUSTING"))
|
{"const_jousting", makeBonusNode("JOUSTING")},
|
||||||
("KING_1", makeBonusNode("KING1"))
|
{"KING_1", makeBonusNode("KING1")},
|
||||||
("KING_2", makeBonusNode("KING2"))
|
{"KING_2", makeBonusNode("KING2")},
|
||||||
("KING_3", makeBonusNode("KING3"))
|
{"KING_3", makeBonusNode("KING3")},
|
||||||
("const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY"))
|
{"const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY")},
|
||||||
("CATAPULT", makeBonusNode("CATAPULT"))
|
{"CATAPULT", makeBonusNode("CATAPULT")},
|
||||||
("MULTI_HEADED", makeBonusNode("ATTACKS_ALL_ADJACENT"))
|
{"MULTI_HEADED", makeBonusNode("ATTACKS_ALL_ADJACENT")},
|
||||||
("IMMUNE_TO_MIND_SPELLS", makeBonusNode("MIND_IMMUNITY"))
|
{"IMMUNE_TO_MIND_SPELLS", makeBonusNode("MIND_IMMUNITY")},
|
||||||
("HAS_EXTENDED_ATTACK", makeBonusNode("TWO_HEX_ATTACK_BREATH"));
|
{"HAS_EXTENDED_ATTACK", makeBonusNode("TWO_HEX_ATTACK_BREATH")}
|
||||||
|
};
|
||||||
|
|
||||||
auto hasAbility = [&](const std::string name) -> bool
|
auto hasAbility = [&](const std::string name) -> bool
|
||||||
{
|
{
|
||||||
|
@ -100,23 +100,25 @@ bool PlayerColor::isValidPlayer() const
|
|||||||
|
|
||||||
std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType)
|
std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType)
|
||||||
{
|
{
|
||||||
static const std::map<Battle::ActionType, std::string> actionTypeToString = boost::assign::map_list_of
|
static const std::map<Battle::ActionType, std::string> actionTypeToString =
|
||||||
(Battle::END_TACTIC_PHASE, "End tactic phase")
|
{
|
||||||
(Battle::INVALID, "Invalid")
|
{Battle::END_TACTIC_PHASE, "End tactic phase"},
|
||||||
(Battle::NO_ACTION, "No action")
|
{Battle::INVALID, "Invalid"},
|
||||||
(Battle::HERO_SPELL, "Hero spell")
|
{Battle::NO_ACTION, "No action"},
|
||||||
(Battle::WALK, "Walk")
|
{Battle::HERO_SPELL, "Hero spell"},
|
||||||
(Battle::DEFEND, "Defend")
|
{Battle::WALK, "Walk"},
|
||||||
(Battle::RETREAT, "Retreat")
|
{Battle::DEFEND, "Defend"},
|
||||||
(Battle::SURRENDER, "Surrender")
|
{Battle::RETREAT, "Retreat"},
|
||||||
(Battle::WALK_AND_ATTACK, "Walk and attack")
|
{Battle::SURRENDER, "Surrender"},
|
||||||
(Battle::SHOOT, "Shoot")
|
{Battle::WALK_AND_ATTACK, "Walk and attack"},
|
||||||
(Battle::WAIT, "Wait")
|
{Battle::SHOOT, "Shoot"},
|
||||||
(Battle::CATAPULT, "Catapult")
|
{Battle::WAIT, "Wait"},
|
||||||
(Battle::MONSTER_SPELL, "Monster spell")
|
{Battle::CATAPULT, "Catapult"},
|
||||||
(Battle::BAD_MORALE, "Bad morale")
|
{Battle::MONSTER_SPELL, "Monster spell"},
|
||||||
(Battle::STACK_HEAL, "Stack heal")
|
{Battle::BAD_MORALE, "Bad morale"},
|
||||||
(Battle::DAEMON_SUMMONING, "Daemon summoning");
|
{Battle::STACK_HEAL, "Stack heal"},
|
||||||
|
{Battle::DAEMON_SUMMONING, "Daemon summoning"}
|
||||||
|
};
|
||||||
|
|
||||||
auto it = actionTypeToString.find(actionType);
|
auto it = actionTypeToString.find(actionType);
|
||||||
if (it == actionTypeToString.end()) return os << "<Unknown type>";
|
if (it == actionTypeToString.end()) return os << "<Unknown type>";
|
||||||
|
@ -26,21 +26,22 @@
|
|||||||
#define FOREACH_RED_CHILD(pname) TNodes lchildren; getRedChildren(lchildren); for(CBonusSystemNode *pname : lchildren)
|
#define FOREACH_RED_CHILD(pname) TNodes lchildren; getRedChildren(lchildren); for(CBonusSystemNode *pname : lchildren)
|
||||||
#define FOREACH_RED_PARENT(pname) TNodes lparents; getRedParents(lparents); for(CBonusSystemNode *pname : lparents)
|
#define FOREACH_RED_PARENT(pname) TNodes lparents; getRedParents(lparents); for(CBonusSystemNode *pname : lparents)
|
||||||
|
|
||||||
#define BONUS_NAME(x) ( #x, Bonus::x )
|
#define BONUS_NAME(x) { #x, Bonus::x },
|
||||||
const std::map<std::string, Bonus::BonusType> bonusNameMap = boost::assign::map_list_of BONUS_LIST;
|
const std::map<std::string, Bonus::BonusType> bonusNameMap = { BONUS_LIST };
|
||||||
#undef BONUS_NAME
|
#undef BONUS_NAME
|
||||||
|
|
||||||
#define BONUS_VALUE(x) ( #x, Bonus::x )
|
#define BONUS_VALUE(x) { #x, Bonus::x },
|
||||||
const std::map<std::string, Bonus::ValueType> bonusValueMap = boost::assign::map_list_of BONUS_VALUE_LIST;
|
const std::map<std::string, Bonus::ValueType> bonusValueMap = { BONUS_VALUE_LIST };
|
||||||
#undef BONUS_VALUE
|
#undef BONUS_VALUE
|
||||||
|
|
||||||
#define BONUS_SOURCE(x) ( #x, Bonus::x )
|
#define BONUS_SOURCE(x) { #x, Bonus::x },
|
||||||
const std::map<std::string, Bonus::BonusSource> bonusSourceMap = boost::assign::map_list_of BONUS_SOURCE_LIST;
|
const std::map<std::string, Bonus::BonusSource> bonusSourceMap = { BONUS_SOURCE_LIST };
|
||||||
#undef BONUS_SOURCE
|
#undef BONUS_SOURCE
|
||||||
|
|
||||||
#define BONUS_ITEM(x) ( #x, Bonus::x )
|
#define BONUS_ITEM(x) { #x, Bonus::x },
|
||||||
|
|
||||||
const std::map<std::string, ui16> bonusDurationMap = boost::assign::map_list_of
|
const std::map<std::string, ui16> bonusDurationMap =
|
||||||
|
{
|
||||||
BONUS_ITEM(PERMANENT)
|
BONUS_ITEM(PERMANENT)
|
||||||
BONUS_ITEM(ONE_BATTLE)
|
BONUS_ITEM(ONE_BATTLE)
|
||||||
BONUS_ITEM(ONE_DAY)
|
BONUS_ITEM(ONE_DAY)
|
||||||
@ -50,26 +51,33 @@ const std::map<std::string, ui16> bonusDurationMap = boost::assign::map_list_of
|
|||||||
BONUS_ITEM(UNITL_BEING_ATTACKED)
|
BONUS_ITEM(UNITL_BEING_ATTACKED)
|
||||||
BONUS_ITEM(UNTIL_ATTACK)
|
BONUS_ITEM(UNTIL_ATTACK)
|
||||||
BONUS_ITEM(STACK_GETS_TURN)
|
BONUS_ITEM(STACK_GETS_TURN)
|
||||||
BONUS_ITEM(COMMANDER_KILLED);
|
BONUS_ITEM(COMMANDER_KILLED)
|
||||||
|
};
|
||||||
|
|
||||||
const std::map<std::string, Bonus::LimitEffect> bonusLimitEffect = boost::assign::map_list_of
|
const std::map<std::string, Bonus::LimitEffect> bonusLimitEffect =
|
||||||
|
{
|
||||||
BONUS_ITEM(NO_LIMIT)
|
BONUS_ITEM(NO_LIMIT)
|
||||||
BONUS_ITEM(ONLY_DISTANCE_FIGHT)
|
BONUS_ITEM(ONLY_DISTANCE_FIGHT)
|
||||||
BONUS_ITEM(ONLY_MELEE_FIGHT)
|
BONUS_ITEM(ONLY_MELEE_FIGHT)
|
||||||
BONUS_ITEM(ONLY_ENEMY_ARMY);
|
BONUS_ITEM(ONLY_ENEMY_ARMY)
|
||||||
|
};
|
||||||
|
|
||||||
const std::map<std::string, TLimiterPtr> bonusLimiterMap = boost::assign::map_list_of
|
const std::map<std::string, TLimiterPtr> bonusLimiterMap =
|
||||||
("SHOOTER_ONLY", make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER))
|
{
|
||||||
("DRAGON_NATURE", make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE))
|
{"SHOOTER_ONLY", make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER)},
|
||||||
("IS_UNDEAD", make_shared<HasAnotherBonusLimiter>(Bonus::UNDEAD));
|
{"DRAGON_NATURE", make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE)},
|
||||||
|
{"IS_UNDEAD", make_shared<HasAnotherBonusLimiter>(Bonus::UNDEAD)}
|
||||||
|
};
|
||||||
|
|
||||||
const std::map<std::string, TPropagatorPtr> bonusPropagatorMap = boost::assign::map_list_of
|
const std::map<std::string, TPropagatorPtr> bonusPropagatorMap =
|
||||||
("BATTLE_WIDE", make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE))
|
{
|
||||||
("VISITED_TOWN_AND_VISITOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR))
|
{"BATTLE_WIDE", make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE)},
|
||||||
("PLAYER_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER))
|
{"VISITED_TOWN_AND_VISITOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR)},
|
||||||
("HERO", make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO))
|
{"PLAYER_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER)},
|
||||||
("TEAM_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)) //untested
|
{"HERO", make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO)},
|
||||||
("GLOBAL_EFFECT", make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)); //untested
|
{"TEAM_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)}, //untested
|
||||||
|
{"GLOBAL_EFFECT", make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)}
|
||||||
|
}; //untested
|
||||||
|
|
||||||
|
|
||||||
#define BONUS_LOG_LINE(x) logBonus->traceStream() << x
|
#define BONUS_LOG_LINE(x) logBonus->traceStream() << x
|
||||||
|
@ -507,10 +507,14 @@ bool JsonParser::error(const std::string &message, bool warning)
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
static const std::unordered_map<std::string, JsonNode::JsonType> stringToType =
|
static const std::unordered_map<std::string, JsonNode::JsonType> stringToType =
|
||||||
boost::assign::map_list_of
|
{
|
||||||
("null", JsonNode::DATA_NULL) ("boolean", JsonNode::DATA_BOOL)
|
{"null", JsonNode::DATA_NULL},
|
||||||
("number", JsonNode::DATA_FLOAT) ("string", JsonNode::DATA_STRING)
|
{"boolean", JsonNode::DATA_BOOL},
|
||||||
("array", JsonNode::DATA_VECTOR) ("object", JsonNode::DATA_STRUCT);
|
{"number", JsonNode::DATA_FLOAT},
|
||||||
|
{"string", JsonNode::DATA_STRING},
|
||||||
|
{"array", JsonNode::DATA_VECTOR},
|
||||||
|
{"object", JsonNode::DATA_STRUCT}
|
||||||
|
};
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -86,42 +86,43 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const std::map<std::string, EResType::Type> stringToRes =
|
static const std::map<std::string, EResType::Type> stringToRes =
|
||||||
boost::assign::map_list_of
|
{
|
||||||
(".TXT", EResType::TEXT)
|
{".TXT", EResType::TEXT},
|
||||||
(".JSON", EResType::TEXT)
|
{".JSON", EResType::TEXT},
|
||||||
(".DEF", EResType::ANIMATION)
|
{".DEF", EResType::ANIMATION},
|
||||||
(".MSK", EResType::MASK)
|
{".MSK", EResType::MASK},
|
||||||
(".MSG", EResType::MASK)
|
{".MSG", EResType::MASK},
|
||||||
(".H3C", EResType::CAMPAIGN)
|
{".H3C", EResType::CAMPAIGN},
|
||||||
(".H3M", EResType::MAP)
|
{".H3M", EResType::MAP},
|
||||||
(".FNT", EResType::BMP_FONT)
|
{".FNT", EResType::BMP_FONT},
|
||||||
(".TTF", EResType::TTF_FONT)
|
{".TTF", EResType::TTF_FONT},
|
||||||
(".BMP", EResType::IMAGE)
|
{".BMP", EResType::IMAGE},
|
||||||
(".JPG", EResType::IMAGE)
|
{".JPG", EResType::IMAGE},
|
||||||
(".PCX", EResType::IMAGE)
|
{".PCX", EResType::IMAGE},
|
||||||
(".PNG", EResType::IMAGE)
|
{".PNG", EResType::IMAGE},
|
||||||
(".TGA", EResType::IMAGE)
|
{".TGA", EResType::IMAGE},
|
||||||
(".WAV", EResType::SOUND)
|
{".WAV", EResType::SOUND},
|
||||||
(".82M", EResType::SOUND)
|
{".82M", EResType::SOUND},
|
||||||
(".SMK", EResType::VIDEO)
|
{".SMK", EResType::VIDEO},
|
||||||
(".BIK", EResType::VIDEO)
|
{".BIK", EResType::VIDEO},
|
||||||
(".MJPG", EResType::VIDEO)
|
{".MJPG", EResType::VIDEO},
|
||||||
(".MPG", EResType::VIDEO)
|
{".MPG", EResType::VIDEO},
|
||||||
(".AVI", EResType::VIDEO)
|
{".AVI", EResType::VIDEO},
|
||||||
(".MP3", EResType::MUSIC)
|
{".MP3", EResType::MUSIC},
|
||||||
(".OGG", EResType::MUSIC)
|
{".OGG", EResType::MUSIC},
|
||||||
(".FLAC", EResType::MUSIC)
|
{".FLAC", EResType::MUSIC},
|
||||||
(".ZIP", EResType::ARCHIVE_ZIP)
|
{".ZIP", EResType::ARCHIVE_ZIP},
|
||||||
(".LOD", EResType::ARCHIVE_LOD)
|
{".LOD", EResType::ARCHIVE_LOD},
|
||||||
(".PAC", EResType::ARCHIVE_LOD)
|
{".PAC", EResType::ARCHIVE_LOD},
|
||||||
(".VID", EResType::ARCHIVE_VID)
|
{".VID", EResType::ARCHIVE_VID},
|
||||||
(".SND", EResType::ARCHIVE_SND)
|
{".SND", EResType::ARCHIVE_SND},
|
||||||
(".PAL", EResType::PALETTE)
|
{".PAL", EResType::PALETTE},
|
||||||
(".VCGM1", EResType::CLIENT_SAVEGAME)
|
{".VCGM1", EResType::CLIENT_SAVEGAME},
|
||||||
(".VSGM1", EResType::SERVER_SAVEGAME)
|
{".VSGM1", EResType::SERVER_SAVEGAME},
|
||||||
(".ERM", EResType::ERM)
|
{".ERM", EResType::ERM},
|
||||||
(".ERT", EResType::ERT)
|
{".ERT", EResType::ERT},
|
||||||
(".ERS", EResType::ERS);
|
{".ERS", EResType::ERS}
|
||||||
|
};
|
||||||
|
|
||||||
auto iter = stringToRes.find(extension);
|
auto iter = stringToRes.find(extension);
|
||||||
if (iter == stringToRes.end())
|
if (iter == stringToRes.end())
|
||||||
@ -131,9 +132,10 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
|
|||||||
|
|
||||||
std::string EResTypeHelper::getEResTypeAsString(EResType::Type type)
|
std::string EResTypeHelper::getEResTypeAsString(EResType::Type type)
|
||||||
{
|
{
|
||||||
#define MAP_ENUM(value) (EResType::value, #value)
|
#define MAP_ENUM(value) {EResType::value, #value},
|
||||||
|
|
||||||
static const std::map<EResType::Type, std::string> stringToRes = boost::assign::map_list_of
|
static const std::map<EResType::Type, std::string> stringToRes =
|
||||||
|
{
|
||||||
MAP_ENUM(TEXT)
|
MAP_ENUM(TEXT)
|
||||||
MAP_ENUM(ANIMATION)
|
MAP_ENUM(ANIMATION)
|
||||||
MAP_ENUM(MASK)
|
MAP_ENUM(MASK)
|
||||||
@ -156,7 +158,8 @@ std::string EResTypeHelper::getEResTypeAsString(EResType::Type type)
|
|||||||
MAP_ENUM(ERM)
|
MAP_ENUM(ERM)
|
||||||
MAP_ENUM(ERT)
|
MAP_ENUM(ERT)
|
||||||
MAP_ENUM(ERS)
|
MAP_ENUM(ERS)
|
||||||
MAP_ENUM(OTHER);
|
MAP_ENUM(OTHER)
|
||||||
|
};
|
||||||
|
|
||||||
#undef MAP_ENUM
|
#undef MAP_ENUM
|
||||||
|
|
||||||
|
@ -87,12 +87,14 @@ void CBasicLogConfigurator::configure()
|
|||||||
|
|
||||||
ELogLevel::ELogLevel CBasicLogConfigurator::getLogLevel(const std::string & level)
|
ELogLevel::ELogLevel CBasicLogConfigurator::getLogLevel(const std::string & level)
|
||||||
{
|
{
|
||||||
static const std::map<std::string, ELogLevel::ELogLevel> levelMap = boost::assign::map_list_of
|
static const std::map<std::string, ELogLevel::ELogLevel> levelMap =
|
||||||
("trace", ELogLevel::TRACE)
|
{
|
||||||
("debug", ELogLevel::DEBUG)
|
{"trace", ELogLevel::TRACE},
|
||||||
("info", ELogLevel::INFO)
|
{"debug", ELogLevel::DEBUG},
|
||||||
("warn", ELogLevel::WARN)
|
{"info", ELogLevel::INFO},
|
||||||
("error", ELogLevel::ERROR);
|
{"warn", ELogLevel::WARN},
|
||||||
|
{"error", ELogLevel::ERROR},
|
||||||
|
};
|
||||||
|
|
||||||
const auto & levelPair = levelMap.find(level);
|
const auto & levelPair = levelMap.find(level);
|
||||||
if(levelPair != levelMap.end())
|
if(levelPair != levelMap.end())
|
||||||
@ -103,15 +105,17 @@ ELogLevel::ELogLevel CBasicLogConfigurator::getLogLevel(const std::string & leve
|
|||||||
|
|
||||||
EConsoleTextColor::EConsoleTextColor CBasicLogConfigurator::getConsoleColor(const std::string & colorName)
|
EConsoleTextColor::EConsoleTextColor CBasicLogConfigurator::getConsoleColor(const std::string & colorName)
|
||||||
{
|
{
|
||||||
static const std::map<std::string, EConsoleTextColor::EConsoleTextColor> colorMap = boost::assign::map_list_of
|
static const std::map<std::string, EConsoleTextColor::EConsoleTextColor> colorMap =
|
||||||
("default", EConsoleTextColor::DEFAULT)
|
{
|
||||||
("green", EConsoleTextColor::GREEN)
|
{"default", EConsoleTextColor::DEFAULT},
|
||||||
("red", EConsoleTextColor::RED)
|
{"green", EConsoleTextColor::GREEN},
|
||||||
("magenta", EConsoleTextColor::MAGENTA)
|
{"red", EConsoleTextColor::RED},
|
||||||
("yellow", EConsoleTextColor::YELLOW)
|
{"magenta", EConsoleTextColor::MAGENTA},
|
||||||
("white", EConsoleTextColor::WHITE)
|
{"yellow", EConsoleTextColor::YELLOW},
|
||||||
("gray", EConsoleTextColor::GRAY)
|
{"white", EConsoleTextColor::WHITE},
|
||||||
("teal", EConsoleTextColor::TEAL);
|
{"gray", EConsoleTextColor::GRAY},
|
||||||
|
{"teal", EConsoleTextColor::TEAL},
|
||||||
|
};
|
||||||
|
|
||||||
const auto & colorPair = colorMap.find(colorName);
|
const auto & colorPair = colorMap.find(colorName);
|
||||||
if(colorPair != colorMap.end())
|
if(colorPair != colorMap.end())
|
||||||
|
@ -402,9 +402,14 @@ CTerrainViewPatternConfig::~CTerrainViewPatternConfig()
|
|||||||
|
|
||||||
ETerrainGroup::ETerrainGroup CTerrainViewPatternConfig::getTerrainGroup(const std::string & terGroup) const
|
ETerrainGroup::ETerrainGroup CTerrainViewPatternConfig::getTerrainGroup(const std::string & terGroup) const
|
||||||
{
|
{
|
||||||
static const std::map<std::string, ETerrainGroup::ETerrainGroup> terGroups
|
static const std::map<std::string, ETerrainGroup::ETerrainGroup> terGroups =
|
||||||
= boost::assign::map_list_of("normal", ETerrainGroup::NORMAL)("dirt", ETerrainGroup::DIRT)
|
{
|
||||||
("sand", ETerrainGroup::SAND)("water", ETerrainGroup::WATER)("rock", ETerrainGroup::ROCK);
|
{"normal", ETerrainGroup::NORMAL},
|
||||||
|
{"dirt", ETerrainGroup::DIRT},
|
||||||
|
{"sand", ETerrainGroup::SAND},
|
||||||
|
{"water", ETerrainGroup::WATER},
|
||||||
|
{"rock", ETerrainGroup::ROCK},
|
||||||
|
};
|
||||||
auto it = terGroups.find(terGroup);
|
auto it = terGroups.find(terGroup);
|
||||||
if(it == terGroups.end()) throw std::runtime_error(boost::str(boost::format("Terrain group '%s' does not exist.") % terGroup));
|
if(it == terGroups.end()) throw std::runtime_error(boost::str(boost::format("Terrain group '%s' does not exist.") % terGroup));
|
||||||
return it->second;
|
return it->second;
|
||||||
|
@ -199,8 +199,13 @@ CRmgTemplate::CSize CJsonRmgTemplateLoader::parseMapTemplateSize(const std::stri
|
|||||||
|
|
||||||
std::vector<std::string> parts;
|
std::vector<std::string> parts;
|
||||||
boost::split(parts, text, boost::is_any_of("+"));
|
boost::split(parts, text, boost::is_any_of("+"));
|
||||||
static const std::map<std::string, int> mapSizeMapping = boost::assign::map_list_of("s", CMapHeader::MAP_SIZE_SMALL)
|
static const std::map<std::string, int> mapSizeMapping =
|
||||||
("m", CMapHeader::MAP_SIZE_MIDDLE)("l", CMapHeader::MAP_SIZE_LARGE)("xl", CMapHeader::MAP_SIZE_XLARGE);
|
{
|
||||||
|
{"s", CMapHeader::MAP_SIZE_SMALL},
|
||||||
|
{"m", CMapHeader::MAP_SIZE_MIDDLE},
|
||||||
|
{"l", CMapHeader::MAP_SIZE_LARGE},
|
||||||
|
{"xl", CMapHeader::MAP_SIZE_XLARGE},
|
||||||
|
};
|
||||||
auto it = mapSizeMapping.find(parts[0]);
|
auto it = mapSizeMapping.find(parts[0]);
|
||||||
if(it == mapSizeMapping.end())
|
if(it == mapSizeMapping.end())
|
||||||
{
|
{
|
||||||
@ -224,9 +229,13 @@ CRmgTemplate::CSize CJsonRmgTemplateLoader::parseMapTemplateSize(const std::stri
|
|||||||
|
|
||||||
ETemplateZoneType::ETemplateZoneType CJsonRmgTemplateLoader::parseZoneType(const std::string & type) const
|
ETemplateZoneType::ETemplateZoneType CJsonRmgTemplateLoader::parseZoneType(const std::string & type) const
|
||||||
{
|
{
|
||||||
static const std::map<std::string, ETemplateZoneType::ETemplateZoneType> zoneTypeMapping = boost::assign::map_list_of
|
static const std::map<std::string, ETemplateZoneType::ETemplateZoneType> zoneTypeMapping =
|
||||||
("playerStart", ETemplateZoneType::PLAYER_START)("cpuStart", ETemplateZoneType::CPU_START)
|
{
|
||||||
("treasure", ETemplateZoneType::TREASURE)("junction", ETemplateZoneType::JUNCTION);
|
{"playerStart", ETemplateZoneType::PLAYER_START},
|
||||||
|
{"cpuStart", ETemplateZoneType::CPU_START},
|
||||||
|
{"treasure", ETemplateZoneType::TREASURE},
|
||||||
|
{"junction", ETemplateZoneType::JUNCTION},
|
||||||
|
};
|
||||||
auto it = zoneTypeMapping.find(type);
|
auto it = zoneTypeMapping.find(type);
|
||||||
if(it == zoneTypeMapping.end()) throw std::runtime_error("Zone type unknown.");
|
if(it == zoneTypeMapping.end()) throw std::runtime_error("Zone type unknown.");
|
||||||
return it->second;
|
return it->second;
|
||||||
@ -333,4 +342,4 @@ CRmgTemplateStorage::CRmgTemplateStorage()
|
|||||||
CRmgTemplateStorage::~CRmgTemplateStorage()
|
CRmgTemplateStorage::~CRmgTemplateStorage()
|
||||||
{
|
{
|
||||||
for (auto & pair : templates) delete pair.second;
|
for (auto & pair : templates) delete pair.second;
|
||||||
}
|
}
|
||||||
|
@ -704,7 +704,7 @@ void CGameHandler::battleAfterLevelUp( const BattleResult &result )
|
|||||||
visitObjectAfterVictory = false;
|
visitObjectAfterVictory = false;
|
||||||
|
|
||||||
//handle victory/loss of engaged players
|
//handle victory/loss of engaged players
|
||||||
std::set<PlayerColor> playerColors = boost::assign::list_of(finishingBattle->loser)(finishingBattle->victor);
|
std::set<PlayerColor> playerColors = {finishingBattle->loser, finishingBattle->victor};
|
||||||
checkVictoryLossConditions(playerColors);
|
checkVictoryLossConditions(playerColors);
|
||||||
|
|
||||||
if(result.result == BattleResult::SURRENDER || result.result == BattleResult::ESCAPE) //loser has escaped or surrendered
|
if(result.result == BattleResult::SURRENDER || result.result == BattleResult::ESCAPE) //loser has escaped or surrendered
|
||||||
@ -1819,7 +1819,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
|
|||||||
SetObjectProperty sop(obj->id, 1, owner.getNum());
|
SetObjectProperty sop(obj->id, 1, owner.getNum());
|
||||||
sendAndApply(&sop);
|
sendAndApply(&sop);
|
||||||
|
|
||||||
std::set<PlayerColor> playerColors = boost::assign::list_of(owner)(oldOwner);
|
std::set<PlayerColor> playerColors = {owner, oldOwner};
|
||||||
checkVictoryLossConditions(playerColors);
|
checkVictoryLossConditions(playerColors);
|
||||||
|
|
||||||
if(owner < PlayerColor::PLAYER_LIMIT && dynamic_cast<const CGTownInstance *>(obj)) //town captured
|
if(owner < PlayerColor::PLAYER_LIMIT && dynamic_cast<const CGTownInstance *>(obj)) //town captured
|
||||||
|
Loading…
Reference in New Issue
Block a user