Fixed instant crash in last commit by adding valid testdata.yml, and fixed testdata.yml parsing.
This commit is contained in:
parent
9cda61a895
commit
aba0014e27
4 changed files with 39 additions and 14 deletions
13
gamemap.py
13
gamemap.py
|
@ -220,12 +220,12 @@ list of lists of tuples."""
|
|||
# Some things, like containers, have other things as custom values,
|
||||
# so they need IDs as well.
|
||||
if thing.thingType in 'iun':
|
||||
nextThing = self.addThingRecursive(thing.customValues, nextThing)
|
||||
nextThing = GameMap.addThingRecursive(thing.customValues, nextThing)
|
||||
if thing.thingType == 'n':
|
||||
for i in thing.tempInventory:
|
||||
if i.thingID == -1:
|
||||
i.thingID = nextThing
|
||||
nextThing = self.addThingRecursive(i.customValues, nextThing + 1)
|
||||
nextThing = GameMap.addThingRecursive(i.customValues, nextThing + 1)
|
||||
thing.addThing(i)
|
||||
del thing.tempInventory
|
||||
pos = self.coordsToInt(thing.x, thing.y)
|
||||
|
@ -242,21 +242,22 @@ list of lists of tuples."""
|
|||
self.persistent.append(thing.thingID)
|
||||
return nextThing
|
||||
|
||||
def addThingRecursive(self, container, nextThing = 0):
|
||||
@staticmethod
|
||||
def addThingRecursive(container, nextThing = 0):
|
||||
if isinstance(container, _gt.Thing):
|
||||
if container.thingID == -1:
|
||||
container.thingID = nextThing
|
||||
nextThing = self.addThingRecursive(container.customValues, nextThing)
|
||||
nextThing = GameMap.addThingRecursive(container.customValues, nextThing)
|
||||
return nextThing + 1
|
||||
else:
|
||||
return nextThing
|
||||
elif isinstance(container, dict):
|
||||
for i in container:
|
||||
nextThing = self.addThingRecursive(container[i], nextThing)
|
||||
nextThing = GameMap.addThingRecursive(container[i], nextThing)
|
||||
return nextThing
|
||||
elif isinstance(container, list):
|
||||
for i in container:
|
||||
nextThing = self.addThingRecursive(i, nextThing)
|
||||
nextThing = GameMap.addThingRecursive(i, nextThing)
|
||||
return nextThing
|
||||
else:
|
||||
return nextThing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue