gemwarrior 0.8.6 → 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gemwarrior +15 -9
  3. data/gemwarrior.gemspec +1 -0
  4. data/lib/gemwarrior/arena.rb +10 -10
  5. data/lib/gemwarrior/battle.rb +41 -36
  6. data/lib/gemwarrior/entities/item.rb +2 -2
  7. data/lib/gemwarrior/entities/items/arena_master.rb +4 -4
  8. data/lib/gemwarrior/entities/items/bed.rb +1 -1
  9. data/lib/gemwarrior/entities/items/couch.rb +1 -1
  10. data/lib/gemwarrior/entities/items/floor_tile.rb +3 -3
  11. data/lib/gemwarrior/entities/items/gun.rb +1 -1
  12. data/lib/gemwarrior/entities/items/herb.rb +1 -1
  13. data/lib/gemwarrior/entities/items/ladder.rb +2 -2
  14. data/lib/gemwarrior/entities/items/map.rb +2 -2
  15. data/lib/gemwarrior/entities/items/massive_door.rb +1 -1
  16. data/lib/gemwarrior/entities/items/opalaser.rb +1 -1
  17. data/lib/gemwarrior/entities/items/pond.rb +2 -2
  18. data/lib/gemwarrior/entities/items/rope.rb +2 -2
  19. data/lib/gemwarrior/entities/items/snowman.rb +1 -1
  20. data/lib/gemwarrior/entities/items/sparklything.rb +1 -1
  21. data/lib/gemwarrior/entities/items/tent.rb +1 -1
  22. data/lib/gemwarrior/entities/items/tower_switch.rb +1 -1
  23. data/lib/gemwarrior/entities/items/waterfall.rb +1 -1
  24. data/lib/gemwarrior/entities/location.rb +19 -19
  25. data/lib/gemwarrior/entities/monster.rb +2 -2
  26. data/lib/gemwarrior/entities/monsters/alexandrat.rb +3 -3
  27. data/lib/gemwarrior/entities/monsters/amberoo.rb +3 -3
  28. data/lib/gemwarrior/entities/monsters/amethystle.rb +3 -3
  29. data/lib/gemwarrior/entities/monsters/apatiger.rb +2 -2
  30. data/lib/gemwarrior/entities/monsters/aquamarine.rb +3 -3
  31. data/lib/gemwarrior/entities/monsters/bloodstorm.rb +3 -3
  32. data/lib/gemwarrior/entities/monsters/bosses/emerald.rb +4 -4
  33. data/lib/gemwarrior/entities/monsters/bosses/garynetty.rb +2 -2
  34. data/lib/gemwarrior/entities/monsters/citrinaga.rb +3 -3
  35. data/lib/gemwarrior/entities/monsters/coraliz.rb +3 -3
  36. data/lib/gemwarrior/entities/monsters/cubicat.rb +3 -3
  37. data/lib/gemwarrior/entities/monsters/diaman.rb +3 -3
  38. data/lib/gemwarrior/entities/player.rb +275 -263
  39. data/lib/gemwarrior/evaluator.rb +448 -448
  40. data/lib/gemwarrior/game.rb +5 -5
  41. data/lib/gemwarrior/inventory.rb +14 -10
  42. data/lib/gemwarrior/misc/animation.rb +1 -1
  43. data/lib/gemwarrior/misc/music.rb +1 -1
  44. data/lib/gemwarrior/misc/name_generator.rb +8 -8
  45. data/lib/gemwarrior/misc/player_levels.rb +1 -1
  46. data/lib/gemwarrior/misc/timer.rb +50 -0
  47. data/lib/gemwarrior/misc/wordlist.rb +7 -7
  48. data/lib/gemwarrior/repl.rb +55 -21
  49. data/lib/gemwarrior/version.rb +1 -1
  50. data/lib/gemwarrior/world.rb +21 -21
  51. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4adb293d5ef28ea948ddefa890aba39e892b1f67
4
- data.tar.gz: abb4df914fa5da5d2300d434d9a5b3c823099f75
3
+ metadata.gz: 6d62c41e85fe6c1517f33d1254e5110ef0f7865a
4
+ data.tar.gz: 61ba0897384b10410d1047636330f5ab4d228a58
5
5
  SHA512:
6
- metadata.gz: 4af0a454c2928b69af31098408600aafcbe20690db64ec49085bac65d494627daab325b5d4fb393a5d7c96f9c31fe98f63a783e02a97ddb0b74ec5b0cbd1070d
7
- data.tar.gz: ce558c2829a12c6b1bc5ebd3de146ab8f1e9348bf4c4e2bc7c1e042bfd14d239f420f30b45386ede65e1e5eaa6a2054964b424f23a2b5c996592d383b181c15b
6
+ metadata.gz: 65e8374beb7b7ea6122d5e84edcd16cba935beb3a9bb93c9fe1b688a09233040b1832363e87e919a43616224eea4963155a1603a3974260dd5166d0919e6d886
7
+ data.tar.gz: 54d4f5e2fbbc7e966ff139f602686f594dbf0a50ea259dc01aeab584d6570d8062f7d57eb974bf00975b961a6a582a1e7e920fce1fea16e0d10509a9bd6d77e5
@@ -2,13 +2,19 @@
2
2
 
3
3
  require 'optparse'
4
4
 
5
- require_relative '../lib/gemwarrior/version'
6
5
  require_relative '../lib/gemwarrior/game'
6
+ require_relative '../lib/gemwarrior/version'
7
7
 
8
- GAME_NAME = "Gem Warrior"
8
+ GAME_NAME = 'Gem Warrior'
9
9
 
10
10
  def parse_options
11
- options = {:debug_mode => false, :god_mode => false, :beast_mode => false, :use_wordnik => false, :sound => false}
11
+ options = {
12
+ :debug_mode => false,
13
+ :god_mode => false,
14
+ :beast_mode => false,
15
+ :use_wordnik => false,
16
+ :sound => false
17
+ }
12
18
 
13
19
  optparse = OptionParser.new do |opts|
14
20
  opts.on('-v', '--version', 'Display version number and exit') do
@@ -19,19 +25,19 @@ def parse_options
19
25
  opts.on('-d', '--debug', 'Turn debug on') do
20
26
  options[:debug_mode] = true
21
27
  end
22
-
28
+
23
29
  opts.on('-g', '--god', 'Set godmode to true on load') do
24
30
  options[:god_mode] = true
25
31
  end
26
-
32
+
27
33
  opts.on('-b', '--beast', 'Set beastmode to true on load') do
28
34
  options[:beast_mode] = true
29
35
  end
30
-
36
+
31
37
  opts.on('-w', '--wordnik', 'Use Wordnik to generate more diverse, dynamic descriptors of entities') do
32
38
  options[:use_wordnik] = true
33
39
  end
34
-
40
+
35
41
  opts.on('-s', '--sound', 'Turn sound on') do
36
42
  options[:sound] = true
37
43
  end
@@ -45,9 +51,9 @@ end
45
51
  def print_error(error)
46
52
  case error
47
53
  when OptionParser::InvalidOption
48
- puts "#{$PROGRAM_NAME}: illegal option #{error.args.join(' ')}"
54
+ puts "#{$GAME_NAME}: illegal option #{error.args.join(' ')}"
49
55
  else
50
- puts "An unexpected error occurred while running #{$PROGRAM_NAME}:"
56
+ puts "An unexpected error occurred while running #{$GAME_NAME}:"
51
57
  puts " #{error}\n"
52
58
  end
53
59
  end
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency 'json', '~> 1.8.2'
26
26
  spec.add_runtime_dependency 'colorize', '~> 0.7.7'
27
27
  spec.add_runtime_dependency 'feep', '~> 0.1.3'
28
+ spec.add_runtime_dependency 'clocker', '~> 0.1.2'
28
29
  #spec.add_runtime_dependency 'hr', '~> 0.0.2'
29
30
 
30
31
  #spec.add_runtime_dependency 'wordnik', '~> 4.12'
@@ -12,7 +12,7 @@ module Gemwarrior
12
12
  self.world = options.fetch(:world)
13
13
  self.player = options.fetch(:player)
14
14
  end
15
-
15
+
16
16
  def start
17
17
  print_arena_intro
18
18
 
@@ -22,12 +22,12 @@ module Gemwarrior
22
22
  monster = generate_monster
23
23
  battle = Battle.new({:world => self.world, :player => self.player, :monster => monster})
24
24
  battle.start(is_arena = true)
25
-
25
+
26
26
  monsters_vanquished += 1
