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
@@ -1,43 +1,44 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'gemwarrior/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'gemwarrior'
8
- spec.version = Gemwarrior::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ['Michael Chadwick']
11
- spec.email = 'mike@codana.me'
12
- spec.homepage = 'http://rubygems.org/gems/gemwarrior'
13
- spec.summary = 'RubyGem text adventure'
14
- spec.description = 'A fun text adventure in the form of a RubyGem!'
15
-
16
- spec.files = `git ls-files`.split("\n")
17
- spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
- spec.require_paths = ['lib']
20
- spec.license = 'MIT'
21
-
22
- spec.add_runtime_dependency 'os', '~> 0.9', '>= 0.9.6'
23
- spec.add_runtime_dependency 'http', '~> 0.8.10'
24
- spec.add_runtime_dependency 'json', '~> 1.8.2'
25
- spec.add_runtime_dependency 'colorize', '~> 0.7.7'
26
- spec.add_runtime_dependency 'matrext', '~> 0.4.10'
27
- spec.add_runtime_dependency 'clocker', '~> 0.1.6'
28
- spec.add_runtime_dependency 'gems', '~> 0.8.3'
29
-
30
- # sound systems
31
- #spec.add_runtime_dependency 'feep', '~> 0.1.3'
32
- #spec.add_runtime_dependency 'win32-sound', '~> 0.6.0'
33
- #spec.add_runtime_dependency 'bloopsaphone', '>= 0.4'
34
-
35
- spec.add_development_dependency 'bundler', '~> 1.8'
36
- spec.add_development_dependency 'rake', '~> 10.0'
37
- spec.add_development_dependency 'rubocop', '~> 0.52.1'
38
- spec.add_development_dependency 'rspec'
39
- spec.add_development_dependency 'rspec-nc'
40
- spec.add_development_dependency 'guard'
41
- spec.add_development_dependency 'guard-rspec'
42
- spec.add_development_dependency 'pry-byebug', '~> 3.0'
43
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gemwarrior/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gemwarrior'
8
+ spec.version = Gemwarrior::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ['Michael Chadwick']
11
+ spec.email = 'mike@codana.me'
12
+ spec.homepage = 'http://rubygems.org/gems/gemwarrior'
13
+ spec.summary = 'RubyGem text adventure'
14
+ spec.description = 'A fun text adventure in the form of a RubyGem!'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+ spec.license = 'MIT'
21
+
22
+ spec.add_runtime_dependency 'os', '~> 0.9', '>= 0.9.6'
23
+ spec.add_runtime_dependency 'http', '~> 0.8.10'
24
+ spec.add_runtime_dependency 'json', '~> 1.8.2'
25
+ spec.add_runtime_dependency 'colorize', '~> 0.8'
26
+ spec.add_runtime_dependency 'matrext', '~> 1'
27
+ spec.add_runtime_dependency 'clocker', '~> 0.1.6'
28
+ spec.add_runtime_dependency 'gems', '~> 0.8.3'
29
+
30
+ # sound systems
31
+ #spec.add_runtime_dependency 'feep', '~> 0.1.3'
32
+ #spec.add_runtime_dependency 'win32-sound', '~> 0.6.0'
33
+ #spec.add_runtime_dependency 'bloopsaphone', '>= 0.4'
34
+
35
+ spec.add_development_dependency 'bundler', '~> 2.1'
36
+ spec.add_development_dependency 'rake', '~> 12.3.3'
37
+ spec.add_development_dependency 'rubocop', '~> 0.52.1'
38
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
39
+ spec.add_development_dependency 'rspec-nc', '~> 0.3'
40
+ spec.add_development_dependency 'guard', '~> 2.16'
41
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
42
+ spec.add_development_dependency 'pry-byebug', '~> 3.9'
43
+ spec.add_development_dependency 'awesome_print', '~> 1.8'
44
+ end
@@ -47,6 +47,7 @@ module Gemwarrior
47
47
 
48
48
  def describe(world)
49
49
  desc_text = "#{description}".colorize(:white)
50
+ desc_text
50
51
  end
51
52
 
52
53
  def describe_detailed(world)
@@ -7,12 +7,12 @@ module Gemwarrior
7
7
  class Item < Entity
8
8
  attr_accessor :is_armor,
9
9
  :is_weapon
10
-
10
+
11
11
  attr_reader :use
12
12
 
13
13
  def initialize
14
14
  super
15
-
15
+
16
16
  self.is_armor = false
17
17
  self.is_weapon = false
18
18
  end
@@ -20,7 +20,7 @@ module Gemwarrior
20
20
  def use(world)
21
21
  'That item does not do anything...yet.'
22
22
  end
23
-
23
+
24
24
  def describe_detailed(world)
25
25
  desc_text = "\"#{name_display}\"\n".colorize(:yellow)
26
26
  desc_text << "(#{name})\n".colorize(:green)
@@ -13,5 +13,16 @@ module Gemwarrior
13
13
  self.description = 'Reddish-orangeish in color, this fruit looks sweet, but it is heavy and feels more like a rock you would sooner not bite into.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ if !self.used
19
+ puts 'You attempt to consume the apple, but stop midway through your first bite. Something tells you this is not a good idea, and you stop.'
20
+ puts
21
+ self.used = true
22
+ else
23
+ puts 'Remembering the odd feeling you got the last time you attempted to use the apple, you refrain.'
24
+ { type: nil, data: nil }
25
+ end
26
+ end
16
27
  end
17
28
  end
@@ -13,5 +13,10 @@ module Gemwarrior
13
13
  self.description = 'A nice stone mug, perfect for putting things into and then using to carry such things from place to place.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ puts 'Nothing in the cup at the moment, so not very usable.'
19
+ { type: nil, data: nil }
20
+ end
16
21
  end
17
22
  end
@@ -10,8 +10,13 @@ module Gemwarrior
10
10
 
11
11
  self.name = 'dehumidifier'
12
12
  self.name_display = 'Dehumidifier'
13
- self.description = 'Humidity stands approximately zero chance when its presence.'
13
+ self.description = 'Humidity stands approximately zero chance of surviving when in its presence.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ puts 'Despite your figeting, the lack of humidity remains the same.'
19
+ { type: nil, data: nil }
20
+ end
16
21
  end
17
22
  end
@@ -13,5 +13,10 @@ module Gemwarrior
13
13
  self.description = 'A blue and green feather. It is soft and tender, unlike the craven bird that probably shed it.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ puts 'Soft to the touch, you wonder what it could be used before besides temporary comfort.'
19
+ { type: nil, data: nil }
20
+ end
16
21
  end
17
22
  end
@@ -13,5 +13,10 @@ module Gemwarrior
13
13
  self.description = 'Petals the color of clear sky and a stem of bright white. A most curious plant.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ puts 'You inhale the flower, metaphorically. Smells nice.'
19
+ { type: nil, data: nil }
20
+ end
16
21
  end
17
22
  end
@@ -13,5 +13,10 @@ module Gemwarrior
13
13
  self.description = 'Certainly greater than the sum of its parts, this smallish stone glows faintly and feels slick to the touch.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ puts 'The keystone glows a bit brighter when you grasp it tightly.'
19
+ { type: nil, data: nil }
20
+ end
16
21
  end
17
22
  end
@@ -7,7 +7,7 @@ module Gemwarrior
7
7
  class Pedestal < Item
8
8
  # CONSTANTS
9
9
  USE_TEXT = '** WHOOOOOSH **'
10
-
10
+
11
11
  attr_accessor :switches
12
12
 
13
13
  def initialize
@@ -28,17 +28,17 @@ module Gemwarrior
28
28
  ['amberoo', jumble('amberoo'), nil],
29
29
  ['alexandrat', jumble('alexandrat'), nil]
30
30
  ]
31
-
31
+
32
32
  self.switches = self.switches.sort_by { rand }
33
33
  end
34
34
 
35
35
  def use(world)
36
36
  puts 'You look at the pedestal and its switches. The raised gem beckons you to push it and, deductively, you believe that pressing it will do something. However, those switches probably have something to do with the result.'
37
-
37
+
38
38
  loop do
39
39
  print_switches(self.switches)
40
-
41
- puts
40
+
41
+ puts
42
42
  puts 'You can rearrange the letters in the words themselves, and you can push the large gem. What do you do?'
43
43
  puts
44
44
  puts '>> 1 Rearrange the letters in switch 1\'s word'
@@ -50,7 +50,7 @@ module Gemwarrior
50
50
  puts '>> 7 Push the large gem into the pedestal'
