big time reset, we are not using TMX anymore, but instead using the JS 
format because it is way simpler to parse
This commit is contained in:
Benjamin Kirkbride
2020-05-01 19:19:08 -04:00
parent 03d70163f4
commit 4ff013c1f8
23 changed files with 87 additions and 4 deletions

View File

@@ -1,3 +0,0 @@
import pytest
pytest.main(["--tb=native", "-s", "tests"])

View File

@@ -0,0 +1,68 @@
{ "compressionlevel":0,
"height":6,
"infinite":false,
"layers":[
{
"data":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48],
"height":6,
"id":1,
"name":"Tile Layer 1",
"opacity":1,
"type":"tilelayer",
"visible":true,
"width":8,
"x":0,
"y":0
}],
"nextlayerid":2,
"nextobjectid":1,
"orientation":"orthogonal",
"properties":[
{
"name":"bool property - false",
"type":"bool",
"value":false
},
{
"name":"bool property - true",
"type":"bool",
"value":true
},
{
"name":"color property",
"type":"color",
"value":"#ff49fcff"
},
{
"name":"file property",
"type":"file",
"value":"..\/..\/..\/..\/..\/..\/..\/var\/log\/syslog"
},
{
"name":"float property",
"type":"float",
"value":1.23456789
},
{
"name":"int property",
"type":"int",
"value":13
},
{
"name":"string property",
"type":"string",
"value":"Hello, World!!"
}],
"renderorder":"right-down",
"tiledversion":"1.3.1",
"tileheight":32,
"tilesets":[
{
"firstgid":1,
"source":"tile_set.json"
}],
"tilewidth":32,
"type":"map",
"version":1.2,
"width":8
}

View File

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

View File

@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="32" tileheight="32" infinite="0" nextlayerid="16" nextobjectid="10">
<tileset firstgid="1" source="tile_set_image.tsx"/>
<layer id="1" name="Tile Layer 1" width="10" height="10">
<data encoding="csv">
1,2,3,4,5,6,7,8,30,30,
9,10,11,12,13,14,15,16,30,30,
17,18,19,20,21,22,23,24,30,30,
25,26,27,28,29,30,31,32,30,30,
33,34,35,36,37,38,39,40,30,30,
41,42,43,44,45,46,47,48,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,30,30,30,30,30,30,30,
30,30,30,30,30,30,30,30,30,30
</data>
</layer>
<layer id="2" name="Tile Layer 2" width="10" height="10" opacity="0.5">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,46,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,6,7,7,7,7,7,8,0,
0,0,14,15,15,15,15,15,16,0,
0,0,22,23,23,23,23,23,24,0
</data>
</layer>
<group id="3" name="Group 1">
<properties>
<property name="bool property" type="bool" value="true"/>
</properties>
<layer id="5" name="Tile Layer 4" width="10" height="10" offsetx="49" offsety="-50">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,31,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0
</data>
</layer>
<layer id="4" name="Tile Layer 3" width="10" height="10">
<data encoding="csv">
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
1,2,3,0,0,0,0,0,0,0,
9,10,11,0,0,0,0,0,0,0,
17,18,19,0,0,0,0,0,0,0
</data>
</layer>
</group>
<objectgroup color="#000000" draworder="index" id="6" name="Object Layer 1" opacity="0.9" offsetx="4.66667" offsety="-4.33333">
<object id="1" name="rectangle 1" type="rectangle type" x="200.25" y="210.75" width="47.25" height="25" rotation="15"/>
<object id="2" name="polygon 1" type="polygon type" x="252.5" y="87.75" rotation="-21">
<polygon points="0,0 -41.25,24.25 -11,67.25 25.75,39.75 -9,37.75"/>
</object>
<object id="3" name="elipse 1" type="elipse type" x="198.75" y="102.5" width="17.75" height="14.25">
<ellipse/>
</object>
<object id="4" name="point 1" type="point type" x="174.25" y="186">
<point/>
</object>
<object id="7" name="insert text 1" type="insert text type" x="11.3958" y="48.5833" width="107.625" height="27.25">
<text fontfamily="Sans Serif" pixelsize="17" wrap="1" color="#b40303" italic="1" underline="1" strikeout="1">Hello World</text>
</object>
<object id="6" name="inserted tile 1" type="inserted tile type" gid="3221225503" x="47.25" y="72.5" width="47" height="53" rotation="31">
<properties>
<property name="tile property bool" type="bool" value="true"/>
</properties>
</object>
<object id="8" name="polyline 1" type="polyline type" x="144.667" y="112">
<polyline points="0,0 -14.3333,35.6667 15.3333,18.3333"/>
</object>
<object id="9" name="polygon 2" type="polygon type" x="69.8333" y="168.333">
<polygon points="-3.25,-17.25 -15,10.75 20.75,4.5"/>
</object>
</objectgroup>
</map>

