Skip to content

Commit

Permalink
Autogenerate scenario schema doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kostmo committed Sep 23, 2023
1 parent e06e04f commit 0fff045
Show file tree
Hide file tree
Showing 29 changed files with 941 additions and 260 deletions.
1 change: 1 addition & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ cliParser =
, Just Recipes <$ switch (long "recipes" <> help "Generate recipes page (uses data from recipes.yaml)")
, Just Capabilities <$ switch (long "capabilities" <> help "Generate capabilities page (uses entity map)")
, Just Commands <$ switch (long "commands" <> help "Generate commands page (uses constInfo, constCaps and inferConst)")
, Just Scenario <$ switch (long "scenario" <> help "Generate scenario schema page")
]
seed :: Parser (Maybe Int)
seed = optional $ option auto (long "seed" <> short 's' <> metavar "INT" <> help "Seed to use for world generation")
Expand Down
269 changes: 269 additions & 0 deletions data/scenarios/README_NEW.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions data/schema/attribute.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/attribute.json",
"title": "Scenario-local attributes",
"description": "Local attribute definitions",
"title": "Attributes",
"description": "Scenario-local attribute definitions",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down
5 changes: 3 additions & 2 deletions data/schema/combustion.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/combustion.json",
"title": "Swarm entity combustion",
"description": "Properties of combustion",
"title": "Combustion",
"description": "Properties of entity combustion",
"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -13,6 +13,7 @@
},
"duration": {
"type": "array",
"default": [100, 200],
"items": [
{
"name": "minimum",
Expand Down
2 changes: 1 addition & 1 deletion data/schema/cosmic-loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"type": "string",
"description": "Name of subworld"
},
"loc": {"$ref": "./planar-loc.json"}
"loc": {"$ref": "planar-loc.json"}
}
}
11 changes: 5 additions & 6 deletions data/schema/display.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/display.json",
"title": "Swarm entity display",
"description": "How to display an entity or robot in the Swarm game",
"title": "Display",
"description": "Swarm entity display. A display specifies how an entity or a robot (robots are essentially special kinds of entities) is displayed in the world. It consists of a key-value mapping described by the following table.",
"type": "object",
"additionalProperties": false,
"properties": {
Expand All @@ -13,8 +13,7 @@
},
"orientationMap": {
"default": {},
"type": "object",
"description": "Currently unused"
"$ref": "orientation-map.json"
},
"curOrientation": {
"default": null,
Expand Down Expand Up @@ -47,12 +46,12 @@
"blue",
"water"
],
"description": "The name of the attribute that should be used to style the robot or entity. A list of currently valid attributes can be found at https://github.com/swarm-game/swarm/blob/main/src/Swarm/TUI/Attr.hs."
"description": "The name of the attribute that should be used to style the robot or entity. A list of currently valid attributes can be found [here](https://github.com/swarm-game/swarm/blob/main/src/Swarm/TUI/View/Attribute/Attr.hs)."
},
"priority": {
"default": 1,
"type": "number",
"description": "When multiple entities and robots occupy the same cell, the one with the highest priority is drawn. By default, entities have priority 1, and robots have priority 10."
"description": "When multiple entities and robots occupy the same cell, the one with the highest priority is drawn. By default, entities have priority `1`, and robots have priority `10`."
},
"invisible": {
"default": false,
Expand Down
104 changes: 2 additions & 102 deletions data/schema/entities.json
Original file line number Diff line number Diff line change
@@ -1,110 +1,10 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/entities.json",
"title": "Swarm entities",
"title": "Entities",
"description": "Description of entities in the Swarm game",
"type": "array",
"items": {
"description": "Description of an entity in the Swarm game",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the entity. This is what will show up in the inventory and how the entity can be referred to."
},
"display": {
"type": "object",
"$ref": "./display.json",
"description": "Display information for the entity."
},
"plural": {
"default": "null",
"type": "string",
"description": "An explicit plural form of the name of the entity. If omitted, standard heuristics will be used for forming the English plural of its name."
},
"description": {
"type": "array",
"items": [
{
"type": "string"
}
],
"description": "A description of the entity, as a list of paragraphs."
},
"orientation": {
"default": "null",
"type": "array",
"items": [
{
"name": "X coordinate",
"type": "number"
},
{
"name": "Y coordinate",
"type": "number"
}
],
"description": "A 2-tuple of integers specifying an orientation vector for the entity. Currently unused."
},
"growth": {
"default": "null",
"type": "array",
"items": [
{
"name": "minimum",
"type": "number"
},
{
"name": "maximum",
"type": "number"
}
],
"description": "For growable entities, a 2-tuple of integers specifying the minimum and maximum amount of time taken for one growth stage. The actual time for one growth stage will be chosen uniformly at random from this range; it takes two growth stages for an entity to be fully grown."
},
"combustion": {
"type": "object",
"$ref": "./combustion.json",
"description": "Properties of combustion."
},
"yields": {
"default": "null",
"type": "string",
"description": "The name of the entity which will be added to a robot's inventory when it executes grab or harvest on this entity. If omitted, the entity will simply yield itself."
},
"properties": {
"default": "[]",
"type": "array",
"items": [
{
"type": "string",
"examples": [
"unwalkable",
"portable",
"infinite",
"known",
"growable"
]
}
],
"description": "A list of properties of this entity. See Entity properties."
},
"capabilities": {
"default": "[]",
"type": "array",
"items": [
{
"type": "string"
}
],
"description": "A list of capabilities provided by entity, when it is equipped as a device. See Capabilities."
}
},
"required": [
"name",
"display",
"description"
]
"$ref": "entity.json"
}

}
105 changes: 105 additions & 0 deletions data/schema/entity.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/entity.json",
"title": "Entity",
"description": "Description of an entity in the Swarm game",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "The name of the entity. This is what will show up in the inventory and how the entity can be referred to."
},
"display": {
"type": "object",
"$ref": "display.json",
"description": "Display information for the entity."
},
"plural": {
"default": "null",
"type": "string",
"description": "An explicit plural form of the name of the entity. If omitted, standard heuristics will be used for forming the English plural of its name."
},
"description": {
"type": "array",
"items": [
{
"type": "string"
}
],
"description": "A description of the entity, as a list of paragraphs."
},
"orientation": {
"default": "null",
"type": "array",
"items": [
{
"name": "X coordinate",
"type": "number"
},
{
"name": "Y coordinate",
"type": "number"
}
],
"description": "A 2-tuple of integers specifying an orientation vector for the entity. Currently unused."
},
"growth": {
"default": "null",
"type": "array",
"items": [
{
"name": "minimum",
"type": "number"
},
{
"name": "maximum",
"type": "number"
}
],
"description": "For growable entities, a 2-tuple of integers specifying the minimum and maximum amount of time taken for one growth stage. The actual time for one growth stage will be chosen uniformly at random from this range; it takes two growth stages for an entity to be fully grown."
},
"combustion": {
"type": "object",
"$ref": "combustion.json",
"description": "Properties of combustion."
},
"yields": {
"default": "null",
"type": "string",
"description": "The name of the entity which will be added to a robot's inventory when it executes grab or harvest on this entity. If omitted, the entity will simply yield itself."
},
"properties": {
"default": [],
"type": "array",
"items": [
{
"type": "string",
"examples": [
"unwalkable",
"portable",
"infinite",
"known",
"growable"
]
}
],
"description": "A list of properties of this entity."
},
"capabilities": {
"default": [],
"type": "array",
"items": [
{
"type": "string"
}
],
"description": "A list of capabilities provided by entity, when it is equipped as a device. See Capabilities."
}
},
"required": [
"name",
"display",
"description"
]
}
2 changes: 1 addition & 1 deletion data/schema/explicit-waypoint.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"description": "Waypoint name",
"type": "string"
},
"loc": {"$ref": "./planar-loc.json"}
"loc": {"$ref": "planar-loc.json"}
}
}
4 changes: 2 additions & 2 deletions data/schema/inventory.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/inventory.json",
"title": "Swarm entity inventory",
"description": "A list of [count, entity name] pairs, specifying the number of each entity.",
"title": "Inventory",
"description": "A list of `[count, entity name]` pairs, specifying the number of each entity.",
"type": "array",
"items": {
"type": "array",
Expand Down
17 changes: 17 additions & 0 deletions data/schema/named-structure.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/named-structure.json",
"title": "Named structure",
"description": "Structure definitions",
"type": "object",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "Name of this substructure"
},
"structure": {
"$ref": "structure.json"
}
}
}
8 changes: 5 additions & 3 deletions data/schema/objective.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/objective.json",
"title": "Scenario goals and their prerequisites",
"description": "The top-level objectives field contains a list of objectives that must be completed in sequence. Each objective has a goal description and a condition.",
"title": "Objective",
"description": "Scenario goals and their prerequisites. The top-level objectives field contains a list of objectives that must be completed in sequence. Each objective has a goal description and a condition.",
"type": "object",
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -35,6 +35,8 @@
"description": "A compact (2-3 word) summary of the goal",
"type": "string"
},
"prerequisite": {}
"prerequisite": {
"$ref": "prerequisite.json"
}
}
}
22 changes: 22 additions & 0 deletions data/schema/orientation-map.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/swarm-game/swarm/main/data/schema/orientation-map.json",
"title": "Orientation map",
"description": "Mapping from cardinal directions to display characters",
"type": "object",
"additionalProperties": false,
"properties": {
"east": {
"type": "string"
},
"north": {
"type": "string"
},
"west": {
"type": "string"
},
"south": {
"type": "string"
}
}
}
Loading

0 comments on commit 0fff045

Please sign in to comment.