1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +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

@@ -33,8 +33,8 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode)
{
double effectiveness = std::min((getMarketEfficiency() + 1.0) / 20.0, 0.5);
double r = LIBRARY->resourceTypeHandler->getById(id1)->getPrice(); //value of given resource
double g = LIBRARY->resourceTypeHandler->getById(id2)->getPrice() / effectiveness; //value of wanted resource
double r = GameResID(id1).toResource()->getPrice(); //value of given resource
double g = GameResID(id2).toResource()->getPrice() / effectiveness; //value of wanted resource
if(r>g) //if given resource is more expensive than wanted
{
@@ -54,7 +54,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode)
double effectiveness = effectivenessArray[std::min(getMarketEfficiency(), 8)];
double r = LIBRARY->creatures()->getByIndex(id1)->getRecruitCost(EGameResID::GOLD); //value of given creature in gold
double g = LIBRARY->resourceTypeHandler->getById(id2)->getPrice() / effectiveness; //value of wanted resource
double g = GameResID(id2).toResource()->getPrice() / effectiveness; //value of wanted resource
if(r>g) //if given resource is more expensive than wanted
{
@@ -75,7 +75,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode)
case EMarketMode::RESOURCE_ARTIFACT:
{
double effectiveness = std::min((getMarketEfficiency() + 3.0) / 20.0, 0.6);
double r = LIBRARY->resourceTypeHandler->getById(id1)->getPrice(); //value of offered resource
double r = GameResID(id1).toResource()->getPrice(); //value of offered resource
double g = LIBRARY->artifacts()->getByIndex(id2)->getPrice() / effectiveness; //value of bought artifact in gold
if(id1 != 6) //non-gold prices are doubled
@@ -89,7 +89,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode)
{
double effectiveness = std::min((getMarketEfficiency() + 3.0) / 20.0, 0.6);
double r = LIBRARY->artifacts()->getByIndex(id1)->getPrice() * effectiveness;
double g = LIBRARY->resourceTypeHandler->getById(id2)->getPrice();
double g = GameResID(id2).toResource()->getPrice();
// if(id2 != 6) //non-gold prices are doubled
// r /= 2;