Exemple #1
0
 def command(self, userId, args):
     if not args or len(args) == 0:
         resultString = ['Usage: command [command name] [args]',
                         'where command like go, attack, harvest']
     else:
         robot = Robot(self.db.robots.find_one({'owner': userId}))
         tmpres = robot.add_command(args[0], args[1:])
         if tmpres == 'OK':
             resultString = ['ACCEPTED']
             self.db.robots.update(
                 {'name': robot.name, 'owner': robot.owner},
                 {'$set': robot.to_update()}
             )
         else:
             resultString = [tmpres]
     return resultString
Exemple #2
0
 def process_robot(self, json):
     #print('process robot', json['name'])
     robot = Robot(json)
     robot.process_action()
     self.db.robots.update({'name': robot.name, 'owner': robot.owner},
                           {'$set': robot.to_update()})