gemwarrior 0.15.4 → 0.15.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/README.md +44 -44
  4. data/bin/gemwarrior +6 -5
  5. data/data/default_world.yaml +66 -66
  6. data/data/fantasy_names.yaml +4223 -4223
  7. data/gemwarrior.gemspec +44 -43
  8. data/lib/gemwarrior/entities/entity.rb +1 -0
  9. data/lib/gemwarrior/entities/item.rb +3 -3
  10. data/lib/gemwarrior/entities/items/apple.rb +11 -0
  11. data/lib/gemwarrior/entities/items/cup.rb +5 -0
  12. data/lib/gemwarrior/entities/items/dehumidifier.rb +6 -1
  13. data/lib/gemwarrior/entities/items/feather.rb +5 -0
  14. data/lib/gemwarrior/entities/items/flower.rb +5 -0
  15. data/lib/gemwarrior/entities/items/keystone.rb +5 -0
  16. data/lib/gemwarrior/entities/items/pedestal.rb +20 -20
  17. data/lib/gemwarrior/entities/items/stonemite.rb +5 -0
  18. data/lib/gemwarrior/entities/people/arena_master.rb +49 -49
  19. data/lib/gemwarrior/entities/people/rockney.rb +2 -2
  20. data/lib/gemwarrior/entities/people/ware_hawker.rb +3 -3
  21. data/lib/gemwarrior/entities/person.rb +3 -2
  22. data/lib/gemwarrior/entities/player.rb +15 -11
  23. data/lib/gemwarrior/entities/weapon.rb +1 -1
  24. data/lib/gemwarrior/evaluator.rb +4 -3
  25. data/lib/gemwarrior/inventory.rb +11 -5
  26. data/lib/gemwarrior/misc/audio.rb +65 -36
  27. data/lib/gemwarrior/misc/audio_cues.rb +71 -7
  28. data/lib/gemwarrior/misc/bloops_cues.rb +63 -5
  29. data/lib/gemwarrior/misc/name_generator.rb +7 -7
  30. data/lib/gemwarrior/repl.rb +131 -17
  31. data/lib/gemwarrior/version.rb +1 -1
  32. data/tests/compare_versions.rb +18 -0
  33. data/tests/getch_test.rb +9 -0
  34. data/tests/hooch.rb +16 -0
  35. data/tests/item_hashes.rb +7 -0
  36. data/tests/json_api_call.rb +42 -0
  37. data/tests/module_hashes.rb +90 -0
  38. data/tests/test-class/test-class.rb +50 -0
  39. data/tests/test-feep/test-feep.rb +35 -0
  40. data/tests/test-save-load/save-load.rb +181 -0
  41. data/tests/test-save-load/save.conf +2 -0
  42. data/tests/test-singleton/game.rb +4 -0
  43. data/tests/test-singleton/game_options.rb +15 -0
  44. metadata +58 -33
@@ -0,0 +1,50 @@
1
+ class Rat
2
+ attr_accessor :name,
3
+ :level,
4
+ :hp
5
+
6
+ def initialize(name = 'rat')
7
+ self.name = name
8
+ self.level = rand(1..4)
9
+ self.hp = rand((self.level * 3)..(self.level * 5))
10
+ end
11
+ end
12
+
13
+ m = [Rat.new]
14
+
15
+ rat_o = m[0]
16
+ rat_c = m[0].clone
17
+
18
+ puts "[initial]"
19
+ puts "m[0] : #{m[0].inspect}"
20
+ puts "rat_o : #{rat_o.inspect}"
21
+ puts "rat_c : #{rat_c.inspect}"
22
+
23
+ m[0].hp -= 1
24
+
25
+ puts "[m[0] - 1hp]"
26
+ puts "m[0] : #{m[0].inspect}"
27
+ puts "rat_o : #{rat_o.inspect}"
28
+ puts "rat_c : #{rat_c.inspect}"
29
+
30
+ rat_o.hp -= 1
31
+
32
+ puts "[rat_o - 1hp]"
33
+ puts "m[0] : #{m[0].inspect}"
34
+ puts "rat_o : #{rat_o.inspect}"
35
+ puts "rat_c : #{rat_c.inspect}"
36
+
37
+ rat_c.hp -= 1
38
+
39
+ puts "[rat_c - 1hp]"
40
+ puts "m[0] : #{m[0].inspect}"
41
+ puts "rat_o : #{rat_o.inspect}"
42
+ puts "rat_c : #{rat_c.inspect}"
43
+
44
+ rat_c2 = m[0].clone
45
+
46
+ puts "[rat_c2 created from m[0]]"
47
+ puts "m[0] : #{m[0].inspect}"
48
+ puts "rat_o : #{rat_o.inspect}"
49
+ puts "rat_c : #{rat_c.inspect}"
50
+ puts "rat_c2: #{rat_c2.inspect}"
@@ -0,0 +1,35 @@
1
+ require 'feep'
2
+
3
+ sequence = [
4
+ {freq_or_note: 'A3', duration: 80},
5
+ {freq_or_note: 'E4', duration: 80},
6
+ {freq_or_note: 'G4', duration: 80},
7
+ {freq_or_note: 'C#5', duration: 80},
8
+ {freq_or_note: 'G5', duration: 240}
9
+ ]
10
+
11
+ defaults = {
12
+ :freq_or_note => '440',
13
+ :waveform => 'saw',
14
+ :volume => 0.3,
15
+ :duration => 100,
16
+ :notext => true
17
+ }
18
+
19
+ sequence.each do |seq|
20
+ puts "seq before merge: #{seq}"
21
+
22
+ seq = defaults.merge(seq)
23
+
24
+ puts "seq after merge: #{seq}"
25
+
26
+ puts "playing #{seq[:freq_or_note]}"
27
+
28
+ Feep::Base.new({
29
+ :freq_or_note => seq[:freq_or_note],
30
+ :waveform => seq[:waveform],
31
+ :volume => seq[:volume],
32
+ :duration => seq[:duration],
33
+ :notext => seq[:notext]
34
+ })
35
+ end
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env ruby
2
+ require 'io/console'
3
+
4
+ class SaveLoad
5
+ SAVE_DATA_FILE = 'save.conf'
6
+
7
+ attr_accessor :data_changed
8
+
9
+ def initialize
10
+ self.data_changed = false
11
+ end
12
+
13
+ module Config
14
+ def self.add key, value
15
+ @@data ||= {}
16
+ @@data[key] = value
17
+ end
18
+
19
+ def self.data
20
+ @@data ||= {}
21
+ end
22
+ end
23
+
24
+ def show_change_data_menu
25
+ puts 'Change Data'
26
+ puts '-----------'
27
+ puts
28
+ puts " (1) Name: #{Config.data['name']}"
29
+ puts " (2) Age: #{Config.data['age']}"
30
+ puts " (3) Hometown: #{Config.data['hometown']}"
31
+ puts
32
+ puts ' (q) Back to main menu'
33
+ puts
34
+ print 'data> '
35
+ choice = STDIN.getch.downcase
36
+
37
+ case choice
38
+ when '1'
39
+ print 'Name: '
40
+ answer = gets.chomp
41
+
42
+ unless answer.empty?
43
+ if Config.data['name'].nil?
44
+ Config.add 'name', answer
45
+ else
46
+ Config.data['name'] = answer
47
+ end
48
+ self.data_changed = true
49
+ end
50
+ show_change_data_menu
51
+ when '2'
52
+ print 'Age: '
53
+ answer = gets.chomp
54
+
55
+ unless answer.empty?
56
+ if Config.data['age'].nil?
57
+ Config.add 'age', answer
58
+ else
59
+ Config.data['age'] = answer
60
+ end
61
+ self.data_changed = true
62
+ end
63
+ show_change_data_menu
64
+ when '3'
65
+ print 'Hometown: '
66
+ answer = gets.chomp
67
+
68
+ unless answer.empty?
69
+ if Config.data['hometown'].nil?
70
+ Config.add 'hometown', answer
71
+ else
72
+ Config.data['hometown'] = answer
73
+ end
74
+ self.data_changed = true
75
+ end
76
+ show_change_data_menu
77
+ when 'q', 'x'
78
+ puts
79
+ return
80
+ else
81
+ show_change_data_menu
82
+ end
83
+ end
84
+
85
+ def show_main_menu
86
+ puts 'Main Menu'
87
+ puts '---------'
88
+ puts
89
+ puts ' (1) Display loaded data'
90
+ puts ' (2) Change data'
91
+ puts ' (3) Read from save file'
92
+ puts ' (4) Write to save file'
93
+ puts
94
+ puts ' (q) Quit from script'
95
+ puts
96
+ print 'menu> '
97
+ choice = STDIN.getch.downcase
98
+
99
+ case choice
100
+ when '1'
101
+ puts choice
102
+ display_loaded_data
103
+ show_main_menu
104
+ when '2'
105
+ puts choice
106
+ show_change_data_menu
107
+ show_main_menu
108
+ when '3'
109
+ puts choice
110
+ read_from_save
111
+ show_main_menu
112
+ when '4'
113
+ puts choice
114
+ write_to_save
115
+ show_main_menu
116
+ when 'x', 'q'
117
+ puts choice
118
+ if data_changed
119
+ puts 'You changed stuff. Do you want to save before exiting? (y/n)'
120
+ answer = STDIN.getch.downcase
121
+
122
+ case answer
123
+ when 'y'
124
+ write_to_save
125
+ end
126
+ end
127
+ puts "Exiting..."
128
+ exit
129
+ else
130
+ show_main_menu
131
+ end
132
+ end
133
+
134
+ def display_loaded_data
135
+ if Config.data.empty?
136
+ puts 'No loaded data yet.'
137
+ puts
138
+ else
139
+ Config.data.each do |key, val|
140
+ puts "#{key} : #{val}"
141
+ end
142
+ puts
143
+ end
144
+ end
145
+
146
+ def read_from_save
147
+ if File.exist?(SAVE_DATA_FILE)
148
+ #save_data = YAML.load_file(SAVE_DATA_FILE)
149
+
150
+ print 'Overwrite current session with saved data? (y/n) '
151
+ a = STDIN.getch.chomp.downcase
152
+
153
+ case a
154
+ when 'y'
155
+ File.open(SAVE_DATA_FILE).readlines.each do |line|
156
+ l = line.split(':')
157
+ Config.add l[0], l[1]
158
+ end
159
+ puts "Successfully read from #{SAVE_DATA_FILE}"
160
+ puts
161
+ end
162
+ else
163
+ puts 'No save file.'
164
+ end
165
+ end
166
+
167
+ def write_to_save
168
+ File.open(SAVE_DATA_FILE, 'w') do |f|
169
+ Config.data.each do |key, val|
170
+ f.puts "#{key}:#{val}"
171
+ end
172
+ end
173
+ puts "Wrote to #{SAVE_DATA_FILE}"
174
+ puts
175
+ end
176
+ end
177
+
178
+ puts 'Welcome to the Save/Load data test!'
179
+ puts
180
+ sl = SaveLoad.new
181
+ sl.show_main_menu
@@ -0,0 +1,2 @@
1
+ name:mike
2
+ age:34
@@ -0,0 +1,4 @@
1
+ require_relative 'game_options'
2
+
3
+ puts GameOptions.data
4
+ puts GameOptions.data['sound_enabled']
@@ -0,0 +1,15 @@
1
+ module GameOptions
2
+ def self.add key, value
3
+ @@data ||= {}
4
+ @@data[key] = value
5
+ end
6
+
7
+ def self.data
8
+ @@data ||= {}
9
+ end
10
+ end
11
+
12
+ GameOptions.data
13
+
14
+ GameOptions.add 'sound_enabled', true
15
+ GameOptions.add 'sound_volume', 0.3
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.4
4
+ version: 0.15.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-08 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -64,28 +64,28 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.7.7
67
+ version: '0.8'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.7.7
74
+ version: '0.8'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: matrext
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.4.10
81
+ version: '1'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 0.4.10
88
+ version: '1'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: clocker
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -120,28 +120,28 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '1.8'
123
+ version: '2.1'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '1.8'
130
+ version: '2.1'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rake
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '10.0'
137
+ version: 12.3.3
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '10.0'
144
+ version: 12.3.3
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: rubocop
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -160,72 +160,86 @@ dependencies:
160
160
  name: rspec
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - ">="
163
+ - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '0'
165
+ version: 3.9.0
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
- - - ">="
170
+ - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '0'
172
+ version: 3.9.0
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: rspec-nc
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
- - - ">="
177
+ - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: '0'
179
+ version: '0.3'
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - ">="
184
+ - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: '0'
186
+ version: '0.3'
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: guard
189
189
  requirement: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - ">="
