1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-05-13 22:06:58 +02:00

Changed getQuantityRangeStringForId handling

This commit is contained in:
Dydzio 2023-01-15 16:19:55 +01:00
parent 8248feebf7
commit 804b164c75
2 changed files with 20 additions and 23 deletions

View File

@ -24,6 +24,19 @@
VCMI_LIB_NAMESPACE_BEGIN VCMI_LIB_NAMESPACE_BEGIN
const std::map<CCreature::CreatureQuantityId, std::string> CCreature::creatureQuantityRanges =
{
{CCreature::CreatureQuantityId::FEW, "1-4"},
{CCreature::CreatureQuantityId::SEVERAL, "5-9"},
{CCreature::CreatureQuantityId::PACK, "10-19"},
{CCreature::CreatureQuantityId::LOTS, "20-49"},
{CCreature::CreatureQuantityId::HORDE, "50-99"},
{CCreature::CreatureQuantityId::THRONG, "100-249"},
{CCreature::CreatureQuantityId::SWARM, "250-499"},
{CCreature::CreatureQuantityId::ZOUNDS, "500-999"},
{CCreature::CreatureQuantityId::LEGION, "1000+"}
};
int32_t CCreature::getIndex() const int32_t CCreature::getIndex() const
{ {
return idNumber.toEnum(); return idNumber.toEnum();
@ -195,30 +208,13 @@ CCreature::CreatureQuantityId CCreature::getQuantityID(const int & quantity)
std::string CCreature::getQuantityRangeStringForId(const CCreature::CreatureQuantityId & quantityId) std::string CCreature::getQuantityRangeStringForId(const CCreature::CreatureQuantityId & quantityId)
{ {
switch(quantityId) if(creatureQuantityRanges.find(quantityId) != creatureQuantityRanges.end())
{ return creatureQuantityRanges.at(quantityId);
case CCreature::CreatureQuantityId::FEW:
return "1-4"; logGlobal->error("Wrong quantityId: %d", (int)quantityId);
case CCreature::CreatureQuantityId::SEVERAL: assert(0);
return "5-9";
case CCreature::CreatureQuantityId::PACK:
return "10-19";
case CCreature::CreatureQuantityId::LOTS:
return "20-49";
case CCreature::CreatureQuantityId::HORDE:
return "50-99";
case CCreature::CreatureQuantityId::THRONG:
return "100-249";
case CCreature::CreatureQuantityId::SWARM:
return "250-499";
case CCreature::CreatureQuantityId::ZOUNDS:
return "500-999";
case CCreature::CreatureQuantityId::LEGION:
return "1000+";
default:
return "[ERROR]"; return "[ERROR]";
} }
}
int CCreature::estimateCreatureCount(ui32 countID) int CCreature::estimateCreatureCount(ui32 countID)
{ {

View File

@ -248,6 +248,7 @@ public:
private: private:
void fillWarMachine(); void fillWarMachine();
static const std::map<CreatureQuantityId, std::string> creatureQuantityRanges;
}; };
class DLL_LINKAGE CCreatureHandler : public CHandlerBase<CreatureID, Creature, CCreature, CreatureService> class DLL_LINKAGE CCreatureHandler : public CHandlerBase<CreatureID, Creature, CCreature, CreatureService>