mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-31 22:05:10 +02:00
Split enum EMonsterStrength into EMonsterStrength and EZoneMonsterStrength.
Removed obsolete ZONE_ and GLOBAL_ from enum item names. Simplified serialization of zone monster strength in preparation for adding zone monster strength: none.
This commit is contained in:
parent
9373239c03
commit
7f180b6e81
@ -310,11 +310,11 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
|
|||||||
|
|
||||||
if(monsterStrength == EMonsterStrength::RANDOM)
|
if(monsterStrength == EMonsterStrength::RANDOM)
|
||||||
{
|
{
|
||||||
monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG));
|
monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::WEAK, EMonsterStrength::STRONG));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (vstd::iswithin(waterContent, EWaterContent::NONE, EWaterContent::ISLANDS));
|
assert (vstd::iswithin(waterContent, EWaterContent::NONE, EWaterContent::ISLANDS));
|
||||||
assert (vstd::iswithin(monsterStrength, EMonsterStrength::GLOBAL_WEAK, EMonsterStrength::GLOBAL_STRONG));
|
assert (vstd::iswithin(monsterStrength, EMonsterStrength::WEAK, EMonsterStrength::STRONG));
|
||||||
|
|
||||||
|
|
||||||
//rectangular maps are the future of gaming
|
//rectangular maps are the future of gaming
|
||||||
|
@ -151,7 +151,7 @@ std::string CMapGenerator::getMapDescription() const
|
|||||||
const std::string waterContentStr[3] = { "none", "normal", "islands" };
|
const std::string waterContentStr[3] = { "none", "normal", "islands" };
|
||||||
const std::string monsterStrengthStr[3] = { "weak", "normal", "strong" };
|
const std::string monsterStrengthStr[3] = { "weak", "normal", "strong" };
|
||||||
|
|
||||||
int monsterStrengthIndex = mapGenOptions.getMonsterStrength() - EMonsterStrength::GLOBAL_WEAK; //does not start from 0
|
int monsterStrengthIndex = mapGenOptions.getMonsterStrength() - EMonsterStrength::WEAK; //does not start from 0
|
||||||
const auto * mapTemplate = mapGenOptions.getMapTemplate();
|
const auto * mapTemplate = mapGenOptions.getMapTemplate();
|
||||||
|
|
||||||
if(!mapTemplate)
|
if(!mapTemplate)
|
||||||
|
@ -140,7 +140,7 @@ ZoneOptions::ZoneOptions():
|
|||||||
owner(std::nullopt),
|
owner(std::nullopt),
|
||||||
matchTerrainToTown(true),
|
matchTerrainToTown(true),
|
||||||
townsAreSameType(false),
|
townsAreSameType(false),
|
||||||
zoneMonsterStrength(EMonsterStrength::ZONE_NORMAL),
|
monsterStrength(EZoneMonsterStrength::NORMAL),
|
||||||
minesLikeZone(NO_ZONE),
|
minesLikeZone(NO_ZONE),
|
||||||
terrainTypeLikeZone(NO_ZONE),
|
terrainTypeLikeZone(NO_ZONE),
|
||||||
treasureLikeZone(NO_ZONE)
|
treasureLikeZone(NO_ZONE)
|
||||||
@ -378,25 +378,14 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
|||||||
|
|
||||||
{
|
{
|
||||||
//TODO: add support for std::map to serializeEnum
|
//TODO: add support for std::map to serializeEnum
|
||||||
static const std::vector<std::string> STRENGTH =
|
static const std::vector<std::string> zoneMonsterStrengths =
|
||||||
{
|
{
|
||||||
"weak",
|
"weak",
|
||||||
"normal",
|
"normal",
|
||||||
"strong"
|
"strong"
|
||||||
};
|
};
|
||||||
|
|
||||||
si32 rawStrength = 0;
|
handler.serializeEnum("monsters", monsterStrength, EZoneMonsterStrength::NORMAL, zoneMonsterStrengths); // default is normal monsters
|
||||||
if(handler.saving)
|
|
||||||
{
|
|
||||||
rawStrength = static_cast<decltype(rawStrength)>(zoneMonsterStrength);
|
|
||||||
rawStrength++;
|
|
||||||
}
|
|
||||||
handler.serializeEnum("monsters", rawStrength, EMonsterStrength::ZONE_NORMAL + 1, STRENGTH);
|
|
||||||
if(!handler.saving)
|
|
||||||
{
|
|
||||||
rawStrength--;
|
|
||||||
zoneMonsterStrength = static_cast<decltype(zoneMonsterStrength)>(rawStrength);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(treasureLikeZone == NO_ZONE)
|
if(treasureLikeZone == NO_ZONE)
|
||||||
|
@ -41,17 +41,24 @@ namespace EWaterContent
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace EZoneMonsterStrength
|
||||||
|
{
|
||||||
|
enum EZoneMonsterStrength
|
||||||
|
{
|
||||||
|
WEAK,
|
||||||
|
NORMAL,
|
||||||
|
STRONG
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace EMonsterStrength
|
namespace EMonsterStrength
|
||||||
{
|
{
|
||||||
enum EMonsterStrength
|
enum EMonsterStrength
|
||||||
{
|
{
|
||||||
RANDOM = -2,
|
RANDOM = -1,
|
||||||
ZONE_WEAK = -1,
|
WEAK = 2,
|
||||||
ZONE_NORMAL = 0,
|
NORMAL = 3,
|
||||||
ZONE_STRONG = 1,
|
STRONG = 4
|
||||||
GLOBAL_WEAK = 2,
|
|
||||||
GLOBAL_NORMAL = 3,
|
|
||||||
GLOBAL_STRONG = 4
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +163,7 @@ public:
|
|||||||
|
|
||||||
void serializeJson(JsonSerializeFormat & handler);
|
void serializeJson(JsonSerializeFormat & handler);
|
||||||
|
|
||||||
EMonsterStrength::EMonsterStrength zoneMonsterStrength;
|
EZoneMonsterStrength::EZoneMonsterStrength monsterStrength;
|
||||||
|
|
||||||
bool areTownsSameType() const;
|
bool areTownsSameType() const;
|
||||||
bool isMatchTerrainToTown() const;
|
bool isMatchTerrainToTown() const;
|
||||||
|
@ -410,7 +410,7 @@ CGCreature * ObjectManager::chooseGuard(si32 strength, bool zoneGuard)
|
|||||||
//http://forum.vcmi.eu/viewtopic.php?p=12426#12426
|
//http://forum.vcmi.eu/viewtopic.php?p=12426#12426
|
||||||
|
|
||||||
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
|
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
|
||||||
int monsterStrength = (zoneGuard ? 0 : zone.zoneMonsterStrength) + mapMonsterStrength - 1; //array index from 0 to 4
|
int monsterStrength = (zoneGuard ? 0 : zone.monsterStrength - EZoneMonsterStrength::NORMAL) + mapMonsterStrength - 1; //array index from 0 to 4
|
||||||
static const std::array<int, 5> value1{2500, 1500, 1000, 500, 0};
|
static const std::array<int, 5> value1{2500, 1500, 1000, 500, 0};
|
||||||
static const std::array<int, 5> value2{7500, 7500, 7500, 5000, 5000};
|
static const std::array<int, 5> value2{7500, 7500, 7500, 5000, 5000};
|
||||||
static const std::array<float, 5> multiplier1{0.5, 0.75, 1.0, 1.5, 1.5};
|
static const std::array<float, 5> multiplier1{0.5, 0.75, 1.0, 1.5, 1.5};
|
||||||
|
@ -687,7 +687,7 @@ void TreasurePlacer::createTreasures(ObjectManager & manager)
|
|||||||
const int maxAttempts = 2;
|
const int maxAttempts = 2;
|
||||||
|
|
||||||
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
|
int mapMonsterStrength = map.getMapGenOptions().getMonsterStrength();
|
||||||
int monsterStrength = zone.zoneMonsterStrength + mapMonsterStrength - 1; //array index from 0 to 4
|
int monsterStrength = zone.monsterStrength - EZoneMonsterStrength::NORMAL + mapMonsterStrength - 1; //array index from 0 to 4
|
||||||
|
|
||||||
static int minGuardedValues[] = { 6500, 4167, 3000, 1833, 1333 };
|
static int minGuardedValues[] = { 6500, 4167, 3000, 1833, 1333 };
|
||||||
minGuardedValue = minGuardedValues[monsterStrength];
|
minGuardedValue = minGuardedValues[monsterStrength];
|
||||||
|
@ -143,11 +143,11 @@ void WindowNewMap::loadUserSettings()
|
|||||||
{
|
{
|
||||||
case EMonsterStrength::RANDOM:
|
case EMonsterStrength::RANDOM:
|
||||||
ui->monsterOpt1->setChecked(true); break;
|
ui->monsterOpt1->setChecked(true); break;
|
||||||
case EMonsterStrength::GLOBAL_WEAK:
|
case EMonsterStrength::WEAK:
|
||||||
ui->monsterOpt2->setChecked(true); break;
|
ui->monsterOpt2->setChecked(true); break;
|
||||||
case EMonsterStrength::GLOBAL_NORMAL:
|
case EMonsterStrength::NORMAL:
|
||||||
ui->monsterOpt3->setChecked(true); break;
|
ui->monsterOpt3->setChecked(true); break;
|
||||||
case EMonsterStrength::GLOBAL_STRONG:
|
case EMonsterStrength::STRONG:
|
||||||
ui->monsterOpt4->setChecked(true); break;
|
ui->monsterOpt4->setChecked(true); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,11 +199,11 @@ void WindowNewMap::saveUserSettings()
|
|||||||
if(ui->monsterOpt1->isChecked())
|
if(ui->monsterOpt1->isChecked())
|
||||||
monster = EMonsterStrength::RANDOM;
|
monster = EMonsterStrength::RANDOM;
|
||||||
else if(ui->monsterOpt2->isChecked())
|
else if(ui->monsterOpt2->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_WEAK;
|
monster = EMonsterStrength::WEAK;
|
||||||
else if(ui->monsterOpt3->isChecked())
|
else if(ui->monsterOpt3->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_NORMAL;
|
monster = EMonsterStrength::NORMAL;
|
||||||
else if(ui->monsterOpt4->isChecked())
|
else if(ui->monsterOpt4->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_STRONG;
|
monster = EMonsterStrength::STRONG;
|
||||||
s.setValue(newMapMonsterStrength, static_cast<int>(monster));
|
s.setValue(newMapMonsterStrength, static_cast<int>(monster));
|
||||||
|
|
||||||
auto templateName = ui->templateCombo->currentText();
|
auto templateName = ui->templateCombo->currentText();
|
||||||
@ -252,11 +252,11 @@ void WindowNewMap::on_okButton_clicked()
|
|||||||
if(ui->monsterOpt1->isChecked())
|
if(ui->monsterOpt1->isChecked())
|
||||||
monster = EMonsterStrength::RANDOM;
|
monster = EMonsterStrength::RANDOM;
|
||||||
if(ui->monsterOpt2->isChecked())
|
if(ui->monsterOpt2->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_WEAK;
|
monster = EMonsterStrength::WEAK;
|
||||||
if(ui->monsterOpt3->isChecked())
|
if(ui->monsterOpt3->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_NORMAL;
|
monster = EMonsterStrength::NORMAL;
|
||||||
if(ui->monsterOpt4->isChecked())
|
if(ui->monsterOpt4->isChecked())
|
||||||
monster = EMonsterStrength::GLOBAL_STRONG;
|
monster = EMonsterStrength::STRONG;
|
||||||
|
|
||||||
mapGenOptions.setWaterContent(water);
|
mapGenOptions.setWaterContent(water);
|
||||||
mapGenOptions.setMonsterStrength(monster);
|
mapGenOptions.setMonsterStrength(monster);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user