# 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/objects/basescript.py
# class Script(object):
#     '''This is a placeholder class used for doing object script things.
#     It's mostly just used for detecting if an object is really a script or not.
#     '''
#     def __init__(self, mongo_engine_object=None):
#         self.me_obj = mongo_engine_object
#         print "Initted with %s" % self.me_obj
# 
#     def create(self):
#         '''Create this Script's ScriptedObject database object.'''
#         pass
# 
#     def activate(self, *args, **kwargs):
#         '''Do something when the scripted object is activated/clicked/etc.
#         Script.tick() and Script.activate() are not usually called from
#         the same instance.
#         Do not rely on saved instance state. Store it in the database.
#         '''
#         pass
# 
#     def roll(self, dicestring):
#         '''Roll dice specified by dicestring and return the value.
#         Does not allow more dice than the MAX_DICE_AMOUNT setting
#         to be rolled at once.'''
# 
#         rolls, num, sides, mod = parse(dicestring)
#         num = int(num)
#         sides = int(sides)
#         mod = int(mod)
#         if num > MAX_DICE_AMOUNT:
#             raise UserWarning("Cannot roll more than %d dice at once." % MAX_DICE_AMOUNT)
# 
#         rolls = []
#         for i in xrange(num):
#             #print "Rolling dice #%d of %d: %f%% done." % (i, num, (float(i)/float(num))*100)
#             rolls.append(random.randrange(1, int(sides)+1)+int(mod))
#         return sum(rolls)
# 
#     def say(self, message):
#         '''Write the given text to the zone message database.'''
#         Message(sender=self.me_obj.name, message=message, loc_x=self.me_obj.loc_x, loc_y=self.me_obj.loc_y, loc_z=self.me_obj.loc_z, player_generated=False).save()
#         print "[%s] %s: %s" % (datetime.datetime.now(), self.me_obj.name, message)
# 
#     def rand_say(self, sayings):
#         '''Pick a random saying from sayings and say it.'''
#         self.say(random.choice(sayings))
# 
#     def tick(self):
#         pass
# 
#     def move(self, xmod, ymod, zmod):
#         self.me_obj.loc_x += xmod
#         self.me_obj.loc_y += ymod
#         self.me_obj.loc_z += zmod
#         self.me_obj.set_modified()
# 
#         from helpers import manhattan
#         ourx, oury = self.me_obj.loc_x, self.me_obj.loc_y
#         for o in Object.get_objects(physical=True):
#             # Is the distance between that object and the character less than 3?
#             if manhattan(o.loc_x, o.loc_y, ourx, oury) < 1:
#                 # We collided against something, so return now and don't
#                 # save the location changes into the database.
#                 return False
#         else:
#             # We didn't collide with any objects.
#             self.me_obj.save()
#             return True
# 
#     def wander(self):
#         return self.move(random.randint(-1, 1), random.randint(-1, 1), random.randint(-1, 1))


from elixir_models import Object
from games.objects.basescript import Script


class ChatBot(Script):
    idle_chat = ["Try clicking on me.", "Maybe Right Click>Activate?"]
    activation = ['Nice! You activated me.']

    @classmethod
    def create(cls):

# 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/objects/basescript.py
# class Script(object):
#     '''This is a placeholder class used for doing object script things.
#     It's mostly just used for detecting if an object is really a script or not.
#     '''
#     def __init__(self, mongo_engine_object=None):
#         self.me_obj = mongo_engine_object
#         print "Initted with %s" % self.me_obj
# 
#     def create(self):
#         '''Create this Script's ScriptedObject database object.'''
#         pass
# 
#     def activate(self, *args, **kwargs):
#         '''Do something when the scripted object is activated/clicked/etc.
#         Script.tick() and Script.activate() are not usually called from
#         the same instance.
#         Do not rely on saved instance state. Store it in the database.
#         '''
#         pass
# 
#     def roll(self, dicestring):
#         '''Roll dice specified by dicestring and return the value.
#         Does not allow more dice than the MAX_DICE_AMOUNT setting
#         to be rolled at once.'''
# 
#         rolls, num, sides, mod = parse(dicestring)
#         num = int(num)
#         sides = int(sides)
#         mod = int(mod)
#         if num > MAX_DICE_AMOUNT:
#             raise UserWarning("Cannot roll more than %d dice at once." % MAX_DICE_AMOUNT)
# 
#         rolls = []
#         for i in xrange(num):
#             #print "Rolling dice #%d of %d: %f%% done." % (i, num, (float(i)/float(num))*100)
#             rolls.append(random.randrange(1, int(sides)+1)+int(mod))
#         return sum(rolls)
# 
#     def say(self, message):
#         '''Write the given text to the zone message database.'''
#         Message(sender=self.me_obj.name, message=message, loc_x=self.me_obj.loc_x, loc_y=self.me_obj.loc_y, loc_z=self.me_obj.loc_z, player_generated=False).save()
#         print "[%s] %s: %s" % (datetime.datetime.now(), self.me_obj.name, message)
# 
#     def rand_say(self, sayings):
#         '''Pick a random saying from sayings and say it.'''
#         self.say(random.choice(sayings))
# 
#     def tick(self):
#         pass
# 
#     def move(self, xmod, ymod, zmod):
#         self.me_obj.loc_x += xmod
#         self.me_obj.loc_y += ymod
#         self.me_obj.loc_z += zmod
#         self.me_obj.set_modified()
# 
#         from helpers import manhattan
#         ourx, oury = self.me_obj.loc_x, self.me_obj.loc_y
#         for o in Object.get_objects(physical=True):
#             # Is the distance between that object and the character less than 3?
#             if manhattan(o.loc_x, o.loc_y, ourx, oury) < 1:
#                 # We collided against something, so return now and don't
#                 # save the location changes into the database.
#                 return False
#         else:
#             # We didn't collide with any objects.
#             self.me_obj.save()
#             return True
# 
#     def wander(self):
#         return self.move(random.randint(-1, 1), random.randint(-1, 1), random.randint(-1, 1))


# Path: games/objects/chatbot.py
from elixir_models import Object
from games.objects.basescript import Script



class ChatBot(Script):
    idle_chat = ["Try clicking on me.", "Maybe Right Click>Activate?"]
    activation = ['Nice! You activated me.']

    @classmethod
    def create(cls):

        obj = Object()