def click(self, clickx, clicky, noneSelected): if self._present: if self.inInventory and clickx > self._position[ 0] and clickx < self._position[ 0] + 64 and clicky > self._position[ 1] and clicky < self._position[1] + 64: if self.selected: # If the item is currently selected, unselect it. self.displayNameBelow(False) self.changeSprite(self._inventoryRestingSprite) self.selected = False elif noneSelected: # If the item is currently unselected, select it. self.displayNameBelow(True) self.changeSprite(self._inventorySelectedSprite) self.selected = True return True elif noneSelected and clickx > self._position[ 0] and clickx < self._position[0] + self._size[ 0] and clicky > self._position[ 1] and clicky < self._position[1] + self._size[ 1] and self.canInteract( ): # If the item is not currently in the inventory, then it must be collected and added to the inventory. self.inInventory = True self._present = False self._couldBeInteractedWith = False self._canvas.delete(self.__thisObject) self._inventory.addItem(self) return True if self.selected and self.effect != None and not self.effect( self, self.objectsOfInteraction, clickx, clicky): infobox = Infobox(self._canvas, "You can't do that.", 1500) infobox.show() return True return False
def funkyFrostingFuelEffect(fuel, darbyCart, clickx, clicky): global darbyCartHasGas if darbyCart.click(clickx, clicky, False): fuel._inventory.removeItem(fuel) darbyCartHasGas = True infobox = Infobox(canvas, "You put the fuel in the Darby Cart.", 2500) infobox.show() return True return False
def darbyCartKeysEffect(keys, darbyCart, clickx, clicky): global darbyCartHasKey if darbyCart.click(clickx, clicky, False): keys._inventory.removeItem(keys) keys.depopulate() darbyCartHasKey = True infobox = Infobox(canvas, "You put the keys in the ignition.", 2500) infobox.show() return True return False
def darbyCartEffect(thisCart): global darbyCartHasKey, darbyCartHasGas, winByAbandonment if darbyCartHasKey and darbyCartHasGas: winByAbandonment(0) elif not darbyCartHasKey: infobox = Infobox(canvas, "The key is missing.", 1500) infobox.show() else: infobox = Infobox(canvas, "The gas tank is empty.", 1500) infobox.show()
def addItem(self, item): infobox = Infobox(self.__canvas, "You got: " + item.name, 2500) infobox.show() reopen = False if self.__open: self.closeInventory() reopen = True self.items[item.name] = item sorted(self.items) if reopen: self.openInventory() item.inInventory = True
def lose(event): if event == 0: player.enabled = False inventory.active(False) brian.populate() info = Infobox(canvas, 'Brian has been summoned!', 2500) info.show() root.after(2500, lose, 1) if event == 1: info = Infobox(canvas, 'Foolishly, you have not prepared for Brian.', 2500) info.show() root.after(2500, lose, 2) if event == 2: brian.depopulate() brian.populate(308, 570) info = Infobox(canvas, 'Beep Boop. Ya ded.', 1500) info.show() root.after(1500, lose, 3) if event == 3: stairwell.unloadRoom() Room([], [], sprites.titleCards[4], canvas, inventory, titleCard=True, player=player).loadRoom()
def winByIce(event): if event == 0: player.enabled = False inventory.active(False) brian.populate() info = Infobox(canvas, 'Brian has been summoned!', 2500) info.show() root.after(2500, winByIce, 1) if event == 1: brian.depopulate() brianFallen.populate() info = Infobox(canvas, 'Whoops! There he goes!', 2500) info.show() root.after(2500, winByIce, 2) if event == 2: info = Infobox(canvas, "He's fallen and he can't get up! He ded.", 2500) info.show() root.after(2500, winByIce, 3) if event == 3: stairwell.unloadRoom() Room([], [], sprites.titleCards[3], canvas, inventory, titleCard=True, player=player).loadRoom()
def pedestalEffect(thisPedestal): infobox = Infobox(canvas, "It's a strange-looking pedestal.", 1500) infobox.show()
def iceOnStairsEffect(thisIce): infobox = Infobox(canvas, "The ice is sitting at the top of the stairs.", 1500) infobox.show()
def calculatorOnPedestalEffect(thisCalculator): infobox = Infobox(canvas, "The calculator is sitting on the pedestal.", 1500) infobox.show()
def chunkOfIceEffect(thisChunkOfIce): infobox = Infobox(canvas, "Wow! That's a big piece of ice!", 1500) infobox.show()