gemwarrior 0.9.23 → 0.9.24

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f98fe21d4e8bc60fc35a70412c557c61c3b58a2c
4
- data.tar.gz: 8f1c02ecc713082b4049b01add40eb2d5209cc80
3
+ metadata.gz: e9a1b18616466767287b7ffa529ea5601c8fc44b
4
+ data.tar.gz: 18b96dfb87948ec1aae7b6dcc689ca61473ccf7d
5
5
  SHA512:
6
- metadata.gz: 6fd750bdd5b1791f61d6cd295e682c0b66d9abcd0e22934fda3e5d580b0eee8858dc86882e07c2a910571dea52904cfdceb8a3be3280e5be5ea114e2354b047c
7
- data.tar.gz: 3f981fef70c2c9e8444e2dc5e0e4e47a52a901d775581012ac384e2d0df16443ed6ac7980cdc75d0ff578af1094fb317b86d2f6e890be357dd531a345c34851c
6
+ metadata.gz: 76d1391273ec80e83ed990557c69f7906a25b94a258a0d30ccc5f017dfb293ecb88ac37400ab9e59e34e0fdf9cb3ca57ca4163a950dfffa0b1f9493a2d3bdab5
7
+ data.tar.gz: e36826f4e67b5e6c171d9456429f95d7b8b98d6d562cb1f76e887dddacda65dcfba9dfda7fe35091a283a9fe945273c1cb14bcd42b79fe8d78f9552bf7a2bd1f
data/gemwarrior.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency 'colorize', '~> 0.7.7'
26
26
  spec.add_runtime_dependency 'matrext', '~> 0.4.8'
27
27
  spec.add_runtime_dependency 'clocker', '~> 0.1.2'
28
- spec.add_runtime_dependency 'feep', '~> 0.1.3'
28
+ spec.add_runtime_dependency 'win32-sound', '~> 0.6.0'
29
29
  spec.add_runtime_dependency 'github_api', '~> 0.12.4'
30
30
 
31
31
  # gems for future features
@@ -23,6 +23,17 @@ module Gemwarrior
23
23
  end
24
24
 
25
25
  def start(is_arena = nil, is_event = nil)
26
+ if world.sound
27
+ Music::cue([
28
+ {:frequencies => 'G4', :duration => 50},
29
+ {:frequencies => 'G#4', :duration => 50},
30
+ {:frequencies => 'G4', :duration => 50},
31
+ {:frequencies => 'G#4', :duration => 50},
32
+ {:frequencies => 'G4', :duration => 50},
33
+ {:frequencies => 'G#4', :duration => 50}
34
+ ])
35
+ end
36
+
26
37
  print_battle_line
27
38
 
28
39
  if is_arena
@@ -47,8 +58,8 @@ module Gemwarrior
47
58
  # main battle loop
48
59
  loop do
49
60
  if monster_dead?
50
- monster_death
51
- return
61
+ result = monster_death
62
+ return result
52
63
  elsif player_dead?
53
64
  player_death
54
65
  return 'death'
@@ -111,12 +122,18 @@ module Gemwarrior
111
122
  puts "You attack #{monster.name}#{player.cur_weapon_name}!"
112
123
  dmg = calculate_damage_to(monster)
113
124
  if dmg > 0
125
+ if world.sound
126
+ Music::cue([{:frequencies => 'A4,E4,B5', :duration => 75}])
127
+ end
114
128
  take_damage(monster, dmg)
115
129
  if monster_dead?
116
- monster_death
117
- return
130
+ result = monster_death
131
+ return result
118
132
  end
119
133
  else
134
+ if world.sound
135
+ Music::cue([{:frequencies => 'A4', :duration => 75}])
136
+ end
120
137
  puts 'You miss entirely!'.colorize(:yellow)
121
138
  end
122
139
  when 'defend', 'd'
@@ -222,10 +239,17 @@ module Gemwarrior
222
239
 
223
240
  def monster_attacks_player
224
241
  puts "#{monster.name} attacks you!"
242
+
225
243
  dmg = calculate_damage_to(player)
226
244
  if dmg > 0
245
+ if world.sound
246
+ Music::cue([{:frequencies => 'B4,E#5,A5', :duration => 75}])
247
+ end
227
248
  take_damage(player, dmg)
228
249
  else
250
+ if world.sound
251
+ Music::cue([{:frequencies => 'B4', :duration => 75}])
252
+ end
229
253
  puts "#{monster.name} misses entirely!".colorize(:yellow)
230
254
  end
231
255
  end
