gemwarrior 0.14.6 → 0.14.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88f93a63ffbbc7334133b9ea23c40aae700d9f78
4
- data.tar.gz: fa4a6078ecbc1b11687fc42861e6a955481e2e56
3
+ metadata.gz: 08d2a9ec1dc8918cdae9406a4f763ba1d5ec2061
4
+ data.tar.gz: 29756295507196dc1b0b2df0f36a8c04eec65230
5
5
  SHA512:
6
- metadata.gz: 2bb197442769ca3e5b792cfea0376a1adb5f8fb88af2d7ef75ff9c1d984f8dafdfa71dedcce4a2789fb7bf8d9f3a0d2ffcf77ad88a18d714f5797b60a50c6910
7
- data.tar.gz: 33e4ea84b9312a221148b674d9ec9bff3c4d47793c6b257acb320d2897cf47eb0c8feb7c969c7ab623d2b67acd7b1b1b86a861968b8a14805ef8f983599d8881
6
+ metadata.gz: 38454c0717ce69f971ebbea780444b0c56dede944f085d911d2ffbe353afc46052cee5b54267b538eb1e912e202a5f7473e7a65e3d695bcd2e87315b5dee627d
7
+ data.tar.gz: 49c8ea652e0f8676663a693741aee7056fa0b5b01cc4dd08527101050ad97d996abedf97e31203e3cdf81a7d497ad9e6e9f2d34a0bbb8a6f3dda04e9a34f8f8e
data/bin/gemwarrior CHANGED
@@ -20,33 +20,31 @@ GW_DEFAULT_WORLD_BIN = File.expand_path('../../data/default_world.bin', __FILE_
20
20
  GW_DEFAULT_WRAP_WIDTH = 80
21
21
 
22
22
  def parse_options_cli
23
+ # default options
23
24
  options = {
24
- beast_mode: false,
25
- debug_mode: false,
26
- god_mode: false,
27
- new_skip: false,
28
- resume_skip: false,
29
- sound_enabled: false,
30
- sound_system: 'feep',
31
- sound_volume: 0.3,
32
- use_wordnik: false,
33
- extra_command: nil
25
+ beast_mode: false,
26
+ debug_mode: false,
27
+ god_mode: false,
28
+ new_skip: false,
29
+ resume_skip: false,
30
+ sound_enabled: false,
31
+ sound_system: 'bloops',
32
+ sound_volume: 0.3,
33
+ use_wordnik: false,
34
+ fight_completion: false,
35
+ extra_command: nil
34
36
  }
35
37
 
36
- options_file = read_options_file
37
-
38
- unless options_file.nil?
39
- sound_enabled_option = options_file[0][1].eql?('false') ? false : true
40
- sound_system_selected = options_file[1][1]
41
- sound_volume_option = options_file[2][1].to_f
42
- use_wordnik_option = options_file[3][1].eql?('false') ? false : true
43
-
44
- options[:sound_enabled] = sound_enabled_option
45
- options[:sound_system] = sound_system_selected
46
- options[:sound_volume] = sound_volume_option
47
- options[:use_wordnik] = use_wordnik_option
38
+ # options file has next precedence
39
+ unless (opts_file = read_options_file).nil?
40
+ options[:sound_enabled] = (opts_file[:sound_enabled].eql?('false') ? false : true) if opts_file[:sound_enabled]
41
+ options[:sound_system] = (opts_file[:sound_system].eql?('false') ? false : true) if opts_file[:sound_system]
42
+ options[:sound_volume] = (opts_file[:sound_volume].to_f) if opts_file[:sound_volume]
43
+ options[:use_wordnik] = (opts_file[:use_wordnik].eql?('false') ? false : true) if opts_file[:use_wordnik]
44
+ options[:fight_completion] = (opts_file[:fight_completion].eql?('false') ? false : true) if opts_file[:fight_completion]
48
45
  end
49
46
 
47
+ # command line has next precedence
50
48
  optparse = OptionParser.new do |opts|
51
49
  opts.on('-b', '--beast', 'Enable debug[beastmode]') do
52
50
  options[:beast_mode] = true
@@ -81,6 +79,10 @@ def parse_options_cli
81
79
  options[:use_wordnik] = true
82
80
  end
83
81
 
82
+ opts.on('-f', '--fight-completion', 'Fighting without specifying an enemy will attack first one it finds') do
83
+ options[:fight_completion] = false
84
+ end
85
+
84
86
  opts.on('-x', '--extra COMMAND,PARAM1,PARAM2,PARAM3', String, 'Run a command, with optional params, immediately upon beginning the game') do |xc|
85
87
  options[:extra_command] = xc.gsub(',',' ')
86
88
  end
@@ -103,13 +105,14 @@ end
103
105
 
104
106
  def read_options_file
105
107
  if File.exist?(GameOptions.data['options_file_path'])
106
- options = []
108
+ options = {}
107
109
  File.open(GameOptions.data['options_file_path']).readlines.each do |line|
108
- options << line.chomp.split(':')
110
+ kv = line.chomp.split(':')
111
+ options[kv[0].to_sym] = kv[1]
109
112
  end
110
113
 
111
114
  # check for null
112
- return options[0][0].eql?('sound_enabled') ? options : nil
115
+ return options[:sound_enabled] ? options : nil
113
116
  end
114
117
  nil
115
118
  end
@@ -118,7 +121,7 @@ def init_config
118
121
  Dir.mkdir(GW_HOME) unless Dir.exist?(GW_HOME)
119
122
 
120
123
  sound_system_default = OS.windows? ? 'win32-sound' : 'bloops'
121
-
124
+
122
125
  GameOptions.add 'sound_system', sound_system_default
123
126
  GameOptions.add 'save_file_mode', 'Y'
124
127
  GameOptions.add 'default_world_path_yaml', GW_DEFAULT_WORLD_YAML
@@ -32,7 +32,7 @@ module Gemwarrior
32
32
  self.monster_level_range = options.fetch(:monster_level_range)
33
33
  self.items = options.fetch(:items)
34
34
  self.monsters_abounding = options.fetch(:monsters_abounding)
35
- self.bosses_abounding = options.fetch[:bosses_abounding]
35
+ self.bosses_abounding = options.fetch(:bosses_abounding)
36
36
  self.checked_for_monsters = false
37
37
  self.visited = false
38
38
  end
@@ -60,6 +60,10 @@ module Gemwarrior
60
60
  self.items.map{|i| i.name.downcase}.include?(item_name.downcase)
61
61
  end
62
62
 
63
+ def has_any_monsters?
64
+ monsters_abounding.length > 0
65
+ end
66
+
63
67
  def has_monster?(monster_name)
64
68
  monsters_abounding.map{|m| m.name.downcase}.include?(monster_name.downcase)
65
69
  end
@@ -642,7 +642,16 @@ module Gemwarrior
642
642
  end
643
643
  when 'attack', 'a', 'fight', 'f'
644
644
  if param1.nil?
645
- ERROR_ATTACK_PARAM_MISSING
645
+ if GameOptions.data['fight_completion']
646
+ if player_cur_location.has_any_monsters?
647
+ monster_param = player_cur_location.monsters_abounding[0].name
648
+ self.parse("attack #{monster_param}")
649
+ else
650
+ ERROR_ATTACK_PARAM_INVALID
651
+ end
652
+ else
653
+ ERROR_ATTACK_PARAM_MISSING
654
+ end
646
655
  else
647
656
  monster_name = param1
648
657
  if world.has_monster_to_attack?(monster_name)
@@ -41,6 +41,7 @@ module Gemwarrior
41
41
  GameOptions.add 'sound_system', options.fetch(:sound_system)
42
42
  GameOptions.add 'sound_volume', options.fetch(:sound_volume)
43
43
  GameOptions.add 'use_wordnik', options.fetch(:use_wordnik)
44
+ GameOptions.add 'fight_completion', options.fetch(:fight_completion)
44
45
 
45
46
  # add classes for creatures, monsters, people, items, weapons, and armor to game
46
47
  # also add them to the global GameAssets
@@ -107,6 +108,7 @@ module Gemwarrior
107
108
  f.puts "sound_system:#{GameOptions.data['sound_system']}"
108
109
  f.puts "sound_volume:#{GameOptions.data['sound_volume']}"
109
110
  f.puts "use_wordnik:#{GameOptions.data['use_wordnik']}"
111
+ f.puts "fight_completion:#{GameOptions.data['fight_completion']}"
110
112
  end
111
113
  end
112
114
 
@@ -242,12 +242,13 @@ module Gemwarrior
242
242
  puts 'Gem Warrior General Options'.colorize(:yellow)
243
243
  puts '================================='.colorize(:yellow)
244
244
  puts
245
- puts 'Change several sound (quite experimental for now) options, and whether Wordnik is used to generate more dynamic descriptors of entities (valid WORDNIK_API_KEY environment variable must be set).'
245
+ puts 'Change several sound options, whether Wordnik is used to generate more dynamic descriptors of entities (valid WORDNIK_API_KEY environment variable must be set), and if attack/fight commands need to have a target or not (if enabled, will attack first monster in vicinty).'
246
246
  puts
247
- puts " (1) SOUND ENABLED : #{GameOptions.data['sound_enabled']}"
248
- puts " (2) SOUND SYSTEM : #{GameOptions.data['sound_system']}"
249
- puts " (3) SOUND VOLUME : #{GameOptions.data['sound_volume']}"
250
- puts " (4) USE WORDNIK : #{GameOptions.data['use_wordnik']}"
247
+ puts " (1) SOUND ENABLED : #{GameOptions.data['sound_enabled']}"
248
+ puts " (2) SOUND SYSTEM : #{GameOptions.data['sound_system']}"
249
+ puts " (3) SOUND VOLUME : #{GameOptions.data['sound_volume']}"
250
+ puts " (4) USE WORDNIK : #{GameOptions.data['use_wordnik']}"
251
+ puts " (5) FIGHT COMPLETION : #{GameOptions.data['fight_completion']}"
251
252
  puts
252
253
  puts '================================='.colorize(:yellow)
253
254
  puts
@@ -282,6 +283,10 @@ module Gemwarrior
282
283
  print answer
283
284
  GameOptions.data['use_wordnik'] = !GameOptions.data['use_wordnik']
284
285
  print_options
286
+ when '5'
287
+ print answer
288
+ GameOptions.data['fight_completion'] = !GameOptions.data['fight_completion']
289
+ print_options
285
290
  else
286
291
  print answer
287
292
  return
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.14.6'
5
+ VERSION = '0.14.7'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.6
4
+ version: 0.14.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick