mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
fixed random reward generation in CGVisitableOPW
This commit is contained in:
@@ -40,6 +40,12 @@ void Res::ResourceSet::amax(const TResourceCap &val)
|
|||||||
::vstd::amax(elem, val);
|
::vstd::amax(elem, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Res::ResourceSet::amin(const TResourceCap &val)
|
||||||
|
{
|
||||||
|
for(auto & elem : *this)
|
||||||
|
::vstd::amin(elem, val);
|
||||||
|
}
|
||||||
|
|
||||||
void Res::ResourceSet::positive()
|
void Res::ResourceSet::positive()
|
||||||
{
|
{
|
||||||
for(auto & elem : *this)
|
for(auto & elem : *this)
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ namespace Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
DLL_LINKAGE void amax(const TResourceCap &val); //performs vstd::amax on each element
|
DLL_LINKAGE void amax(const TResourceCap &val); //performs vstd::amax on each element
|
||||||
|
DLL_LINKAGE void amin(const TResourceCap &val); //performs vstd::amin on each element
|
||||||
DLL_LINKAGE void positive(); //values below 0 are set to 0 - upgrade cost can't be negative, for example
|
DLL_LINKAGE void positive(); //values below 0 are set to 0 - upgrade cost can't be negative, for example
|
||||||
DLL_LINKAGE bool nonZero() const; //returns true if at least one value is non-zero;
|
DLL_LINKAGE bool nonZero() const; //returns true if at least one value is non-zero;
|
||||||
DLL_LINKAGE bool canAfford(const ResourceSet &price) const;
|
DLL_LINKAGE bool canAfford(const ResourceSet &price) const;
|
||||||
|
|||||||
@@ -1108,25 +1108,27 @@ void CGVisitableOPW::setRandomReward(CRandomGenerator &rand)
|
|||||||
{
|
{
|
||||||
case Obj::MYSTICAL_GARDEN:
|
case Obj::MYSTICAL_GARDEN:
|
||||||
info.resize(1);
|
info.resize(1);
|
||||||
|
info[0].limiter.numOfGrants = 1;
|
||||||
|
info[0].reward.resources.amin(0);
|
||||||
if (rand.nextInt(1) == 0)
|
if (rand.nextInt(1) == 0)
|
||||||
{
|
{
|
||||||
info[0].reward.resources[Res::GEMS] = 5;
|
info[0].reward.resources[Res::GEMS] = 5;
|
||||||
info[0].limiter.numOfGrants = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info[0].reward.resources[Res::GOLD] = 500;
|
info[0].reward.resources[Res::GOLD] = 500;
|
||||||
info[0].limiter.numOfGrants = 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Obj::WINDMILL:
|
case Obj::WINDMILL:
|
||||||
info.resize(1);
|
info.resize(1);
|
||||||
|
info[0].reward.resources.amin(0);
|
||||||
// 3-6 of any resource but wood and gold
|
// 3-6 of any resource but wood and gold
|
||||||
info[0].reward.resources[rand.nextInt(Res::MERCURY, Res::GEMS)] = rand.nextInt(3, 6);
|
info[0].reward.resources[rand.nextInt(Res::MERCURY, Res::GEMS)] = rand.nextInt(3, 6);
|
||||||
info[0].limiter.numOfGrants = 1;
|
info[0].limiter.numOfGrants = 1;
|
||||||
break;
|
break;
|
||||||
case Obj::WATER_WHEEL:
|
case Obj::WATER_WHEEL:
|
||||||
info.resize(1);
|
info.resize(1);
|
||||||
|
info[0].reward.resources.amin(0);
|
||||||
info[0].reward.resources[Res::GOLD] = 500;
|
info[0].reward.resources[Res::GOLD] = 500;
|
||||||
info[0].limiter.numOfGrants = 1;
|
info[0].limiter.numOfGrants = 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user