mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 07:30:41 +09:00
Follow mod pack string proposal
Make all properties on the mod pack object except sha1 required and add the base mod if it does not exist in order to align the JSON representation with the proposed Mod Pack String format I published on the Factorio Forums (https://forums.factorio.com/103578)
This commit is contained in:
1 parent
f863aee3c2
commit
fafdac21fb
1 file changed
+12
-9
@@ -108,6 +108,7 @@ class ModPack {
|
||||
static jsonSchema = {
|
||||
type: "object",
|
||||
additionalProperties: false,
|
||||
required: ["name", "description", "factorio_version", "mods", "settings"],
|
||||
properties: {
|
||||
"id": { type: "integer" },
|
||||
"name": { type: "string" },
|
||||
@@ -151,23 +152,25 @@ class ModPack {
|
||||
};
|
||||
}
|
||||
if (json.is_deleted) { this.isDeleted = json.is_deleted; }
|
||||
|
||||
if (!this.mods.has("base")) {
|
||||
this.mods.set("base", { name: "base", enabled: true, version: this.factorioVersion });
|
||||
}
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
let json = {
|
||||
id: this.id,
|
||||
};
|
||||
if (this.name) { json.name = this.name; }
|
||||
if (this.description) { json.description = this.description; }
|
||||
json.factorio_version = this.factorioVersion;
|
||||
if (this.mods.size) { json.mods = [...this.mods.values()]; }
|
||||
if (this.settings) {
|
||||
json.settings = {
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
factorio_version: this.factorioVersion,
|
||||
mods: [...this.mods.values()],
|
||||
settings: {
|
||||
"startup": Object.fromEntries(this.settings["startup"]),
|
||||
"runtime-global": Object.fromEntries(this.settings["runtime-global"]),
|
||||
"runtime-per-user": Object.fromEntries(this.settings["runtime-per-user"]),
|
||||
};
|
||||
}
|
||||
},
|
||||
};
|
||||
if (this.isDeleted) { json.is_deleted = this.isDeleted; }
|
||||
return json;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user