<commit_before>class StartRound
  attr_reader :errors, :round

  def initialize(game)
    @game = game
    @round = nil
    @errors = []
  end

  def call
    @game.with_lock do
      start_round if round_can_be_started
    end

    success?
  end

  private

  def round_can_be_started
    # TODO: implement validations for starting round
    true
  end

  def start_round
    @round = @game.rounds.new

    first_trick = @round.tricks.new

    unless @round.save && first_trick.save
      add_error("failed to start the round")
    end
  end

  def success?
    @errors.empty?
  end

  def add_error(message)
    @errors << message
  end
end
<commit_msg>Create all 10 tricks at start of round<commit_after>class StartRound
  attr_reader :errors, :round

  def initialize(game)
    @game = game
    @round = nil
    @errors = []
  end

  def call
    @game.with_lock do
      start_round if round_can_be_started
    end
  end

  private

  def round_can_be_started
    # TODO: implement validations for starting round
    true
  end

  def start_round
    @round = @game.rounds.create!

    Round::NUMBER_OF_TRICKS.times do |n|
      @round.tricks.create!(number_in_round: n)
    end
  end
end

{'fraction_non_alphanumeric': 0.07196652719665272, 'fraction_numerical': 0.0016736401673640166, 'mean_word_length': 2.668711656441718, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5908618', 'n_tokens_mistral': 419, 'n_tokens_neox': 394, 'n_words': 112}