191
+ - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: '0'
193
+ version: '2.16'
194
194
  type: :development
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - ">="
198
+ - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: '0'
200
+ version: '2.16'
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: guard-rspec
203
203
  requirement: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">="
205
+ - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '0'
207
+ version: '4.7'
208
208
  type: :development
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - ">="
212
+ - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '0'
214
+ version: '4.7'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: pry-byebug
217
217
  requirement: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - "~>"
220
220
  - !ruby/object:Gem::Version
221
- version: '3.0'
221
+ version: '3.9'
222
222
  type: :development
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: '3.0'
228
+ version: '3.9'
229
+ - !ruby/object:Gem::Dependency
230
+ name: awesome_print
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - "~>"
234
+ - !ruby/object:Gem::Version
235
+ version: '1.8'
236
+ type: :development
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - "~>"
241
+ - !ruby/object:Gem::Version
242
+ version: '1.8'
229
243
  description: A fun text adventure in the form of a RubyGem!
230
244
  email: mike@codana.me
231
245
  executables:
@@ -343,11 +357,23 @@ files:
343
357
  - lib/gemwarrior/world.rb
344
358
  - spec/gemwarrior_spec.rb
345
359
  - spec/spec_helper.rb
360
+ - tests/compare_versions.rb
361
+ - tests/getch_test.rb
362
+ - tests/hooch.rb
363
+ - tests/item_hashes.rb
364
+ - tests/json_api_call.rb
365
+ - tests/module_hashes.rb
366
+ - tests/test-class/test-class.rb
367
+ - tests/test-feep/test-feep.rb
368
+ - tests/test-save-load/save-load.rb
369
+ - tests/test-save-load/save.conf
370
+ - tests/test-singleton/game.rb
371
+ - tests/test-singleton/game_options.rb
346
372
  homepage: http://rubygems.org/gems/gemwarrior
347
373
  licenses:
348
374
  - MIT
349
375
  metadata: {}
350
- post_install_message:
376
+ post_install_message:
351
377
  rdoc_options: []
352
378
  require_paths:
353
379
  - lib
@@ -362,9 +388,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
388
  - !ruby/object:Gem::Version
363
389
  version: '0'
364
390
  requirements: []
365
- rubyforge_project:
366
- rubygems_version: 2.7.4
367
- signing_key:
391
+ rubygems_version: 3.1.4
392
+ signing_key:
368
393
  specification_version: 4
369
394
  summary: RubyGem text adventure
370
395
  test_files: