Class: MM::MoveGenerator
- Inherits:
-
Object
- Object
- MM::MoveGenerator
- Defined in:
- lib/games/mastermind/move_generator.rb
Instance Attribute Summary collapse
-
#game ⇒ Object
Returns the value of attribute game.
Instance Method Summary collapse
- #computer? ⇒ Boolean
- #computer_move ⇒ Object
- #current_player ⇒ Object
- #get_move ⇒ Object
- #get_player_choice(game) ⇒ Object
- #human? ⇒ Boolean
- #input_helper ⇒ Object
Instance Attribute Details
#game ⇒ Object
Returns the value of attribute game.
4 5 6 |
# File 'lib/games/mastermind/move_generator.rb', line 4 def game @game end |
Instance Method Details
#computer? ⇒ Boolean
41 42 43 |
# File 'lib/games/mastermind/move_generator.rb', line 41 def computer? game.current_player_computer? end |
#computer_move ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/games/mastermind/move_generator.rb', line 20 def computer_move secret_code = [] 4.times do secret_code.push((1..6).to_a.sample) end secret_code end |
#current_player ⇒ Object
29 30 31 |
# File 'lib/games/mastermind/move_generator.rb', line 29 def current_player game.current_player end |
#get_move ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/games/mastermind/move_generator.rb', line 11 def get_move if human? input_helper.get_player_choice(game) elsif computer? input_helper.computer_choosing_graphic computer_move end end |
#get_player_choice(game) ⇒ Object
6 7 8 9 |
# File 'lib/games/mastermind/move_generator.rb', line 6 def get_player_choice(game) @game = game get_move end |
#human? ⇒ Boolean
37 38 39 |
# File 'lib/games/mastermind/move_generator.rb', line 37 def human? game.current_player_human? end |
#input_helper ⇒ Object
33 34 35 |
# File 'lib/games/mastermind/move_generator.rb', line 33 def input_helper game.input_helper end |