コード例 #1
0
ファイル: models.py プロジェクト: OthersGames/asylum-jam
 def __player_set(self, player):
     "Setter. Allows for self.player = value"
     if inherits_from(player, TypeClass):
         player = player.dbobj
     set_field_cache(self, "player", player)
     # we must set this here or superusers won't be able to
     # bypass lockchecks unless they start the game connected
     # to the character in question.
     self.locks.cache_lock_bypass(self)
コード例 #2
0
ファイル: models.py プロジェクト: abbacode/avaloria
    def obj_set(self, value):
        "Setter. Allows for self.obj = value"
        global _TYPECLASS
        if not _TYPECLASS:
            from src.typeclasses.typeclass import TypeClass as _TYPECLASS

        if isinstance(value, _TYPECLASS):
            value = value.dbobj
        try:
            set_field_cache(self, "obj", value)
        except Exception:
            logger.log_trace()
            raise Exception("Cannot assign %s as a player object!" % value)
コード例 #3
0
ファイル: models.py プロジェクト: YourCyborg/Sun-RPI
 def __home_set(self, home):
     "Setter. Allows for self.home = value"
     try:
         if home == None or type(home) == ObjectDB:
             hom = home
         elif ObjectDB.objects.dbref(home):
             hom = ObjectDB.objects.dbref_search(home)
             if hom and hasattr(hom,'dbobj'):
                 hom = _GA(hom, "dbobj")
             else:
                 hom = _GA(home, "dbobj")
         else:
             hom = _GA(home, "dbobj")
         set_field_cache(self, "home", hom)
     except Exception:
         string = "Cannot set home: "
         string += "%s is not a valid home."
         _GA(self, "msg")(_(string) % home)
         logger.log_trace(string)
コード例 #4
0
ファイル: models.py プロジェクト: YourCyborg/Sun-RPI
    def __location_set(self, location):
        "Setter. Allows for self.location = location"
        try:
            old_loc = _GA(self, "location")
            if ObjectDB.objects.dbref(location):
                # dbref search
                loc = ObjectDB.objects.dbref_search(location)
                loc = loc and _GA(loc, "dbobj")
            elif location and type(location) != ObjectDB:
                loc = _GA(location, "dbobj")
            else:
                loc = location

            # recursive location check
            def is_loc_loop(loc, depth=0):
                "Recursively traverse the target location to make sure we are not in it."
                if depth > 10: return
                elif loc == self: raise RuntimeError
                elif loc == None: raise RuntimeWarning # just to quickly get out
                return is_loc_loop(_GA(loc, "db_location"), depth+1)
            # check so we don't create a location loop - if so, RuntimeError will be raised.
            try: is_loc_loop(loc)
            except RuntimeWarning: pass

            # set the location
            set_field_cache(self, "location", loc)
            # update the contents of each location
            if old_loc:
                _GA(_GA(old_loc, "dbobj"), "contents_update")()
            if loc:
                _GA(loc, "contents_update")()
        except RuntimeError:
            string = "Cannot set location, "
            string += "%s.location = %s would create a location-loop." % (self.key, loc)
            _GA(self, "msg")(_(string))
            logger.log_trace(string)
            raise RuntimeError(string)
        except Exception, e:
            string = "Cannot set location (%s): " % str(e)
            string += "%s is not a valid location." % location
            _GA(self, "msg")(_(string))
            logger.log_trace(string)
            raise Exception(string)
コード例 #5
0
ファイル: models.py プロジェクト: YourCyborg/Sun-RPI
 def __destination_set(self, destination):
     "Setter. Allows for self.destination = destination"
     try:
         if destination == None or type(destination) == ObjectDB:
             # destination is None or a valid object
             dest = destination
         elif ObjectDB.objects.dbref(destination):
             # destination is a dbref; search
             dest = ObjectDB.objects.dbref_search(destination)
             if dest and _GA(self, "_hasattr")(dest,'dbobj'):
                 dest = _GA(dest, "dbobj")
             else:
                 dest = _GA(destination, "dbobj")
         else:
             dest = destination.dbobj
         set_field_cache(self, "destination", dest)
     except Exception:
         string = "Cannot set destination: "
         string += "%s is not a valid destination." % destination
         _GA(self, "msg")(string)
         logger.log_trace(string)
         raise
コード例 #6
0
ファイル: models.py プロジェクト: YourCyborg/Sun-RPI
 def __player_set(self, player):
     "Setter. Allows for self.player = value"
     if inherits_from(player, TypeClass):
         player = player.dbobj
     set_field_cache(self, "player", player)
コード例 #7
0
ファイル: models.py プロジェクト: TaliesinSkye/evennia
 def is_connected_del(self):
     "Deleter. Allows for del is_connected"
     set_field_cache(self, "is_connected", False)
コード例 #8
0
ファイル: models.py プロジェクト: TaliesinSkye/evennia
 def is_connected_set(self, value):
     "Setter. Allows for self.is_connected = value"
     set_field_cache(self, "is_connected", value)
コード例 #9
0
ファイル: models.py プロジェクト: abbacode/avaloria
 def character_set(self, character):
     "Setter. Allows for self.character = value"
     if inherits_from(character, TypeClass):
         character = character.dbobj
     set_field_cache(self, "obj", character)
コード例 #10
0
ファイル: models.py プロジェクト: OthersGames/asylum-jam
 def __sessid_set(self, sessid):
     "Setter. Allows for self.player = value"
     set_field_cache(self, "sessid", sessid)