From 6b7d88f131cbb04a063663d2843470f22166003c Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Sat, 25 Dec 2021 22:20:36 -0500 Subject: [PATCH] Initial work on mkdocs documentation --- docs/Makefile | 20 --- docs/index.md | 7 + docs/make.bat | 35 ---- docs/reference/common_types.md | 3 + docs/reference/layer.md | 1 + docs/reference/parser.md | 3 + docs/reference/properties.md | 1 + docs/reference/tiled_map.md | 3 + docs/reference/tiled_object.md | 1 + docs/reference/tileset.md | 1 + docs/reference/wang_set.md | 5 + docs/reference/world.md | 3 + docs/source/api.rst | 59 ------ docs/source/conf.py | 64 ------- docs/source/index.rst | 20 --- mkdocs.yml | 44 +++++ pytiled_parser/__init__.py | 2 +- pytiled_parser/common_types.py | 13 +- pytiled_parser/tiled_map.py | 14 +- pytiled_parser/util.py | 3 + pytiled_parser/wang_set.py | 48 +++++ pytiled_parser/world.py | 52 ++++-- setup.cfg | 13 +- tests/test_data/world_tests/both/expected.py | 170 ++---------------- .../world_tests/pattern_matched/expected.py | 112 +----------- .../world_tests/static_defined/expected.py | 108 +---------- 26 files changed, 199 insertions(+), 606 deletions(-) delete mode 100644 docs/Makefile create mode 100644 docs/index.md delete mode 100644 docs/make.bat create mode 100644 docs/reference/common_types.md create mode 100644 docs/reference/layer.md create mode 100644 docs/reference/parser.md create mode 100644 docs/reference/properties.md create mode 100644 docs/reference/tiled_map.md create mode 100644 docs/reference/tiled_object.md create mode 100644 docs/reference/tileset.md create mode 100644 docs/reference/wang_set.md create mode 100644 docs/reference/world.md delete mode 100644 docs/source/api.rst delete mode 100644 docs/source/conf.py delete mode 100644 docs/source/index.rst create mode 100644 mkdocs.yml diff --git a/docs/Makefile b/docs/Makefile deleted file mode 100644 index d0c3cbf..0000000 --- a/docs/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# Minimal makefile for Sphinx documentation -# - -# You can set these variables from the command line, and also -# from the environment for the first two. -SPHINXOPTS ?= -SPHINXBUILD ?= sphinx-build -SOURCEDIR = source -BUILDDIR = build - -# Put it first so that "make" without argument is like "make help". -help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - -.PHONY: help Makefile - -# Catch-all target: route all unknown targets to Sphinx using the new -# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). -%: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..3d4b099 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,7 @@ +# PyTiled Parser + +PyTiled Parser is a Python Library for parsing maps made with the [Tiled Map Editor](https://www.mapeditor.org) for 2D games in a strictly typed fashion. + +PyTiled Parser is not tied to any particular graphics library, and as such could be used with [Arcade](https://api.arcade.academy), [Pyglet](https://pyglet.readthedocs.io), [Pygame](https://www.pygame.org/news), or any other Python graphics library. + +While we don't offer any direct integrations to other libraries/frameworks, [Arcade](https://api.arcade.academy) has full integration for PyTiled Parser out of the box, and would be a good resource to use as an example implementation. diff --git a/docs/make.bat b/docs/make.bat deleted file mode 100644 index 6247f7e..0000000 --- a/docs/make.bat +++ /dev/null @@ -1,35 +0,0 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% - -:end -popd diff --git a/docs/reference/common_types.md b/docs/reference/common_types.md new file mode 100644 index 0000000..c484087 --- /dev/null +++ b/docs/reference/common_types.md @@ -0,0 +1,3 @@ +# Common Types + +::: pytiled_parser.common_types diff --git a/docs/reference/layer.md b/docs/reference/layer.md new file mode 100644 index 0000000..dae0d71 --- /dev/null +++ b/docs/reference/layer.md @@ -0,0 +1 @@ +# Layer diff --git a/docs/reference/parser.md b/docs/reference/parser.md new file mode 100644 index 0000000..550593a --- /dev/null +++ b/docs/reference/parser.md @@ -0,0 +1,3 @@ +# Parser + +::: pytiled_parser.parser diff --git a/docs/reference/properties.md b/docs/reference/properties.md new file mode 100644 index 0000000..d03ffb6 --- /dev/null +++ b/docs/reference/properties.md @@ -0,0 +1 @@ +# Properties diff --git a/docs/reference/tiled_map.md b/docs/reference/tiled_map.md new file mode 100644 index 0000000..63e9e63 --- /dev/null +++ b/docs/reference/tiled_map.md @@ -0,0 +1,3 @@ +# tiled_map + +::: pytiled_parser.tiled_map diff --git a/docs/reference/tiled_object.md b/docs/reference/tiled_object.md new file mode 100644 index 0000000..7b512fc --- /dev/null +++ b/docs/reference/tiled_object.md @@ -0,0 +1 @@ +# Tiled Object diff --git a/docs/reference/tileset.md b/docs/reference/tileset.md new file mode 100644 index 0000000..adb6e29 --- /dev/null +++ b/docs/reference/tileset.md @@ -0,0 +1 @@ +# TileSet diff --git a/docs/reference/wang_set.md b/docs/reference/wang_set.md new file mode 100644 index 0000000..39bf4d7 --- /dev/null +++ b/docs/reference/wang_set.md @@ -0,0 +1,5 @@ +# wang_set + +::: pytiled_parser.wang_set + rendering: + members_order: source diff --git a/docs/reference/world.md b/docs/reference/world.md new file mode 100644 index 0000000..c91e0cc --- /dev/null +++ b/docs/reference/world.md @@ -0,0 +1,3 @@ +# Worlds + +::: pytiled_parser.world diff --git a/docs/source/api.rst b/docs/source/api.rst deleted file mode 100644 index b4e7e41..0000000 --- a/docs/source/api.rst +++ /dev/null @@ -1,59 +0,0 @@ -PyTiled Parser API -================== - -pytiled\_parser.common\_types ------------------------------------- - -.. automodule:: pytiled_parser.common_types - :members: - :undoc-members: - :show-inheritance: - -pytiled\_parser.layer ----------------------------- - -.. automodule:: pytiled_parser.layer - :members: - :undoc-members: - :show-inheritance: - -pytiled\_parser.properties ---------------------------------- - -.. automodule:: pytiled_parser.properties - :members: - :undoc-members: - :show-inheritance: - - -pytiled\_parser.tiled\_map ---------------------------------- - -.. automodule:: pytiled_parser.tiled_map - :members: - :undoc-members: - :show-inheritance: - -pytiled\_parser.tiled\_object ------------------------------------- - -.. automodule:: pytiled_parser.tiled_object - :members: - :undoc-members: - :show-inheritance: - -pytiled\_parser.tileset ------------------------------- - -.. automodule:: pytiled_parser.tileset - :members: - :undoc-members: - :show-inheritance: - -pytiled\_parser.util ---------------------------- - -.. automodule:: pytiled_parser.util - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/source/conf.py b/docs/source/conf.py deleted file mode 100644 index 4054de5..0000000 --- a/docs/source/conf.py +++ /dev/null @@ -1,64 +0,0 @@ -# Configuration file for the Sphinx documentation builder. -# -# This file only contains a selection of the most common options. For a full -# list see the documentation: -# https://www.sphinx-doc.org/en/master/usage/configuration.html - -# -- Path setup -------------------------------------------------------------- - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -# -import os -import sys - -sys.path.insert(0, os.path.abspath('../..')) - -# -- Project information ----------------------------------------------------- - -project = 'PyTiled Parser' -copyright = '2021, Beefy-Swain, Cleptomania' -author = 'Beefy-Swain, Cleptomania' - -# The full version, including alpha/beta/rc tags -release = '1.0.0' - - -# -- General configuration --------------------------------------------------- - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.coverage', - 'sphinx.ext.viewcode', - 'sphinx.ext.napoleon', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This pattern also affects html_static_path and html_extra_path. -exclude_patterns = [] - -source_suffix = '.rst' - -master_doc = 'index' - -pygments_style = 'sphinx' - -# -- Options for HTML output ------------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = 'sphinx_rtd_theme' - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index 1067262..0000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,20 +0,0 @@ -PyTiled Parser -============== - -PyTiled Parser is a Python library for parsing `Tiled Map Editor`_ (`.json`) files used to generate maps and levels for 2D games. - -PyTiled Parser is not tied to any particular graphics library, and can be used with Arcade_, Pyglet_, Pygame_, and more. - -API documentation ------------------ - -.. toctree:: - :maxdepth: 2 - - api - -For More Info -------------- - -* `PyTiled Parser on Github `_ -* `PyTiled Parser on PyPi `_ \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml new file mode 100644 index 0000000..3197b92 --- /dev/null +++ b/mkdocs.yml @@ -0,0 +1,44 @@ +site_name: PyTiled Parser +site_url: https://learn-arcade.dev/ +repo_url: https://github.com/benjamin-kirkbride/pytiled_parser +repo_name: benjamin-kirkbride/pytiled_parser +theme: + features: + - search.suggest + name: material + palette: + - media: "(prefers-color-scheme: light)" + scheme: default + toggle: + icon: material/lightbulb-outline + name: Switch to dark mode + - media: "(prefers-color-scheme: dark)" + scheme: slate + primary: cyan + accent: pink + toggle: + icon: material/lightbulb + name: Switch to light mode +plugins: + - search + - mkdocstrings: + handlers: + python: + selection: + filters: + - "!^__" + - "!^_" + watch: + - pytiled_parser +nav: +- PyTiled Parser: index.md +- API Reference: + - reference/common_types.md + - reference/layer.md + - reference/parser.md + - reference/properties.md + - reference/tiled_map.md + - reference/tiled_object.md + - reference/tileset.md + - reference/wang_set.md + - reference/world.md \ No newline at end of file diff --git a/pytiled_parser/__init__.py b/pytiled_parser/__init__.py index f37e2ae..f2b73fa 100644 --- a/pytiled_parser/__init__.py +++ b/pytiled_parser/__init__.py @@ -11,7 +11,7 @@ PyTiled Parser is not tied to any particular graphics library or game engine. # pylint: disable=too-few-public-methods -from .common_types import OrderedPair, Size +from .common_types import Color, OrderedPair, Size from .exception import UnknownFormat from .layer import ImageLayer, Layer, LayerGroup, ObjectLayer, TileLayer from .parser import parse_map diff --git a/pytiled_parser/common_types.py b/pytiled_parser/common_types.py index 6f53aee..97253c6 100644 --- a/pytiled_parser/common_types.py +++ b/pytiled_parser/common_types.py @@ -4,11 +4,9 @@ from typing import NamedTuple -import attr - class Color(NamedTuple): - """Color NamedTuple. + """Represents an RGBA color value as a four value Tuple. Attributes: red: Red, between 1 and 255. @@ -23,13 +21,8 @@ class Color(NamedTuple): alpha: int -@attr.s(auto_attribs=True) -class Template: - """FIXME TODO""" - - class Size(NamedTuple): - """Size NamedTuple. + """Represents a two dimensional size as a two value Tuple. Attributes: width: The width of the object in pixels. @@ -41,7 +34,7 @@ class Size(NamedTuple): class OrderedPair(NamedTuple): - """OrderedPair NamedTuple. + """Represents a two dimensional position as a two value Tuple. Attributes: x: X coordinate. diff --git a/pytiled_parser/tiled_map.py b/pytiled_parser/tiled_map.py index 9c1c1ba..04d252f 100644 --- a/pytiled_parser/tiled_map.py +++ b/pytiled_parser/tiled_map.py @@ -1,3 +1,7 @@ +"""The tiled_map module contains the primary TiledMap class which represents a single +map from Tiled. +""" + from pathlib import Path from typing import Dict, List, Optional @@ -13,9 +17,15 @@ TilesetDict = Dict[int, Tileset] @attr.s(auto_attribs=True) class TiledMap: - """Object for storing a TMX with all associated layers and properties. + """Object for storing a Tiled map with all associated objects. - See: https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#map + This object is the top level object for a map. It contains all layers within a map, + as well as all Tiesets used by the map. When creating an implementation, this will + be the primary class to work with to pull all data relating to a map. + + [TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#map) + + [JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#map) Attributes: infinite: If the map is infinite or not. diff --git a/pytiled_parser/util.py b/pytiled_parser/util.py index f8bb18b..0e850b9 100644 --- a/pytiled_parser/util.py +++ b/pytiled_parser/util.py @@ -9,6 +9,9 @@ from pytiled_parser.common_types import Color def parse_color(color: str) -> Color: """Convert Tiled color format into PyTiled's. + + Tiled's color format is #AARRGGBB and PyTiled's is an RGBA tuple. + Args: color (str): Tiled formatted color string. Returns: diff --git a/pytiled_parser/wang_set.py b/pytiled_parser/wang_set.py index 9241742..a2250d9 100644 --- a/pytiled_parser/wang_set.py +++ b/pytiled_parser/wang_set.py @@ -1,3 +1,10 @@ +"""This module contains a number of classes related to Wang Sets. + +Wang Sets are the underlying data used by Tiled's terrain system. +See [Tiled's docs about terrain](https://doc.mapeditor.org/en/stable/manual/terrain/) +and also the [TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangsets) +and the [JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-set) +""" from typing import Dict, List, Optional import attr @@ -8,6 +15,18 @@ from pytiled_parser.properties import Properties @attr.s(auto_attribs=True) class WangTile: + """Defines a Wang tile by linking a tile in the tileset to a Wang ID. + + [TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangtile) + + [JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-tile) + + Attributes: + tile_id: The ID of the tile this WangTile maps to + wang_id: The wang color indexes for this tile. This is a list of IDs referring + to colors within the wang set. In the order of top, top right, right, + bottom right, bottom, bottom left, left, top left. + """ tile_id: int wang_id: List[int] @@ -15,6 +34,19 @@ class WangTile: @attr.s(auto_attribs=True) class WangColor: + """A color that can be used to define the corner and/or edge of a Wang tile + + [TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangcolor) + + [JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-color) + + Attributes: + color: An RGBA color used to identify this Wang color + name: The name for this color + probability: The probability used when randomizing tiles + properties: The properties for this wang color + tile: Tile ID of the tile representing this color + """ color: Color name: str @@ -25,6 +57,22 @@ class WangColor: @attr.s(auto_attribs=True) class WangSet: + """A complete Wang Set defining a list of corner and edge + [WangColors][pytiled_parser.wang_set.WangColor], and any number of + [WangTiles][pytiled_parser.wang_set.WangTile] + + [TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangset) + + [JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-set) + + Attributes: + name: Name of the WangSet + properties: The properties for this wang set + tile: Tile ID of the tile representing this Wang Set + wang_colors: A list of [WangColors][pytiled_parser.wang_set.WangColor] + wang_tiles: A list of [WangTiles][pytiled_parser.wang_set.WangTile] + wang_type: A string noting the type of this wang set + """ name: str tile: int diff --git a/pytiled_parser/world.py b/pytiled_parser/world.py index 797ff39..837da09 100644 --- a/pytiled_parser/world.py +++ b/pytiled_parser/world.py @@ -1,3 +1,14 @@ +"""This module provides an implementation for World files from Tiled. + +See [Tiled's docs for Worlds](https://doc.mapeditor.org/en/stable/manual/worlds/) +for more info about worlds and how to use them. + +The functionality within PyTiled Parser is to load the world and outline the size +and position of each map, and provide the path to the map file. Loading a world +does not automatically load each map within the world, this is so that the game +or engine implementation can decide how to handle map loading. +""" + import json import re from os import listdir @@ -9,28 +20,49 @@ import attr from typing_extensions import TypedDict from pytiled_parser.common_types import OrderedPair, Size -from pytiled_parser.parser import parse_map -from pytiled_parser.tiled_map import TiledMap @attr.s(auto_attribs=True) class WorldMap: + """Represents a map within a world. - tiled_map: TiledMap + This object can be accessed to load in a map after loading the world. + + This class translates to each object within the `maps` list of a + World file + + Attributes: + map_file: A Path object to the map file, can be passed to + [parse_map][pytiled_parser.parser.parse_map] + size: The size of the map in pixels + coordinates: The position of the map within the world in pixels + """ + + map_file: Path size: Size coordinates: OrderedPair @attr.s(auto_attribs=True) class World: + """Represents a world file. + + Attributes: + maps: The list of maps within the world. These are not fully parsed + [TiledMap][pytiled_parser.tiled_map.TiledMap] objects, but rather + [WorldMap][pytiled_parser.world.WorldMap] objects which can be used + to later parse each individual map. + only_show_adjacent: Largely only used by the Tiled editor to determine + if only maps adjacent to the active one should be displayed. This + could be used to determine implementation behavior as well though + to toggle auto-loading of adjacent maps or something of the sort. + """ maps: List[WorldMap] only_show_adjacent: bool = False class RawPattern(TypedDict): - """The keys and their types that appear in a Pattern JSON Object.""" - regexp: str multiplierX: float multiplierY: float @@ -39,8 +71,6 @@ class RawPattern(TypedDict): class RawWorldMap(TypedDict): - """The keys and their types that appear in a WorldMap JSON Object.""" - fileName: str height: float width: float @@ -49,8 +79,6 @@ class RawWorldMap(TypedDict): class RawWorld(TypedDict): - """The keys and their types that appear in a World JSON Object.""" - maps: List[RawWorldMap] patterns: List[RawPattern] onlyShowAdjacentMaps: bool @@ -66,10 +94,8 @@ def _parse_world_map(raw_world_map: RawWorldMap, map_file: Path) -> WorldMap: Returns: WorldMap: The parsed WorldMap object """ - tiled_map = parse_map(map_file) - return WorldMap( - tiled_map=tiled_map, + map_file=map_file, size=Size(raw_world_map["width"], raw_world_map["height"]), coordinates=OrderedPair(raw_world_map["x"], raw_world_map["y"]), ) @@ -82,7 +108,7 @@ def parse_world(file: Path) -> World: file: Path to the world's file Returns: - World: A properly parsed World + World: A properly parsed [World][pytiled_parser.world.World] """ with open(file) as world_file: diff --git a/setup.cfg b/setup.cfg index 2ccb360..acba33c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,16 +52,9 @@ build = pep517 docs = - sphinx - sphinx_rtd_theme - -[build_sphinx] -source-dir = docs -build-dir = docs/build -all_files = 1 - -[upload-sphinx] -upload-dir = docs/build/html + mkdocs + mkdocs-material + mkdocstrings [bdist_wheel] universal=0 diff --git a/tests/test_data/world_tests/both/expected.py b/tests/test_data/world_tests/both/expected.py index 748299b..57d2dc1 100644 --- a/tests/test_data/world_tests/both/expected.py +++ b/tests/test_data/world_tests/both/expected.py @@ -1,6 +1,6 @@ from pathlib import Path -from pytiled_parser import common_types, layer, tiled_map, tileset, world +from pytiled_parser import common_types, world EXPECTED = world.World( only_show_adjacent=False, @@ -8,173 +8,23 @@ EXPECTED = world.World( world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(-160, 0), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_manual_one.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_manual_one.json") + .absolute() + .resolve(), ), world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(0, 0), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_p0-n0.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_p0-n0.json") + .absolute() + .resolve(), ), world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(0, 160), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_p0-n1.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_p0-n1.json") + .absolute() + .resolve(), ), ], ) diff --git a/tests/test_data/world_tests/pattern_matched/expected.py b/tests/test_data/world_tests/pattern_matched/expected.py index d7ffaa6..6703c79 100644 --- a/tests/test_data/world_tests/pattern_matched/expected.py +++ b/tests/test_data/world_tests/pattern_matched/expected.py @@ -8,116 +8,16 @@ EXPECTED = world.World( world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(0, 0), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_p0-n0.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_p0-n0.json") + .absolute() + .resolve(), ), world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(0, 160), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_p0-n1.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_p0-n1.json") + .absolute() + .resolve(), ), ], ) diff --git a/tests/test_data/world_tests/static_defined/expected.py b/tests/test_data/world_tests/static_defined/expected.py index f29750b..9b50ec6 100644 --- a/tests/test_data/world_tests/static_defined/expected.py +++ b/tests/test_data/world_tests/static_defined/expected.py @@ -8,116 +8,12 @@ EXPECTED = world.World( world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(0, 0), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_01.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_01.json").absolute().resolve(), ), world.WorldMap( size=common_types.Size(160, 160), coordinates=common_types.OrderedPair(160, 0), - tiled_map=tiled_map.TiledMap( - map_file=Path(Path(__file__).parent / "map_02.json") - .absolute() - .resolve(), - infinite=False, - map_size=common_types.Size(5, 5), - next_layer_id=2, - next_object_id=1, - orientation="orthogonal", - render_order="right-down", - tiled_version="1.6.0", - tile_size=common_types.Size(32, 32), - version="1.6", - tilesets={ - 1: tileset.Tileset( - columns=8, - image=Path( - Path(__file__).parent - / "../../images/tmw_desert_spacing.png" - ) - .absolute() - .resolve(), - image_width=265, - image_height=199, - firstgid=1, - margin=1, - spacing=1, - name="tileset", - tile_count=48, - tiled_version="1.6.0", - tile_height=32, - tile_width=32, - version="1.6", - type="tileset", - ) - }, - layers=[ - layer.TileLayer( - name="Tile Layer 1", - opacity=1, - visible=True, - id=1, - size=common_types.Size(5, 5), - data=[ - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - [30, 30, 30, 30, 30], - ], - ) - ], - ), + map_file=Path(Path(__file__).parent / "map_02.json").absolute().resolve(), ), ], )