示例#1
0
 def weapons(self):
     """
     >>> char = Character({})
     >>> char.weapons[0].displayname()
     'Fist'
     >>> halberd = char.acquire_item(Item(load_yaml('items','halberd.yaml')))
     >>> item = Item(char.get('inventory/pack')[0])
     >>> char.equip_item(item)
     (True, '[ ] has equiped Halberd')
     >>> char.weapons[0].displayname()
     'Halberd'
     >>> len(char.weapons)
     1
     """
     equipedweapons = self.equiped_by_type('weapon')
     if not equipedweapons:
         messages.warning('No weapons equipped - equipping fist')
         fist = Item(load_yaml('items', 'ff7b801f5dfa6ad84870ca1ce2d43c74685d9ddbfcdc488e2ad66caa.yaml'))
         fist = self.acquire_item(fist)
         self.equip_item(fist)
         equipedweapons = self.equiped_by_type('weapon')
     if equipedweapons and equipedweapons[0].get('slot', "") == 'twohand':
         return [equipedweapons[0]]
     debug('Equipped weapons', equipedweapons)
     return equipedweapons
示例#2
0
 def delframe(self):
     key = 'animations/%s' % self.currentanimation
     idx = self.previewsprite.frame
     messages.warning('Deleted frame %s' % (idx))
     try:
         del self.item()[key][idx]
     except IndexError:
         debug('Tried to delete from an already empty list.')
示例#3
0
文件: npc.py 项目: ajventer/mirthless
 def moveto(self, map, x, y):
     if not mapname:
         return
     if not isinstance(x, int) or not isinstance(y, int):
         try:
             x = int(x)
             y = int(y)
         except:
             return
     if not map.tile(x,y).canenter():
         return
     current = self.location()
     if current.get('map') and x and y:
         gamemap = GameMap(load_yaml('maps', current['map']))
         gamemap.removefromtile(current['x'], current['y'],self,'npc')
     map.addtotile(x, y, 'npc', self)
     if map.tile(x,y).revealed():
         messages.warning('%s moves to %sx%s' %(self.displayname(),x, y))
示例#4
0
 def moveto(self, map, x, y):
     if not isinstance(x, int) or not isinstance(y, int):
         try:
             x = int(x)
             y = int(y)
         except:
             return
     if not map.tile(x,y).canenter():
         return
     current = self.location()
     if current.get('map') and x and y:
         gamemap = GameMap(load_yaml('maps', current['map']))
         gamemap.removefromtile(current['x'], current['y'],self,'player')
     self.put('location/x', x)
     self.put('location/y', y)
     self.put('location/map', map.get_hash())
     map.addtotile(x, y, 'player', True)
     messages.warning('%s moves to %sx%s' %(self.displayname(),x, y))
     map.reveal(x, y, self.lightradius)
示例#5
0
 def give_xp(self, xp):
     """
     >>> char = Character(load_yaml('characters', 'bardic_rogue.yaml'))
     >>> level = char.get('combat/level-hitdice', 1)
     >>> nl = char.next_level()
     >>> debug(char.give_xp(nl + 10))
     >>> char.get('combat/level-hitdice', 1) == level + 1
     True
     """
     current_xp = int(self.get('personal/xp', 0))
     new_xp = current_xp + int(xp)
     self.put('personal/xp', str(new_xp))
     messages.message('%s gains %s experience points. XP now: %s' % (self.displayname(), xp, new_xp))
     next_level = self.next_level()
     if new_xp >= next_level and next_level != -1:
         messages.warning(self.level_up())
         messages.error('Check for and apply manual increases to other stats if needed !')
     else:
         messages.message('Next level at %s. %s experience points to go' % (next_level, next_level - new_xp))
     return new_xp
示例#6
0
def todo_event():
    messages.warning('Event not yet implemented')