def deathMonster(monster): ''' What happens when a non-player character dies? Monster is actor class instance. ''' GAME.addMessage(monster.name + " has been slain!") monster.creatureToItems()
def handleOtherGameInputs(event): if event.key == pygame.K_g: GAME.player.pickupObjects() if event.key == pygame.K_y: entryPortal = GAME.player.isOnPortal() if entryPortal is None: return GAME.transitPortal(entryPortal)
def drop(self): actor = self.currentContainer.owner GAME.currentLevel.addObject(self) #clunky AF # GAME.currentLevel.objects.append(self) #clunky AF self.currentContainer.inventory.remove(self) #self.currentContainer = None self.x = actor.x self.y = actor.y self.resyncGraphicPosition() GAME.addMessage("item " + self.name + " dropped!")
def pickup(self, actor): if actor.container: if actor.container.volume_used + self.volume > actor.container.max_volume: GAME.addMessage(actor.name + " doesn't have enough room") else: GAME.addMessage(actor.name + " picked up " + self.name) actor.container.inventory.append(self) GAME.currentLevel.removeObject(self) # GAME.currentLevel.objects.remove(self) self.currentContainer = actor.container
def castHeal(target, value) -> float: ''' Target is a Creature type. ''' print("heal was cast") #TODO: implement creature.heal function endHp = min(target.maxHp, target.hp + value) deltaHp = endHp - target.hp target.hp = endHp if deltaHp > 0: GAME.addMessage(target.name + " heals for " + str(deltaHp)) return True else: GAME.addMessage(target.name + " is already at full HP") return False
def initializeGame(): pygame.init() pygame.key.set_repeat(200, 200) # Makes holding down keys work. if 1: level0 = Level("town3") GAME.levels.append(level0) GAME.currentLevel = level0 level0.placePlayerAtPortal(level0.portals[1]) level1 = Level("mapwPIES4") GAME.levels.append(level1) GAME.couplePortals(level0.portals[0], level1.portals[0]) level2 = Level("mapwPIES3") GAME.levels.append(level2) GAME.couplePortals(level1.portals[1], level2.portals[0]) GAME.viewer = GAME.player GAME.camera = graphics.Camera(viewer=GAME.player)
def execute(self) -> bool: # attack at the start of the duration. if not self.started: if self.target.dead: return False GAME.addMessage( f'{self.actor.uniqueName} attacks {self.target.uniqueName}') if not dexterityFunction(self.actor, self.target): GAME.addMessage(f'... and misses!') # add stunned time return False damage = damageFunction(self.actor, self.target) GAME.addMessage(f'... and hits for {damage} hp!') self.target.scheduleDamage(dhp=damage, emoteName='fireSmall') self.tick() return True
def equip(self) -> None: #self.canBeEquipped(owner) #self.owner.unequipElseInSlot(self) #slot stuff self.equipped = True GAME.addMessage(f'{self.name} equipped')
def unequip(self) -> None: #slot stuff self.equipped = False GAME.addMessage(f'{self.name} unequipped')