Class: PaitinHangman::Player
- Inherits:
-
Object
- Object
- PaitinHangman::Player
show all
- Includes:
- SimpleMethods
- Defined in:
- lib/paitin_hangman/player.rb
Instance Method Summary
collapse
#choice_integrity, #decide, #length_one?, #number?, #option_integrity, #unique?, #verify_name_integrity
Instance Method Details
#first_player_name(name) ⇒ Object
5
6
7
8
|
# File 'lib/paitin_hangman/player.rb', line 5
def first_player_name(name)
player1 = name
get_friend_name(player1)
end
|
#game(player1, player2) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/paitin_hangman/player.rb', line 17
def game(player1, player2)
begin
puts "Please enter one of your names: #{player1} or #{player2}"
name = verify_name_integrity
end until name == player1 || name == player2
other_player = player2 if name == player1
other_player = player1 if name == player2
Message.level_choice
level_integrity(name, other_player)
end
|
#get_friend_name(player1) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/paitin_hangman/player.rb', line 10
def get_friend_name(player1)
puts "Hi #{player1}, what is the name of your friend"
player2 = verify_name_integrity
puts "Hello, #{player1} and #{player2}, who will like to challenge"
game(player1, player2)
end
|
#level_integrity(name, other_player) ⇒ Object
28
29
30
31
32
33
34
35
|
# File 'lib/paitin_hangman/player.rb', line 28
def level_integrity(name, other_player)
choice = gets.chomp
until choice == "1" || choice == "2" || choice == "3"
puts "Please press either '1', '2' or '3'"
choice = STDIN.gets.chomp
end
select_level(choice, name, other_player)
end
|
#select_level(choice, name, other_player) ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/paitin_hangman/player.rb', line 37
def select_level(choice, name, other_player)
case choice
when "1" then Levels.new(other_player, 4, 8, 10, name)
when "2" then Levels.new(other_player, 9, 12, 12, name)
when "3" then Levels.new(other_player, 13, 25, 15, name)
end
end
|