1
0
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:
Laserlicht
2025-09-16 01:52:47 +02:00
parent 2bf9454b77
commit 3ec731ef6e
11 changed files with 20 additions and 74 deletions

View File

@@ -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" },

View File

@@ -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

View File

@@ -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" :

View File

@@ -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",

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -107,7 +107,6 @@ 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("score", score);

View File

@@ -375,7 +375,6 @@ 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);
}

View File

@@ -536,7 +536,6 @@ 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);
}

View File

@@ -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;

View File

@@ -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;