2012-11-21 12:13:33 +03:00
|
|
|
#include "StdInc.h"
|
2012-11-11 15:23:31 +03:00
|
|
|
#include "CMapGenOptions.h"
|
|
|
|
|
2013-01-06 22:30:12 +03:00
|
|
|
#include "../GameConstants.h"
|
|
|
|
|
2012-11-13 21:01:31 +03:00
|
|
|
CMapGenOptions::CMapGenOptions() : width(72), height(72), hasTwoLevels(true),
|
2013-01-06 22:30:12 +03:00
|
|
|
playersCnt(RANDOM_SIZE), teamsCnt(RANDOM_SIZE), compOnlyPlayersCnt(0), compOnlyTeamsCnt(RANDOM_SIZE),
|
2012-11-20 20:53:45 +03:00
|
|
|
waterContent(EWaterContent::RANDOM), monsterStrength(EMonsterStrength::RANDOM)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
si32 CMapGenOptions::getWidth() const
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2012-11-13 21:01:31 +03:00
|
|
|
return width;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
|
2013-01-06 22:30:12 +03:00
|
|
|
void CMapGenOptions::setWidth(si32 value)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2012-11-13 21:01:31 +03:00
|
|
|
if(value > 0)
|
|
|
|
{
|
|
|
|
width = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-06 22:30:12 +03:00
|
|
|
throw std::runtime_error("A map width lower than 1 is not allowed.");
|
2012-11-13 21:01:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
si32 CMapGenOptions::getHeight() const
|
2012-11-13 21:01:31 +03:00
|
|
|
{
|
|
|
|
return height;
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
void CMapGenOptions::setHeight(si32 value)
|
2012-11-13 21:01:31 +03:00
|
|
|
{
|
|
|
|
if(value > 0)
|
|
|
|
{
|
|
|
|
height = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-06 22:30:12 +03:00
|
|
|
throw std::runtime_error("A map height lower than 1 is not allowed.");
|
2012-11-13 21:01:31 +03:00
|
|
|
}
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CMapGenOptions::getHasTwoLevels() const
|
|
|
|
{
|
|
|
|
return hasTwoLevels;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMapGenOptions::setHasTwoLevels(bool value)
|
|
|
|
{
|
|
|
|
hasTwoLevels = value;
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
si8 CMapGenOptions::getPlayersCnt() const
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
return playersCnt;
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
void CMapGenOptions::setPlayersCnt(si8 value)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
if((value >= 1 && value <= PlayerColor::PLAYER_LIMIT_I) || value == RANDOM_SIZE)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
playersCnt = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-06 22:30:12 +03:00
|
|
|
throw std::runtime_error("Players count of RMG options should be between 1 and " +
|
2013-03-03 20:06:03 +03:00
|
|
|
boost::lexical_cast<std::string>(PlayerColor::PLAYER_LIMIT) + " or CMapGenOptions::RANDOM_SIZE for random.");
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
si8 CMapGenOptions::getTeamsCnt() const
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
return teamsCnt;
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
void CMapGenOptions::setTeamsCnt(si8 value)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2012-11-20 20:53:45 +03:00
|
|
|
if(playersCnt == RANDOM_SIZE || (value >= 0 && value < playersCnt) || value == RANDOM_SIZE)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
teamsCnt = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Teams count of RMG options should be between 0 and <" +
|
2013-01-06 22:30:12 +03:00
|
|
|
boost::lexical_cast<std::string>(playersCnt) + "(players count) - 1> or CMapGenOptions::RANDOM_SIZE for random.");
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
si8 CMapGenOptions::getCompOnlyPlayersCnt() const
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
return compOnlyPlayersCnt;
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
void CMapGenOptions::setCompOnlyPlayersCnt(si8 value)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2013-03-03 20:06:03 +03:00
|
|
|
if(value == RANDOM_SIZE || (value >= 0 && value <= PlayerColor::PLAYER_LIMIT_I - playersCnt))
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
compOnlyPlayersCnt = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw std::runtime_error(std::string("Computer only players count of RMG options should be ") +
|
2013-03-03 20:06:03 +03:00
|
|
|
"between 0 and <PlayerColor::PLAYER_LIMIT - " + boost::lexical_cast<std::string>(playersCnt) +
|
2013-01-06 22:30:12 +03:00
|
|
|
"(playersCount)> or CMapGenOptions::RANDOM_SIZE for random.");
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
si8 CMapGenOptions::getCompOnlyTeamsCnt() const
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
return compOnlyTeamsCnt;
|
|
|
|
}
|
|
|
|
|
2012-11-20 20:53:45 +03:00
|
|
|
void CMapGenOptions::setCompOnlyTeamsCnt(si8 value)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2013-01-06 22:30:12 +03:00
|
|
|
if(value == RANDOM_SIZE || compOnlyPlayersCnt == RANDOM_SIZE || (value >= 0 && value <= std::max(compOnlyPlayersCnt - 1, 0)))
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
compOnlyTeamsCnt = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw std::runtime_error(std::string("Computer only teams count of RMG options should be ") +
|
|
|
|
"between 0 and <" + boost::lexical_cast<std::string>(compOnlyPlayersCnt) +
|
2013-01-06 22:30:12 +03:00
|
|
|
"(compOnlyPlayersCnt) - 1> or CMapGenOptions::RANDOM_SIZE for random.");
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EWaterContent::EWaterContent CMapGenOptions::getWaterContent() const
|
|
|
|
{
|
|
|
|
return waterContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMapGenOptions::setWaterContent(EWaterContent::EWaterContent value)
|
|
|
|
{
|
|
|
|
waterContent = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
EMonsterStrength::EMonsterStrength CMapGenOptions::getMonsterStrength() const
|
|
|
|
{
|
|
|
|
return monsterStrength;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMapGenOptions::setMonsterStrength(EMonsterStrength::EMonsterStrength value)
|
|
|
|
{
|
|
|
|
monsterStrength = value;
|
|
|
|
}
|