Class: Commander
- Inherits:
-
Object
- Object
- Commander
- Defined in:
- lib/Commander.rb
Overview
require_relative “Archivist.rb” require_relative “Builder.rb”
Instance Attribute Summary collapse
-
#archivist ⇒ Object
readonly
Returns the value of attribute archivist.
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
Instance Method Summary collapse
- #menucard ⇒ Object
- #prompter ⇒ Object
- #sel_aspect(aspect, character) ⇒ Object
- #sel_concept ⇒ Object
- #sel_screen(character) ⇒ Object
- #startup ⇒ Object
- #terminus ⇒ Object
- #titlecard ⇒ Object
Instance Attribute Details
#archivist ⇒ Object (readonly)
Returns the value of attribute archivist.
6 7 8 |
# File 'lib/Commander.rb', line 6 def archivist @archivist end |
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
6 7 8 |
# File 'lib/Commander.rb', line 6 def builder @builder end |
Instance Method Details
#menucard ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/Commander.rb', line 24 def puts " 1 - build new character" puts " 2 - list all existing characters" puts " 3 - display card of existing character" puts " 4 - exit application" puts print "Enter a number from the list above: " = gets.chomp.to_i if == 1 prompter elsif == 2 Builder.all.each {|character| print character.name + ": " print character.ancestries + ", " print character.backgrounds + ", " print character.classes puts } puts "Press ENTER to return to the main menu." gets elsif == 3 puts "Display which character?" char_name = gets.chomp character = Builder.all.detect{|char|char.name == char_name} if character sel_screen(character) else puts "That character does not exist." end puts "Press ENTER to return to the main menu." gets elsif == 4 terminus else puts "..............." puts ":INVALID INPUT:" puts "```````````````" puts end end |
#prompter ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/Commander.rb', line 140 def prompter startup character = sel_concept sel_screen(@builder) sel_aspect(:ancestries, @builder) sel_aspect(:backgrounds, @builder) sel_aspect(:classes, @builder) sel_screen(@builder) puts "Press ENTER to return to the main menu." gets end |
#sel_aspect(aspect, character) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/Commander.rb', line 120 def sel_aspect(aspect, character) @archivist.send(aspect).keys.each_with_index { |option, index| puts "#{index+1} - #{option}"} choice = gets.chomp until @archivist.confirm(choice, aspect) @archivist.summarize(choice, aspect) puts "Will you play a #{choice}? Y/N" confirm = gets.chomp.capitalize[0] if confirm == "Y" character.send("#{aspect}=", choice) else sel_aspect(aspect, character) end end |
#sel_concept ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/Commander.rb', line 95 def sel_concept name = gets.chomp @archivist = Archivist.new @builder = Builder.new(name) end |
#sel_screen(character) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/Commander.rb', line 103 def sel_screen(character) puts " _______________ ___ ___ ___ __ __ __ _ _ _" puts "|" puts "| #{character.name}" puts "|_______________ ___ ___ ___ __ __ __ _ _ _" puts "|" if character.ancestries puts "| Ancestry: #{character.ancestries}" if character.ancestries puts "| Background: #{character.backgrounds}" if character.backgrounds puts "| Class: #{character.classes}" if character.classes puts "|" if character.classes puts "'" puts "'" puts "'" end |
#startup ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/Commander.rb', line 87 def startup puts "A legend begins with a name." puts puts " Who are you?" end |
#terminus ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/Commander.rb', line 72 def terminus puts puts "Fare thee well, and may your ventures be magical!" puts puts "__________________________________________________________________" puts " __ .__ _____.__ .___ " puts " ___________ _/ |_| |___/ ____\\__| ____ __| _/___________ " puts " \\____ \\__ \\\\ __\\ | \\ __\\| |/ \\ / __ |/ __ \\_ __ \\ " puts " | |_> > __ \\| | | Y \\ | | | | \\/ /_/ \\ ___/| | \\/ " puts " | __(____ /__| |___| /__| |__|___| /\\____ |\\___ >__| " puts " |__| \\/ \\/ \\/ \\/ \\/ " puts "__________________________________________________________________" puts end |
#titlecard ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/Commander.rb', line 8 def titlecard puts "__________________________________________________________________" puts " __ .__ _____.__ .___ " puts " ___________ _/ |_| |___/ ____\\__| ____ __| _/___________ " puts " \\____ \\__ \\\\ __\\ | \\ __\\| |/ \\ / __ |/ __ \\_ __ \\ " puts " | |_> > __ \\| | | Y \\ | | | | \\/ /_/ \\ ___/| | \\/ " puts " | __(____ /__| |___| /__| |__|___| /\\____ |\\___ >__| " puts " |__| \\/ \\/ \\/ \\/ \\/ " puts "__________________________________________________________________" puts puts "Welcome to Pathfinder, a game of adventure and imagination." puts "This application will help you organize basic character ideas." puts "__________________________________________________________________" puts end |