<commit_before>module Sim
  module Queue

    class ActionEvent < Event

      attr_reader :player, :action, :params

      def initialize player, action, params
        @player = player
        @action = action
        @params = params # Hash
        @start  = Time.now
      end

      def to_s
        "<ActionEvent action=#{@action} player_id=#{@player.id} params=#{@params}>"
      end

      def notify_listners area
        if area
          event_broadcaster.async.notify(area, player)
        end
      end

      def fire
        answer = player.send(action, *params.values)
        $stderr.puts("*** event sending back answer after #{Time.now - @start}")
        player.connection.send_message(action, answer)
        notify_listners(answer[:notify])
      end

    end

  end
end<commit_msg>+ extract respond answer<commit_after>module Sim
  module Queue

    class ActionEvent < Event

      attr_reader :player, :action, :params

      def initialize player, action, params
        @player = player
        @action = action
        @params = params # Hash
        @start  = Time.now
      end

      def to_s
        "<ActionEvent action=#{@action} player_id=#{@player.id} params=#{@params}>"
      end

      def notify_listners area
        if area
          event_broadcaster.async.notify(area, player)
        end
      end

      def fire
        answer = player.send(action, *params.values)
        $stderr.puts("*** event sending back answer after #{Time.now - @start}")
        respond answer
      end

      def respond answer
        player.connection.send_message(action, answer)
        notify_listners(answer[:notify])
      end

    end

  end
end
{'fraction_non_alphanumeric': 0.09367541766109785, 'fraction_numerical': 0.0, 'mean_word_length': 2.122905027932961, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '790936', 'n_tokens_mistral': 481, 'n_tokens_neox': 465, 'n_words': 132}