Sha256: 1f347131c9e0a659f1eceb632a3501e238f43b2dc46c06d1e3dc721c6c03758b
Contents?: true
Size: 589 Bytes
Versions: 2
Compression:
Stored size: 589 Bytes
Contents
# frozen_string_literal: true require_relative 'guess_handler' require_relative 'user' class Game include GuessHandler attr_reader :secret_code, :hint_counter, :attempts, :hints, :name def initialize(user, difficulty) @secret_code = (1..4).to_a.map { |_num| rand(1..6) } @hint_counter = 0 @attempts = { all: difficulty[:attempts], used: 0 } @hints = { all: difficulty[:hints], used: 0 } @name = user.name end def give_a_hint return 0 if @hints[:available].zero? @hints[:all] -= 1 @hints[:used] += 1 @secret_code[@hints[:used]] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_kirill-0.2.13 | lib/codebreaker_kirill/game.rb |
codebreaker_kirill-0.2.11 | lib/codebreaker_kirill/game.rb |