51
51
  puts '>> 8 Stop this nonsense'
52
52
  puts
53
-
53
+
54
54
  print '> '
55
55
  choice = gets.chomp!
56
56
 
@@ -87,18 +87,18 @@ module Gemwarrior
87
87
  switches[5][2] = get_new_word(switch6)
88
88
  when '7'
89
89
  pedestal_configured = true
90
-
90
+
91
91
  for i in 0..switches.length-1 do
92
92
  pedestal_configured = false unless switches[i][0].downcase.eql? switches[i][2].downcase
93
- end
94
-
93
+ end
94
+
95
95
  if pedestal_configured
96
96
  Audio.play_synth(:uncover_secret)
97
97
  puts 'You push the large gem into the pedestal and it descends without a hitch, almost as if it were meant to be. The pedestal begins to violently shake and a strong gust of wind picks you up off the ground. You feel completely taken aback and unsettled, but you have no choice: you are being whisked away somewhere into the sky, destination unknown.'.colorize(:yellow)
98
-
98
+
99
99
  # stats
100
100
  world.player.movements_made += 1
101
-
101
+
102
102
  Animation.run(phrase: USE_TEXT)
103
103
  return { type: 'move', data: 'Sky Tower (Entryway)' }
104
104
  else
@@ -112,35 +112,35 @@ module Gemwarrior
112
112
  end
113
113
  end
114
114
  end
115
-
115
+
116
116
  private
117
-
117
+
118
118
  def print_switches(switches)
119
119
  puts
120
-
120
+
121
121
  switch1 = switches[0][2].nil? ? switches[0][1] : switches[0][2]
122
122
  puts "Switch 1: #{switch1}"
123
123
 
124
124
  switch2 = switches[1][2].nil? ? switches[1][1] : switches[1][2]
125
125
  puts "Switch 2: #{switch2}"
126
-
126
+
127
127
  switch3 = switches[2][2].nil? ? switches[2][1] : switches[2][2]
128
128
  puts "Switch 3: #{switch3}"
129
-
129
+
130
130
  switch4 = switches[3][2].nil? ? switches[3][1] : switches[3][2]
131
131
  puts "Switch 4: #{switch4}"
132
-
132
+
133
133
  switch5 = switches[4][2].nil? ? switches[4][1] : switches[4][2]
134
134
  puts "Switch 5: #{switch5}"
135
-
135
+
136
136
  switch6 = switches[5][2].nil? ? switches[5][1] : switches[5][2]
137
137
  puts "Switch 6: #{switch6}"
138
138
  end
139
-
139
+
140
140
  def jumble(word)