@@ -248,14 +272,21 @@ module Gemwarrior
248
272
  # end game boss!
249
273
  if monster.name.eql?('Emerald')
250
274
  Music::cue([
251
- {:freq_or_note => 'G3', :duration => 50},
252
- {:freq_or_note => 'A3', :duration => 50},
253
- {:freq_or_note => 'B3', :duration => 50},
254
- {:freq_or_note => 'C4', :duration => 50},
255
- {:freq_or_note => 'D4', :duration => 50},
256
- {:freq_or_note => 'E4', :duration => 50},
257
- {:freq_or_note => 'F#4', :duration => 50},
258
- {:freq_or_note => 'G4', :duration => 50}
275
+ {:frequencies => 'G3', :duration => 250},
276
+ {:frequencies => 'A3', :duration => 50},
277
+ {:frequencies => 'B3', :duration => 50},
278
+ {:frequencies => 'C4', :duration => 50},
279
+ {:frequencies => 'D4', :duration => 250},
280
+ {:frequencies => 'E4', :duration => 50},
281
+ {:frequencies => 'F#4', :duration => 50},
282
+ {:frequencies => 'G4', :duration => 50},
283
+ {:frequencies => 'A4', :duration => 250},
284
+ {:frequencies => 'B4', :duration => 50},
285
+ {:frequencies => 'C5', :duration => 50},
286
+ {:frequencies => 'D5', :duration => 50},
287
+ {:frequencies => 'E5', :duration => 50},
288
+ {:frequencies => 'F#5', :duration => 50},
289
+ {:frequencies => 'G5', :duration => 1000}
259
290
  ])
260
291
  puts monster.defeated_text
261
292
  gets
@@ -291,6 +322,15 @@ module Gemwarrior
291
322
  end
292
323
 
293
324
  def player_death
325
+ if world.sound
326
+ Music::cue([
327
+ {:frequencies => 'D#5', :duration => 100},
328
+ {:frequencies => 'A4', :duration => 150},
329
+ {:frequencies => 'F#4', :duration => 200},
330
+ {:frequencies => 'F4', :duration => 1000}
331
+ ])
332
+ end
333
+
294
334
  puts "You are dead, slain by the #{monster.name}!".colorize(:red)
295
335
  print_battle_line
296
336
  end
@@ -225,6 +225,8 @@ module Gemwarrior
225
225
  result = battle.start
226
226
  if result.eql?('death')
227
227
  return 'death'
228
+ elsif result.eql?('exit')
229
+ return 'exit'
228
230
  end
229
231
  end
230
232
 
@@ -308,6 +310,15 @@ module Gemwarrior
308
310
  private
309
311
 
310
312
  def player_death
313
+ if world.sound
314
+ Music::cue([
315
+ {:frequencies => 'D#5', :duration => 100},
316
+ {:frequencies => 'A4', :duration => 150},
317
+ {:frequencies => 'F#4', :duration => 200},
318
+ {:frequencies => 'F4', :duration => 1000}
319
+ ])
320
+ end
321
+
311
322
  puts 'Your actions have reduced you to death.'.colorize(:red)
312
323
  puts 'Somehow, however, your adventure does not end here. Instead, you are whisked back home via some magical force, a bit worse for the weary and somewhat poorer, but ALIVE!'.colorize(:yellow)
313
324
  return 'death'
@@ -315,14 +326,14 @@ module Gemwarrior
315
326
 
316
327
  # TRAVEL
317
328
  def print_traveling_text(direction_text, sound)
318
- Animation::run({:oneline => false, :phrase => "* #{direction_text} *"})
319
329
  if sound
320
330
  Music::cue([
321
- {:freq_or_note => 'C3', :duration => 75},
322
- {:freq_or_note => 'D3', :duration => 75},
323
- {:freq_or_note => 'E3', :duration => 75}
331
+ {:frequencies => 'C4', :duration => 75},
332
+ {:frequencies => 'D4', :duration => 75},
333
+ {:frequencies => 'E4', :duration => 75}
324
334
  ])
325
335
  end
336
+ Animation::run({:oneline => false, :phrase => "* #{direction_text} *"})
326
337
  end
327
338
 
328
339
  # CHARACTER
@@ -496,6 +496,8 @@ module Gemwarrior
496
496
 
497
497
  if result.eql?('death')
498
498
  player_death_resurrection
499
+ elsif result.eql?('exit')
500
+ return 'exit'
499
501
  end
500
502
  else
501
503
  ERROR_ATTACK_PARAM_INVALID
@@ -545,7 +547,9 @@ module Gemwarrior
545
547
  end
