Sha256: 09809132aeee999d03920ee176c10b3d0b0354a16c2a9b08a0d2c34bd22df04e

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 = 0
    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.14 lib/codebreaker/game_stage.rb