141
141
  word.split(//).sort_by { rand }.join('')
142
142
  end
143
-
143
+
144
144
  def get_new_word(switch)
145
145
  new_word = gets.chomp!
146
146
  if switch.downcase.split(//).sort == new_word.downcase.split(//).sort
@@ -13,5 +13,10 @@ module Gemwarrior
13
13
  self.description = 'Stubby cave debris that is neat to look at, as it is off-grey and sparkly, but the size makes it unusable as anything but skipping on a lake.'
14
14
  self.takeable = true
15
15
  end
16
+
17
+ def use(world)
18
+ puts 'You turn the stonemite over and over in your hand. It continues to be a small rock of little import.'
19
+ { type: nil, data: nil }
20
+ end
16
21
  end
17
22
  end
@@ -1,49 +1,49 @@
1
- # lib/gemwarrior/entities/people/arena_master.rb
2
- # Entity::Creature::Person::ArenaMaster
3
-
4
- require_relative '../person'
5
-
6
- module Gemwarrior
7
- class ArenaMaster < Person
8
- # CONSTANTS
9
- ARENA_FEE = 50
10
- ARENA_MASTER_NAME = 'Iolita'
11
-
12
- def initialize
13
- super
14
-
15
- self.name = 'arena_master'
16
- self.name_display = 'Arena Master'
17
- 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
- end
19
-
20
- def use(world)
21
- puts "You approach #{ARENA_MASTER_NAME.colorize(color: :white, background: :black)}, the Arena Master, and ask to prove your mettle in the arena. She snickers to herself, but sees you have a good spirit about you."
22
- puts
23
-
24
- if world.player.rox >= ARENA_FEE
25
- print "She asks for the requisite payment: #{ARENA_FEE} rox. Do you pay up? (y/n) "
26
- answer = gets.chomp.downcase
27
-
28
- case answer
29
- when 'y', 'yes'
30
- world.player.rox -= ARENA_FEE
31
- puts
32
- 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.'
33
- puts
34
- puts 'She finishes by wishing you good luck!'
35
-
36
- return { type: 'arena', data: nil }
37
- else
38
- puts
39
- 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.'
40
- return { type: nil, data: nil }
41
- end
42
- else
43
- puts 'She can tell you seem particularly poor today and says to come back when that has changed.'
44
- puts
45
- return { type: nil, data: nil }
46
- end
47
- end
48
- end
49
- end
1
+ # lib/gemwarrior/entities/people/arena_master.rb
2
+ # Entity::Creature::Person::ArenaMaster
3
+
4
+ require_relative '../person'
5
+
6
+ module Gemwarrior
7
+ class ArenaMaster < Person
8
+ # CONSTANTS
9
+ ARENA_FEE = 50
10
+ ARENA_MASTER_NAME = 'Iolita'
11
+
12
+ def initialize
13
+ super
14
+
15
+ self.name = 'arena_master'
16
+ self.name_display = 'Arena Master'
17
+ 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
+ end
19
+
20
+ def use(world)
21
+ puts "You approach #{ARENA_MASTER_NAME.colorize(color: :white, background: :black)}, the Arena Master, and ask to prove your mettle in the arena. She snickers to herself, but sees you have a good spirit about you."
22
+ puts
23
+
24
+ if world.player.rox >= ARENA_FEE
25
+ print "She asks for the requisite payment: #{ARENA_FEE} rox. Do you pay up? (y/n) "
26
+ answer = gets.chomp.downcase
27
+
28
+ case answer
29
+ when 'y', 'yes'
30
+ world.player.rox -= ARENA_FEE
31
+ puts
32
+ 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.'
33
+ puts
34
+ puts 'She finishes by wishing you good luck!'
35
+
36
+ return { type: 'arena', data: nil }
37
+ else
38
+ puts
39
+ 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.'
40
+ return { type: nil, data: nil }
41
+ end
42
+ else
43
+ puts 'She can tell you seem particularly poor today and says to come back when that has changed.'
44
+ puts
45
+ return { type: nil, data: nil }
46
+ end
47
+ end
48
+ end
49
+ end
@@ -8,8 +8,8 @@ require_relative '../weapons/dagger'
8
8
  module Gemwarrior
9
9
  class Rockney < Person
10
10
  # CONSTANTS
11
- PRICE_HERB = 10
12
- PRICE_DAGGER = 150
11
+ PRICE_HERB = 5
12
+ PRICE_DAGGER = 10
13
13
  PLAYER_ROX_INSUFFICIENT = 'Pity. You are a bit short on funds to purchase that item.'
14
14
  PLAYER_ITEMS_ADDITIONAL = 'Anything else?'
15
15
  PLAYER_COMMAND_INVALID = 'Huh?'
@@ -9,9 +9,9 @@ require_relative '../armor/iron_helmet'
9
9
  module Gemwarrior
10
10
  class WareHawker < Person
11
11
  # CONSTANTS
12
- PRICE_IRON_HELMET = 100
13
- PRICE_MACE = 200
14
- PRICE_SPEAR = 250
12
+ PRICE_IRON_HELMET = 10
13
+ PRICE_MACE = 30
14
+ PRICE_SPEAR = 40
15
15
  PLAYER_ROX_INSUFFICIENT = 'You have insufficient rox to purchase that. Quit testing me, human.'
16
16
  PLAYER_ITEMS_ADDITIONAL = 'Will there be something else?'
17
17
  PLAYER_COMMAND_INVALID = 'That means nothing to me.'
@@ -7,12 +7,13 @@ module Gemwarrior
7
7
  class Person < Creature
8
8
  def initialize
9
9
  super
10
-
10
+
11
11
  self.name = 'person.'
12
12
  self.name_display = Formatting::upstyle(name)
13
13
  self.description = 'It appears to be a person of some kind.'
14
+ self.takeable = false
14
15
  end
15
-
16
+
16
17
  def use(world)
17
18
  'That person does not seem to want to talk to you right now.'
18
19
  end