View File

@@ -1,390 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="8" height="6" tilewidth="32" tileheight="32" infinite="1" nextlayerid="3" nextobjectid="1">
<tileset firstgid="1" source="tile_set_image.tsx"/>
<layer id="1" name="Tile Layer 1" width="8" height="6">
<data encoding="csv">
<chunk x="-32" y="-32" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-16" y="-32" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="0" y="-32" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="16" y="-32" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-32" y="-16" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-16" y="-16" width="16" height="16">
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,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,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,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,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,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,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,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,30,30,30,30,30,30,30,30,
30,30,30,30,30,30,30,30,30,30,30,30,30,1,2,3,
30,30,30,30,30,30,30,30,30,30,30,30,30,9,10,11,
30,30,30,30,30,30,30,30,30,30,30,30,30,17,18,19
</chunk>
<chunk x="0" y="-16" width="16" height="16">
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,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,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,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,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,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,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,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,30,30,30,30,30,30,30,30,
4,5,6,7,8,30,30,30,30,30,30,30,30,30,30,30,
12,13,14,15,16,30,30,30,30,30,30,30,30,30,30,30,
20,21,22,23,24,30,30,30,30,30,30,30,30,30,30,30
</chunk>
<chunk x="16" y="-16" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-32" y="0" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-16" y="0" width="16" height="16">
30,30,30,30,30,30,30,30,30,30,30,30,30,25,26,27,
30,30,30,30,30,30,30,30,30,30,30,30,30,33,34,35,
30,30,30,30,30,30,30,30,30,30,30,30,30,41,42,43,
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,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,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,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,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,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,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,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,30,30,30,30,30,30,30,30
</chunk>
<chunk x="0" y="0" width="16" height="16">
28,29,30,31,32,30,30,30,30,30,30,30,30,30,30,30,
36,37,38,39,40,30,30,30,30,30,30,30,30,30,30,30,
44,45,46,47,48,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,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,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,
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,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,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,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,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,30,30,30,
30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30
</chunk>
<chunk x="16" y="0" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-32" y="16" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="-16" y="16" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="0" y="16" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
<chunk x="16" y="16" width="16" height="16">
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,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,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,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,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,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,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,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,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,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,30,30,30,30,30,30
</chunk>
</data>
</layer>
<layer id="2" name="Tile Layer 2" width="8" height="6">
<data encoding="csv">
<chunk x="-32" y="-16" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,21,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,29,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="16" y="-16" width="16" height="16">
0,0,20,21,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,28,29,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="-16" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
20,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="16" y="0" width="16" height="16">
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
20,21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
28,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
<chunk x="-16" y="16" width="16" height="16">
28,29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
</chunk>
</data>
</layer>
</map>

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="8" height="6" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<properties>
<property name="bool property - false" type="bool" value="false"/>
<property name="bool property - true" type="bool" value="true"/>
<property name="color property" type="color" value="#ff49fcff"/>
<property name="file property" type="file" value="/var/log/syslog"/>
<property name="float property" type="float" value="1.23456789"/>
<property name="int property" type="int" value="13"/>
<property name="string property" value="Hello, World!!"/>
</properties>
<tileset firstgid="1" source="tile_set_image.tsx"/>
<layer id="1" name="Tile Layer 1" width="8" height="6">
<data encoding="csv">
1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48
</data>
</layer>
</map>

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="8" height="6" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<properties>
<property name="bool property - false" type="bool" value="false"/>
<property name="bool property - true" type="bool" value="true"/>
<property name="color property" type="color" value="#ff49fcff"/>
<property name="file property" type="file" value="../../../../../../../../var/log/syslog"/>
<property name="float property" type="float" value="1.23456789"/>
<property name="int property" type="int" value="13"/>
<property name="string property" value="Hello, World!!"/>
</properties>
<tileset firstgid="1" source="tile_set_image.tsx"/>
<layer id="1" name="Tile Layer 1" width="8" height="6">
<data encoding="base64" compression="gzip">
H4sIAAAAAAAAAw3DBRKCQAAAwDMRA7BQLMTE9v+vY3dmWyGEth279uwbOTB26MixExNTM6fOnLtwae7KtYUbt+7ce7D0aOXJsxev3rxb+/Dpy7cfv/782wAcvDirwAAAAA==
</data>
</layer>
</map>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.2.3" orientation="orthogonal" renderorder="right-down" width="8" height="6" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<tileset firstgid="1" source="tile_set_image_objects.tsx"/>
<layer id="1" name="Tile Layer 1" width="8" height="6">
<data encoding="csv">
1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48
</data>
</layer>
</map>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.2" tiledversion="1.3.1" orientation="orthogonal" renderorder="right-down" compressionlevel="0" width="8" height="6" tilewidth="32" tileheight="32" infinite="0" nextlayerid="2" nextobjectid="1">
<properties>
<property name="bool property - false" type="bool" value="false"/>
<property name="bool property - true" type="bool" value="true"/>
<property name="color property" type="color" value="#ff49fcff"/>
<property name="float property" type="float" value="1.23456789"/>
<property name="int property" type="int" value="13"/>
<property name="string property" value="Hello, World!!"/>
</properties>
<tileset firstgid="1" source="tile_set_image.tsx"/>
<layer id="1" name="Tile Layer 1" width="8" height="6" offsetx="16" offsety="-16.42">
<data encoding="csv">
1,2,3,4,5,6,7,8,
9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,
25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,
41,42,43,44,45,46,47,48
</data>
</layer>
</map>

