def __init__(self, scenarioData, roomId, roomAttributes, roomImages): if not (roomAttributes): roomAttributes = Room.roomAttributes super(Room, self).__init__(scenarioData, roomAttributes, roomId) self.objectList = [] self.background = None if not (roomImages): return # Create objects inside the room including the background # TODO: Parsing objects could as well be done in View? self.background = None for imageId in roomImages: images = roomImages[imageId].pop("image") imageAttributes = roomImages[imageId] imageCategory = images[0]["category"] # Create objects according to their category if (imageAttributes["className"] == "Text"): self.objectList.append( Object.Text(self, images[0], imageAttributes, imageId)) elif (imageCategory == "room_background"): self.background = Object.JSONImage(self, images[0], imageAttributes) # TODO: Secret items - fix it in kiigame first elif (imageCategory == "item"): self.objectList.append( Object.Item(self, imageId, images, imageAttributes)) elif (imageCategory == "container"): self.objectList.append( Object.Container(self, imageId, images, imageAttributes)) elif (imageCategory == "door"): self.objectList.append( Object.Door(self, imageId, images, imageAttributes)) elif (imageCategory == "obstacle"): self.objectList.append( Object.Obstacle(self, imageId, images, imageAttributes)) else: self.objectList.append( Object.Object(self, imageId, images, imageAttributes))
def addContainer(self, objectAttributes=None, imageAttributes=None): imageId = self.id + "_container" newObject = Object.Container(self, imageId, imageAttributes, objectAttributes) self.objectList.append(newObject) return newObject