class Mastermind::Main

module Helper

def get_input(message)
  # puts "Whatever it is"
  message
end

def send_message(message)

end

end

Attributes

game[R]
response[R]

Public Class Methods

new() click to toggle source
# File lib/mastermind/main.rb, line 6
def initialize
  @response = Message.new
end

Public Instance Methods

old_play()
Alias for: play
play() click to toggle source
# File lib/mastermind/extensions/extensions.rb, line 20
def play
  level = get_input(@response.level_select.message).to_i
  @game.play(level)
end
Also aliased as: old_play
start() click to toggle source
# File lib/mastermind/main.rb, line 10
def start
  action = get_input(@response.start.message)
  if supported_actions.keys.include? action
    @game ||= Game.new(@response)
    method(supported_actions[action]).call
  else
    send_message @response.unsupported_game_action.message
  end
    start if supported_actions[action] =~ /instructions|background/ || @response.status == :unsupported_action
end

Private Instance Methods

background() click to toggle source
# File lib/mastermind/main.rb, line 26
def background
  send_message(@response.main_message.message)
end
instructions() click to toggle source
# File lib/mastermind/main.rb, line 22
def instructions
  send_message(@response.gameplay_instructions.message)
end
quit_game() click to toggle source
# File lib/mastermind/main.rb, line 34
def quit_game
  @game.quit_game
end
supported_actions() click to toggle source
# File lib/mastermind/main.rb, line 38
def supported_actions
  {
    'p' => 'play',
    'play' => 'play',
    'q' => 'quit_game',
    'quit' => 'quit_game',
    'i' => 'instructions',
    'instructions' => 'instructions',
    'b' => 'background',
    'background' => 'background'
  }
end