def dequip(self): if not self.is_equipped: return self.is_equipped = False Messages.new( 'Dequipped ' + self.owner.name + ' from ' + self.slot_str + '.', libtcod.light_yellow)
def inspect(self): if self.owner.equipment: item = self.owner.equipment stats_list = [] if item.power_bonus != 0: stats_list.append(str(item.power_bonus) + ' Power') if item.defense_bonus != 0: stats_list.append(str(item.defense_bonus) + ' Defense') if item.armor_bonus != 0: stats_list.append(str(item.armor_bonus) + ' AC') if item.magic_bonus != 0: stats_list.append(str(item.magic_bonus) + ' Magic') if item.max_hp_bonus != 0: stats_list.append(str(item.max_hp_bonus) + ' Max HP') if item.max_mana_bonus != 0: stats_list.append(str(item.max_mana_bonus) + ' Max Mana') if item.fighting_bonus != 0: stats_list.append(str(item.fighting_bonus) + ' Fighting') if item.shielding_bonus != 0: stats_list.append(str(item.shielding_bonus) + ' Shielding') if item.conjuring_bonus != 0: stats_list.append(str(item.conjuring_bonus) + ' Conjuring') if item.archery_bonus != 0: stats_list.append(str(item.archery_bonus) + ' Archery') if item.hexes_bonus != 0: stats_list.append(str(item.hexes_bonus) + ' Hexes') if item.evasion_bonus != 0: stats_list.append(str(item.evasion_bonus) + ' Evasion') if item.accuracy_bonus != 0: stats_list.append(str(item.accuracy_bonus) + ' Accuracy') if item.speed_bonus != 0: stats_list.append(str(item.speed_bonus) + ' Speed') if item.dmg_reduction_bonus != 0: stats_list.append('all physical damage taken reduced by ' + str(item.dmg_reduction_bonus)) if item.heal_kill_bonus != 0: stats_list.append('chance to restore health or mana on kill') if item.magic_resist_bonus != 0: stats_list.append( str(item.magic_resist_bonus * 100) + ' %% magic Resistance') if item.lifesteal_bonus != 0: stats_list.append(str(item.lifesteal_bonus) + ' lifesteal') string = ', '.join(stats_list) else: string = '' youseea = 'You see a' if self.owner.name[0] in 'aeiouAEIOU': youseea += 'n ' else: youseea += ' ' if string != '': text = youseea + self.owner.name + '. ' + self.description + ' It yields ' + string + '.' else: text = youseea + self.owner.name + '. ' + self.description Messages.new(text, libtcod.light_gray)
def equip(self): assert self.owner.inventory is not None, 'cannot equip item without an inventory!' old_equip = self.owner.inventory.get_equipped_in_slot(self.slot) if old_equip is not None: old_equip.dequip() self.is_equipped = True Messages.new( 'Equipped ' + self.owner.name + ' on ' + self.slot_str + '.', libtcod.light_green)
def drop(self, player): self.owner.inventory.items.remove(self.owner) self.owner.x = player.x self.owner.y = player.y youdroppeda = 'You dropped a' if self.owner.name[0] in 'aeiouAEIOU': youdroppeda += 'n ' else: youdroppeda += ' ' if self.owner.equipment: self.owner.equipment.dequip() Messages.new(youdroppeda + self.owner.name + '.', libtcod.yellow)
def use(self, player): if self.owner.equipment: if not self.owner.equipment.prof_restriction: self.owner.equipment.toggle_equip() elif player.prof not in self.owner.equipment.prof_restriction: Messages.new('You cannot make use of this item!', libtcod.red) else: self.owner.equipment.toggle_equip() elif self.use_function is None: Messages.new('The ' + self.owner.name + ' cannot be used.') elif self.use_function() != 'cancelled': self.owner.inventory.items.remove(self.owner) elif self.spellname is not None: raise NotImplementedError( 'append_spell(spellname) not implemented')
def monster_death(monster_entity): Messages.new('You have slain the ' + monster_entity.name + '!', libtcod.orange) monster_entity.char = 'x' monster_entity.color = libtcod.dark_red monster_entity.blocks = False monster_entity.fighter = None monster_entity.ai = None monster_entity.name = 'remains of ' + monster_entity.name monster_entity.send_to_back(DeathFunctions.world.objects) try: monster_entity.timeobj.release() except AttributeError: print('Tried to release ' + monster_entity.name + ' but no time component found!')
def player_death(player_entity): Messages.new('You have died!', libtcod.red) player_entity.char = 'X' player_entity.color = libtcod.dark_red DeathFunctions.world.game_state = GameState.PLAYER_DEAD