27
-
27
+
28
28
  puts 'Do you wish to continue fighting in the Arena? (Y/N)'
29
29
  answer = gets.chomp.downcase
30
-
30
+
31
31
  case answer
32
32
  when 'yes', 'y'
33
33
  next
@@ -43,15 +43,15 @@ module Gemwarrior
43
43
  end
44
44
  end
45
45
  end
46
-
46
+
47
47
  private
48
-
48
+
49
49
  def generate_monster
50
50
  random_monster = nil
51
-
51
+
52
52
  loop do
53
53
  random_monster = world.monsters[rand(0..world.monsters.length-1)]
54
-
54
+
55
55
  unless random_monster.is_boss
56
56
  break
57
57
  end
@@ -59,13 +59,13 @@ module Gemwarrior
59
59
 
60
60
  return random_monster.clone
61
61
  end
62
-
62
+
63
63
  def print_arena_intro
64
64
  puts '**************************'.colorize(:red)
65
65
  puts '* YOU ENTER THE ARENA!!! *'.colorize(:red)
66
66
  puts '**************************'.colorize(:red)
67
67
  end
68
-
68
+
69
69
  def print_arena_outro
70
70
  puts '**************************'.colorize(:red)
71
71
  puts '* YOU LEAVE THE ARENA!!! *'.colorize(:red)
@@ -6,24 +6,24 @@ require_relative 'misc/player_levels'
6
6
  module Gemwarrior
7
7
  class Battle
8
8
  include PlayerLevels
9
-
9
+
10
10
  # CONSTANTS
11
11
  ## ERRORS
12
12
  ERROR_ATTACK_OPTION_INVALID = 'That will not do anything against the monster.'
13
13
  BEAST_MODE_ATTACK = 100
14
-
14
+
15
15
  ## MESSAGES
16
16
  TEXT_ESCAPE = 'POOF'
17
-
17
+
18
18
  attr_accessor :world, :player, :monster, :player_defending
19
-
19
+
20
20
  def initialize(options)
21
21
  self.world = options.fetch(:world)
22
22
  self.player = options.fetch(:player)
23
23
  self.monster = options.fetch(:monster)
24
24
  self.player_defending = false
25
25
  end
26
-
26
+
27
27
  def start(is_arena = nil, is_event = nil)
28
28
  print_battle_line
29
29
 
@@ -35,7 +35,7 @@ module Gemwarrior
35
35
  else
36
36
  puts "You decide to attack #{monster.name}!"
37
37
  end
38
-
38
+
39
39
  puts "#{monster.name} cries out: \"#{monster.battlecry}\"".colorize(:yellow)
40
40
 
41
41
  # first strike!
@@ -45,7 +45,7 @@ module Gemwarrior
45
45
  monster_attacks_player
46
46
  end
47
47
  end
48
-
48
+
49
49
  # main battle loop
50
50
  loop do
51
51
  if monster_dead?
@@ -61,14 +61,14 @@ module Gemwarrior
61
61
  if monster_near_death?
62
62
  puts "#{monster.name} is almost dead!\n".colorize(:yellow)
63
63
  end
64
-
64
+
65
65
  puts
66
66
  print "PLAYER :: #{player.hp_cur.to_s.rjust(3)} HP"
67
67
  if world.debug_mode
68
68
  print " (LVL: #{player.level})"
69
69
  end
70
70
  print "\n"
71
-
71
+
72
72
  print "MONSTER :: "
73
73
  if world.debug_mode || PlayerLevels::get_level_stats(player.level)[:special_abilities].include?(:rocking_vision)
74
74
  print "#{monster.hp_cur.to_s.rjust(3)}"
@@ -81,9 +81,9 @@ module Gemwarrior
81
81
  end
82
82
  print "\n"
83
83
  puts
84
-
84
+
85
85
  self.player_defending = false
86
-
86
+
87
87
  puts 'What do you do?'
88
88
  print '['.colorize(:yellow)
89
89
  print 'F'.colorize(:green)
@@ -97,7 +97,7 @@ module Gemwarrior
97
97
  print 'R'.colorize(:green)
98
98
  print 'un]'.colorize(:yellow)
99
99
  print "\n"
100
-
100
+
101
101
  cmd = STDIN.gets.chomp.downcase
102
102
 
103
103
  # player action
