mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
Artifact Merchant: selling artifacts. Messy, but completes H3 town structures functionalities.
BTW updating screen after closing marketplace is broken.
This commit is contained in:
@ -6798,7 +6798,19 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode)
|
||||
val2 = 1;
|
||||
}
|
||||
break;
|
||||
case ARTIFACT_RESOURCE:
|
||||
{
|
||||
float effectiveness = std::min(((float)getMarketEfficiency()+3.0f) / 20.0f, 0.6f);
|
||||
float r = VLC->arth->artifacts[id1]->price * effectiveness,
|
||||
g = VLC->objh->resVals[id2];
|
||||
|
||||
// if(id2 != 6) //non-gold prices are doubled
|
||||
// r /= 2;
|
||||
|
||||
val1 = 1;
|
||||
val2 = (r / g) + 0.5f;
|
||||
}
|
||||
break;
|
||||
case CREATURE_EXP:
|
||||
{
|
||||
val1 = 1;
|
||||
@ -7081,6 +7093,19 @@ si32 CArtifactSet::getArtPos(const CArtifactInstance *art) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
const CArtifactInstance * CArtifactSet::getArtByInstanceId(int artInstId) const
|
||||
{
|
||||
for(std::map<ui16, ArtSlotInfo>::const_iterator i = artifactsWorn.begin(); i != artifactsWorn.end(); i++)
|
||||
if(i->second.artifact->id == artInstId)
|
||||
return i->second.artifact;
|
||||
|
||||
for(int i = 0; i < artifactsInBackpack.size(); i++)
|
||||
if(artifactsInBackpack[i].artifact->id == artInstId)
|
||||
return artifactsInBackpack[i].artifact;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool CArtifactSet::hasArt(ui32 aid, bool onlyWorn /*= false*/) const
|
||||
{
|
||||
return getArtPos(aid, onlyWorn) != -1;
|
||||
@ -7154,4 +7179,4 @@ void CArtifactSet::eraseArtSlot(ui16 slot)
|
||||
slot -= Arts::BACKPACK_START;
|
||||
artifactsInBackpack.erase(artifactsInBackpack.begin() + slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user