Initial tests for worlds

This commit is contained in:
Darren Eberly
2021-05-15 23:50:15 -04:00
parent 6beb77b97d
commit e5caf6daee
17 changed files with 774 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
from pathlib import Path
from pytiled_parser import common_types, layer, tiled_map, tileset, world
EXPECTED = world.World(
only_show_adjacent=False,
maps=[
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,
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],
],
)
],
),
),
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,
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],
],
)
],
),
),
],
)

View File

@@ -0,0 +1,32 @@
{ "compressionlevel":-1,
"height":5,
"infinite":false,
"layers":[
{
"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],
"height":5,
"id":1,
"name":"Tile Layer 1",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":5,
"x":0,
"y":0
}],
"nextlayerid":2,
"nextobjectid":1,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.6.0",
"tileheight":32,
"tilesets":[
{
"firstgid":1,
"source":"tileset.json"
}],
"tilewidth":32,
"type":"map",
"version":"1.6",
"width":5
}

View File

@@ -0,0 +1,32 @@
{ "compressionlevel":-1,
"height":5,
"infinite":false,
"layers":[
{
"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],
"height":5,
"id":1,
"name":"Tile Layer 1",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":5,
"x":0,
"y":0
}],
"nextlayerid":2,
"nextobjectid":1,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.6.0",
"tileheight":32,
"tilesets":[
{
"firstgid":1,
"source":"tileset.json"
}],
"tilewidth":32,
"type":"map",
"version":"1.6",
"width":5
}

View File

@@ -0,0 +1,14 @@
{ "columns":8,
"image":"..\/..\/images\/tmw_desert_spacing.png",
"imageheight":199,
"imagewidth":265,
"margin":1,
"name":"tileset",
"spacing":1,
"tilecount":48,
"tiledversion":"1.6.0",
"tileheight":32,
"tilewidth":32,
"type":"tileset",
"version":"1.6"
}

View File

@@ -0,0 +1,12 @@
{
"patterns": [
{
"regexp": "map_p(\\d+)-n(\\d+)\\.json",
"multiplierX": 160,
"multiplierY": 160,
"offsetX": 0,
"offsetY": 0
}
],
"type": "world"
}