<commit_before>require './fighter'
require './world'

class Server
  def initialize
    @server = TCPServer.new(3939)
    @fighters = []
    @world = World.new

    puts "Server started. Waiting for connections..."
  end


  def start
    accept_connections
  end

  private
    def accept_connections
      while (connection = @server.accept)
        Thread.new(connection) do |c|
          new_connection(c)
        end
      end

    end

    def new_connection(connection)
      connection_limit_check(connection)

      fighter = create_new_fighter(connection)

      welcome(fighter)

      fighter.name = ask_name(fighter)

      announce_fighter_join

      # This actually makes sure both fighters joined before it returns.
      @world.join(fighter)

      fighter.connection.puts @world.map

      while text = fighter.connection.gets.chomp
        @world.step(fighter, text)<commit_msg>Moved server startup text to more appropriate place<commit_after>require './fighter'
require './world'

class Server
  def initialize
    @server = TCPServer.new(3939)
    @fighters = []
    @world = World.new
  end

  def start
    accept_connections
  end

  private
    def accept_connections
      puts "Server started. Accepting connections..."

      while (connection = @server.accept)
        Thread.new(connection) do |c|
          new_connection(c)
        end
      end

    end

    def new_connection(connection)
      connection_limit_check(connection)

      fighter = create_new_fighter(connection)

      welcome(fighter)

      fighter.name = ask_name(fighter)

      announce_fighter_join

      # This actually makes sure both fighters joined before it returns.
      @world.join(fighter)

      fighter.connection.puts @world.map

      while text = fighter.connection.gets.chomp
        @world.step(fighter, text)
{'fraction_non_alphanumeric': 0.07965084560829241, 'fraction_numerical': 0.00436442989634479, 'mean_word_length': 2.6102362204724407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1582727', 'n_tokens_mistral': 559, 'n_tokens_neox': 522, 'n_words': 133}