class PlayGOT::CLI
Attributes
turn[RW]
you[RW]
Public Instance Methods
choose_house()
click to toggle source
# File lib/play_GOT/cli.rb, line 27 def choose_house puts "Your destiny awaits. Lo and behold.".light_red @you.choose_house puts "You've chosen the #{@you.house.name.light_green}. Great and glorious it is.\n'#{@you.house.words.light_green}' it chants.\nIn #{@you.house.region.gsub("The", "the").light_green} it resides." puts "No one doubts it for being the #{@you.house.titles.join(", ").light_green}.\nLet #{@you.house.ancestral_weapons.join(" and ").light_green} be your secret weapon." puts "\nAre you sure about your choice? Type Y or YES to continue or anything else to choose again.".light_red confirm = gets.upcase.strip if confirm == "Y" || confirm == "YES" puts "Glory to your name #{@you.name.light_green}, Lord of the #{@you.house.name.light_green}. Winter is coming and the night is long. It's time to gather your soldiers." else choose_house end end
continue()
click to toggle source
# File lib/play_GOT/cli.rb, line 95 def continue puts "\nWhen you are ready, press any key to continue.".light_red input = gets.strip if @you.enemies.size > 0 menu else win end end
exit()
click to toggle source
# File lib/play_GOT/cli.rb, line 119 def exit puts "Are you sure you want to leave? Type Y or YES to confirm or anything else to go back to the menu.".light_red confirm = gets.strip.upcase if confirm == "Y" || confirm == "YES" puts "Goodbye, #{@you.name.light_green}. See you next time in the Game of Thrones." exit! else menu end end
initiate_player()
click to toggle source
# File lib/play_GOT/cli.rb, line 18 def initiate_player puts "Who are you, stranger?".light_red @you = PlayGOT::Player.new puts "Welcome, #{@you.name.light_green}, to the land of Westeros." end
rules()
click to toggle source
# File lib/play_GOT/cli.rb, line 46 def rules puts "\nTo win the Game of Thrones you must do the following: " puts "1 - Survive the Winter that sweeps through Westeros randomly.".blue puts "2 - Conquer all your enemies or turn them into your allies. ".blue puts "Your #{'stamina'.light_green} determines your probability of surviving the Winter. Each additional ally adds another 5 percent chance of survival. Each lost battle decreases 5 percent." puts "Your #{'tactic'.light_green} determines your probability of fleeing from an enemy. Some secret weapons may increase your chance of success." puts "Your #{'loyalty'.light_green} determines your probability of winning over an ally. Some secret weapons may increase your chance of persuasion." end
start()
click to toggle source
# File lib/play_GOT/cli.rb, line 4 def start puts "When you play the Game of Thrones, you win or you die." initiate_player PlayGOT::API.new.create_houses choose_house @turn = 0 continue end
win()
click to toggle source
# File lib/play_GOT/cli.rb, line 108 def win puts "All hail your Grace, #{@you.name.light_green} of #{@you.house.name.light_green}, First of Your Name, King of the Andals and the First Men, Lord of the Six Kingdoms, and Protector of the Realm." puts "\nWesteros is yours. May your rule long and prosperous, and your name remembered forever.".blue puts "\nUntil next time.\n".light_red exit! end