Class: PaitinHangman::Paitin

Inherits:
Object
  • Object
show all
Includes:
SimpleMethods
Defined in:
lib/paitin_hangman.rb

Instance Method Summary collapse

Methods included from SimpleMethods

#decide, #length_one?, #number?, #option_integrity, #unique?, #verify_name_integrity

Instance Method Details

#choice_integrity(choice) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/paitin_hangman.rb', line 21

def choice_integrity(choice)
  case choice
  when "p", "play" then new_game
  when "i", "instruction" then instruction
  when "q", "quit" then exit
  when "l", "load" then GameResumption.new
  else
    try_again
  end
end

#game_controlObject



11
12
13
14
# File 'lib/paitin_hangman.rb', line 11

def game_control
  Message.welcome
  process
end

#instructionObject



37
38
39
40
# File 'lib/paitin_hangman.rb', line 37

def instruction
  Message.instruction
  process
end

#new_gameObject



42
43
44
45
46
47
# File 'lib/paitin_hangman.rb', line 42

def new_game
  Message.game_intro
  name = verify_name_integrity
  puts "Hi #{name}, Select a mode"
  play(name)
end

#play(name) ⇒ Object

> This technically begins the game



50
51
52
53
54
55
56
57
58
# File 'lib/paitin_hangman.rb', line 50

def play(name)
  Message.game_type
  option_integrity
  if @option == "2"
    Computer.new.level_integrity(name)
  else
    Player.new.first_player_name(name)
  end
end

#processObject



16
17
18
19
# File 'lib/paitin_hangman.rb', line 16

def process
  choice = gets.chomp.downcase
  choice_integrity(choice)
end

#try_againObject



32
33
34
35
# File 'lib/paitin_hangman.rb', line 32

def try_again
  Message.valid_option
  process
end