1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Implemented basic version of configurable Witch Hut

This commit is contained in:
Ivan Savenko
2023-09-30 18:47:47 +03:00
parent 79b7518b0e
commit fd01a25352
28 changed files with 316 additions and 296 deletions

View File

@@ -24,6 +24,38 @@ ui16 Rewardable::Configuration::getResetDuration() const
return resetParameters.period;
}
std::optional<int> Rewardable::Configuration::getVariable(const std::string & category, const std::string & name) const
{
std::string variableID = category + '@' + name;
if (variables.values.count(variableID))
return variables.values.at(variableID);
return std::nullopt;
}
JsonNode Rewardable::Configuration::getPresetVariable(const std::string & category, const std::string & name) const
{
std::string variableID = category + '@' + name;
if (variables.values.count(variableID))
return variables.preset.at(variableID);
else
return JsonNode();
}
void Rewardable::Configuration::presetVariable(const std::string & category, const std::string & name, const JsonNode & value)
{
std::string variableID = category + '@' + name;
variables.preset[variableID] = value;
}
void Rewardable::Configuration::initVariable(const std::string & category, const std::string & name, int value)
{
std::string variableID = category + '@' + name;
variables.values[variableID] = value;
}
void Rewardable::ResetInfo::serializeJson(JsonSerializeFormat & handler)
{
handler.serializeInt("period", period);
@@ -39,6 +71,11 @@ void Rewardable::VisitInfo::serializeJson(JsonSerializeFormat & handler)
handler.serializeInt("visitType", visitType);
}
void Rewardable::Variables::serializeJson(JsonSerializeFormat & handler)
{
// TODO
}
void Rewardable::Configuration::serializeJson(JsonSerializeFormat & handler)
{
handler.serializeStruct("onSelect", onSelect);