View File

@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.2" tiledversion="1.2.3" name="tile_set_image" tilewidth="32" tileheight="32" spacing="1" margin="1" tilecount="48" columns="8">
<image source="images/tmw_desert_spacing.png" width="265" height="199"/>
</tileset>

View File

@@ -1,40 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.2" tiledversion="1.2.3" name="tile_set_image" tilewidth="32" tileheight="32" spacing="1" margin="1" tilecount="48" columns="8">
<image source="images/tmw_desert_spacing.png" width="265" height="199"/>
<tile id="9">
<objectgroup draworder="index">
<object id="2" name="wall" type="rectangle type" x="1" y="1" width="32" height="32" rotation="1"/>
</objectgroup>
</tile>
<tile id="19">
<objectgroup draworder="index">
<object id="1" name="wall corner" type="polygon type" x="32" y="1" rotation="1">
<polygon points="0,0 -32,0 -32,32 -16,32.1818 -15.8182,16.9091 0.181818,17.0909"/>
</object>
</objectgroup>
</tile>
<tile id="20">
<objectgroup draworder="index">
<object id="1" name="polyline" type="polyline type" x="1.45455" y="1.45455" rotation="1">
<polyline points="0,0 25.0909,21.2727 9.63636,28.3636"/>
</object>
</objectgroup>
</tile>
<tile id="31">
<objectgroup draworder="index">
<object id="1" name="rock 1" type="elipse type" x="5.09091" y="2.54545" width="19.6364" height="19.2727" rotation="1">
<ellipse/>
</object>
<object id="2" name="rock 2" type="elipse type" x="16.1818" y="22" width="8.54545" height="8.36364" rotation="-1">
<ellipse/>
</object>
</objectgroup>
</tile>
<tile id="45">
<objectgroup draworder="index">
<object id="1" name="sign" type="point type" x="14.7273" y="26.3636">
<point/>
</object>
</objectgroup>
</tile>
</tileset>

File diff suppressed because one or more lines are too long

View File

