Sha256: 17af7d768dd5558ab90fd415007e46ac773de2114e5d325a576de423df5f6f89

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

require 'yaml'
require 'tty-prompt'
require 'colorize'
require 'artii'

require_relative 'adventure'
require_relative 'bank'
require_relative 'store'
require_relative 'leaderboard'
require_relative '../model/events'

module Town
    def menu
        system 'clear'
        player = YAML.load(File.read(ENV['HOME'] + "/." + "playerdata.yml"))
        puts "Welcome to #{'Hazelwood'.colorize(:magenta)}, #{player.name.colorize(:yellow)}!" + "\n" + "=" * 40 + "\n"*2
        puts ::Events.town + "\n"*2
        prompt = TTY::Prompt.new
        prompt.select("What would you like to do?") do |menu|
            menu.choice 'Adventure'.colorize(:green), -> {::Adventure.start}
            menu.choice 'Bank'.colorize(:yellow), -> {::Bank.start}
            menu.choice 'Store'.colorize(:blue), -> {::Store.menu}
            menu.choice 'Leaderboard'.colorize(:light_magenta), -> {::Leaderboard.start}
            menu.choice 'Quit'.colorize(:red), -> {::Town.quit}
        end
    end

    def quit
        system 'clear'
        player = YAML.load(File.read(ENV['HOME'] + "/." + "playerdata.yml"))
        system 'clear'
        titleStyle = Artii::Base.new :font => 'slant'
        puts "Thanks for playing! See you next time," +"\n"*4 + "#{(titleStyle.asciify(player.name)).colorize(:yellow)}"
        sleep(3)
        exit!
    end

    module_function :quit,
                    :menu
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lotrd-0.1.9 lib/lotrd/view/town.rb