Sha256: a84ccd473dfa02a4d9bdf43bead833f5e5d22b6669ab7be3126bd60c503dc2be

Contents?: true

Size: 611 Bytes

Versions: 4

Compression:

Stored size: 611 Bytes

Contents

module Codebreaker
  class GameStage
    attr_reader :step_number, :endgame, :attempts, :compare_result, :win
    attr_accessor :hint_used

    def initialize(user_code_length:, attempts:)
      @step_number = 1
      @endgame = false
      @attempts = attempts
      @compare_result = []
      @user_code_length = user_code_length
      @hint_used = 0
    end

    def step(compare_result)
      @compare_result = compare_result
      @step_number += 1
      @win = @compare_result.length == @user_code_length && @compare_result.all?
      @endgame = true if @step_number > @attempts || @win
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codebreaker-ga-0.2.5 lib/codebreaker/game_stage.rb
codebreaker-ga-0.2.4 lib/codebreaker/game_stage.rb
codebreaker-ga-0.2.3 lib/codebreaker/game_stage.rb
codebreaker-ga-0.2.2 lib/codebreaker/game_stage.rb