@@ -1,223 +0,0 @@
"""Unit tests for pytiled_parser"""
import xml.etree.ElementTree as etree
from contextlib import ExitStack as does_not_raise
import pytest
from pytiled_parser import objects, utilities, xml_parser
LAYER_DATA = [
(
'<layer id="1" name="Tile Layer 1" width="10" height="10">' + "</layer>",
(int(1), "Tile Layer 1", None, None, None),
),
(
'<layer id="2" name="Tile Layer 2" width="10" height="10" opacity="0.5">'
+ "</layer>",
(int(2), "Tile Layer 2", None, float(0.5), None),
),
(
'<layer id="5" name="Tile Layer 4" width="10" height="10" offsetx="49" offsety="-50">'
+ "<properties>"
+ "</properties>"
+ "</layer>",
(int(5), "Tile Layer 4", objects.OrderedPair(49, -50), None, "properties",),
),
]
@pytest.mark.parametrize("xml,expected", LAYER_DATA)
def test_parse_layer(xml, expected, monkeypatch):
def mockreturn(*args):
return "properties"
monkeypatch.setattr(xml_parser, "_parse_properties_element", mockreturn)
result = xml_parser._parse_layer(etree.fromstring(xml))
assert result == expected
@pytest.mark.parametrize(
"test_input,expected",
[
("#001122", (0x00, 0x11, 0x22, 0xFF)),
("001122", (0x00, 0x11, 0x22, 0xFF)),
("#FF001122", (0x00, 0x11, 0x22, 0xFF)),
("FF001122", (0x00, 0x11, 0x22, 0xFF)),
("FF001122", (0x00, 0x11, 0x22, 0xFF)),
],
)
def test_color_parsing(test_input, expected):
assert utilities.parse_color(test_input) == expected
layer_data = [
(
etree.fromstring(
"<data>\n1,2,3,4,5,6,7,8,\n"
"9,10,11,12,13,14,15,16,\n"
"17,18,19,20,21,22,23,24,\n"
"25,26,27,28,29,30,31,32,\n"
"33,34,35,36,37,38,39,40,\n"
"41,42,43,44,45,46,47,48\n</data>"
),
8,
"csv",
None,
[
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
],
does_not_raise(),
),
(
etree.fromstring("<data>\n0,0,0,0,0\n</data>"),
5,
"csv",
None,
[[0, 0, 0, 0, 0]],
does_not_raise(),
),
(
etree.fromstring(
"<data>AQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEAAAABEAAAASAAAAEwAAABQAAAAVAAAAFgAAABcAAAAYAAAAGQAAABoAAAAbAAAAHAAAAB0AAAAeAAAAHwAAACAAAAAhAAAAIgAAACMAAAAkAAAAJQAAACYAAAAnAAAAKAAAACkAAAAqAAAAKwAAACwAAAAtAAAALgAAAC8AAAAwAAAA</data>"
),
8,
"base64",
None,
[
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
],
does_not_raise(),
),
(
etree.fromstring(
"<data>eJwNwwUSgkAAAMAzEQOwUCzExPb/r2N3ZlshhLYdu/bsGzkwdujIsRMTUzOnzpy7cGnuyrWFG7fu3Huw9GjlybMXr968W/vw6cu3H7/+/NsAMw8EmQ==</data>"
),
8,
"base64",
"zlib",
[
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
],
does_not_raise(),
),
(
etree.fromstring(
"<data>H4sIAAAAAAAAAw3DBRKCQAAAwDMRA7BQLMTE9v+vY3dmWyGEth279uwbOTB26MixExNTM6fOnLtwae7KtYUbt+7ce7D0aOXJsxev3rxb+/Dpy7cfv/782wAcvDirwAAAAA==</data>"
),
8,
"base64",
"gzip",
[
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
],
does_not_raise(),
),
(
etree.fromstring("<data>SGVsbG8gV29ybGQh</data>"),
8,
"base64",
"lzma",
[
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
],
pytest.raises(ValueError),
),
(
etree.fromstring(
"<data>/ .---- --..-- ..--- --..-- ...-- --..-- ....- --..-- ..... --..-- -.... --..-- --... --..-- ---.. --..-- / ----. --..-- .---- ----- --..-- .---- .---- --..-- .---- ..--- --..-- .---- ...-- --..-- .---- ....- --..-- .---- ..... --..-- .---- -.... --..-- / .---- --... --..-- .---- ---.. --..-- .---- ----. --..-- ..--- ----- --..-- ..--- .---- --..-- ..--- ..--- --..-- ..--- ...-- --..-- ..--- ....- --..-- / ..--- ..... --..-- ..--- -.... --..-- ..--- --... --..-- ..--- ---.. --..-- ..--- ----. --..-- ...-- ----- --..-- ...-- .---- --..-- ...-- ..--- --..-- / ...-- ...-- --..-- ...-- ....- --..-- ...-- ..... --..-- ...-- -.... --..-- ...-- --... --..-- ...-- ---.. --..-- ...-- ----. --..-- ....- ----- --..-- / ....- .---- --..-- ....- ..--- --..-- ....- ...-- --..-- ....- ....- --..-- ....- ..... --..-- ....- -.... --..-- ....- --... --..-- ....- ---..</data>"
),
8,
"morse",
None,
[
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
],
pytest.raises(ValueError),
),
]
@pytest.mark.parametrize(
"layer_data,width,encoding,compression,expected,raises", layer_data
)
def test_decode_layer_data(layer_data, width, encoding, compression, expected, raises):
with raises:
assert (
xml_parser._decode_tile_layer_data(layer_data, width, encoding, compression)
== expected
)
# FIXME: use hypothesis for this
def create_tile_set(qty_of_tiles):
""" Create tile set of specific size.
"""
tile_set = objects.TileSet(None, None)
if qty_of_tiles == 0:
return tile_set
tiles = {}
for tile_id in range(qty_of_tiles):
tiles[tile_id] = objects.Tile(id_=tile_id)
tile_set.tiles = tiles
return tile_set
tile_by_gid = [
(1, {1: create_tile_set(0)}, None),
(1, {1: create_tile_set(1)}, objects.Tile(id_=0)),
(1, {1: create_tile_set(2)}, objects.Tile(id_=0)),
(2, {1: create_tile_set(1)}, None),
(10, {1: create_tile_set(10)}, objects.Tile(id_=9)),
(1, {1: create_tile_set(1), 2: create_tile_set(1)}, objects.Tile(id_=0)),
(2, {1: create_tile_set(1), 2: create_tile_set(1)}, objects.Tile(id_=0)),
(3, {1: create_tile_set(1), 2: create_tile_set(1)}, None),
(15, {1: create_tile_set(5), 6: create_tile_set(10)}, objects.Tile(id_=9)),
(
20,
{1: create_tile_set(5), 6: create_tile_set(10), 16: create_tile_set(10),},
objects.Tile(id_=4),
),
]
@pytest.mark.parametrize("gid,tile_sets,expected", tile_by_gid)
def test_get_tile_by_gid(gid, tile_sets, expected):
assert utilities.get_tile_by_gid(gid, tile_sets) == expected

