Module: Mathangman::Difficulty

Included in:
Game
Defined in:
lib/mathangman/difficulty.rb

Instance Method Summary collapse

Instance Method Details

#check_difficultyObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mathangman/difficulty.rb', line 5

def check_difficulty
  diff = gets.chomp
  levels = ["7", "8", "9"]
  if levels.include? diff
    first_guess(diff)
  elsif diff == "*"
    quitter("pre_game")
  else
    puts @display.invalid_entry
    puts @display.difficulty
    check_difficulty
  end
end

#diff_level(diff) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mathangman/difficulty.rb', line 19

def diff_level(diff)
  @diff = diff
  if diff == "7"
    @wrongs_num = @len / 2 + @guess_bonus
    return unusable = false if @len > 4 && @len < 13
  elsif diff == "8"
    @wrongs_num = @len / 2 + ( @guess_bonus - 1 )
    return unusable = false if @len > 6 && @len < 13
  elsif diff == "9"
    @wrongs_num = @len / 2
    return unusable = false if @len > 9 && @len < 13
  end
  true
end