Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions docs/resources/visualizing-your-world-logic.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# Visualizing Your World Logic

## Visualizing Regions as a UML Diagram
There's a wonderful tool in Archipelago (written by el_) that allows viewing all of your region connections visually as a diagram! Manual doesn't officially have a way to use this tool yet, but we hope to one day!

(To make use of this feature, you'll want to get a UML viewer like PlantUML.)
When troubleshooting region connections while building a world, it can be helpful to see that you've connected those regions (and their locations) properly. By setting the `generate_region_diagram: true` in your yaml, a UML file will be added to your Archipelago install folder when you generate this world. Open that UML file in a UML viewer (such as PlantUML), and it will lay out region connections with boxes and lines interconnecting them.

![](../img/resources/visualize-regions-uml-example.png)

Until Manual officially supports using it, there's a workaround to use it if you don't mind looking at a tiny amount of code:
To generate a region diagram:

1. Extract/unzip your apworld into a folder in your worlds folder, as if you were going to make changes to it.
2. Open the `__init__.py` file that's in the main folder (not the `hooks` folder).
3. Search for the text `visualize_regions`.
4. Remove the `#` from the front of the two lines that match to uncomment them.
5. Save the `__init__.py` and generate your world!
6. Open the .puml file that gets generated in your Archipelago folder. It will have the same name as your apworld.
1. Install your apworld as if you were going to play it
2. Generate a template yaml, and set any options that might change the logic
3. Add `generate_region_diagram: true` to your yaml
4. Generate a seed
5. Find the .puml file that gets generated in your Archipelago folder. It will have the same name as your apworld.
6. Put the contents of that file into a viewer like [PlantUML](https://www.planttext.com/)

## Organizing Connected Ideas on a Graph
Some tools can help with visualizing your game's structure.
Expand Down
15 changes: 0 additions & 15 deletions docs/syntax/meta.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ If you'd like to see all the available properties and their allowed values, view

## The meta.json structure
The properties for this file are broken down into these headings below:
- [Visualizing region connections with UML](#visualizing-region-connections-with-uml)
- `enable_region_diagram`
- [APWorld description](#apworld-description)
- `apworld_description`
- [WebWorld - Tutorials](#webworld---tutorials)
Expand All @@ -25,19 +23,6 @@ The properties for this file are broken down into these headings below:

---

### Visualizing region connections with UML
When troubleshooting region connections while building a world, it can be helpful to see that you've connected those regions (and their locations) properly. By setting the `enable_region_diagram` property to true, a UML file will be added to your Archipelago install folder when you generate this world. Open that UML file in a UML viewer (such as PlantUML), and it will lay out region connections with boxes and lines interconnecting them.

Here's an example of enabling the creation of a region diagram during generation:

```json
{
"enable_region_diagram": true
}
```

---

### APWorld description
The world description describes the game that this APWorld was made for. This is the text that is shown for that game in the "Supported Games" listing of a running webhost.

Expand Down
5 changes: 0 additions & 5 deletions schemas/Manual.meta.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@
}
}
}
},
"enable_region_diagram": {
"description": "Enable the generation of puml diagram of your apworld region and locations for debug purposes",
"type": "boolean",
"default": false
}
},
"definitions": {
Expand Down
2 changes: 0 additions & 2 deletions src/Meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@ def set_world_webworld(web: WebWorld) -> WebWorld:
the player must manually refrain from using these gathered items until the tracker shows that they have been acquired or sent.
""")
world_webworld: ManualWeb = set_world_webworld(ManualWeb())

enable_region_diagram = bool(meta_table.get("enable_region_diagram", False))
5 changes: 5 additions & 0 deletions src/Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class FillerTrapPercent(Range):
"""How many fillers will be replaced with traps. 0 means no additional traps, 100 means all fillers are traps."""
range_end = 100

class GenerateRegionDiagram(Toggle):
"""Generate a region diagram."""
visibility = Visibility.none # Hidden option

def createChoiceOptions(values: dict, aliases: dict) -> dict:
values = {'option_' + i: v for i, v in values.items()}
aliases = {'alias_' + i: v for i, v in aliases.items()}
Expand Down Expand Up @@ -61,6 +65,7 @@ def addOptionToGroup(option_name: str, group: str):

manual_options: dict[str, Type[Option[Any]]] = before_options_defined({})
manual_options["start_inventory_from_pool"] = StartInventoryPool
manual_options["generate_region_diagram"] = GenerateRegionDiagram

if len(victory_names) > 1:
if manual_options.get('goal'):
Expand Down
4 changes: 2 additions & 2 deletions src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .Data import item_table, location_table, event_table, region_table, category_table
from .Game import game_name, filler_item_name, starting_items
from .Meta import world_description, world_webworld, enable_region_diagram
from .Meta import world_description, world_webworld
from .Locations import location_id_to_name, location_name_to_id, location_name_to_location, location_name_groups, victory_names, event_name_to_event
from .Items import item_id_to_name, item_name_to_id, item_name_to_item, item_name_groups
from .DataValidation import runGenerationDataValidation, runPreFillDataValidation
Expand Down Expand Up @@ -402,7 +402,7 @@ def generate_basic(self):
after_generate_basic(self, self.multiworld, self.player)

# Enable this in Meta.json to generate a diagram of your manual. Only works on 0.4.4+
if enable_region_diagram:
if get_option_value(self.multiworld, self.player, "generate_region_diagram"):
from Utils import visualize_regions
visualize_regions(self.multiworld.get_region("Menu", self.player), f"{self.game}_{self.player}.puml")

Expand Down
4 changes: 1 addition & 3 deletions src/data/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,5 @@
}
}
}
},
"_comment_":"Enable the generation of puml diagram of your apworld region and locations for debug purposes",
"enable_region_diagram": false
}
}