class Tavern
Public Class Methods
new()
click to toggle source
only available as an option in the Town
The tavern will “heal” the player by restoring mana and hp
# File lib/places.rb, line 153 def initialize load_data puts # formatting puts "You enter the tavern. The air is thick with smoke, but the fire in the hearth" puts "is warm and inviting." puts if @player.cur_hp < @player.hp # formatting puts "Some rest would probably do you good, #{@player.name}." if @player.cur_hp < @player.hp puts # formatting end
Public Instance Methods
choices()
click to toggle source
# File lib/places.rb, line 163 def choices move = 0 until move == "4" begin puts # formatting puts bar_top.yellow puts stat_bar(@player.name, @player.xp, @player.lvl, @player.coin, @player.cur_hp, @player.cur_mana) puts bar_low.yellow puts # formatting room_cost = @player.lvl*2 nourish_cost = @player.lvl c = Choice.new "What would you like to do in the tavern, #{@player.name}?", { "1" => "Buy some food. | Cost: #{nourish_cost} coins.", "2" => "Buy a drink. | Cost: #{nourish_cost} coins.", "3" => "Rest. | Cost: #{room_cost} coins.", "4" => "Leave the tavern." } move = c.prompt end while not (move == "1" or move == "2" or move == "3" or move == "4") case when move == "1" if @player.coin >= @player.lvl and @player.buff_food != true @player.buff_food = true puts # formatting puts "You find a seat at an open table and the waiter approaches to take your order." puts # formatting puts "The waiter tells you the food is so darn good, that it will help sustain your" puts "health as you travel in the dungeon." puts # formatting puts "You order and enjoy a delicious meal, #{@player.name}, you really do feel swell!" @player.coin = @player.coin - @player.lvl save_data elsif @player.buff_food == true puts #formatting puts "You couldn't possibly eat anymore." else puts # formatting puts "You can't afford a meal! Go to the dungeon and earn some money!" end when move == "2" if @player.coin >= @player.lvl and @player.buff_drink != true @player.buff_drink = true puts # formatting puts "You sally up to the bar and the barkeep approaches to take your order." puts # formatting puts "The barkeep tells you the wine is so fancy, that it will help sustain your" puts "mana as you travel in the dungeon." puts # formatting puts "You swirl the wine, sniff, then take a sip, #{@player.name}, you really do feel superior!" @player.coin = @player.coin - @player.lvl save_data elsif @player.buff_drink == true puts #formatting puts "You couldn't possibly drink anymore." else puts # formatting puts "You can't afford wine, you churl! Go to the dungeon and earn some money!" end when move == "3" if @player.coin >= @player.lvl*2 and (@player.cur_hp != @player.hp or @player.cur_mana != @player.mana) health = @player.cur_hp mana = @player.cur_mana @player.coin = @player.coin - @player.lvl*2 restore_player health = @player.cur_hp - health mana = @player.cur_mana - mana puts # formatting puts "You pay for a small room and get a good night of rest." puts "Resting has restored #{health} health points and #{mana} points of mana." elsif (@player.cur_hp == @player.hp and @player.cur_mana == @player.mana) puts # formatting puts "You don't really need to rest, get out there and make your own discoveries!" else puts # formatting puts "You can't afford a room! Hit the dungeon and earn some money!" end when move == "4" puts # formatting puts "Feeling much better, you step out of the tavern and back into town." save_data return end end end