diff --git a/gamemap.py b/gamemap.py index 825c98e..2c4be4e 100644 --- a/gamemap.py +++ b/gamemap.py @@ -309,11 +309,15 @@ list of lists of tuples.""" return nextThing elif isinstance(container, dict): for i in container: + if isinstance(container[i], _gt.Prefab): + container[i] = GameMap.resolvePrefab(prefabs, container[i]) nextThing = GameMap.addThingRecursive(GameMap.resolvePrefab(prefabs, container[i]), prefabs, nextThing) return nextThing elif isinstance(container, list): - for i in container: - nextThing = GameMap.addThingRecursive(GameMap.resolvePrefab(prefabs, i), prefabs, nextThing) + for i in range(len(container)): + if isinstance(container[i], _gt.Prefab): + container[i] = GameMap.resolvePrefab(prefabs, container[i]) + nextThing = GameMap.addThingRecursive(container[i], prefabs, nextThing) return nextThing else: return nextThing diff --git a/gameshell.py b/gameshell.py index 863ce81..bb394f6 100644 --- a/gameshell.py +++ b/gameshell.py @@ -497,7 +497,28 @@ Player is modified through side-effect.""" del instr[1] thingName = ' '.join(instr[1:]) if len(thingName) == 0: - print(f"{self.gameBase.player.name} looks at nothing.") + # Print the lists of items again. + longestLen = 0 + for i in player.thingNames: + if len(i) > longestLen: + longestLen = len(i) + if longestLen > 0: + inv = player.inventory # do this assignment because player.inventory is O(n) + print('{{0:<{0}}}{1}'.format(max(6, longestLen+2), "Container:").format("Inv:")) + i = 0 + while i < len(inv) and i < len(cont): + print('{{0:<{0}}}{1}'.format(longestLen+2, cont[i].name).format(inv[i].name)) + i += 1 + while i < len(inv): + print(inv[i].name) + i += 1 + while i < len(cont): + print(' '*(longestLen+2) + cont[i].name) + i += 1 + else: + print('Container:') + for i in cont: + print(i.name) else: # Check the container first. for i in range(len(cont)):