Class: Human

Inherits:
Player show all
Defined in:
lib/rps_telwell/player.rb

Overview

Create Human player

Instance Attribute Summary

Attributes inherited from Player

#wins

Instance Method Summary collapse

Methods inherited from Player

#initialize, #valid_move?

Constructor Details

This class inherits a constructor from Player

Instance Method Details

#get_moveObject

Human version of get_move


33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rps_telwell/player.rb', line 33

def get_move
	error_message = nil
	loop do
		puts error_message || "Select your move:"
		move = gets.chomp.to_i
		if valid_move?(move)
			return move
			break
		else
			error_message = "Invalid input, please enter a number 1-3"
			redo
		end
	end
end