@@ -141,14 +141,14 @@ module Gemwarrior
141
141
  puts ERROR_ATTACK_OPTION_INVALID
142
142
  next
143
143
  end
144
-
144
+
145
145
  # monster action
146
146
  monster_attacks_player
147
147
  end
148
148
  end
149
-
149
+
150
150
  private
151
-
151
+
152
152
  # NEUTRAL
153
153
  def calculate_damage_to(entity)
154
154
  miss = rand(0..(100 + entity.defense))
@@ -169,22 +169,22 @@ module Gemwarrior
169
169
  end
170
170
  end
171
171
  end
172
-
172
+
173
173
  def take_damage(entity, dmg)
174
174
  entity.hp_cur = entity.hp_cur.to_i - dmg.to_i
175
175
  who_gets_wounded = ''
176
-
176
+
177
177
  if entity.eql?(monster)
178
178
  who_gets_wounded = "> You wound #{monster.name} for "
179
179
  else
180
180
  who_gets_wounded = "> You are wounded for "
181
181
  end
182
-
182
+
183
183
  print who_gets_wounded
184
184
  Animation::run({ :phrase => dmg.to_s, :speed => :slow, :oneline => true, :alpha => false, :random => false })
185
185
  print " point(s)!\n"
186
186
  end
187
-
187
+
188
188
  # MONSTER
189
189
  def monster_strikes_first?(is_event = nil)
190
190
  if (monster.dexterity > player.dexterity) || is_event
@@ -199,7 +199,7 @@ module Gemwarrior
199
199
  end
200
200
  end
201
201
  end
202
-
202
+
203
203
  def monster_attacks_player
204
204
  puts "#{monster.name} attacks you!"
205
205
  dmg = calculate_damage_to(player)
@@ -216,14 +216,19 @@ module Gemwarrior
216
216
  def monster_near_death?
217
217
  ((monster.hp_cur.to_f / monster.hp_max.to_f) < 0.10)
218
218
  end
219
-
219
+
220
220
  def monster_dead?
221
221
  monster.hp_cur <= 0
222
222
  end
223
-
223
+
224
224
  def monster_death
225
225
  puts "You have defeated #{monster.name}!\n".colorize(:green)
226
+
227
+ # stats
228
+ world.player.monsters_killed += 1
229
+
226
230
  if monster.is_boss
231
+ # end game boss!
227
232
  if monster.name.eql?("Emerald")
