class MastermindSname::Message
Public Instance Methods
blank_space(n)
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 61 def blank_space(n) n.times do print " " end end
body_message()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 52 def body_message blank_space(10) puts "CONGRATS! You got the sequence #{@player[:game_colours].join}" blank_space(10) puts "LEVEL: #{@player[:full_level]}" blank_space(10) puts "GUESSES: #{@player[:guesses_count]}" end
border()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 96 def border 59.times do print "=" end print "\n" end
cheat(game_colours)
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 39 def cheat(game_colours) "The sequence is #{game_colours.join}" end
congratulations_screen(player)
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 12 def congratulations_screen(player) @player = player horizontal_stars vertical_stars body_message vertical_stars horizontal_stars end
game_over()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 80 def game_over puts "Game Over, You are out of Guesses" end
get_instructions()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 114 def get_instructions print "Instructions\nEnter p to start \nEnter your name and level \nb - beginner, i - intermediate, a - advanced \nRandom code of elements. You have 10 guesses \nTo view entry history, enter h at any time. \nTo view sequence, enter c or cheat at any time \nTo quit the game enter q or quit. \nThe game is timed" print "\n" Sname.new.start_choice("p") end
get_level_message()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 8 def get_level_message puts "Select your level: (b)eginner, (i)ntermediate, (a)dvanced" end
goodbye_message()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 76 def goodbye_message puts "Thank you for playing MASTERMIND" end
horizontal_stars()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 32 def horizontal_stars 30.times do print "* " end print "\n" end
invalid_level()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 3 def invalid_level puts "Enter valid level, \"b\" for"\ " Beginner, \"i\" for Intermediate, \"a\" for Advanced" end
message_border()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 67 def message_border blank_space(10) 56.times do print "=" end print "\n" blank_space(20) end
play_again()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 127 def play_again puts "Do you want to play again? (y for yes/ press any other key to quit)" end
splash_screen()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 84 def splash_screen blank_space(10) 56.times do print "=" end print "\n" blank_space(10) puts "Welcome to MASTERMIND" blank_space(10) puts "Would you like to (p)lay, (r)ead instructions or (q)uit" end
start(player, game_colours)
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 21 def start(player, game_colours) colours = "(r)ed, (g)reen, (y)ellow, (b)lue" if game_colours.length == 4 colours = "(r)ed, (g)reen, (y)ellow, (b)lue, (o)"\ "range" if game_colours.length == 6 colours = "(r)ed, (g)reen, (y)ellow, (b)lue, (o)"\ "range, (v)iolet" if game_colours.length == 8 "Hello #{player[:name]} I have generated a code with"\ " #{game_colours.length} elements made up of a combination of"\ " any of: #{colours}... Can you guess the colour" end
top_ten_head()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 103 def top_ten_head 20.times do print "=" end print "Top Players" 20.times do print "=" end print "\n" end
vertical_stars()
click to toggle source
# File lib/mastermind_sname/sname/message.rb, line 43 def vertical_stars 3.times do print "*" blank_space(59) print "*" print "\n" end end