def at_object_creation(self): """ Called once, when this object is first created. This is the normal hook to overload for most object types. """ super(MudderyPlayerCharacter, self).at_object_creation() # honour if not HONOURS_MAPPER.has_info(self): if self.db.level >= settings.MIN_HONOUR_LEVEL: HONOURS_MAPPER.set_honour(self, 0) else: HONOURS_MAPPER.set_honour(self, -1) # Set default data. if not self.attributes.has("nickname"): self.db.nickname = "" if not self.attributes.has("unlocked_exits"): self.db.unlocked_exits = set() if not self.attributes.has("revealed_map"): self.db.revealed_map = set() # set custom attributes if not self.attributes.has("attributes"): self.db.attributes = {} """
def at_object_creation(self): """ Called once, when this object is first created. This is the normal hook to overload for most object types. """ super(MudderyPlayerCharacter, self).at_object_creation() # honour if not HONOURS_MAPPER.has_info(self): HONOURS_MAPPER.set_honour(self, -1) # Set default data. if not self.attributes.has("nickname"): self.db.nickname = "" if not self.attributes.has("unlocked_exits"): self.db.unlocked_exits = set() if not self.attributes.has("revealed_map"): self.db.revealed_map = set() # set custom attributes if not self.attributes.has("attributes"): self.db.attributes = {} # Choose a random career. if not self.attributes.has("career"): self.db.career = "" try: careers = DATA_SETS.character_careers.objects.all() if careers: career = random.choice(careers) self.db.career = career.key except Exception, e: pass
def at_initial_setup(): """ Build up the default world and set default locations. """ try: # load world data import_local_data() print("Import local data.") # load game settings GAME_SETTINGS.reset() print("Reset game settings.") # build world builder.build_all() print("Builder build all.") # set limbo's desc limbo_obj = search.search_object("#2", exact=True) if limbo_obj: limbo_obj[0].db.desc = LIMBO_DESC limbo_obj[0].position = None print("Set limbo object.") # set default locations builder.reset_default_locations() print("Set default locations.") superuser = search.search_object("#1", exact=True) if superuser: superuser = superuser[0] # move the superuser to the start location start_location = search.search_object(settings.START_LOCATION, exact=True) if start_location: start_location = start_location[0] superuser.move_to(start_location, quiet=True) # set superuser's data superuser.set_data_key( GAME_SETTINGS.get("default_player_character_key")) superuser.set_level(1) superuser.set_nickname("superuser") # set superuser's honour to -1 HONOURS_MAPPER.set_honour(superuser, -1) print("Set supervisor.") except Exception, e: ostring = "Can't set initial data: %s" % e print(ostring) print(traceback.format_exc())
def at_initial_setup(): """ Build up the default world and set default locations. """ try: # load game settings GAME_SETTINGS.reset() print("Reset game settings.") # build world builder.build_all() print("Builder build all.") # set limbo's desc limbo_obj = search.search_object("#2", exact=True) if limbo_obj: limbo_obj[0].db.desc = LIMBO_DESC limbo_obj[0].position = None print("Set limbo object.") # set default locations builder.reset_default_locations() print("Set default locations.") superuser = search.search_object("#1", exact=True) if superuser: superuser = superuser[0] # move the superuser to the start location start_location = search.search_object(settings.START_LOCATION, exact=True) if start_location: start_location = start_location[0] superuser.move_to(start_location, quiet=True) # set superuser's data superuser.set_data_key(GAME_SETTINGS.get("default_player_character_key")) superuser.set_level(1) superuser.set_nickname("superuser") # set superuser's honour to -1 HONOURS_MAPPER.set_honour(superuser, -1) print("Set superuser.") except Exception, e: ostring = "Can't set initial data: %s" % e print(ostring) print(traceback.format_exc())
def level_up(self): """ Upgrade level. Returns: None """ super(MudderyPlayerCharacter, self).level_up() # set honour if self.db.level >= settings.MIN_HONOUR_LEVEL: if not HONOURS_MAPPER.has_info(self): HONOURS_MAPPER.set_honour(self, 0) self.msg({"msg": _("{rThe honour hall is now opened.{n")}) # notify the player self.msg({"msg": _("{c%s upgraded to level %s.{n") % (self.get_name(), self.db.level)})