Sha256: 0f2b9e84c21738b5ede323c0bfbd4a28b56c80487f4c7677f6c467442177633b

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

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

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codebreaker-ga-0.2.8 lib/codebreaker/game_stage.rb
codebreaker-ga-0.2.7 lib/codebreaker/game_stage.rb
codebreaker-ga-0.2.6 lib/codebreaker/game_stage.rb