Skip to content

Commit e5caf6d

Browse files
committed
Initial tests for worlds
1 parent 6beb77b commit e5caf6d

File tree

17 files changed

+774
-0
lines changed

17 files changed

+774
-0
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
from pathlib import Path
2+
3+
from pytiled_parser import common_types, layer, tiled_map, tileset, world
4+
5+
EXPECTED = world.World(
6+
only_show_adjacent=False,
7+
maps=[
8+
world.WorldMap(
9+
size=common_types.Size(160, 160),
10+
coordinates=common_types.OrderedPair(-160, 0),
11+
tiled_map=tiled_map.TiledMap(
12+
map_file=Path(Path(__file__).parent / "map_manual_one.json")
13+
.absolute()
14+
.resolve(),
15+
infinite=False,
16+
map_size=common_types.Size(5, 5),
17+
next_layer_id=2,
18+
next_object_id=1,
19+
orientation="orthogonal",
20+
render_order="right-down",
21+
tiled_version="1.6.0",
22+
tile_size=common_types.Size(32, 32),
23+
version="1.6",
24+
tilesets={
25+
1: tileset.Tileset(
26+
columns=8,
27+
image=Path(
28+
Path(__file__).parent
29+
/ "../../images/tmw_desert_spacing.png"
30+
)
31+
.absolute()
32+
.resolve(),
33+
image_width=265,
34+
image_height=199,
35+
margin=1,
36+
spacing=1,
37+
name="tileset",
38+
tile_count=48,
39+
tiled_version="1.6.0",
40+
tile_height=32,
41+
tile_width=32,
42+
version="1.6",
43+
type="tileset",
44+
)
45+
},
46+
layers=[
47+
layer.TileLayer(
48+
name="Tile Layer 1",
49+
opacity=1,
50+
visible=True,
51+
id=1,
52+
size=common_types.Size(5, 5),
53+
data=[
54+
[30, 30, 30, 30, 30],
55+
[30, 30, 30, 30, 30],
56+
[30, 30, 30, 30, 30],
57+
[30, 30, 30, 30, 30],
58+
[30, 30, 30, 30, 30],
59+
],
60+
)
61+
],
62+
),
63+
),
64+
world.WorldMap(
65+
size=common_types.Size(160, 160),
66+
coordinates=common_types.OrderedPair(0, 0),
67+
tiled_map=tiled_map.TiledMap(
68+
map_file=Path(Path(__file__).parent / "map_p0-n0.json")
69+
.absolute()
70+
.resolve(),
71+
infinite=False,
72+
map_size=common_types.Size(5, 5),
73+
next_layer_id=2,
74+
next_object_id=1,
75+
orientation="orthogonal",
76+
render_order="right-down",
77+
tiled_version="1.6.0",
78+
tile_size=common_types.Size(32, 32),
79+
version="1.6",
80+
tilesets={
81+
1: tileset.Tileset(
82+
columns=8,
83+
image=Path(
84+
Path(__file__).parent
85+
/ "../../images/tmw_desert_spacing.png"
86+
)
87+
.absolute()
88+
.resolve(),
89+
image_width=265,
90+
image_height=199,
91+
margin=1,
92+
spacing=1,
93+
name="tileset",
94+
tile_count=48,
95+
tiled_version="1.6.0",
96+
tile_height=32,
97+
tile_width=32,
98+
version="1.6",
99+
type="tileset",
100+
)
101+
},
102+
layers=[
103+
layer.TileLayer(
104+
name="Tile Layer 1",
105+
opacity=1,
106+
visible=True,
107+
id=1,
108+
size=common_types.Size(5, 5),
109+
data=[
110+
[30, 30, 30, 30, 30],
111+
[30, 30, 30, 30, 30],
112+
[30, 30, 30, 30, 30],
113+
[30, 30, 30, 30, 30],
114+
[30, 30, 30, 30, 30],
115+
],
116+
)
117+
],
118+
),
119+
),
120+
world.WorldMap(
121+
size=common_types.Size(160, 160),
122+
coordinates=common_types.OrderedPair(0, 160),
123+
tiled_map=tiled_map.TiledMap(
124+
map_file=Path(Path(__file__).parent / "map_p0-n1.json")
125+
.absolute()
126+
.resolve(),
127+
infinite=False,
128+
map_size=common_types.Size(5, 5),
129+
next_layer_id=2,
130+
next_object_id=1,
131+
orientation="orthogonal",
132+
render_order="right-down",
133+
tiled_version="1.6.0",
134+
tile_size=common_types.Size(32, 32),
135+
version="1.6",
136+
tilesets={
137+
1: tileset.Tileset(
138+
columns=8,
139+
image=Path(
140+
Path(__file__).parent
141+
/ "../../images/tmw_desert_spacing.png"
142+
)
143+
.absolute()
144+
.resolve(),
145+
image_width=265,
146+
image_height=199,
147+
margin=1,
148+
spacing=1,
149+
name="tileset",
150+
tile_count=48,
151+
tiled_version="1.6.0",
152+
tile_height=32,
153+
tile_width=32,
154+
version="1.6",
155+
type="tileset",
156+
)
157+
},
158+
layers=[
159+
layer.TileLayer(
160+
name="Tile Layer 1",
161+
opacity=1,
162+
visible=True,
163+
id=1,
164+
size=common_types.Size(5, 5),
165+
data=[
166+
[30, 30, 30, 30, 30],
167+
[30, 30, 30, 30, 30],
168+
[30, 30, 30, 30, 30],
169+
[30, 30, 30, 30, 30],
170+
[30, 30, 30, 30, 30],
171+
],
172+
)
173+
],
174+
),
175+
),
176+
],
177+
)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ "compressionlevel":-1,
2+
"height":5,
3+
"infinite":false,
4+
"layers":[
5+
{
6+
"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],
7+
"height":5,
8+
"id":1,
9+
"name":"Tile Layer 1",
10+
"opacity":1,
11+
"type":"tilelayer",
12+
"visible":true,
13+
"width":5,
14+
"x":0,
15+
"y":0
16+
}],
17+
"nextlayerid":2,
18+
"nextobjectid":1,
19+
"orientation":"orthogonal",
20+
"renderorder":"right-down",
21+
"tiledversion":"1.6.0",
22+
"tileheight":32,
23+
"tilesets":[
24+
{
25+
"firstgid":1,
26+
"source":"tileset.json"
27+
}],
28+
"tilewidth":32,
29+
"type":"map",
30+
"version":"1.6",
31+
"width":5
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ "compressionlevel":-1,
2+
"height":5,
3+
"infinite":false,
4+
"layers":[
5+
{
6+
"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],
7+
"height":5,
8+
"id":1,
9+
"name":"Tile Layer 1",
10+
"opacity":1,
11+
"type":"tilelayer",
12+
"visible":true,
13+
"width":5,
14+
"x":0,
15+
"y":0
16+
}],
17+
"nextlayerid":2,
18+
"nextobjectid":1,
19+
"orientation":"orthogonal",
20+
"renderorder":"right-down",
21+
"tiledversion":"1.6.0",
22+
"tileheight":32,
23+
"tilesets":[
24+
{
25+
"firstgid":1,
26+
"source":"tileset.json"
27+
}],
28+
"tilewidth":32,
29+
"type":"map",
30+
"version":"1.6",
31+
"width":5
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{ "compressionlevel":-1,
2+
"height":5,
3+
"infinite":false,
4+
"layers":[
5+
{
6+
"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],
7+
"height":5,
8+
"id":1,
9+
"name":"Tile Layer 1",
10+
"opacity":1,
11+
"type":"tilelayer",
12+
"visible":true,
13+
"width":5,
14+
"x":0,
15+
"y":0
16+
}],
17+
"nextlayerid":2,
18+
"nextobjectid":1,
19+
"orientation":"orthogonal",
20+
"renderorder":"right-down",
21+
"tiledversion":"1.6.0",
22+
"tileheight":32,
23+
"tilesets":[
24+
{
25+
"firstgid":1,
26+
"source":"tileset.json"
27+
}],
28+
"tilewidth":32,
29+
"type":"map",
30+
"version":"1.6",
31+
"width":5
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{ "columns":8,
2+
"image":"..\/..\/images\/tmw_desert_spacing.png",
3+
"imageheight":199,
4+
"imagewidth":265,
5+
"margin":1,
6+
"name":"tileset",
7+
"spacing":1,
8+
"tilecount":48,
9+
"tiledversion":"1.6.0",
10+
"tileheight":32,
11+
"tilewidth":32,
12+
"type":"tileset",
13+
"version":"1.6"
14+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"maps": [
3+
{
4+
"fileName": "map_manual_one.json",
5+
"height": 160,
6+
"width": 160,
7+
"x": -160,
8+
"y": 0
9+
}
10+
],
11+
"patterns": [
12+
{
13+
"regexp": "map_p(\\d+)-n(\\d+)\\.json",
14+
"multiplierX": 160,
15+
"multiplierY": 160,
16+
"offsetX": 0,
17+
"offsetY": 0
18+
}
19+
],
20+
"onlyShowAdjacentMaps": false,
21+
"type": "world"
22+
}

0 commit comments

Comments
 (0)