Sha256: 882440c0f87dd26a4e1750424496d26efaa7ae843714bed8d9723514d2bf1da5

Contents?: true

Size: 1.5 KB

Versions: 12

Compression:

Stored size: 1.5 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 = {
    :debug_mode   => false, 
    :god_mode     => false, 
    :beast_mode   => false, 
    :use_wordnik  => false, 
    :sound        => false
  }

  optparse = OptionParser.new do |opts|
    opts.on('-v', '--version', 'Display version number and exit') do
      puts "#{GAME_NAME} v#{Gemwarrior::VERSION}"
      exit
    end

    opts.on('-d', '--debug', 'Turn debug on') do
      options[:debug_mode] = true
    end

    opts.on('-g', '--god', 'Set godmode to true on load') do
      options[:god_mode] = true
    end

    opts.on('-b', '--beast', 'Set beastmode to true on load') do
      options[:beast_mode] = true
    end

    opts.on('-w', '--wordnik', 'Use Wordnik to generate more diverse, dynamic descriptors of entities') do
      options[:use_wordnik] = true
    end

    opts.on('-s', '--sound', 'Turn sound on') do
      options[:sound] = true
    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

12 entries across 12 versions & 1 rubygems

Version Path
gemwarrior-0.9.9 bin/gemwarrior
gemwarrior-0.9.8 bin/gemwarrior
gemwarrior-0.9.7 bin/gemwarrior
gemwarrior-0.9.6 bin/gemwarrior
gemwarrior-0.9.5 bin/gemwarrior
gemwarrior-0.9.4 bin/gemwarrior
gemwarrior-0.9.3 bin/gemwarrior
gemwarrior-0.9.2 bin/gemwarrior
gemwarrior-0.9.1 bin/gemwarrior
gemwarrior-0.9.0 bin/gemwarrior
gemwarrior-0.8.8 bin/gemwarrior
gemwarrior-0.8.7 bin/gemwarrior