def __init__(self, scenarioData, startAttributes, startImages): super(Start, self).__init__(scenarioData, startAttributes, "start") self.nameable = False for imageId in startImages: imageAttributes = startImages[imageId].pop("image")[0] objectAttributes = startImages[imageId] imageId = imageAttributes["id"] # Create objects according to its category if (imageId == "beginning"): self.beginningImage = Object.BeginningImage( self, imageAttributes, objectAttributes) if (imageId == "start"): self.background = Object.JSONImage(self, imageAttributes, objectAttributes)
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 __init__(self, scenarioData, endId, endAttributes, endImages): if not (endAttributes): endAttributes = End.endAttributes super(End, self).__init__(scenarioData, endAttributes, endId) self.endImages = [] self.endText = None self.nameable = False if not (endImages): return for imageId in endImages: imageAttributes = endImages[imageId].pop("image")[0] objectAttributes = endImages[imageId] imageId = imageAttributes["id"] self.endImages.append( Object.JSONImage(self, imageAttributes, objectAttributes))
def createPlaceholderImage(self, imagePath): self.placeholderImage = Object.JSONImage(self, None, None, self.id) self.placeholderImage.setSource(imagePath)