546
548
 
547
549
  def player_death_resurrection
548
- puts 'Somehow, though, your adventure does not end here. Instead, you are whisked back home via some magical force, a bit worse for the weary and somewhat poorer, but ALIVE!'.colorize(:yellow)
550
+ puts 'Somehow, though, your adventure does not end here!'.colorize(:yellow)
551
+ puts 'Instead, you are whisked back home via some magical force.'.colorize(:yellow)
552
+ puts 'A bit worse for the weary and somewhat poorer, but you are ALIVE!'.colorize(:yellow)
549
553
  world.player.hp_cur = 1
550
554
  world.player.rox -= (world.player.rox * 0.1).to_i
551
555
  if world.player.rox < 0
@@ -3,7 +3,6 @@
3
3
 
4
4
  require 'colorize'
5
5
  require 'matrext'
6
- require 'feep'
7
6
 
8
7
  require_relative 'entities/player'
9
8
  require_relative 'entities/items/herb'
@@ -1,34 +1,28 @@
1
1
  # lib/gemwarrior/misc/music.rb
2
2
  # Music cue
3
3
 
4
+ require 'win32/sound'
5
+ include Win32
6
+
7
+ require_relative 'musical_notes'
8
+
4
9
  module Gemwarrior
5
- module Music
10
+ module Music
6
11
  def self.cue(sequence)
7
- defaults = {
8
- :freq_or_note => 440,
9
- :waveform => 'saw',
10
- :volume => 0.3,
11
- :duration => 500,
12
- :notext => true
13
- }
14
-
15
- Thread.start {
16
- sequence.each do |note|
17
- note_to_play = note[:freq_or_note]
18
- waveform = note[:waveform].nil? ? defaults[:waveform] : note[:waveform]
19
- volume = note[:volume].nil? ? defaults[:volume] : note[:volume]
20
- duration = note[:duration].nil? ? defaults[:duration] : note[:duration]
21
- notext = note[:notext].nil? ? defaults[:notext] : note[:notext]
12
+ if OS.windows?
13
+ threads = []
22
14
 
23
- Feep::Base.new({
24
- :freq_or_note => note_to_play,
25
- :waveform => waveform,
26
- :volume => volume,
27
- :duration => duration,
28
- :notext => notext
29
- })
30
- end
31
- }
15
+ Thread.start {
16
+ sequence.each do |seq|
17
+ seq[:frequencies].split(',').each do |note|
18
+ threads << Thread.new {
19
+ Sound::play_freq(Notes::NOTE_FREQ[note], seq[:duration], 0.1)
20
+ }
21
+ end
22
+ threads.each { |th| th.join }
23
+ end
24
+ }
25
+ end
32
26
  end
33
27
  end
34
28
  end