228
233
  Music::cue([
229
234
  {:freq_or_note => 'G3', :duration => 50},
@@ -258,25 +263,25 @@ module Gemwarrior
258
263
  world.location_by_coords(player.cur_coords).remove_monster(monster.name)
259
264
  end
260
265
  end
261
-
266
+
262
267
  # PLAYER
263
268
  def update_player_stats
264
269
  old_player_level = PlayerLevels::check_level(player.xp)
265
-
270
+
266
271
  player.xp = player.xp + monster.xp
267
272
  player.rox = player.rox + monster.rox
268
-
273
+
269
274
  monster_items = monster.inventory.items
270
275
  unless monster_items.nil?
271
276
  player.inventory.items.concat monster_items unless monster_items.empty?
272
277
  end
273
-
278
+
274
279
  new_player_level = PlayerLevels::check_level(player.xp)
275
-
280
+
276
281
  if new_player_level > old_player_level
277
282
  Animation::run({:phrase => '** LEVEL UP! **'})
278
283
  new_stats = PlayerLevels::get_level_stats(new_player_level)
279
-
284
+
280
285
  player.level = new_stats[:level]
281
286
  puts "You are now level #{player.level}!"
282
287
  player.hp_cur = new_stats[:hp_max]
@@ -294,22 +299,22 @@ module Gemwarrior
294
299
  puts "You now have #{player.dexterity} dexterity points!"
295
300
  end
296
301
  end
297
-
302
+
298
303
  def player_near_death?
299
304
  ((player.hp_cur.to_f / player.hp_max.to_f) < 0.10 && !player.god_mode)
300
305
  end
301
-
306
+
302
307
  def player_dead?
303
308
  (player.hp_cur <= 0 && !player.god_mode)
304
309
  end
305
-
310
+
306
311
  def player_death
307
312
  puts "You are dead, slain by the #{monster.name}!".colorize(:red)
308
313
  puts 'Your adventure ends here. Try again next time!'.colorize(:red)
309
314
  print_battle_line
310
- exit(0)
315
+ return 'exit'
311
316
  end
312
-
317
+
313
318
  def player_escape?
314
319
  if (player.dexterity > monster.dexterity)
315
320
  return true
@@ -323,13 +328,13 @@ module Gemwarrior
323
328
  end
324
329
  end
325
330
  end
326
-
331
+
327
332
  # STATUS TEXT
328
-
333
+
329
334
  def print_escape_text
330
335
  Animation::run({ :phrase => "** POOF **", :oneline => true })
331
336
  end
332
-
337
+
333
338
  def print_battle_line
334
339
  puts '******************************'
335
340
  end
@@ -12,11 +12,11 @@ module Gemwarrior
12
12
  :equippable,
13
13
  :equipped,
14
14
  :use
15
-
15
+
16
16
  def use(inventory = nil)
17
17
  'That item does not do anything...yet.'
18
18
  end
19
-
19
+
20
20
  def describe
21
21
  status_text = name.upcase.colorize(:green)
22
22
  status_text << "\n#{description} \n".colorize(:white)
@@ -7,7 +7,7 @@ module Gemwarrior
7
7
  class ArenaMaster < Item
8
8
  # CONSTANTS
9
9
  ARENA_FEE = 50
10
-
10
+
11
11
  def initialize
12
12
  self.name = 'arena_master'
13
13
  self.description = 'She wears simple clothing, but carries herself with an air of authority. You think she may be the person to talk with if you want to engage in battle.'
@@ -18,11 +18,11 @@ module Gemwarrior
18
18
  self.equippable = false
19
19
  self.equipped = false
20
20
  end
21
-
21
+
22
22
  def use(player = nil)
23
23
  puts 'You approach the Arena Master and ask to fight. She snickers to herself, but sees you have a good spirit about you.'
24
24
  puts
25
-
25
+
26
26
  if player.rox >= 50
27
27
  puts "She asks for the requisite payment: #{ARENA_FEE} rox. Do you pay up? (Y/N)"
28
28
  answer = gets.chomp.downcase
@@ -31,7 +31,7 @@ module Gemwarrior
31
31
  puts 'She pockets the money and motions toward the center of the arena. She reminds you that you will be facing an ever-worsening onslaught of monsters. Each one you dispatch nets you a bonus cache of rox in addition to whatever the monster gives you. You will also become more experienced the longer you last. Finally, you can give up at any time between battles.'
32
32
  puts
33
33
  puts 'She finishes by wishing you good luck!'
34
-
34
+
35
35
  return {:type => 'arena', :data => nil}
36
36
  else
37
37
  puts 'She gives you a dirty look, as you have obviously wasted her time. You are told not to mess around with her anymore, and she turns away from you.'
@@ -15,7 +15,7 @@ module Gemwarrior
15
15
  self.equippable = false
16
16
  self.equipped = false
17
17
  end
18
-
18
+
19
19
  def use(player = nil)
20
20
  Animation::run({:phrase => '** ZZZZZ **'})
21
21
  puts 'You unmake the bed, get under the covers, close your eyes, and begin to think about all the things you need to do today. You realize sleep is not one of them and quickly get back up, remake the bed, and get on about your day.'
@@ -15,7 +15,7 @@ module Gemwarrior
15
15
  self.equippable = false
16
16
  self.equipped = false
17
17
  end
18
-
18
+
19
19
  def use(player = nil)
20
20
  puts 'Your body comes to rest somewhere below the surface of the cloudy apparatus, almost as if it were floating *amongst* the couch. The feeling is heavenly, and you actually feel somewhat better after getting back up.'
21
21
  puts '>> You regain a hit point.'
@@ -15,13 +15,13 @@ module Gemwarrior
15
15
  self.equippable = false
16
16
  self.equipped = false
17
17
  end
18
-
18
+
19
19
  def use(player = nil)
20
20
  puts 'You slowly lower your foot onto the tile, and then gently depress it, through the floor. Your whole body begins to feel light, lifeless. You black out.'
21
21
  puts
22
-
22
+
23
23
  Animation::run({ :phrase => '*** SHOOOOOM ***' })
24
-
24
+
25
25
  {:type => 'move', :data => 'Rock Quarry'}
26
26
  end
27
27
  end