def get_frame_message(self): msg = FrameMessage() msg['id'] = self.id msg['x'] = limit(m2p(self.get_position()['x'])) msg['y'] = limit(m2p(self.get_position()['y'])) msg['direction'] = self.get_direction() msg['state'] = getattr(self, 'state', 'unknown') return msg
def trigger_event(self, event_type, x, y): msg = EventMessage() msg['type'] = event_type msg['x'] = limit(m2p(x)) msg['y'] = limit(m2p(y)) self.networking_factory.broadcast_messages([ msg, ])
def get_update_message(self, recipient=None): msg = UpdateMessage() msg['id'] = self.id msg['entity_type'] = self.__class__.__name__ msg['width'] = limit(m2p(self.get_dimensions()['width'])) msg['height'] = limit(m2p(self.get_dimensions()['height'])) msg['x'] = limit(m2p(self.get_position()['x'])) msg['y'] = limit(m2p(self.get_position()['y'])) msg['direction'] = self.get_direction() msg['state'] = getattr(self, 'state', 'unknown') msg['player'] = (recipient and hasattr(recipient, 'session_id') and hasattr(self, 'player') and hasattr(self.player, 'session_id') and recipient.session_id == self.player.session_id) return msg
def trigger_event(self, event_type, x, y): msg = EventMessage() msg['type'] = event_type msg['x'] = limit(m2p(x)) msg['y'] = limit(m2p(y)) self.networking_factory.broadcast_messages([msg,])