View File

@@ -1,98 +0,0 @@
import os
from pathlib import Path
import pytest
import pytiled_parser
TESTS_DIR = Path(os.path.dirname(os.path.abspath(__file__)))
TEST_DATA = TESTS_DIR / "test_data"
def test_map_simple():
"""
TMX with a very simple spritesheet tile set and some properties.
"""
test_map = pytiled_parser.parse_tile_map(TEST_DATA / "test_map_simple.tmx")
# map
# unsure how to get paths to compare propperly
assert test_map.parent_dir == TEST_DATA
assert test_map.version == "1.2"
assert test_map.tiled_version == "1.2.3"
assert test_map.orientation == "orthogonal"
assert test_map.render_order == "right-down"
assert test_map.map_size == (8, 6)
assert test_map.tile_size == (32, 32)
assert test_map.infinite == False
assert test_map.next_layer_id == 2
assert test_map.next_object_id == 1
# optional, not for orthogonal maps
assert test_map.hex_side_length == None
assert test_map.stagger_axis == None
assert test_map.stagger_index == None
assert test_map.background_color == None
assert test_map.properties == {
"bool property - false": False,
"bool property - true": True,
"color property": "#ff49fcff",
"file property": Path("/var/log/syslog"),
"float property": 1.23456789,
"int property": 13,
"string property": "Hello, World!!",
}
# tileset
assert test_map.tile_sets[1].name == "tile_set_image"
assert test_map.tile_sets[1].max_tile_size == (32, 32)
assert test_map.tile_sets[1].spacing == 1
assert test_map.tile_sets[1].margin == 1
assert test_map.tile_sets[1].tile_count == 48
assert test_map.tile_sets[1].columns == 8
assert test_map.tile_sets[1].tile_offset == None
assert test_map.tile_sets[1].grid == None
assert test_map.tile_sets[1].properties == None
# unsure how to get paths to compare propperly
assert str(test_map.tile_sets[1].image.source) == ("images/tmw_desert_spacing.png")
assert test_map.tile_sets[1].image.trans == None
assert test_map.tile_sets[1].image.size == (265, 199)
assert test_map.tile_sets[1].terrain_types == None
assert test_map.tile_sets[1].tiles == {}
# layers
assert test_map.layers[0].layer_data == [
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
]
assert test_map.layers[0].id_ == 1
assert test_map.layers[0].name == "Tile Layer 1"
assert test_map.layers[0].offset == None
assert test_map.layers[0].opacity == None
assert test_map.layers[0].properties == None
assert test_map.layers[0].size == (8, 6)
@pytest.mark.parametrize(
"test_input,expected",
[
("#001122", (0x00, 0x11, 0x22, 0xFF)),
("001122", (0x00, 0x11, 0x22, 0xFF)),
("#FF001122", (0x00, 0x11, 0x22, 0xFF)),
("FF001122", (0x00, 0x11, 0x22, 0xFF)),
("FF001122", (0x00, 0x11, 0x22, 0xFF)),
],
)
def test_color_parsing(test_input, expected):
"""
Tiled has a few different types of color representations.
"""
assert pytiled_parser.utilities.parse_color(test_input) == expected

