replace XML terrains for E3 with JSON configuration

This commit is contained in:
Enno Rehling 2015-09-11 22:41:57 +02:00
parent 7e8fef01af
commit 2a25488ed1
5 changed files with 245 additions and 65 deletions

View File

@ -1,6 +1,7 @@
{
"include": [
"keywords.json"
"keywords.json",
"e3/terrains.json"
],
"settings": {
"game.id": 3,

View File

@ -14,7 +14,6 @@
<xi:include href="config://game/ships.xml"/>
<xi:include href="config://game/shipnames.xml"/>
<xi:include href="config://game/terrains.xml"/>
<xi:include href="config://core/calendar.xml"/>
<xi:include href="config://game/items.xml" />
<xi:include href="config://game/strings.xml"/>

235
conf/e3/terrains.json Normal file
View File

@ -0,0 +1,235 @@
{
"terrains": {
"ocean": {
"size": 100,
"flags": [ "sea", "swim", "sail", "fly" ]
},
"plain": {
"size": 4000,
"herbs": [ "h0", "h4" ],
"seed": 3,
"road": 50,
"flags": [ "forest", "cavalry", "land", "walk", "sail", "fly" ],
"production": {
"iron": {
"chance": 0.1,
"level": "2d4-1",
"base": "5d8",
"div": "2d20+10"
},
"stone": {
"chance": 0.15,
"level": "1d4",
"base": "5d8",
"div": "2d30+20"
},
"laen": {
"chance": 0.01,
"level": "1d4",
"base": "1d4",
"div": "2d20+50"
}
}
},
"swamp": {
"size": 1200,
"herbs": [ "h6", "h8" ],
"seed": 2,
"road": 75,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {
"iron": {
"chance": 0.02,
"level": "2d4-1",
"base": "5d8",
"div": "2d20+10"
},
"stone": {
"chance": 0.02,
"level": "1d4",
"base": "5d8",
"div": "2d30+20"
},
"laen": {
"chance": 0.02,
"level": "1d4",
"base": "1d4",
"div": "2d20+50"
}
}
},
"desert": {
"size": 400,
"seed": 2,
"road": 75,
"flags": [ "cavalry", "land", "walk", "sail", "fly" ],
"herbs": [ "h9", "h11" ],
"production": {
"iron": {
"chance": 0.15,
"level": "2d4-1",
"base": "5d8",
"div": "2d20+10"
},
"stone": {
"chance": 0.25,
"level": "1d4",
"base": "5d8",
"div": "2d30+20"
},
"laen": {
"chance": 0.025,
"level": "1d4",
"base": "1d4",
"div": "2d20+50"
}
}
},
"highland": {
"size": 2300,
"seed": 2,
"road": 100,
"flags": [ "cavalry", "land", "walk", "sail", "fly" ],
"herbs": [ "h12", "h14" ],
"production": {
"iron": {
"chance": 0.15,
"level": "2d4-1",
"base": "5d8",
"div": "2d20+10"
},
"stone": {
"chance": 0.25,
"level": "1d4",
"base": "5d8",
"div": "2d30+20"
},
"laen": {
"chance": 0.025,
"level": "1d4",
"base": "1d4",
"div": "2d20+50"
}
}
},
"mountain": {
"size": 600,
"seed": 2,
"road": 250,
"flags": [ "land", "walk", "sail", "fly" ],
"herbs": [ "h15", "h17" ],
"production": {
"iron": {
"chance": 1.0,
"level": "1",
"base": "50",
"div": "50"
},
"stone": {
"chance": 1.0,
"level": "1",
"base": "100",
"div": "100"
},
"laen": {
"chance": 0.05,
"level": "1",
"base": "4",
"div": "100"
}
}
},
"glacier": {
"size": 150,
"seed": 2,
"road": 250,
"flags": [ "arctic", "land", "walk", "sail", "fly" ],
"herbs": [ "h18", "h20" ],
"production": {
"iron": {
"chance": 1.0,
"level": "1",
"base": "3",
"div": "50"
},
"stone": {
"chance": 1.0,
"level": "1",
"base": "2",
"div": "100"
},
"laen": {
"chance": 0.05,
"level": "1",
"base": "4",
"div": "100"
}
}
},
"packice": {
"flags": [ "arctic", "swim", "walk", "sail", "fly" ]
},
"firewall": {
"flags": [ "forbidden" ]
},
"volcano": {
"size": 400,
"seed": 1,
"road": 250,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {
"iron": {
"chance": 0.5,
"level": "1",
"base": "50",
"div": "50"
},
"stone": {
"chance": 0.5,
"level": "1",
"base": "100",
"div": "100"
},
"laen": {
"chance": 0.075,
"level": "1",
"base": "4",
"div": "100"
}
}
},
"activevolcano": {
"size": 400,
"road": 250,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {
"iron": {
"chance": 0.5,
"level": "1",
"base": "50",
"div": "50"
},
"stone": {
"chance": 0.5,
"level": "1",
"base": "100",
"div": "100"
},
"laen": {
"chance": 0.075,
"level": "1",
"base": "4",
"div": "100"
}
}
},
"default": {
"size": 0,
"herbs": [],
"seed": 0,
"road": 0,
"flags": [ "land", "walk", "sail", "fly" ],
"production": {}
}
}
}

View File

@ -1,61 +0,0 @@
<?xml version="1.0" ?>
<terrains>
<!-- defaults: build="yes" walk="yes" sail="yes" fly="yes" swim="no" forest="no" sea="no" land="yes" forbidden="no" arctic="no" cavalry="no" size="0" -->
<terrain name="ocean" size="100" walk="no" swim="yes" land="no" sea="yes" />
<terrain name="plain" size="4000" road="50" forest="yes" cavalry="yes" seed="3">
<herb name="h0" />
<herb name="h4" />
<resource name="iron" chance="0.1" level="2d4-1" base="5d8" div="2d20+10" />
<resource name="stone" chance="0.15" level="1d4" base="5d8" div="2d30+20" />
<resource name="laen" chance="0.01" level="1d4" base="1d4" div="2d20+50" />
</terrain>
<terrain name="swamp" size="1200" road="75" seed="2">
<herb name="h6" />
<herb name="h8" />
<resource name="iron" chance="0.02" level="2d4-1" base="5d8" div="2d20+10" />
<resource name="stone" chance="0.02" level="1d4" base="5d8" div="2d30+20" />
<resource name="laen" chance="0.02" level="1d4" base="1d4" div="2d20+50" />
</terrain>
<terrain name="desert" size="400" road="100" cavalry="yes" seed="2">
<herb name="h9" />
<herb name="h11" />
<resource name="iron" chance="0.15" level="2d4-1" base="5d8" div="2d20+10" />
<resource name="stone" chance="0.25" level="1d4" base="5d8" div="2d30+20" />
<resource name="laen" chance="0.025" level="1d4" base="1d4" div="2d20+50" />
</terrain>
<terrain name="highland" size="2300" road="100" cavalry="yes" seed="2">
<herb name="h12" />
<herb name="h14" />
<resource name="iron" chance="0.15" level="2d4-1" base="5d8" div="2d20+10" />
<resource name="stone" chance="0.25" level="1d4" base="5d8" div="2d30+20" />
<resource name="laen" chance="0.025" level="1d4" base="1d4" div="2d20+50" />
</terrain>
<terrain name="mountain" size="600" road="250" seed="2">
<herb name="h15" />
<herb name="h17" />
<resource name="iron" chance="1.0" level="1" base="50" div="50" />
<resource name="stone" chance="1.0" level="1" base="100" div="100" />
<resource name="laen" chance="0.05" level="1" base="4" div="100" />
</terrain>
<terrain name="glacier" size="150" road="250" arctic="yes" seed="2">
<herb name="h18" />
<herb name="h20" />
<resource name="iron" chance="1.0" level="1" base="3" div="50" />
<resource name="stone" chance="1.0" level="1" base="2" div="100" />
<resource name="laen" chance="0.05" level="1" base="4" div="100" />
</terrain>
<terrain name="packice" land="no" arctic="yes" swim="yes"/>
<terrain name="firewall" road="250" land="no" walk="no" sail="no" fly="no" forbidden="yes" />
<terrain name="fog" sail="no" land="no" />
<terrain name="thickfog" forbidden="yes" sail="no" walk="no" fly="no" land="no" />
<terrain name="volcano" size="400" road="250" seed="1">
<resource name="iron" chance="0.5" level="1" base="50" div="50" />
<resource name="stone" chance="0.5" level="1" base="100" div="100" />
<resource name="laen" chance="0.075" level="1" base="4" div="100" />
</terrain>
<terrain name="activevolcano" size="400" road="250">
<resource name="iron" chance="0.5" level="1" base="50" div="50" />
<resource name="stone" chance="0.5" level="1" base="100" div="100" />
<resource name="laen" chance="0.075" level="1" base="4" div="100" />
</terrain>
</terrains>

View File

@ -784,14 +784,20 @@ static void json_include(cJSON *json) {
fclose(F);
config = cJSON_Parse(data);
free(data);
json_config(config);
cJSON_Delete(config);
if (config) {
json_config(config);
cJSON_Delete(config);
}
else {
log_error("invalid JSON, could not parse %s", child->valuestring);
}
}
}
}
void json_config(cJSON *json) {
cJSON *child;
assert(json);
if (json->type != cJSON_Object) {
log_error("config is not a json object: %d", json->type);
return;