Пример #1
0
    def on_user_message(self, meta):
        changed = False
        if ('username' in meta):
            new_username = meta['username'][0:10]
            if (new_username != self.meta['username']):
                self.meta['username'] = new_username
                logging.info("%s is now known as %s" %
                             (self.session_id, self.meta['username']))
                changed = True

        if ('gender' in meta and meta['gender'] != self.meta['gender']):
            self.meta['gender'] = meta['gender']
            changed = True

        if ('slots' in meta and meta['slots'] != self.meta['slots']):
            if (verify_slots(meta['slots'], self.meta['budget'])):
                self.meta['slots'] = meta['slots']
                changed = True
            else:
                logging.info(
                    "%s provided incorrect meta msg (%s). Discarding" %
                    (self.meta['username'], meta['slots']))

        if (changed):
            self.archer.update_attributes()
Пример #2
0
	def on_user_action(self, message):
		spawn_points = self.world.get_spawn_points()
		shuffle(spawn_points)
		logging.info(message);
		if(message['action'] == 'spawn'):
			if(self.archer.can_spawn()):
				if(verify_slots(self.meta['slots'], self.meta['budget'])):
					self.archer.spawn(spawn_points[0])
				else:
					logging.info('denying %s spawn, incorrect slots %s' % (self.meta['username'], self.meta['slots']))
		if(message['action'] == 'suicide'):
			self.archer.kill();
		if(message['action'] == 'stop'):
			self.archer.want_stop()
		if(message['action'] == 'move'):
			self.archer.want_move(message['direction'])
		if(message['action'] == 'attack'):
			self.archer.want_attack(message['direction'])
Пример #3
0
 def on_user_action(self, message):
     spawn_points = self.world.get_spawn_points()
     shuffle(spawn_points)
     logging.info(message)
     if (message['action'] == 'spawn'):
         if (self.archer.can_spawn()):
             if (verify_slots(self.meta['slots'], self.meta['budget'])):
                 self.archer.spawn(spawn_points[0])
             else:
                 logging.info('denying %s spawn, incorrect slots %s' %
                              (self.meta['username'], self.meta['slots']))
     if (message['action'] == 'suicide'):
         self.archer.kill()
     if (message['action'] == 'stop'):
         self.archer.want_stop()
     if (message['action'] == 'move'):
         self.archer.want_move(message['direction'])
     if (message['action'] == 'attack'):
         self.archer.want_attack(message['direction'])
Пример #4
0
	def on_user_message(self, meta):
		changed = False
		if('username' in meta):
			new_username = meta['username'][0:10]
			if(new_username != self.meta['username']):
				self.meta['username'] = new_username
				logging.info("%s is now known as %s" % (self.session_id, self.meta['username']))
				changed = True
				
		if('gender' in meta and meta['gender'] != self.meta['gender']):
			self.meta['gender'] = meta['gender']
			changed = True

		if('slots' in meta and meta['slots'] != self.meta['slots']):
			if(verify_slots(meta['slots'], self.meta['budget'])):
				self.meta['slots'] = meta['slots']
				changed = True
			else:
				logging.info("%s provided incorrect meta msg (%s). Discarding" 
					% (self.meta['username'], meta['slots']))

		if(changed):
			self.archer.update_attributes()