2
2
# Monster battle
3
3
4
4
require_relative 'misc/player_levels'
5
+ require_relative 'game_options'
5
6
6
7
module Gemwarrior
7
8
class Battle
@@ -23,16 +24,14 @@ def initialize(options)
23
24
end
24
25
25
26
def start ( is_arena = nil , is_event = nil )
26
- if world . sound_enabled
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
- ] , world . sound_volume )
35
- end
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
+ ] )
36
35
37
36
print_battle_line
38
37
@@ -77,21 +76,17 @@ def start(is_arena = nil, is_event = nil)
77
76
78
77
# print health info
79
78
print "#{ player . name . upcase . ljust ( 12 ) } :: #{ player . hp_cur . to_s . rjust ( 3 ) } HP"
80
- if world . debug_mode
81
- print " (LVL: #{ player . level } )"
82
- end
79
+ print " (LVL: #{ player . level } )" if GameOptions . data [ 'debug_mode' ]
83
80
print "\n "
84
81
85
82
print "#{ monster . name . upcase . ljust ( 12 ) } :: "
86
- if world . debug_mode || player . special_abilities . include? ( :rocking_vision )
83
+ if GameOptions . data [ ' debug_mode' ] || player . special_abilities . include? ( :rocking_vision )
87
84
print "#{ monster . hp_cur . to_s . rjust ( 3 ) } "
88
85
else
89
86
print '???'
90
87
end
91
88
print ' HP'
92
- if world . debug_mode
93
- print " (LVL: #{ monster . level } )"
94
- end
89
+ print " (LVL: #{ monster . level } )" if GameOptions . data [ 'debug_mode' ]
95
90
print "\n "
96
91
puts
97
92
@@ -122,18 +117,16 @@ def start(is_arena = nil, is_event = nil)
122
117
puts "You attack #{ monster . name } #{ player . cur_weapon_name } !"
123
118
dmg = calculate_damage_to ( monster )
124
119
if dmg > 0
125
- if world . sound_enabled
126
- Music ::cue ( [ { frequencies : 'A4,E4,B5' , duration : 75 } ] , world . sound_volume )
127
- end
120
+ Music ::cue ( [ { frequencies : 'A4,E4,B5' , duration : 75 } ] )
121
+
128
122
take_damage ( monster , dmg )
129
123
if monster_dead?
130
124
result = monster_death
131
125
return result
132
126
end
133
127
else
134
- if world . sound_enabled
135
- Music ::cue ( [ { frequencies : 'A4' , duration : 75 } ] , world . sound_volume )
136
- end
128
+ Music ::cue ( [ { frequencies : 'A4' , duration : 75 } ] )
129
+
137
130
puts 'You miss entirely!' . colorize ( :yellow )
138
131
end
139
132
when 'defend' , 'd'
@@ -145,7 +138,7 @@ def start(is_arena = nil, is_event = nil)
145
138
print "#{ monster . name } " . colorize ( :white )
146
139
print " (#{ monster . hp_cur } /#{ monster . hp_max } HP): #{ monster . description } \n "
147
140
puts "It has some distinguishing features, too: face is #{ monster . face } , hands are #{ monster . hands } , and general mood is #{ monster . mood } ."
148
- if world . debug_mode
141
+ if GameOptions . data [ ' debug_mode' ]
149
142
puts 'If defeated, will receive:'
150
143
puts " >> XP : #{ monster . xp } "
151
144
puts " >> ROX : #{ monster . rox } "
@@ -192,7 +185,7 @@ def calculate_damage_to(entity)
192
185
atk_range = base_atk_lo ..base_atk_hi
193
186
194
187
# beast mode modifier
195
- if player . beast_mode
188
+ if GameOptions . data [ ' beast_mode' ]
196
189
atk_range = BEAST_MODE_ATTACK ..BEAST_MODE_ATTACK
197
190
# level 3 ability modifier
198
191
elsif player . special_abilities . include? ( :rock_slide )
@@ -250,14 +243,12 @@ def monster_attacks_player
250
243
251
244
dmg = calculate_damage_to ( player )
252
245
if dmg > 0
253
- if world . sound_enabled
254
- Music ::cue ( [ { frequencies : 'B4,E#5,A5' , duration : 75 } ] , world . sound_volume )
255
- end
246
+ Music ::cue ( [ { frequencies : 'B4,E#5,A5' , duration : 75 } ] )
247
+
256
248
take_damage ( player , dmg )
257
249
else
258
- if world . sound_enabled
259
- Music ::cue ( [ { frequencies : 'B4' , duration : 75 } ] , world . sound_volume )
260
- end
250
+ Music ::cue ( [ { frequencies : 'B4' , duration : 75 } ] )
251
+
261
252
puts "#{ monster . name } misses entirely!" . colorize ( :yellow )
262
253
end
263
254
end
@@ -279,25 +270,24 @@ def monster_death
279
270
if monster . is_boss
280
271
# end game boss!
281
272
if monster . name . eql? ( 'Emerald' )
282
- if world . sound_enabled
283
- Music ::cue ( [
284
- { frequencies : 'G3' , duration : 250 } ,
285
- { frequencies : 'A3' , duration : 50 } ,
286
- { frequencies : 'B3' , duration : 50 } ,
287
- { frequencies : 'C4' , duration : 50 } ,
288
- { frequencies : 'D4' , duration : 250 } ,
289
- { frequencies : 'E4' , duration : 50 } ,
290
- { frequencies : 'F#4' , duration : 50 } ,
291
- { frequencies : 'G4' , duration : 50 } ,
292
- { frequencies : 'A4' , duration : 250 } ,
293
- { frequencies : 'B4' , duration : 50 } ,
294
- { frequencies : 'C5' , duration : 50 } ,
295
- { frequencies : 'D5' , duration : 50 } ,
296
- { frequencies : 'E5' , duration : 50 } ,
297
- { frequencies : 'F#5' , duration : 50 } ,
298
- { frequencies : 'G5' , duration : 1000 }
299
- ] , world . sound_volume )
300
- end
273
+ Music ::cue ( [
274
+ { frequencies : 'G3' , duration : 250 } ,
275
+ { frequencies : 'A3' , duration : 50 } ,
276
+ { frequencies : 'B3' , duration : 50 } ,
277
+ { frequencies : 'C4' , duration : 50 } ,
278
+ { frequencies : 'D4' , duration : 250 } ,
279
+ { frequencies : 'E4' , duration : 50 } ,
280
+ { frequencies : 'F#4' , duration : 50 } ,
281
+ { frequencies : 'G4' , duration : 50 } ,
282
+ { frequencies : 'A4' , duration : 250 } ,
283
+ { frequencies : 'B4' , duration : 50 } ,
284
+ { frequencies : 'C5' , duration : 50 } ,
285
+ { frequencies : 'D5' , duration : 50 } ,
286
+ { frequencies : 'E5' , duration : 50 } ,
287
+ { frequencies : 'F#5' , duration : 50 } ,
288
+ { frequencies : 'G5' , duration : 1000 }
289
+ ] )
290
+
301
291
puts monster . defeated_text
302
292
gets
303
293
return 'exit'
@@ -324,23 +314,14 @@ def monster_death
324
314
325
315
# PLAYER
326
316
def player_near_death?
327
- ( ( player . hp_cur . to_f / player . hp_max . to_f ) < 0.10 && !player . god_mode )
317
+ ( ( player . hp_cur . to_f / player . hp_max . to_f ) < 0.10 && !GameOptions . data [ ' god_mode' ] )
328
318
end
329
319
330
320
def player_dead?
331
- ( player . hp_cur <= 0 && !player . god_mode )
321
+ ( player . hp_cur <= 0 && !GameOptions . data [ ' god_mode' ] )
332
322
end
333
323
334
324
def player_death
335
- if world . sound_enabled
336
- Music ::cue ( [
337
- { frequencies : 'D#5' , duration : 100 } ,
338
- { frequencies : 'A4' , duration : 150 } ,
339
- { frequencies : 'F#4' , duration : 200 } ,
340
- { frequencies : 'F4' , duration : 1000 }
341
- ] , world . sound_volume )
342
- end
343
-
344
325
puts "You are dead, slain by the #{ monster . name } !" . colorize ( :red )
345
326
print_battle_line
346
327
end
0 commit comments