Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- The code I'm trying to emulate to check for typeclass, so that the hands aren't listed in the inventory.
- https://github.com/evennia/ainneve/blob/develop/world/chargen.py#L614
- """
- """
- Traceback (most recent call last):
- File "d:\muddev\evennia\evennia\commands\cmdhandler.py", line 591, in _run_command
- ret = cmd.func()
- File ".\commands\command.py", line 147, in func
- if not item['typeclass'] in ("typeclasses.objects.ObjHands",):
- TypeError: 'ObjHands' object is not subscriptable
- An untrapped error occurred.
- (Traceback was logged 19-08-17 00:44:17-04).
- """
- class CmdInventory(Command):
- """
- view inventory
- Usage:
- inventory
- inv
- Shows your inventory.
- """
- key = "inventory"
- aliases = ["inv", "i"]
- locks = "cmd:all()"
- arg_regex = r"$"
- def func(self):
- """check inventory"""
- items = self.caller.contents
- if not items:
- string = "You are not carrying anything."
- else:
- table = self.styled_table(border="header")
- for item in items:
- if not item['typeclass'] in ("typeclasses.objects.ObjHands",):
- table.add_row("|C%s|n" % item.name, item.db.desc or "")
- string = "|wYou are carrying:\n%s" % table
- self.caller.msg(string)
- """ objects.py where the ObjHands class resides. It's currently empty until I can think of what to put in it."""
- from evennia import DefaultObject
- class Object(DefaultObject):
- pass
- class ObjHands(DefaultObject):
- pass
- """ characters.py where the hands are created """
- from evennia import DefaultCharacter
- from evennia.utils.create import create_object
- from evennia.utils.utils import (list_to_string, inherits_from, lazy_property)
- from world.combat_handler import CombatHandler
- class Character(DefaultCharacter):
- pass
- class Player_Character(DefaultCharacter):
- @lazy_property
- def combat(self):
- return CombatHandler(self)
- def at_object_creation(self):
- # Stats
- self.attributes.add('gsp', 10)
- self.attributes.add('hp', {'max_hp': 100, 'current_hp': 100})
- # Statuses
- self.attributes.add('approached', [])
- self.attributes.add('ko', False)
- self.attributes.add('feinted', None)
- self.attributes.add('busy', False)
- # Skills
- self.attributes.add('def_skills', {'weapon': {'high': {}, 'mid': {}, 'low':{}}, 'dodge': {'high': {}, 'mid': {}, 'low':{}}, 'shield': {'high': {}, 'mid': {}, 'low':{}}})
- self.attributes.add('def_rb', {'high': 0, 'mid': 0, 'low': 0})
- # Hands
- if not 'left hand' or 'right hand' in self.contents:
- left_hand = create_object(typeclass='objects.ObjHands', key='left hand', location=self, home=self)
- right_hand = create_object(typeclass='objects.ObjHands', key='right hand', location=self, home=self)
- self.attributes.add('left_hand', left_hand.contents)
- self.attributes.add('right_hand', right_hand.contents)
- def return_appearance(self, looker, **kwargs):
- if not looker:
- return ""
- # get description, build string
- string = self.create_desc()
- return string
- def create_desc(self):
- desc = ""
- figure = self.db.figure
- facial = self.db.facial
- hair = self.db.hair
- height = figure.get('height')
- build = figure.get('build')
- sex = figure.get('gender')
- eye_color = facial.get('eye_color')
- nose = facial.get('nose')
- lips = facial.get('lips')
- chin = facial.get('chin')
- face = facial.get('face')
- skin_color = facial.get('skin_color')
- length = hair.get('length')
- texture = hair.get('texture')
- hair_color = hair.get('hair_color')
- style = hair.get('style')
- # The figure should result in "You see a <height> <build> <gender>."
- gender = ('man' if sex == 'male' else 'woman')
- desc += f"You see a {height} {build} {gender}. "
- # 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."
- gender = ('He' if sex == 'male' else 'She')
- desc += (f"{gender} has {eye_color} eyes set above a {nose} nose, "
- f"{lips} lips and a {chin} chin in a {face} {skin_color} face. ")
- # The hair should result in "<gender> has <length> <texture> <color> hair <style>."
- if length == 'bald':
- desc += f"{gender} is {length}. "
- else:
- desc += f"{gender} has {length} {texture} {hair_color} hair {style}. "
- return desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement