Advertisement
Kovitikus

characters.py

Aug 17th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.21 KB | None | 0 0
  1. from evennia import DefaultCharacter
  2. from evennia.utils.create import create_object
  3. from evennia.utils.utils import (list_to_string, inherits_from, lazy_property)
  4. from world.combat_handler import CombatHandler
  5.  
  6.  
  7. class Character(DefaultCharacter):
  8.     pass
  9.  
  10. class Player_Character(DefaultCharacter):
  11.  
  12.     @lazy_property
  13.     def combat(self):
  14.         return CombatHandler(self)
  15.  
  16.     def at_object_creation(self):
  17.         # Stats
  18.         self.attributes.add('gsp', 10)
  19.         self.attributes.add('hp', {'max_hp': 100, 'current_hp': 100})
  20.  
  21.         # Statuses
  22.         self.attributes.add('approached', [])
  23.         self.attributes.add('ko', False)
  24.         self.attributes.add('feinted', None)
  25.         self.attributes.add('busy', False)
  26.         self.attributes.add('wielding', None)
  27.  
  28.         # Skills
  29.         self.attributes.add('def_skills', {'weapon': {'high': {}, 'mid': {}, 'low':{}}, 'dodge': {'high': {}, 'mid': {}, 'low':{}}, 'shield': {'high': {}, 'mid': {}, 'low':{}}})
  30.         self.attributes.add('def_rb', {'high': 0, 'mid': 0, 'low': 0})
  31.  
  32.         # Hands
  33.         left = self.search('left hand', quiet=True)
  34.         right = self.search('right hand', quiet=True)
  35.         if not left:
  36.             create_object(typeclass='objects.ObjHands', key='left hand', location=self, home=self)
  37.         if not right:
  38.             create_object(typeclass='objects.ObjHands', key='right hand', location=self, home=self)
  39.         self.attributes.add('left_hand', None)
  40.         self.attributes.add('right_hand', None)
  41.        
  42.        
  43.  
  44.     def return_appearance(self, looker, **kwargs):
  45.         if not looker:
  46.             return ""
  47.        
  48.         # get description, build string
  49.         string  = self.create_desc()
  50.         return string
  51.  
  52.     def create_desc(self):
  53.         desc = ""
  54.        
  55.         figure = self.db.figure
  56.         facial = self.db.facial
  57.         hair = self.db.hair
  58.  
  59.         height = figure.get('height')
  60.         build = figure.get('build')
  61.         sex = figure.get('gender')
  62.  
  63.         eye_color = facial.get('eye_color')
  64.         nose = facial.get('nose')
  65.         lips = facial.get('lips')
  66.         chin = facial.get('chin')
  67.         face = facial.get('face')
  68.         skin_color = facial.get('skin_color')
  69.  
  70.         length = hair.get('length')
  71.         texture = hair.get('texture')
  72.         hair_color = hair.get('hair_color')
  73.         style = hair.get('style')
  74.  
  75.         # The figure should result in "You see a <height> <build> <gender>."
  76.         gender = ('man' if sex == 'male' else 'woman')
  77.         desc += f"You see a {height} {build} {gender}. "
  78.        
  79.         # The facial should result in "He has <color> eyes set above an <shape> nose, <shape> lips and a <shape> chin in a <shape> <color> face."
  80.         gender = ('He' if sex == 'male' else 'She')
  81.         desc += (f"{gender} has {eye_color} eyes set above a {nose} nose, "
  82.                 f"{lips} lips and a {chin} chin in a {face} {skin_color} face. ")
  83.  
  84.         # The hair should result in "<gender> has <length> <texture> <color> hair <style>."
  85.         if length == 'bald':
  86.             desc += f"{gender} is {length}. "
  87.         else:
  88.             desc += f"{gender} has {length} {texture} {hair_color} hair {style}. "
  89.         return desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement