Class: Tavern

Inherits:
Object
  • Object
show all
Defined in:
lib/places.rb

Instance Method Summary collapse

Constructor Details

#initializeTavern

only available as an option in the Town The tavern will “heal” the player by restoring mana and hp



153
154
155
156
157
158
159
160
161
# 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

Instance Method Details

#choicesObject



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# 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