1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

introduce toResourceType

This commit is contained in:
Laserlicht
2025-09-15 00:08:18 +02:00
parent acd067e587
commit d808bd6412
34 changed files with 160 additions and 102 deletions

View File

@@ -471,7 +471,7 @@ int32_t getArtifactBonusScoreImpl(const std::shared_ptr<Bonus> & bonus)
case BonusType::UNDEAD_RAISE_PERCENTAGE:
return bonus->val * 400;
case BonusType::GENERATE_RESOURCE:
return bonus->val * LIBRARY->resourceTypeHandler->getById(bonus->subtype.as<GameResID>())->getPrice() * 10;
return bonus->val * bonus->subtype.as<GameResID>().toResource()->getPrice() * 10;
case BonusType::SPELL_DURATION:
return bonus->val * 200;
case BonusType::MAGIC_RESISTANCE:

View File

@@ -44,13 +44,13 @@ std::string AbstractGoal::toString() const
switch(goalType)
{
case COLLECT_RES:
desc = "COLLECT RESOURCE " + LIBRARY->resourceTypeHandler->getById(resID)->getJsonKey() + " (" + std::to_string(value) + ")";
desc = "COLLECT RESOURCE " + GameResID(resID).toResource()->getJsonKey() + " (" + std::to_string(value) + ")";
break;
case TRADE:
{
auto obj = cb->getObjInstance(ObjectInstanceID(objid));
if (obj)
desc = (boost::format("TRADE %d of %s at %s") % value % LIBRARY->resourceTypeHandler->getById(resID)->getJsonKey() % obj->getObjectName()).str();
desc = (boost::format("TRADE %d of %s at %s") % value % GameResID(resID).toResource()->getJsonKey() % obj->getObjectName()).str();
}
break;
case GATHER_TROOPS:

View File

@@ -57,13 +57,13 @@ std::string AbstractGoal::name() const //TODO: virtualize
case BUILD_STRUCTURE:
return "BUILD STRUCTURE";
case COLLECT_RES:
desc = "COLLECT RESOURCE " + LIBRARY->resourceTypeHandler->getById(resID)->getJsonKey() + " (" + std::to_string(value) + ")";
desc = "COLLECT RESOURCE " + GameResID(resID).toResource()->getJsonKey() + " (" + std::to_string(value) + ")";
break;
case TRADE:
{
auto obj = cb->getObjInstance(ObjectInstanceID(objid));
if (obj)
desc = (boost::format("TRADE %d of %s at %s") % value % LIBRARY->resourceTypeHandler->getById(resID)->getJsonKey() % obj->getObjectName()).str();
desc = (boost::format("TRADE %d of %s at %s") % value % GameResID(resID).toResource()->getJsonKey() % obj->getObjectName()).str();
}
break;
case GATHER_TROOPS: