gemwarrior 0.15.13 → 0.15.14

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
  SHA256:
3
- metadata.gz: 32da6152f4ce6dccf6acc5ef3c9a66dec1c1a1b851751f9d28efffba5accc17e
4
- data.tar.gz: 8dcc14d6abd6378750629309d7e52d02c1f932c0cd950f8b59d7970d77a996e4
3
+ metadata.gz: c4b71d7a26b3d881e7451d4f0374a2ff847b08b2781190dc535da4be03216d93
4
+ data.tar.gz: 6706573b955217a0f75d5df3eaee248e0e199b8c8586d5f4a8245aa6b7a4d9fe
5
5
  SHA512:
6
- metadata.gz: 0bcdafec3b61d634cee410aa8a96b15c6aa6a4aed4fee124319d827cacc3b3117538d114d063d1a1e4ebe14054faa6792465ced5962f3aafca712da640c4df46
7
- data.tar.gz: afcea73e004084bca9c10d50b19c90a292a684ce033b571a0ade436dbdbb243edf5bd0ac1963199142c297fd938fb66ac0682b5b5ad25c0f6f7688cb8514d174
6
+ metadata.gz: 9f3e6f2d65f809e9403d3d91f3daebe3c60bde70b017e2c4db6e0cb8367365716f144baf4c9fbb0a565a24503b65eb68da17b5c49b3fcc91ef66e1660c78483e
7
+ data.tar.gz: a8b4a0873299d590b9bc389d15e1e28c9594f39e480447b7ffc7ba5812bddeb091cf37ab77bfc92d570902aa849866c9d4bcf0cbab38081aedee33dd2476e2c2
data/bin/gemwarrior CHANGED
@@ -9,21 +9,72 @@ require_relative '../lib/gemwarrior/version'
9
9
 
10
10
  include Gemwarrior
11
11
 
12
- GAME_NAME = 'Gem Warrior'
13
- GW_HOME = "#{Dir.home}/.gemwarrior"
14
- GW_SAVE_FILE_YAML = "#{GW_HOME}/gw_sav.yaml"
15
- GW_SAVE_FILE_BIN = "#{GW_HOME}/gw_sav.dat"
16
- GW_OPTS_FILE = "#{GW_HOME}/gw_opts"
17
- GW_LOG_FILE = "#{GW_HOME}/gw_log"
18
- GW_DEFAULT_WORLD_YAML = File.expand_path('../../data/default_world.yaml', __FILE__)
19
- GW_DEFAULT_WORLD_BIN = File.expand_path('../../data/default_world.bin', __FILE__)
20
- GW_DEFAULT_WRAP_WIDTH = 80
12
+ GW_NAME = 'Gem Warrior'
13
+ GW_HOME_PATH = "#{Dir.home}/.gemwarrior"
14
+ GW_SAVE_FILE_YAML_PATH = "#{GW_HOME_PATH}/gw_sav.yaml"
15
+ GW_SAVE_FILE_BIN_PATH = "#{GW_HOME_PATH}/gw_sav.dat"
16
+ GW_SAVE_FILE_MODE_DEFAULT = 'Y' # YAML
17
+ GW_OPTS_FILE_PATH = "#{GW_HOME_PATH}/gw_opts"
18
+ GW_LOG_FILE_PATH = "#{GW_HOME_PATH}/gw_log"
19
+ GW_WRAP_WIDTH_DEFAULT = 80
20
+
21
+ def print_error(error)
22
+ case error
23
+ when OptionParser::InvalidOption
24
+ puts "#{GW_NAME}: illegal option #{error.args.join(' ')}"
25
+ else
26
+ puts "An unexpected error occurred while running #{GW_NAME}:"
27
+ puts " #{error}\n"
28
+ end
29
+ end
30
+
31
+ def init_config(world)
32
+ Dir.mkdir(GW_HOME_PATH) unless Dir.exist?(GW_HOME_PATH)
33
+
34
+ log_file_path = GW_LOG_FILE_PATH
35
+ options_file_path = GW_OPTS_FILE_PATH
36
+ save_file_mode_default = GW_SAVE_FILE_MODE_DEFAULT
37
+ save_file_bin_path = GW_SAVE_FILE_BIN_PATH
38
+ save_file_yaml_path = GW_SAVE_FILE_YAML_PATH
39
+ sound_system_default = OS.windows? ? 'win32-sound' : 'bloops'
40
+ world_yaml_path = File.expand_path("../../data/#{world}.yaml", __FILE__)
41
+ world_bin_path = File.expand_path("../../data/#{world}.bin", __FILE__)
42
+ wrap_width = GW_WRAP_WIDTH_DEFAULT
43
+
44
+ GameOptions.add 'log_file_path', log_file_path
45
+ GameOptions.add 'options_file_path', options_file_path
46
+ GameOptions.add 'save_file_bin_path', save_file_bin_path
47
+ GameOptions.add 'save_file_mode', save_file_mode_default
48
+ GameOptions.add 'save_file_yaml_path', save_file_yaml_path
49
+ GameOptions.add 'sound_system', sound_system_default
50
+ GameOptions.add 'world_bin_path', world_bin_path
51
+ GameOptions.add 'world_yaml_path', world_yaml_path
52
+ GameOptions.add 'wrap_width', wrap_width
53
+ end
54
+
55
+ def read_options_file
56
+ if !File.exist?(GW_OPTS_FILE_PATH)
57
+ File.write(GW_OPTS_FILE_PATH, "")
58
+ end
59
+
60
+ options = {}
61
+
62
+ File.open(GW_OPTS_FILE_PATH).readlines.each do |line|
63
+ kv = line.chomp.split(':')
64
+ options[kv[0].to_sym] = kv[1]
65
+ end
66
+
67
+ # check for null
68
+ return options[:sound_enabled] ? options : nil
69
+ end
21
70
 
22
71
  def parse_options_cli
23
72
  # default options
24
73
  options = {
25
74
  beast_mode: false,
26
75
  debug_mode: false,
76
+ extra_command: nil,
77
+ fight_completion: false,
27
78
  god_mode: false,
28
79
  new_skip: false,
29
80
  resume_skip: false,
@@ -31,17 +82,22 @@ def parse_options_cli
31
82
  sound_system: 'bloops',
32
83
  sound_volume: 0.3,
33
84
  use_wordnik: false,
34
- fight_completion: false,
35
- extra_command: nil
85
+ world_name: 'default_world'
36
86
  }
37
87
 
38
88
  # options file has next precedence
39
89
  unless (opts_file = read_options_file).nil?
90
+ options[:fight_completion] = (opts_file[:fight_completion].eql?('false') ? false : true) if opts_file[:fight_completion]
91
+
40
92
  options[:sound_enabled] = (opts_file[:sound_enabled].eql?('false') ? false : true) if opts_file[:sound_enabled]
93
+
41
94
  options[:sound_system] = (opts_file[:sound_system]) if opts_file[:sound_system]
95
+
42
96
  options[:sound_volume] = (opts_file[:sound_volume].to_f) if opts_file[:sound_volume]
97
+
43
98
  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]
99
+
100
+ opts_file[:world_name] = (opts_file[:world_name]) if opts_file[:world_name]
45
101
  end
46
102
 
47
103
  # command line has next precedence
@@ -54,10 +110,18 @@ def parse_options_cli
54
110
  options[:debug_mode] = true
55
111
  end
56
112
 
113
+ opts.on('-f', '--fight-completion', 'Fighting without specifying an enemy will attack first one it finds') do
114
+ options[:fight_completion] = false
115
+ end
116
+
57
117
  opts.on('-g', '--god', 'Enable debug[godmode]') do
58
118
  options[:god_mode] = true
59
119
  end
60
120
 
121
+ opts.on('-k', '--wordnik', 'Enable Wordnik to generate more diverse, dynamic descriptors of entities') do
122
+ options[:use_wordnik] = true
123
+ end
124
+
61
125
  opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do
62
126
  options[:new_skip] = true
63
127
  end
@@ -71,19 +135,15 @@ def parse_options_cli
71
135
  end
72
136
 
73
137
  opts.on('-v', '--version', 'Display version number and exit') do
74
- puts "#{GAME_NAME} v#{Gemwarrior::VERSION}"
138
+ puts "#{GW_NAME} v#{Gemwarrior::VERSION}"
75
139
  exit
76
140
  end
77
141
 
78
- opts.on('-w', '--wordnik', 'Enable Wordnik to generate more diverse, dynamic descriptors of entities') do
79
- options[:use_wordnik] = true
142
+ opts.on('-w', '--world WORLD_NAME', String, 'Build Gemwarrior with alternate world data file') do |world_name|
143
+ options[:world_name] = world_name
80
144
  end
81
145
 
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
-
86
- opts.on('-x', '--extra COMMAND,PARAM1,PARAM2,PARAM3', String, 'Run a command, with optional params, immediately upon beginning the game') do |xc|
146
+ opts.on('-x', '--xtra COMMAND,PARAMS', String, 'Run a command, with optional params, immediately upon beginning the game') do |xc|
87
147
  options[:extra_command] = xc.gsub(',',' ')
88
148
  end
89
149
  end
@@ -93,54 +153,14 @@ def parse_options_cli
93
153
  return options
94
154
  end
95
155
 
96
- def print_error(error)
97
- case error
98
- when OptionParser::InvalidOption
99
- puts "#{GAME_NAME}: illegal option #{error.args.join(' ')}"
100
- else
101
- puts "An unexpected error occurred while running #{GAME_NAME}:"
102
- puts " #{error}\n"
103
- end
104
- end
105
-
106
- def read_options_file
107
- if File.exist?(GameOptions.data['options_file_path'])
108
- options = {}
109
- File.open(GameOptions.data['options_file_path']).readlines.each do |line|
110
- kv = line.chomp.split(':')
111
- options[kv[0].to_sym] = kv[1]
112
- end
113
-
114
- # check for null
115
- return options[:sound_enabled] ? options : nil
116
- end
117
- nil
118
- end
119
-
120
- def init_config
121
- Dir.mkdir(GW_HOME) unless Dir.exist?(GW_HOME)
122
-
123
- sound_system_default = OS.windows? ? 'win32-sound' : 'bloops'
124
- save_file_mode_default = 'Y' # YAML
125
-
126
- GameOptions.add 'sound_system', sound_system_default
127
- GameOptions.add 'save_file_mode', save_file_mode_default
128
- GameOptions.add 'default_world_path_yaml', GW_DEFAULT_WORLD_YAML
129
- GameOptions.add 'default_world_path_bin', GW_DEFAULT_WORLD_BIN
130
- GameOptions.add 'save_file_yaml_path', GW_SAVE_FILE_YAML
131
- GameOptions.add 'save_file_bin_path', GW_SAVE_FILE_BIN
132
- GameOptions.add 'log_file_path', GW_LOG_FILE
133
- GameOptions.add 'options_file_path', GW_OPTS_FILE
134
- GameOptions.add 'wrap_width', GW_DEFAULT_WRAP_WIDTH
135
- end
136
-
137
156
  begin
138
- init_config
139
-
140
157
  options = parse_options_cli
141
158
 
159
+ init_config(options[:world_name])
160
+
142
161
  Gemwarrior::Game.new(options)
143
- rescue => error
144
- print_error(error)
162
+ rescue => e
163
+ print_error(e)
164
+ puts ("#{self.class} - #{e.class}: #{e.message}" + e.backtrace).join("\n")
145
165
  exit(false)
146
166
  end
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gemwarrior::World
2
+ locations:
3
+ - !ruby/object:Gemwarrior::Location
4
+ name: home
5
+ name_display: Home
6
+ visited: true
7
+ description: The little, unimportant, decrepit shack that you live in. What the place lacks in decisive magnanimity is made up for in cozy squalidness. Your bed covers much of the northern corner. Your beloved family chest sits at the foot of the bed.
8
+ coords: &2
9
+ :x: 5
10
+ :y: 0
11
+ :z: 0
12
+ paths:
13
+ :north: true
14
+ :east: true
15
+ :south: false
16
+ :west: true
17
+ danger_level: :none
18
+ monster_level_range:
19
+ items:
20
+ - !ruby/object:Gemwarrior::Bed
21
+ equipped: false
22
+ consumable: false
23
+ used: false
24
+ used_again: false
25
+ number_of_uses:
26
+ name: bed
27
+ name_display: Bed
28
+ description: The place where you sleep when you are not adventuring.
29
+ takeable: false
30
+ talkable: false
31
+ useable: true
32
+ equippable: false
33
+ monsters_abounding: []
34
+ bosses_abounding: []
35
+ checked_for_monsters: false
36
+ player: !ruby/object:Gemwarrior::Player
37
+ name: Player
38
+ description: |-
39
+ Picked to do battle against a wizened madman for a shiny something or other for world-saving purposes.
40
+ face: facey
41
+ hands: handsy
42
+ mood: moody
43
+ level: 1
44
+ xp: 0
45
+ hp_cur: 30
46
+ hp_max: 30
47
+ atk_lo: 1
48
+ atk_hi: 2
49
+ defense: 1
50
+ dexterity: 3
51
+ inventory: !ruby/object:Gemwarrior::Inventory
52
+ armor:
53
+ items: []
54
+ weapon:
55
+ rox: 0
56
+ cur_coords: *2
57
+ special_abilities: []
58
+ monsters_killed: 0
59
+ bosses_killed: 0
60
+ items_taken: 0
61
+ movements_made: 0
62
+ rests_taken: 0
63
+ deaths: 0
64
+ emerald_beaten: false
65
+ shifty_jeweled: false
66
+ shifty_to_jewel: false
67
+ duration:
@@ -0,0 +1,25 @@
1
+ --- !ruby/object:Gemwarrior::World
2
+ locations:
3
+ - !ruby/object:Gemwarrior::Location
4
+ name: home
5
+ name_display: Home
6
+ visited: true
7
+ description: The little, unimportant, decrepit shack that you live in. What the place lacks in decisive magnanimity is made up for in cozy squalidness. Your bed covers much of the northern corner. Your beloved family chest sits at the foot of the bed.
8
+ coords: &2
9
+ :x: 5
10
+ :y: 0
11
+ :z: 0
12
+ paths:
13
+ :north: true
14
+ :east: true
15
+ :south: false
16
+ :west: true
17
+ danger_level: :none
18
+ monster_level_range:
19
+ monsters_abounding: []
20
+ bosses_abounding: []
21
+ checked_for_monsters: false
22
+ emerald_beaten: false
23
+ shifty_jeweled: false
24
+ shifty_to_jewel: false
25
+ duration:
@@ -0,0 +1 @@
1
+ --- !ruby/object:Gemwarrior::World
data/gemwarrior.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  # additional
28
28
  ## runtime deps
29
29
  spec.add_runtime_dependency 'clocker', '~> 0.1.6'
30
- spec.add_runtime_dependency 'colorize', '~> 0.8'
30
+ spec.add_runtime_dependency 'colorize', '~> 1.0'
31
31
  spec.add_runtime_dependency 'gems', '~> 1.2'
32
32
  spec.add_runtime_dependency 'http', '~> 5.1'
33
33
  spec.add_runtime_dependency 'json', '~> 2.6'
@@ -7,6 +7,7 @@ require 'matrext'
7
7
  require_relative 'entities/armor/iron_helmet'
8
8
  require_relative 'entities/items/herb'
9
9
  require_relative 'entities/weapons/dagger'
10
+ require_relative 'entities/player'
10
11
  require_relative 'misc/animation'
11
12
  require_relative 'misc/audio'
12
13
  require_relative 'misc/formatting'
@@ -52,7 +53,7 @@ module Gemwarrior
52
53
  init_weapons
53
54
  init_armor
54
55
 
55
- # create new world based on default template
56
+ # create new world based on yaml/marshall data
56
57
  self.world = init_world
57
58
 
58
59
  # update some player aspects to make more dynamic
@@ -170,20 +171,20 @@ module Gemwarrior
170
171
  mode = GameOptions.data['save_file_mode']
171
172
 
172
173
  if mode.eql?('Y')
173
- if File.exist?(GameOptions.data['default_world_path_yaml'])
174
- File.open(GameOptions.data['default_world_path_yaml'], 'r') do |f|
175
- return YAML.load(f)
174
+ if File.exist?(GameOptions.data['world_yaml_path'])
175
+ File.open(GameOptions.data['world_yaml_path'], 'r') do |f|
176
+ return YAML.unsafe_load(f)
176
177
  end
177
178
  else
178
- puts "Error: cannot load #{GameOptions.data['default_world_path_yaml']}."
179
+ puts "Error: cannot load #{GameOptions.data['world_yaml_path']}."
179
180
  end
180
181
  else
181
- if File.exist?(GameOptions.data['default_world_path_bin'])
182
- File.open(GameOptions.data['default_world_path_bin'], 'r') do |f|
182
+ if File.exist?(GameOptions.data['world_bin_path'])
183
+ File.open(GameOptions.data['world_bin_path'], 'r') do |f|
183
184
  return Marshal.load(f)
184
185
  end
185
186
  else
186
- puts "Error: cannot load #{GameOptions.data['default_world_path_bin']}."
187
+ puts "Error: cannot load #{GameOptions.data['world_bin_path']}."
187
188
  end
188
189
  end
189
190
  end
@@ -120,7 +120,7 @@ module Gemwarrior
120
120
  def get_save_file_name
121
121
  if save_file_exist?
122
122
  File.open(GameOptions.data['save_file_yaml_path'], 'r') do |f|
123
- return YAML.load(f)
123
+ return YAML.unsafe_load(f)
124
124
  end
125
125
  end
126
126
  end
@@ -551,7 +551,7 @@ module Gemwarrior
551
551
  if mode.eql? 'Y'
552
552
  if File.exist?(GameOptions.data['save_file_yaml_path'])
553
553
  File.open(GameOptions.data['save_file_yaml_path'], 'r') do |f|
554
- return YAML.load(f)
554
+ return YAML.unsafe_load(f)
555
555
  end
556
556
  else
557
557
  puts 'No save file exists.'
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.15.13'
5
+ VERSION = '0.15.14'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.13
4
+ version: 0.15.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-06 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clocker
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.8'
33
+ version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.8'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: gems
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -284,6 +284,9 @@ files:
284
284
  - bin/gemwarrior
285
285
  - data/default_world.yaml
286
286
  - data/fantasy_names.yaml
287
+ - data/minimal1.yaml
288
+ - data/minimal2.yaml
289
+ - data/minimal3.yaml
287
290
  - gemwarrior.gemspec
288
291
  - lib/gemwarrior/arena.rb
289
292
  - lib/gemwarrior/battle.rb
@@ -418,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
421
  - !ruby/object:Gem::Version
419
422
  version: '0'
420
423
  requirements: []
421
- rubygems_version: 3.4.12
424
+ rubygems_version: 3.4.19
422
425
  signing_key:
423
426
  specification_version: 4
424
427
  summary: RubyGem text adventure