Sha256: 678bdbfbfa53d9eb6e0eedabfd825da21b2cf200d4627cd12d6867f7d07d91a4

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

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

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

    def step(compare_result)
      @compare_result = compare_result
      @step_number += 1
      @win = @compare_result.length == Game::CODE_LENGTH && @compare_result.all?
      @endgame = true if !valide_allow_step? || @win
    end

    def valide_allow_step?
      @attempts >= @step_number
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker-ga-0.2.13 lib/codebreaker/game_stage.rb