@@ -0,0 +1,34 @@
1
+ # lib/gemwarrior/misc/music.rb
2
+ # Music cue
3
+
4
+ module Gemwarrior
5
+ module Music
6
+ def self.cue(sequence)
7
+ defaults = {
8
+ :freq_or_note => 440,
9
+ :waveform => 'saw',
10
+ :volume => 0.3,
11
+ :duration => 500,
12
+ :notext => true
13
+ }
14
+
15
+ Thread.start {
16
+ sequence.each do |note|
17
+ note_to_play = note[:freq_or_note]
18
+ waveform = note[:waveform].nil? ? defaults[:waveform] : note[:waveform]
19
+ volume = note[:volume].nil? ? defaults[:volume] : note[:volume]
20
+ duration = note[:duration].nil? ? defaults[:duration] : note[:duration]
21
+ notext = note[:notext].nil? ? defaults[:notext] : note[:notext]
22
+
23
+ Feep::Base.new({
24
+ :freq_or_note => note_to_play,
25
+ :waveform => waveform,
26
+ :volume => volume,
27
+ :duration => duration,
28
+ :notext => notext
29
+ })
30
+ end
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,179 @@
1
+ # lib/gemwarrior/misc/musical_notes.rb
2
+ # Musical note->freq hash
3
+
4
+ module Gemwarrior
5
+ module Notes
6
+ NOTE_FREQ = Hash[
7
+ 'C0' => 16.351,
8
+ 'C#0' => 17.324,
9
+ 'Db0' => 17.324,
10
+ 'D0' => 18.354,
11
+ 'D#0' => 19.445,
12
+ 'Eb0' => 19.445,
13
+ 'E0' => 20.601,
14
+ 'F0' => 21.827,
15
+ 'F#0' => 23.124,
16
+ 'Gb0' => 23.124,
17
+ 'G0' => 24.499,
18
+ 'G#0' => 25.956,
19
+ 'Ab0' => 25.956,
20
+ 'A0' => 27.500,
21
+ 'A#0' => 29.135,
22
+ 'Bb0' => 29.135,
23
+ 'B0' => 30.868,
24
+ 'C1' => 32.703,
25
+ 'C#1' => 34.648,
26
+ 'Db1' => 34.648,
27
+ 'D1' => 36.708,
28
+ 'D#1' => 38.891,
29
+ 'Eb1' => 38.891,
30
+ 'E1' => 41.203,
31
+ 'F1' => 43.654,
32
+ 'F#1' => 46.249,
33
+ 'Gb1' => 46.249,
34
+ 'G1' => 48.999,
35
+ 'G#1' => 51.913,
36
+ 'Ab1' => 51.913,
37
+ 'A1' => 55.000,
38
+ 'A#1' => 58.270,
39
+ 'Bb1' => 58.270,
40
+ 'B1' => 61.375,
41
+ 'C2' => 65.406,
42
+ 'C#2' => 69.296,
43
+ 'Db2' => 69.296,
44
+ 'D2' => 73.416,
45
+ 'D#2' => 77.782,
46
+ 'Eb2' => 77.782,
47
+ 'E2' => 82.407,
48
+ 'F2' => 87.307,
49
+ 'F#2' => 92.499,
50
+ 'Gb2' => 92.499,
51
+ 'G2' => 97.999,
52
+ 'G#2' => 97.999,
53
+ 'Ab2' => 103.826,
54
+ 'A2' => 110.000,
55
+ 'A#2' => 116.541,
56
+ 'Bb2' => 116.541,
57
+ 'B2' => 123.471,
58
+ 'C3' => 130.813,
59
+ 'C#3' => 138.591,
60
+ 'Db3' => 138.591,
61
+ 'D3' => 146.832,
62
+ 'D#3' => 155.564,
63
+ 'Eb3' => 155.564,
64
+ 'E3' => 164.814,
65
+ 'F3' => 174.614,
66
+ 'F#3' => 184.997,
67
+ 'Gb3' => 184.997,
68
+ 'G3' => 195.998,
69
+ 'G#3' => 207.652,
70
+ 'Ab3' => 207.652,
71
+ 'A3' => 220.000,
72
+ 'A#3' => 233.082,
73
+ 'Bb3' => 233.082,
74
+ 'B3' => 246.942,
75
+ 'C4' => 261.626,
76
+ 'C#4' => 277.183,
77
+ 'Db4' => 277.183,
78
+ 'D4' => 293.665,
79
+ 'D#4' => 311.127,
80
+ 'Eb4' => 311.127,
81
+ 'E4' => 329.628,
82
+ 'F4' => 349.228,
83
+ 'F#4' => 369.994,
84
+ 'Gb4' => 369.994,
85
+ 'G4' => 391.995,
86
+ 'G#4' => 415.305,
87
+ 'Ab4' => 415.305,
88
+ 'A4' => 440.000,
89
+ 'A#4' => 466.164,
90
+ 'Bb4' => 466.164,
91
+ 'B4' => 493.883,
92
+ 'C5' => 523.251,
93
+ 'C#5' => 554.365,
94
+ 'Db5' => 554.365,
95
+ 'D5' => 587.330,
96
+ 'D#5' => 622.254,
97
+ 'Eb5' => 622.254,
98
+ 'E5' => 659.255,
99
+ 'F5' => 698.457,
100
+ 'F#5' => 739.989,
101
+ 'Gb5' => 739.989,
102
+ 'G5' => 783.991,
103
+ 'G#5' => 830.609,
104
+ 'Ab5' => 830.609,
105
+ 'A5' => 880.000,
106
+ 'A#5' => 932.328,
107
+ 'Bb5' => 932.328,
108
+ 'B5' => 987.767,
109
+ 'C6' => 1046.502,
110
+ 'C#6' => 1108.731,
111
+ 'Db6' => 1108.731,
112
+ 'D6' => 1174.659,
113
+ 'D#6' => 1244.508,
114
+ 'Eb6' => 1244.508,
115
+ 'E6' => 1318.510,
116
+ 'F6' => 1396.913,
117
+ 'F#6' => 1479.978,
118
+ 'Gb6' => 1479.978,
119
+ 'G6' => 1567.982,
120
+ 'G#6' => 1661.219,
121
+ 'Ab6' => 1661.219,
122
+ 'A6' => 1760.000,
123
+ 'A#6' => 1864.655,
124
+ 'Bb6' => 1864.655,
125
+ 'B6' => 1975.533,
126
+ 'C7' => 2093.005,
127
+ 'C#7' => 2217.461,
128
+ 'Db7' => 2217.461,
129
+ 'D7' => 2349.318,
130
+ 'D#7' => 2489.016,
131
+ 'Eb7' => 2489.016,
132
+ 'E7' => 2637.021,
133
+ 'F7' => 2793.826,
134
+ 'F#7' => 2959.956,
135
+ 'Gb7' => 2959.956,
136
+ 'G7' => 3135.964,
137
+ 'G#7' => 3322.438,
138
+ 'Ab7' => 3322.438,
139
+ 'A7' => 3520.000,
140
+ 'A#7' => 3729.310,
141
+ 'Bb7' => 3729.310,
142
+ 'B7' => 3951.066,
143
+ 'C8' => 4186.009,
144
+ 'C#8' => 4434.922,
145
+ 'Db8' => 4434.922,
146
+ 'D8' => 4698.636,
147
+ 'D#8' => 4978.032,
148
+ 'Eb8' => 4978.032,
149
+ 'E8' => 5274.042,
150
+ 'F8' => 5587.652,
151
+ 'F#8' => 5919.910,
152
+ 'Gb8' => 5919.910,
153
+ 'G8' => 6271.928,
154
+ 'G#8' => 6644.876,
155
+ 'Ab8' => 6644.876,
156
+ 'A8' => 7040.000,
157
+ 'A#8' => 7458.620,
158
+ 'Bb8' => 7458.620,
159
+ 'B8' => 7902.132,
160
+ 'C9' => 8372.018,
161
+ 'C#9' => 8869.844,
162
+ 'Db9' => 8869.844,
163
+ 'D9' => 9397.272,
164
+ 'D#9' => 9956.064,
165
+ 'Eb9' => 9956.064,
166
+ 'E9' => 10548.084,
167
+ 'F9' => 11175.304,
168
+ 'F#9' => 11839.820,
169
+ 'Gb9' => 11839.820,
170
+ 'G9' => 12543.856,
171
+ 'G#9' => 13289.752,
172
+ 'Ab9' => 13289.752,
173
+ 'A9' => 14080.000,
174
+ 'A#9' => 14917.240,
175
+ 'Bb9' => 14917.240,
176
+ 'B9' => 15804.264
177
+ ]
178
+ end
179
+ end
@@ -80,12 +80,6 @@ module Gemwarrior
80
80
  end
81
81
 
82
82
  def print_logo
83
- if world.sound
84
- Music::cue([
85
- {:freq_or_note => 'A3,E4,C#5,F#5', :duration => 1000}
86
- ])
87
- end
88
-
89
83
  puts '/-+-+-+ +-+-+-+-+-+-+-\\'.colorize(:yellow)
90
84
  puts '|G|E|M| |W|A|R|R|I|O|R|'.colorize(:yellow)
91
85
  puts '\\-+-+-+ +-+-+-+-+-+-+-/'.colorize(:yellow)
@@ -224,6 +218,12 @@ module Gemwarrior
224
218
  case choice
225
219
  when 'n'
226
220
  clear_screen
221
+ if world.sound
222
+ Music::cue([
223
+ {:frequencies => 'A3,E4,C#5,E5', :duration => 300},
224
+ {:frequencies => 'A3,E4,C#5,F#5', :duration => 600}
225
+ ])
226
+ end
227
227
  print_splash_message
228
228
  print_fortune
229
229
  return
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.23'
5
+ VERSION = '0.9.24'
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.9.23
4
+ version: 0.9.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
@@ -101,19 +101,19 @@ dependencies:
101
101
  - !ruby/object:Gem::Version
102
102
  version: 0.1.2
103
103
  - !ruby/object:Gem::Dependency
104
- name: feep
104
+ name: win32-sound
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 0.1.3
109
+ version: 0.6.0
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 0.1.3
116
+ version: 0.6.0
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: github_api
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -275,6 +275,8 @@ files:
275
275
  - lib/gemwarrior/misc/animation.rb
276
276
  - lib/gemwarrior/misc/formatting.rb
277
277
  - lib/gemwarrior/misc/music.rb
278
+ - lib/gemwarrior/misc/music_exp.rb
279
+ - lib/gemwarrior/misc/musical_notes.rb
278
280
  - lib/gemwarrior/misc/name_generator.rb
279
281
  - lib/gemwarrior/misc/player_levels.rb
280
282
  - lib/gemwarrior/misc/timer.rb