Sha256: 393d01050fae3d038a60cc3ef3a48ad82f5ce0a39168bc285207d56d23accb0a
Contents?: true
Size: 1.87 KB
Versions: 10
Compression:
Stored size: 1.87 KB
Contents
#!/usr/bin/env ruby require 'optparse' require_relative '../lib/gemwarrior/game' require_relative '../lib/gemwarrior/version' GAME_NAME = 'Gem Warrior' def parse_options options = { :beast_mode => false, :debug_mode => false, :god_mode => false, :new_game => false, :sound => false, :use_wordnik => false, :extra_command => nil } optparse = OptionParser.new do |opts| opts.on('-b', '--beast', 'Enable debug[beastmode]') do options[:beast_mode] = true end opts.on('-d', '--debug', 'Enable debug commands in-game') do options[:debug_mode] = true end opts.on('-g', '--god', 'Enable debug[godmode]') do options[:god_mode] = true end opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do options[:new_game] = true end opts.on('-s', '--sound', 'Enable sound (experimental)') do options[:sound] = true end opts.on('-v', '--version', 'Display version number and exit') do puts "#{GAME_NAME} v#{Gemwarrior::VERSION}" exit end opts.on('-w', '--wordnik', 'Enable Wordnik to generate more diverse, dynamic descriptors of entities') do options[:use_wordnik] = true end opts.on('-x', '--extra COMMAND', 'Run a command immediately upon beginning the game') do |xc| options[:extra_command] = xc.to_s end end optparse.parse!() return options end def print_error(error) case error when OptionParser::InvalidOption puts "#{$GAME_NAME}: illegal option #{error.args.join(' ')}" else puts "An unexpected error occurred while running #{$GAME_NAME}:" puts " #{error}\n" end end begin options = parse_options Gemwarrior::Game.new(options) rescue => error print_error(error) exit(false) end
Version data entries
10 entries across 10 versions & 1 rubygems