mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
json validation & mithril remove
This commit is contained in:
@@ -93,17 +93,10 @@
|
||||
},
|
||||
"cost" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"description" : "Cost to recruit this creature",
|
||||
"properties" : {
|
||||
"gold" : { "type" : "number"},
|
||||
"wood" : { "type" : "number"},
|
||||
"ore" : { "type" : "number"},
|
||||
"mercury" : { "type" : "number"},
|
||||
"sulfur" : { "type" : "number"},
|
||||
"crystal" : { "type" : "number"},
|
||||
"gems" : { "type" : "number"}
|
||||
}
|
||||
"additionalProperties" : {
|
||||
"type" : "number"
|
||||
},
|
||||
"description" : "Cost to recruit this creature"
|
||||
},
|
||||
"speed" : { "type" : "number" },
|
||||
"hitPoints" : { "type" : "number" },
|
||||
|
||||
@@ -35,17 +35,10 @@
|
||||
|
||||
"dailyIncome" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"additionalProperties" : {
|
||||
"type" : "number"
|
||||
},
|
||||
"description" : "Daily income that this building provides to owner, if any",
|
||||
"properties" : {
|
||||
"gold" : { "type" : "number"},
|
||||
"wood" : { "type" : "number"},
|
||||
"ore" : { "type" : "number"},
|
||||
"mercury" : { "type" : "number"},
|
||||
"sulfur" : { "type" : "number"},
|
||||
"crystal" : { "type" : "number"},
|
||||
"gems" : { "type" : "number"}
|
||||
}
|
||||
},
|
||||
|
||||
// Properties that might appear since this node is shared with object config
|
||||
|
||||
@@ -139,15 +139,8 @@
|
||||
},
|
||||
"mines" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"properties" : {
|
||||
"gold" : { "type" : "number"},
|
||||
"wood" : { "type" : "number"},
|
||||
"ore" : { "type" : "number"},
|
||||
"mercury" : { "type" : "number"},
|
||||
"sulfur" : { "type" : "number"},
|
||||
"crystal" : { "type" : "number"},
|
||||
"gems" : { "type" : "number"}
|
||||
"additionalProperties" : {
|
||||
"type" : "number"
|
||||
}
|
||||
},
|
||||
"connection" :
|
||||
|
||||
@@ -86,31 +86,17 @@
|
||||
},
|
||||
"cost" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"description" : "Resources needed to build building",
|
||||
"properties" : {
|
||||
"gold" : { "type" : "number"},
|
||||
"wood" : { "type" : "number"},
|
||||
"ore" : { "type" : "number"},
|
||||
"mercury" : { "type" : "number"},
|
||||
"sulfur" : { "type" : "number"},
|
||||
"crystal" : { "type" : "number"},
|
||||
"gems" : { "type" : "number"}
|
||||
}
|
||||
"additionalProperties" : {
|
||||
"type" : "number"
|
||||
},
|
||||
"description" : "Resources needed to build building"
|
||||
},
|
||||
"produce" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"description" : "Resources produced each day by this building",
|
||||
"properties" : {
|
||||
"gold" : { "type" : "number"},
|
||||
"wood" : { "type" : "number"},
|
||||
"ore" : { "type" : "number"},
|
||||
"mercury" : { "type" : "number"},
|
||||
"sulfur" : { "type" : "number"},
|
||||
"crystal" : { "type" : "number"},
|
||||
"gems" : { "type" : "number"}
|
||||
}
|
||||
"additionalProperties" : {
|
||||
"type" : "number"
|
||||
},
|
||||
"description" : "Resources produced each day by this building"
|
||||
},
|
||||
"warMachine" : {
|
||||
"type" : "string",
|
||||
|
||||
@@ -34,10 +34,6 @@ void ResourceSet::serializeJson(JsonSerializeFormat & handler, const std::string
|
||||
|
||||
for(auto & idx : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
{
|
||||
//TODO: add proper support for mithril to map format
|
||||
if(idx == EGameResID::MITHRIL)
|
||||
continue;
|
||||
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), this->operator[](idx), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,6 @@ JsonNode readBuilding(CLegacyConfigParser & parser)
|
||||
for(const std::string & resID : GameConstants::RESOURCE_NAMES)
|
||||
cost[resID].Float() = parser.readNumber();
|
||||
|
||||
cost.Struct().erase("mithril"); // erase mithril to avoid confusing validator
|
||||
|
||||
parser.endLine();
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -107,8 +107,7 @@ void StatisticDataSetEntry::serializeJson(JsonSerializeFormat & handler)
|
||||
{
|
||||
auto zonesData = handler.enterStruct("numMines");
|
||||
for(auto & idx : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
if(idx != GameResID::MITHRIL)
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), numMines[idx], 0);
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), numMines[idx], 0);
|
||||
}
|
||||
handler.serializeInt("score", score);
|
||||
handler.serializeInt("maxHeroLevel", maxHeroLevel);
|
||||
|
||||
@@ -375,8 +375,7 @@ void CQuest::serializeJson(JsonSerializeFormat & handler, const std::string & fi
|
||||
auto r = handler.enterStruct("resources");
|
||||
|
||||
for(auto & idx : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
if(idx != GameResID::MITHRIL)
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), mission.resources[idx], 0);
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), mission.resources[idx], 0);
|
||||
}
|
||||
|
||||
if(missionType == "Hero")
|
||||
|
||||
@@ -536,8 +536,7 @@ void ZoneOptions::serializeJson(JsonSerializeFormat & handler)
|
||||
auto minesData = handler.enterStruct("mines");
|
||||
|
||||
for(auto & idx : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
if(idx != GameResID::MITHRIL)
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), mines[idx], 0);
|
||||
handler.serializeInt(idx.toResource()->getJsonKey(), mines[idx], 0);
|
||||
}
|
||||
|
||||
handler.serializeStruct("customObjects", objectConfig);
|
||||
|
||||
@@ -44,9 +44,6 @@ QuestWidget::QuestWidget(MapController & _controller, CQuest & _sh, QWidget *par
|
||||
ui->lResources->setRowCount(LIBRARY->resourceTypeHandler->getAllObjects().size() - 1);
|
||||
for(auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
{
|
||||
if(i == EGameResID::MITHRIL)
|
||||
continue;
|
||||
|
||||
MetaString str;
|
||||
str.appendName(GameResID(i));
|
||||
auto * item = new QTableWidgetItem(QString::fromStdString(str.toString()));
|
||||
@@ -459,8 +456,6 @@ void QuestDelegate::updateModelData(QAbstractItemModel * model, const QModelInde
|
||||
QStringList resourcesList;
|
||||
for(GameResID resource = GameResID::WOOD; resource < GameResID::COUNT ; resource++)
|
||||
{
|
||||
if(resource == GameResID::MITHRIL)
|
||||
continue;
|
||||
if(quest.mission.resources[resource] == 0)
|
||||
continue;
|
||||
MetaString str;
|
||||
|
||||
@@ -60,9 +60,6 @@ RewardsWidget::RewardsWidget(CMap & m, CRewardableObject & p, QWidget *parent) :
|
||||
ui->lResources->setRowCount(LIBRARY->resourceTypeHandler->getAllObjects().size() - 1);
|
||||
for(auto & i : LIBRARY->resourceTypeHandler->getAllObjects())
|
||||
{
|
||||
if(i == EGameResID::MITHRIL)
|
||||
continue;
|
||||
|
||||
MetaString str;
|
||||
str.appendName(GameResID(i));
|
||||
for(auto * w : {ui->rResources, ui->lResources})
|
||||
@@ -783,8 +780,6 @@ void RewardsDelegate::updateModelData(QAbstractItemModel * model, const QModelIn
|
||||
QStringList resourcesList;
|
||||
for(GameResID resource = GameResID::WOOD; resource < GameResID::COUNT ; resource++)
|
||||
{
|
||||
if(resource == GameResID::MITHRIL)
|
||||
continue; // translated as "Abandoned"?
|
||||
if(vinfo.reward.resources[resource] == 0)
|
||||
continue;
|
||||
MetaString str;
|
||||
|
||||
Reference in New Issue
Block a user