Sha256: 6faafb4c027399ef757d6f23dcc3bb93c48f0ec28a8a36fb65d472c9482b8920

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 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,
    :new_game     => 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
    
    opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do
      options[:new_game] = 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

9 entries across 9 versions & 1 rubygems

Version Path
gemwarrior-0.9.19 bin/gemwarrior
gemwarrior-0.9.18 bin/gemwarrior
gemwarrior-0.9.17 bin/gemwarrior
gemwarrior-0.9.16 bin/gemwarrior
gemwarrior-0.9.15 bin/gemwarrior
gemwarrior-0.9.14 bin/gemwarrior
gemwarrior-0.9.13 bin/gemwarrior
gemwarrior-0.9.12 bin/gemwarrior
gemwarrior-0.9.10 bin/gemwarrior