1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fix Campfire Gold reward amount. Now always one of 400/500/600

This commit is contained in:
Ivan Savenko 2023-01-28 00:01:10 +02:00
parent d82822d37a
commit a2cd17197e
2 changed files with 10 additions and 4 deletions

View File

@ -35,8 +35,7 @@
},
{
"type" : "gold",
"min" : 400,
"max" : 600
"amount" : [ 400, 500, 600 ]
}
]
}

View File

@ -31,10 +31,17 @@ namespace JsonRandom
return defaultValue;
if (value.isNumber())
return static_cast<si32>(value.Float());
if (value.isVector())
{
const auto & vector = value.Vector();
size_t index= rng.getIntRange(0, vector.size()-1)();
return loadValue(vector[index], rng, 0);
}
if (!value["amount"].isNull())
return static_cast<si32>(loadValue(value["amount"], rng, defaultValue));
si32 min = static_cast<si32>(value["min"].Float());
si32 max = static_cast<si32>(value["max"].Float());
si32 min = static_cast<si32>(loadValue(value["min"], rng, 0));
si32 max = static_cast<si32>(loadValue(value["max"], rng, 0));
return rng.getIntRange(min, max)();
}