View File

@@ -1,81 +0,0 @@
"""test test_map_simple_offset.tmx"""
import os
from pathlib import Path
import pytiled_parser
TESTS_DIR = Path(os.path.dirname(os.path.abspath(__file__)))
TEST_DATA = TESTS_DIR / "test_data"
def test_map_simple():
"""
TMX with a very simple spritesheet tile set and some properties.
"""
test_map = pytiled_parser.parse_tile_map(TEST_DATA / "test_map_simple_offset.tmx")
# map
# unsure how to get paths to compare propperly
assert test_map.parent_dir == TEST_DATA
assert test_map.version == "1.2"
assert test_map.tiled_version == "1.3.1"
assert test_map.orientation == "orthogonal"
assert test_map.render_order == "right-down"
assert test_map.map_size == (8, 6)
assert test_map.tile_size == (32, 32)
assert test_map.infinite == False
assert test_map.next_layer_id == 2
assert test_map.next_object_id == 1
# optional, not for orthogonal maps
assert test_map.hex_side_length == None
assert test_map.stagger_axis == None
assert test_map.stagger_index == None
assert test_map.background_color == None
assert test_map.properties == {
"bool property - false": False,
"bool property - true": True,
"color property": "#ff49fcff",
"float property": 1.23456789,
"int property": 13,
"string property": "Hello, World!!",
}
# tileset
assert test_map.tile_sets[1].name == "tile_set_image"
assert test_map.tile_sets[1].max_tile_size == (32, 32)
assert test_map.tile_sets[1].spacing == 1
assert test_map.tile_sets[1].margin == 1
assert test_map.tile_sets[1].tile_count == 48
assert test_map.tile_sets[1].columns == 8
assert test_map.tile_sets[1].tile_offset == None
assert test_map.tile_sets[1].grid == None
assert test_map.tile_sets[1].properties == None
# unsure how to get paths to compare propperly
assert str(test_map.tile_sets[1].image.source) == ("images/tmw_desert_spacing.png")
assert test_map.tile_sets[1].image.trans == None
assert test_map.tile_sets[1].image.size == (265, 199)
assert test_map.tile_sets[1].terrain_types == None
assert test_map.tile_sets[1].tiles == {}
# layers
assert test_map.layers[0].layer_data == [
[1, 2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15, 16],
[17, 18, 19, 20, 21, 22, 23, 24],
[25, 26, 27, 28, 29, 30, 31, 32],
[33, 34, 35, 36, 37, 38, 39, 40],
[41, 42, 43, 44, 45, 46, 47, 48],
]
assert test_map.layers[0].id_ == 1
assert test_map.layers[0].name == "Tile Layer 1"
assert test_map.layers[0].offset == pytiled_parser.objects.OrderedPair(
x=16.0, y=-16.42
)
assert test_map.layers[0].opacity == None
assert test_map.layers[0].properties == None
assert test_map.layers[0].size == (8, 6)

View File

@@ -1,19 +0,0 @@
"""Tests for typing helpers"""
import pytest
from pytiled_parser import typing_helpers as TH
TEST_IS_FLOAT_PARAMS = [
(1, True),
("1", True),
(1.1, True),
("1.1", True),
("one", False),
(None, False),
]
@pytest.mark.parametrize("string,expected", TEST_IS_FLOAT_PARAMS)
def test_is_float(string, expected):
assert TH.is_float(string) == expected