Sha256: 220f3882d78bb39a2626824de88aa7c66416b4f6f5cd709ab670bc755904643e
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true # Main Gem module module CodeBrkrGameTraining # Class for game class Game include Validator extend Statistics extend FileOperations GameError = Class.new(StandardError) attr_reader :user, :difficulty, :code def initialize(user, difficulty) @user = user @difficulty = difficulty validate @code = Code.new @hints_indexes = [] end def code_guessing_attempt(digits_arr) @difficulty.guessing_attempts_decrement! result = @code.code_check(digits_arr) if result[:in_position] == Code::GAME_NUMBERS[:count] result = { win: true } elsif !@difficulty.guessing_attempts_available? result = { loss: true, Ńorrect_answer: @code.to_s } end result end def game_hint @difficulty.hints_decrement! hint = @code.random_secret_digit_according_indexes(@hints_indexes) @hints_indexes << hint[:index] hint[:digit] end private def validate check_type(@user, User) check_type(@difficulty, DifficultyController) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
code_brkr_game_training-0.7.2 | lib/code_brkr_game_training/entities/game.rb |