Class: MastermindSname::Message
- Inherits:
-
Object
- Object
- MastermindSname::Message
- Defined in:
- lib/mastermind_sname/sname/message.rb
Instance Method Summary collapse
- #blank_space(n) ⇒ Object
- #body_message ⇒ Object
- #border ⇒ Object
- #cheat(game_colours) ⇒ Object
- #congratulations_screen(player) ⇒ Object
- #game_over ⇒ Object
- #get_instructions ⇒ Object
- #get_level_message ⇒ Object
- #goodbye_message ⇒ Object
- #horizontal_stars ⇒ Object
- #invalid_level ⇒ Object
- #message_border ⇒ Object
- #play_again ⇒ Object
- #splash_screen ⇒ Object
- #start(player, game_colours) ⇒ Object
- #top_ten_head ⇒ Object
- #vertical_stars ⇒ Object
Instance Method Details
#blank_space(n) ⇒ Object
61 62 63 64 65 |
# File 'lib/mastermind_sname/sname/message.rb', line 61 def blank_space(n) n.times do print " " end end |
#body_message ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/mastermind_sname/sname/message.rb', line 52 def 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 ⇒ Object
96 97 98 99 100 101 |
# File 'lib/mastermind_sname/sname/message.rb', line 96 def border 59.times do print "=" end print "\n" end |
#cheat(game_colours) ⇒ Object
39 40 41 |
# File 'lib/mastermind_sname/sname/message.rb', line 39 def cheat(game_colours) "The sequence is #{game_colours.join}" end |
#congratulations_screen(player) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/mastermind_sname/sname/message.rb', line 12 def congratulations_screen(player) @player = player horizontal_stars vertical_stars vertical_stars horizontal_stars end |
#game_over ⇒ Object
80 81 82 |
# File 'lib/mastermind_sname/sname/message.rb', line 80 def game_over puts "Game Over, You are out of Guesses" end |
#get_instructions ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 |
# 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 ⇒ Object
8 9 10 |
# File 'lib/mastermind_sname/sname/message.rb', line 8 def puts "Select your level: (b)eginner, (i)ntermediate, (a)dvanced" end |
#goodbye_message ⇒ Object
76 77 78 |
# File 'lib/mastermind_sname/sname/message.rb', line 76 def puts "Thank you for playing MASTERMIND" end |
#horizontal_stars ⇒ Object
32 33 34 35 36 37 |
# File 'lib/mastermind_sname/sname/message.rb', line 32 def horizontal_stars 30.times do print "* " end print "\n" end |
#invalid_level ⇒ Object
3 4 5 6 |
# 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 ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/mastermind_sname/sname/message.rb', line 67 def blank_space(10) 56.times do print "=" end print "\n" blank_space(20) end |
#play_again ⇒ Object
127 128 129 |
# 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 ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# 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) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# 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 ⇒ Object
103 104 105 106 107 108 109 110 111 112 |
# 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 ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/mastermind_sname/sname/message.rb', line 43 def vertical_stars 3.times do print "*" blank_space(59) print "*" print "\n" end end |