bloodymines 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/bin/bloodymines +16 -6
  2. metadata +3 -3
data/bin/bloodymines CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # An example of how to use the bloodymines game egnine within a curses program.
3
3
 
4
+ require "optparse"
4
5
  require File.dirname(__FILE__) + "/../lib/bloodymines"
5
6
  require File.dirname(__FILE__) + "/../lib/bloodymines/tui"
6
7
 
@@ -9,15 +10,24 @@ class Bloodymines
9
10
  end
10
11
 
11
12
  # main app
12
- puts "Welcome to bloodymines!"
13
- print "Choose your difficulty: [1]Beginner, [2]Intermediate, [3]Expert > "
13
+ options = {}
14
+ optparse = OptionParser.new do |opts|
15
+ opts.on('-h','--help', 'display this screen') { puts opts; exit }
16
+ opts.on('-d', '--difficulty DIFFICULTY', [:beginner, :intermediate, :expert],
17
+ "Set the difficulty of the game") do |d|
18
+ options[:difficulty] = d
19
+ end
20
+ end
14
21
 
15
- case gets.chomp.to_i
16
- when 2: game = Bloodymines.new(:difficulty => :intermediate)
17
- when 3: game = Bloodymines.new(:difficulty => :expert)
18
- else game = Bloodymines.new
22
+ begin
23
+ optparse.parse!
24
+ rescue OptionParser::MissingArgument, OptionParser::InvalidArgument
25
+ puts "The following difficulty levels are available: beginner, intermediate, expert"
26
+ puts optparse
27
+ exit
19
28
  end
20
29
 
30
+ game = Bloodymines.new(:difficulty => options[:difficulty])
21
31
  game.cursor_x = 0
22
32
  game.cursor_y = 0
23
33
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloodymines
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 7
10
- version: 0.1.7
9
+ - 8
10
+ version: 0.1.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - !binary |