# Path: elixir_models.py
# class Object(BaseModel):
#     '''In-world objects.'''
# 
#     name = CharField()
#     resource = CharField(default="none")
#     owner = CharField(null=True)
# 
#     loc_x = FloatField(default=0)
#     loc_y = FloatField(default=0)
#     loc_z = FloatField(default=0)
# 
#     rot_x = FloatField(default=0)
#     rot_y = FloatField(default=0)
#     rot_z = FloatField(default=0)
# 
#     scale_x = FloatField(default=1)
#     scale_y = FloatField(default=1)
#     scale_z = FloatField(default=1)
# 
#     speed = FloatField(default=1)
#     vel_x = FloatField(default=0)
#     vel_y = FloatField(default=0)
#     vel_z = FloatField(default=0)
# 
#     states = JSONField(default=[])
#     physical = BooleanField(default=True)
#     last_modified = DateTimeField(default=datetime.datetime.now)
# 
#     scripts = JSONField(default=[])
# 
#     @property
#     def loc(self):
#         return (self.loc_x, self.loc_y, self.loc_z)
# 
#     @loc.setter
#     def loc(self, val):
#         self.loc_x, self.loc_y, self.loc_z = val
# 
#     def set_modified(self, date_time=None):
#         if date_time is None:
#             date_time = datetime.datetime.now()
#         self.last_modified = date_time
#         self.save()
# 
#     @staticmethod
#     def get_objects(since=None, physical=None, limit=None, player=None, scripted=None, name=None):
#         # TODO: Needs integration test.
#         obj = Object.select()
# 
#         if since is not None:
#             obj = obj.where(Object.last_modified>=since)
# 
#         if physical is not None:
#             obj = obj.where(Object.physical==physical)
# 
#         if player is not None:
#             obj = obj.where(Object.states.contains('player')).where(Object.name==player)
# 
#         if scripted is not None:
#             obj = obj.where(Object.scripts!=None) # TODO: Have this only return objects with scripts.
# 
#         if name is not None:
#             obj = obj.where(Object.name==name)
# 
#         obj = obj.order_by(Object.last_modified.desc())
# 
#         if limit is not None:
#             obj = obj.limit(limit)
# 
#         if limit == 1:
#             return obj
# 
#         return [o for o in obj]


from random import randint, uniform
from elixir_models import Object
        from sys import maxint
            import logging
# Some helpers for random.
def randloc():
    return randint(-100, 100)

def randrot():
    return randint(-360, 360)

def randscale():
    return uniform(.75, 1.25)


class BaseZone(object):
    def __init__(self, logger=None):
        '''Initialize the zone.
        Insert whatever objects into the database programmatically.
        This includes loading things from a disk file if you so choose.

        It will not run more than once on the zone's database.
        If you want new content on an existing database, either make
        a script to apply changes, or just delete the database for
        that zone and recreate it when the zone is started up again.
        '''

        self.setup_logging(logger=logger)
        self.load()

    @staticmethod
    def randobj(name="Object #%s", resource='object', count=1, states=None, scripts=None):
        objs = []
        for i in xrange(count):

# Path: elixir_models.py
# class Object(BaseModel):
#     '''In-world objects.'''
# 
#     name = CharField()
#     resource = CharField(default="none")
#     owner = CharField(null=True)
# 
#     loc_x = FloatField(default=0)
#     loc_y = FloatField(default=0)
#     loc_z = FloatField(default=0)
# 
#     rot_x = FloatField(default=0)
#     rot_y = FloatField(default=0)
#     rot_z = FloatField(default=0)
# 
#     scale_x = FloatField(default=1)
#     scale_y = FloatField(default=1)
#     scale_z = FloatField(default=1)
# 
#     speed = FloatField(default=1)
#     vel_x = FloatField(default=0)
#     vel_y = FloatField(default=0)
#     vel_z = FloatField(default=0)
# 
#     states = JSONField(default=[])
#     physical = BooleanField(default=True)
#     last_modified = DateTimeField(default=datetime.datetime.now)
# 
#     scripts = JSONField(default=[])
# 
#     @property
#     def loc(self):
#         return (self.loc_x, self.loc_y, self.loc_z)
# 
#     @loc.setter
#     def loc(self, val):
#         self.loc_x, self.loc_y, self.loc_z = val
# 
#     def set_modified(self, date_time=None):
#         if date_time is None:
#             date_time = datetime.datetime.now()
#         self.last_modified = date_time
#         self.save()
# 
#     @staticmethod
#     def get_objects(since=None, physical=None, limit=None, player=None, scripted=None, name=None):
#         # TODO: Needs integration test.
#         obj = Object.select()
# 
#         if since is not None:
#             obj = obj.where(Object.last_modified>=since)
# 
#         if physical is not None:
#             obj = obj.where(Object.physical==physical)
# 
#         if player is not None:
#             obj = obj.where(Object.states.contains('player')).where(Object.name==player)
# 
#         if scripted is not None:
#             obj = obj.where(Object.scripts!=None) # TODO: Have this only return objects with scripts.
# 
#         if name is not None:
#             obj = obj.where(Object.name==name)
# 
#         obj = obj.order_by(Object.last_modified.desc())
# 
#         if limit is not None:
#             obj = obj.limit(limit)
# 
#         if limit == 1:
#             return obj
# 
#         return [o for o in obj]


# Path: games/zones/basezone.py
from random import randint, uniform
from elixir_models import Object
        from sys import maxint
            import logging

# Some helpers for random.
def randloc():
    return randint(-100, 100)

def randrot():
    return randint(-360, 360)

def randscale():
    return uniform(.75, 1.25)


class BaseZone(object):
    def __init__(self, logger=None):
        '''Initialize the zone.
        Insert whatever objects into the database programmatically.
        This includes loading things from a disk file if you so choose.

        It will not run more than once on the zone's database.
        If you want new content on an existing database, either make
        a script to apply changes, or just delete the database for
        that zone and recreate it when the zone is started up again.
        '''

        self.setup_logging(logger=logger)
        self.load()

    @staticmethod
    def randobj(name="Object #%s", resource='object', count=1, states=None, scripts=None):
        objs = []
        for i in xrange(count):

            obj = Object()