gemwarrior 0.9.37 → 0.9.39

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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/bin/gemwarrior +18 -5
  3. data/data/locations.yml +1 -1
  4. data/lib/gemwarrior/entities/creature.rb +3 -13
  5. data/lib/gemwarrior/entities/entity.rb +4 -5
  6. data/lib/gemwarrior/entities/item.rb +15 -14
  7. data/lib/gemwarrior/entities/items/apple.rb +2 -1
  8. data/lib/gemwarrior/entities/items/arena_door.rb +2 -1
  9. data/lib/gemwarrior/entities/items/arena_master.rb +2 -1
  10. data/lib/gemwarrior/entities/items/bed.rb +2 -1
  11. data/lib/gemwarrior/entities/items/couch.rb +2 -1
  12. data/lib/gemwarrior/entities/items/cup.rb +3 -2
  13. data/lib/gemwarrior/entities/items/dagger.rb +2 -1
  14. data/lib/gemwarrior/entities/items/dehumidifier.rb +2 -1
  15. data/lib/gemwarrior/entities/items/feather.rb +2 -1
  16. data/lib/gemwarrior/entities/items/floor_tile.rb +2 -1
  17. data/lib/gemwarrior/entities/items/flower.rb +2 -1
  18. data/lib/gemwarrior/entities/items/gun.rb +2 -1
  19. data/lib/gemwarrior/entities/items/herb.rb +2 -1
  20. data/lib/gemwarrior/entities/items/keystone.rb +2 -1
  21. data/lib/gemwarrior/entities/items/ladder.rb +2 -1
  22. data/lib/gemwarrior/entities/items/letter.rb +2 -2
  23. data/lib/gemwarrior/entities/items/mace.rb +2 -1
  24. data/lib/gemwarrior/entities/items/map.rb +2 -1
  25. data/lib/gemwarrior/entities/items/massive_door.rb +2 -1
  26. data/lib/gemwarrior/entities/items/opalaser.rb +2 -1
  27. data/lib/gemwarrior/entities/items/pedestal.rb +2 -1
  28. data/lib/gemwarrior/entities/items/pond.rb +2 -1
  29. data/lib/gemwarrior/entities/items/rope.rb +2 -1
  30. data/lib/gemwarrior/entities/items/small_hole.rb +2 -1
  31. data/lib/gemwarrior/entities/items/snowman.rb +2 -1
  32. data/lib/gemwarrior/entities/items/sparklything.rb +2 -1
  33. data/lib/gemwarrior/entities/items/spear.rb +2 -1
  34. data/lib/gemwarrior/entities/items/stalactite.rb +2 -1
  35. data/lib/gemwarrior/entities/items/stone.rb +8 -2
  36. data/lib/gemwarrior/entities/items/stonemite.rb +2 -0
  37. data/lib/gemwarrior/entities/items/tent.rb +2 -1
  38. data/lib/gemwarrior/entities/items/throne.rb +2 -1
  39. data/lib/gemwarrior/entities/items/tree.rb +2 -1
  40. data/lib/gemwarrior/entities/items/ware_hawker.rb +2 -1
  41. data/lib/gemwarrior/entities/items/waterfall.rb +2 -1
  42. data/lib/gemwarrior/evaluator.rb +1 -1
  43. data/lib/gemwarrior/game.rb +1 -1
  44. data/lib/gemwarrior/inventory.rb +7 -1
  45. data/lib/gemwarrior/repl.rb +118 -15
  46. data/lib/gemwarrior/version.rb +1 -1
  47. data/lib/gemwarrior/world.rb +2 -1
  48. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 431bad9c347069816c31bd1e177b2150a40cc659
4
- data.tar.gz: edbc3792f12ad73aadef984f5579bcc4ba73371a
3
+ metadata.gz: 559b9c761db2f2d6c316bc3a0e5b886192c8b6d9
4
+ data.tar.gz: f3d2430ee5a96d78cdbb4a49305a0459888280d8
5
5
  SHA512:
6
- metadata.gz: 191c3cb62106e38b149ec02cce77cd531bcb28ecaaae7180f820e7125d58f4732c51d1bfc5a1b34c78b804a97823d8bb0314c020e0a4136b6657bcecdcfcef0b
7
- data.tar.gz: 45efcfcba9b601470e77382f6c30c88d4f9d1e3744547b54469518a466e475573b2464f975238c0bb813e2c0f457e3f44c59fafeef0753b708c265b56d0c0f8c
6
+ metadata.gz: fb0f959d0a25b6a6f46b3fc4827e6a7cd50fa231df25b15afdc38824951a6e3c1f495fb00fbb94d5da50e1fa65bc68dc0101358da35aedf4539791ab8a31a7a8
7
+ data.tar.gz: a0d8c7d3baadb9a4118e558c2e1c58f27c5f8f37fd7498c36624c5daf8b2924dda0632f3d908782e3d54ad06d67abb68b9043d43231ea92159fe9ee9af9d16fb
data/bin/gemwarrior CHANGED
@@ -8,7 +8,12 @@ require_relative '../lib/gemwarrior/version'
8
8
 
9
9
  include Gemwarrior
10
10
 
11
- GAME_NAME = 'Gem Warrior'
11
+ GAME_NAME = 'Gem Warrior'
12
+ GW_HOME_DIRECTORY = "#{Dir.home}/.gemwarrior"
13
+ GW_SAVE_FILE_YAML = "#{Dir.home}/.gemwarrior/gw_sav.yaml"
14
+ GW_SAVE_FILE_BIN = "#{Dir.home}/.gemwarrior/gw_sav.dat"
15
+ GW_OPTS_FILE = "#{Dir.home}/.gemwarrior/gw_opts"
16
+ GW_LOG_FILE = "#{Dir.home}/.gemwarrior/gw_log"
12
17
 
13
18
  def parse_options_cli
14
19
  options = {
@@ -95,11 +100,19 @@ def read_options_file
95
100
  nil
96
101
  end
97
102
 
103
+ def init_config
104
+ Dir.mkdir(GW_HOME_DIRECTORY) unless Dir.exist?(GW_HOME_DIRECTORY)
105
+
106
+ GameOptions.add 'save_file_mode', 'Y'
107
+ GameOptions.add 'save_file_yaml_path', GW_SAVE_FILE_YAML
108
+ GameOptions.add 'save_file_bin_path', GW_SAVE_FILE_BIN
109
+ GameOptions.add 'log_file_path', GW_LOG_FILE
110
+ GameOptions.add 'options_file_path', GW_OPTS_FILE
111
+ end
112
+
98
113
  begin
99
- GameOptions.add 'log_file_path', "#{Dir.home}/.gemwarrior_log"
100
- GameOptions.add 'save_file_path', "#{Dir.home}/.gemwarrior_save"
101
- GameOptions.add 'options_file_path', "#{Dir.home}/.gemwarrior_options"
102
-
114
+ init_config
115
+
103
116
  options = parse_options_cli
104
117
 
105
118
  Gemwarrior::Game.new(options)
data/data/locations.yml CHANGED
@@ -92,7 +92,7 @@
92
92
 
93
93
  -
94
94
  name: 'Metal Tunnel (South Entrance)'
95
- description: 'You are in a tightly-enclosed tunnel running under the ground. The walls are made of shiny, smooth material you think may be some kindof metal. It is claustrophobic, to say the least.'
95
+ description: 'You are in a tightly-enclosed tunnel running under the ground. The walls are made of shiny, smooth material you think may be some kind of metal. It is claustrophobic, to say the least.'
96
96
  danger_level: :moderate
97
97
  coords:
98
98
  x: 8
@@ -5,18 +5,8 @@ require_relative 'entity'
5
5
 
6
6
  module Gemwarrior
7
7
  class Creature < Entity
8
- attr_accessor :face,
9
- :hands,
10
- :mood,
11
- :level,
12
- :xp,
13
- :hp_cur,
14
- :hp_max,
15
- :atk_lo,
16
- :atk_hi,
17
- :defense,
18
- :dexterity,
19
- :inventory,
20
- :rox
8
+ attr_accessor :face, :hands, :mood,
9
+ :level, :xp, :hp_cur, :hp_max, :atk_lo, :atk_hi,
10
+ :defense, :dexterity, :inventory, :rox
21
11
  end
22
12
  end
@@ -5,16 +5,15 @@ module Gemwarrior
5
5
  class Entity
6
6
  # CONSTANTS
7
7
  WRAP_WIDTH = 80
8
-
9
- attr_accessor :name,
10
- :description
8
+
9
+ attr_accessor :name, :description
11
10
 
12
11
  def status
13
12
  status_text = name.ljust(26).upcase.colorize(:green)
14
13
  status_text << "#{description}\n".colorize(:white)
15
14
  end
16
-
17
- def puts(s='', width=WRAP_WIDTH)
15
+
16
+ def puts(s = '', width = WRAP_WIDTH)
18
17
  super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
19
18
  end
20
19
  end
@@ -5,16 +5,15 @@ require_relative 'entity'
5
5
 
6
6
  module Gemwarrior
7
7
  class Item < Entity
8
- attr_accessor :atk_lo,
9
- :atk_hi,
10
- :takeable,
11
- :useable,
12
- :equippable,
13
- :equipped,
14
- :consumable,
15
- :use,
16
- :used,
17
- :number_of_uses
8
+ attr_accessor :atk_lo, :atk_hi, :takeable, :useable, :equippable, :equipped,
9
+ :consumable, :use, :used, :number_of_uses
10
+
11
+ def initialize
12
+ self.equipped = false
13
+ self.consumable = false
14
+ self.used = false
15
+ self.number_of_uses = nil
16
+ end
18
17
 
19
18
  def use(inventory = nil)
20
19
  'That item does not do anything...yet.'
@@ -23,10 +22,12 @@ module Gemwarrior
23
22
  def describe
24
23
  status_text = name.upcase.colorize(:green)
25
24
  status_text << "\n#{description} \n".colorize(:white)
26
- status_text << "ATTACK: #{atk_lo.to_s.rjust(2)}-#{atk_hi.to_s.rjust(2)} ".colorize(:white) unless atk_lo.nil?
27
- status_text << "TAKEABLE? #{takeable} ".colorize(:white)
28
- status_text << "USEABLE? #{useable} ".colorize(:white)
29
- status_text << "EQUIPPABLE? #{equippable} ".colorize(:white)
25
+ status_text << "ATTACK: #{atk_lo}-#{atk_hi} \n".colorize(:white) unless atk_lo.nil?
26
+ status_text << "TAKEABLE? #{takeable}\n".colorize(:white)
27
+ status_text << "USEABLE? #{useable}\n".colorize(:white)
28
+ status_text << "EQUIPPABLE? #{equippable}\n".colorize(:white)
29
+ status_text << "CONSUMABLE? #{consumable}\n".colorize(:white)
30
+ status_text << "NUMBER OF USES? #{number_of_uses}\n".colorize(:white) unless number_of_uses.nil?
30
31
  status_text << "\n"
31
32
  end
32
33
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Apple < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'apple'
10
12
  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.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class ArenaDoor < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'arena_door'
10
12
  self.description = 'The Arena is massive, with its numerous columns and stone walls stretching to the sky, but its entrance door is no slouch, keeping apace. Made of reinforced granite and impossible to break down, it nevertheless opens for you while battles are in session.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -10,6 +10,8 @@ module Gemwarrior
10
10
  ARENA_MASTER_NAME = 'Iolita'
11
11
 
12
12
  def initialize
13
+ super
14
+
13
15
  self.name = 'arena_master'
14
16
  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.'
15
17
  self.atk_lo = nil
@@ -17,7 +19,6 @@ module Gemwarrior
17
19
  self.takeable = false
18
20
  self.useable = true
19
21
  self.equippable = false
20
- self.equipped = false
21
22
  end
22
23
 
23
24
  def use(player = nil)
@@ -9,6 +9,8 @@ module Gemwarrior
9
9
  USE_TEXT = '** ZZZZZ **'
10
10
 
11
11
  def initialize
12
+ super
13
+
12
14
  self.name = 'bed'
13
15
  self.description = 'The place where you sleep when you are not adventuring.'
14
16
  self.atk_lo = nil
@@ -16,7 +18,6 @@ module Gemwarrior
16
18
  self.takeable = false
17
19
  self.useable = true
18
20
  self.equippable = false
19
- self.equipped = false
20
21
  end
21
22
 
22
23
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Couch < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'couch'
10
12
  self.description = 'Ever wanted to sit on a cloud? Now is your chance.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -6,14 +6,15 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Cup < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'cup'
10
- self.description = 'A nice, stone mug, perfect for putting things into and then using to carry such things from place to place.'
12
+ self.description = 'A nice stone mug, perfect for putting things into and then using to carry such things from place to place.'
11
13
  self.atk_lo = nil
12
14
  self.atk_hi = nil
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Dagger < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'dagger'
10
12
  self.description = 'Flint that has been sharpened to a point, attached to a block of smooth granite by thin rope. Truly a work of art.'
11
13
  self.atk_lo = 1
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = true
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Dehumidifier < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'dehumidifier'
10
12
  self.description = 'Petals the color of clear sky and a stem of bright white. A most curious plant.'
11
13
  self.atk_lo = 2
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = true
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Feather < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'feather'
10
12
  self.description = 'A blue and green feather. It is soft and tender, unlike the craven bird that probably shed it.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -9,6 +9,8 @@ module Gemwarrior
9
9
  MOVE_TEXT = '*** SHOOOOOM ***'
10
10
 
11
11
  def initialize
12
+ super
13
+
12
14
  self.name = 'floor_tile'
13
15
  self.description = 'One of the floor tiles, rough-hewn but immaculate, looks...off. Pressable, even.'
14
16
  self.atk_lo = nil
@@ -16,7 +18,6 @@ module Gemwarrior
16
18
  self.takeable = false
17
19
  self.useable = true
18
20
  self.equippable = false
19
- self.equipped = false
20
21
  end
21
22
 
22
23
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Flower < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'flower'
10
12
  self.description = 'Petals the color of clear sky and a stem of bright white. A most curious plant.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Gun < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'gun'
10
12
  self.description = 'Pew pew goes this firearm, you suspect.'
11
13
  self.atk_lo = 2
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = true
15
17
  self.equippable = true
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Herb < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'herb'
10
12
  self.description = 'Green and leafy, this wild herb looks edible.'
11
13
  self.atk_lo = nil
@@ -14,7 +16,6 @@ module Gemwarrior
14
16
  self.useable = true
15
17
  self.consumable = true
16
18
  self.equippable = false
17
- self.equipped = false
18
19
  end
19
20
 
20
21
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Keystone < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'keystone'
10
12
  self.description = 'Certainly greater than the sum of its parts, this smallish stone glows faintly and feels slick to the touch.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -9,6 +9,8 @@ module Gemwarrior
9
9
  USE_TEXT = '*** THUMP ***'
10
10
 
11
11
  def initialize
12
+ super
13
+
12
14
  self.name = 'ladder'
13
15
  self.description = 'Rickety and crudely-fashioned, this ladder descends down into the dropoff, hopefully heading towards something...anything.'
14
16
  self.atk_lo = nil
@@ -16,7 +18,6 @@ module Gemwarrior
16
18
  self.takeable = false
17
19
  self.useable = true
18
20
  self.equippable = false
19
- self.equipped = false
20
21
  end
21
22
 
22
23
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Letter < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'letter'
10
12
  self.description = 'A single page of thin paper, folded at the middle, with some excellent penmanship impressed upon it.'
11
13
  self.atk_lo = nil
@@ -13,8 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
- self.used = false
18
18
  end
19
19
 
20
20
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Mace < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'mace'
10
12
  self.description = 'Sharp spikes atop a steel ball, affixed to a sturdy wooden handle. You could do damage with this.'
11
13
  self.atk_lo = 4
@@ -14,7 +16,6 @@ module Gemwarrior
14
16
  self.useable = true
15
17
  self.consumable = false
16
18
  self.equippable = true
17
- self.equipped = false
18
19
  end
19
20
 
20
21
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Map < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'map'
10
12
  self.description = 'The land of Jool is contained on this piece of canvas, in a useful, if not very detailed, manner.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class MassiveDoor < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'massive_door'
10
12
  self.description = 'Translucent, but not transparent, this door constructed of condensed water vapor is like nothing you have ever seen. It has no keyhole, but it does have a stone-shaped depression floating centrally within it.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Opalaser < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'opalaser'
10
12
  self.description = 'Gleaming with supernatural light, this object feels alien, yet familiar.'
11
13
  self.atk_lo = 9
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = true
15
17
  self.equippable = true
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -11,6 +11,8 @@ module Gemwarrior
11
11
  attr_accessor :switches
12
12
 
13
13
  def initialize
14
+ super
15
+
14
16
  self.name = 'pedestal'
15
17
  self.description = 'A pedestal about 4 feet in height rises up from the ground, with six switches arranged vertically above a large gem affixed to the top. The switches each have a word next to them in some language that looks familiar yet strange. Each letter is made of some kind of ink crudely splashed on stone, and each can be moved to arrange them in a different fashion than they are now. The large gem glitters with utter brilliance.'
16
18
  self.atk_lo = nil
@@ -18,7 +20,6 @@ module Gemwarrior
18
20
  self.takeable = false
19
21
  self.useable = true
20
22
  self.equippable = false
21
- self.equipped = false
22
23
  self.switches = init_switches
23
24
  end
24
25
 
@@ -9,6 +9,8 @@ module Gemwarrior
9
9
  NEEDED_ITEMS = ['dehumidifier', 'feather', 'gun', 'stalactite']
10
10
 
11
11
  def initialize
12
+ super
13
+
12
14
  self.name = 'pond'
13
15
  self.description = 'This tiny pool of water self-ripples every minute or so. Small, floating insects buzz around merrily. A small plaque lays at the foot, reading: "If the right objects curious doth possess, touch the water\'s surface and you\'ll get redress."'
14
16
  self.atk_lo = nil
@@ -16,7 +18,6 @@ module Gemwarrior
16
18
  self.takeable = false
17
19
  self.useable = true
18
20
  self.equippable = false
19
- self.equipped = false
20
21
  end
21
22
 
22
23
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Rope < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'rope'
10
12
  self.description = 'For some reason, a sturdy rope hangs down from a small opening in the metal tunnel\'s ceiling. It appears to hold your weight when taut.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -15,6 +15,8 @@ module Gemwarrior
15
15
  PLAYER_COMMAND_INVALID = '>> "Huh?"'
16
16
 
17
17
  def initialize
18
+ super
19
+
18
20
  self.name = 'small_hole'
19
21
  self.description = 'Amongst the rubble of the alcove, a small hole, barely big enough for a rodent, exists in an absently-minded way near the bottom of the wall.'
20
22
  self.atk_lo = nil
@@ -22,7 +24,6 @@ module Gemwarrior
22
24
  self.takeable = false
23
25
  self.useable = true
24
26
  self.equippable = false
25
- self.equipped = false
26
27
  end
27
28
 
28
29
  def use(player = nil)
@@ -9,6 +9,8 @@ module Gemwarrior
9
9
  USE_TEXT = '*** FOOOOSH ***'
10
10
 
11
11
  def initialize
12
+ super
13
+
12
14
  self.name = 'snowman'
13
15
  self.description = 'Standing solemnly in the snow, a man of snow solemnly stands.'
14
16
  self.atk_lo = nil
@@ -16,7 +18,6 @@ module Gemwarrior
16
18
  self.takeable = false
17
19
  self.useable = true
18
20
  self.equippable = false
19
- self.equipped = false
20
21
  end
21
22
 
22
23
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class SparklyThing < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'Sparkly Thing(tm)'
10
12
  self.description = 'The sparkling that this thing does is unimaginably brilliant.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Spear < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'spear'
10
12
  self.description = 'Sharp spikes atop a steel ball, affixed to a sturdy wooden handle. You could do damage with this.'
11
13
  self.atk_lo = 3
@@ -14,7 +16,6 @@ module Gemwarrior
14
16
  self.useable = true
15
17
  self.consumable = false
16
18
  self.equippable = true
17
- self.equipped = false
18
19
  end
19
20
 
20
21
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Stalactite < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'stalactite'
10
12
  self.description = 'Long protrusion of cave adornment, broken off and fallen to the ground, where the stalagmites sneer at it from.'
11
13
  self.atk_lo = 2
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = false
15
17
  self.equippable = true
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,14 +6,20 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Stone < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'stone'
10
12
  self.description = 'A small, sharp mega pebble, suitable for tossing in amusement, and perhaps combat.'
11
13
  self.atk_lo = 1
12
14
  self.atk_hi = 2
13
15
  self.takeable = true
14
- self.useable = false
16
+ self.useable = true
15
17
  self.equippable = true
16
- self.equipped = false
18
+ end
19
+
20
+ def use(player = nil)
21
+ puts 'You toss the stone a few feet into the air, and then it falls back into your palm. The experience was truly thrilling.'
22
+ { type: nil, data: nil }
17
23
  end
18
24
  end
19
25
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Stonemite < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'stonemite'
10
12
  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.'
11
13
  self.atk_lo = nil
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Tent < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'tent'
10
12
  self.description = 'A magical, two-room suite pops up when you flick this otherwise folded piece of canvas just right, perfect for a night\'s rest.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = true
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  self.number_of_uses = 5
18
19
  end
19
20
 
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Throne < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'throne'
10
12
  self.description = 'Made of what appears to be unfulfilled desires and latent, flawed happiness, the well-crafted seat still looks kinda comfy.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Tree < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'tree'
10
12
  self.description = 'A mighty representation of nature, older than your father\'s father\'s second great-uncle.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = false
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
  end
19
20
  end
@@ -15,6 +15,8 @@ module Gemwarrior
15
15
  PLAYER_COMMAND_INVALID = '>> "That means nothing to me."'
16
16
 
17
17
  def initialize
18
+ super
19
+
18
20
  self.name = 'ware_hawker'
19
21
  self.description = 'A literal anthropomorphic hawk has set up shop behind a crudely-made table. Some wares are scattered atop its surface, seemingly within anyone\'s grasp, but the hawk\'s piercing eyes seem to belie this observation.'
20
22
  self.atk_lo = nil
@@ -22,7 +24,6 @@ module Gemwarrior
22
24
  self.takeable = false
23
25
  self.useable = true
24
26
  self.equippable = false
25
- self.equipped = false
26
27
  end
27
28
 
28
29
  def use(player = nil)
@@ -6,6 +6,8 @@ require_relative '../item'
6
6
  module Gemwarrior
7
7
  class Waterfall < Item
8
8
  def initialize
9
+ super
10
+
9
11
  self.name = 'waterfall'
10
12
  self.description = 'Gallons of murky, sparkling water fall downward from an unknown spot in the sky, ending in a pool on the ground, yet never overflowing.'
11
13
  self.atk_lo = nil
@@ -13,7 +15,6 @@ module Gemwarrior
13
15
  self.takeable = false
14
16
  self.useable = true
15
17
  self.equippable = false
16
- self.equipped = false
17
18
  end
18
19
 
19
20
  def use(player = nil)
@@ -542,7 +542,7 @@ module Gemwarrior
542
542
 
543
543
  def try_to_move_player(direction)
544
544
  if world.can_move?(direction)
545
- world.player.go(world.locations, direction, GameOptions.data['sound_enabled'], GameOptions.data['sound_volume'])
545
+ world.player.go(world.locations, direction)
546
546
  world.location_by_coords(world.player.cur_coords).checked_for_monsters = false
547
547
  world.describe(world.location_by_coords(world.player.cur_coords))
548
548
  else
@@ -20,7 +20,7 @@ module Gemwarrior
20
20
  include PlayerLevels
21
21
 
22
22
  # CONSTANTS
23
- PLAYER_DESC_DEFAULT = 'Picked to do battle against a wizened madman for a shiny something or other for world-saving purposes.'
23
+ PLAYER_DESC_DEFAULT = "Picked to do battle against a wizened madman for a shiny something\nor other for world-saving purposes."
24
24
  PLAYER_INVENTORY_DEFAULT = Inventory.new
25
25
  PLAYER_INVENTORY_DEBUG = Inventory.new([Herb.new])
26
26
  PLAYER_ROX_DEFAULT = 0
@@ -1,6 +1,8 @@
1
1
  # lib/gemwarrior/inventory.rb
2
2
  # Collection of items a creature possesses
3
3
 
4
+ require_relative 'game_options'
5
+
4
6
  module Gemwarrior
5
7
  class Inventory
6
8
  # CONSTANTS
@@ -35,7 +37,11 @@ module Gemwarrior
35
37
  if contains_item?(item_name)
36
38
  items.each do |i|
37
39
  if i.name.eql?(item_name)
38
- return i.description
40
+ if GameOptions.data['debug_mode']
41
+ return i.describe
42
+ else
43
+ return i.description
44
+ end
39
45
  end
40
46
  end
41
47
  else
@@ -37,10 +37,10 @@ module Gemwarrior
37
37
  clocker = Clocker.new
38
38
 
39
39
  at_exit do
40
- pl = world.player
41
- duration = clocker.stop
40
+ world.duration = clocker.stop
42
41
  game.update_options_file
43
- log_stats(duration, pl)
42
+ log_stats(world.duration, world.player)
43
+ #save_game(world)
44
44
  end
45
45
 
46
46
  clocker.clock do
@@ -161,19 +161,19 @@ module Gemwarrior
161
161
  end
162
162
  end
163
163
 
164
- def display_record_of_attempts
164
+ def display_log_of_attempts
165
165
  if File.exist?(GameOptions.data['log_file_path']) and !File.zero?(GameOptions.data['log_file_path'])
166
166
  File.open(GameOptions.data['log_file_path']).readlines.each do |line|
167
167
  print "#{line}"
168
168
  end
169
169
  if GameOptions.data['debug_mode']
170
- print 'Clear record of attempts (y/n)? '
170
+ print 'Clear log of attempts (y/n)? '
171
171
  answer = gets.chomp.downcase
172
172
 
173
173
  case answer
174
174
  when 'y'
175
175
  File.truncate(GameOptions.data['log_file_path'], 0)
176
- puts 'Record of attempts: erased!'
176
+ puts 'Log of attempts: erased!'
177
177
  end
178
178
 
179
179
  puts
@@ -204,10 +204,11 @@ module Gemwarrior
204
204
  puts " GW v#{Gemwarrior::VERSION}"
205
205
  puts '======================='
206
206
  puts ' (N)ew Game'
207
+ #puts ' (R)esume Game' if save_file_exist?
207
208
  puts ' (A)bout'
208
209
  puts ' (H)elp'
209
210
  puts ' (O)ptions'
210
- puts ' (R)ecord of Attempts'
211
+ puts ' (L)og of Attempts'
211
212
  puts ' (C)heck for Updates'
212
213
  puts ' (E)xit'
213
214
  puts '======================='
@@ -226,11 +227,26 @@ module Gemwarrior
226
227
 
227
228
  case choice
228
229
  when 'n'
229
- clear_screen
230
- play_intro_tune
231
- print_splash_message
232
- print_fortune
233
- return
230
+ #if overwrite_save?
231
+ clear_screen
232
+ play_intro_tune
233
+ print_splash_message
234
+ print_fortune
235
+ return
236
+ #else
237
+ # run_main_menu
238
+ #end
239
+ =begin
240
+ when 'r'
241
+ if save_file_exist?
242
+ result = resume_game
243
+ if result.nil?
244
+ run_main_menu
245
+ elsif
246
+ self.world = result
247
+ end
248
+ end
249
+ =end
234
250
  when 'a'
235
251
  puts choice
236
252
  print_about_text
@@ -243,9 +259,9 @@ module Gemwarrior
243
259
  puts choice
244
260
  print_options
245
261
  run_main_menu
246
- when 'r'
262
+ when 'l'
247
263
  puts choice
248
- display_record_of_attempts
264
+ display_log_of_attempts
249
265
  run_main_menu
250
266
  when 'c'
251
267
  puts choice
@@ -262,10 +278,13 @@ module Gemwarrior
262
278
  end
263
279
 
264
280
  def log_stats(duration, pl)
281
+ # display stats upon exit
265
282
  puts '######################################################################'
266
283
  print 'Gem Warrior'.colorize(color: :white, background: :black)
267
284
  print " v#{Gemwarrior::VERSION}".colorize(:yellow)
268
- print " played for #{duration[:mins].to_s.colorize(color: :white, background: :black)} mins, #{duration[:secs].to_s.colorize(color: :white, background: :black)} secs, and #{duration[:ms].to_s.colorize(color: :white, background: :black)} ms\n"
285
+ print " played for #{duration[:mins].to_s.colorize(color: :white, background: :black)} min(s),"
286
+ print " #{duration[:secs].to_s.colorize(color: :white, background: :black)} sec(s),"
287
+ print " and #{duration[:ms].to_s.colorize(color: :white, background: :black)} ms\n"
269
288
  puts '----------------------------------------------------------------------'
270
289
  print "Player killed #{pl.monsters_killed.to_s.colorize(color: :white, background: :black)} monster(s)"
271
290
  print "\n".ljust(8)
@@ -285,6 +304,90 @@ module Gemwarrior
285
304
  end
286
305
  end
287
306
 
307
+ def save_game(world)
308
+ mode = GameOptions.data['save_file_mode']
309
+ puts 'Saving game...'
310
+
311
+ if mode.eql? 'Y'
312
+ File.open(GameOptions.data['save_file_yaml_path'], 'w+') do |f|
313
+ f.write YAML::dump(world)
314
+ end
315
+ elsif mode.eql? 'M'
316
+ File.open(GameOptions.data['save_file_bin_path'], 'w+') do |f|
317
+ f.write Marshal::dump(world)
318
+ end
319
+ else
320
+ puts 'Error: Save file mode not set. Game not saved.'
321
+ return
322
+ end
323
+ puts 'Game saved!'
324
+ end
325
+
326
+ def save_file_exist?
327
+ mode = GameOptions.data['save_file_mode']
328
+ if mode.eql? 'Y'
329
+ File.exist?(GameOptions.data['save_file_yaml_path'])
330
+ elsif mode.eql? 'M'
331
+ File.exist?(GameOptions.data['save_file_bin_path'])
332
+ else
333
+ false
334
+ end
335
+ end
336
+
337
+ def resume_game
338
+ mode = GameOptions.data['save_file_mode']
339
+ puts 'Resuming game...'
340
+
341
+ if save_file_exist?
342
+ if mode.eql? 'Y'
343
+ if File.exist?(GameOptions.data['save_file_yaml_path'])
344
+ File.open(GameOptions.data['save_file_yaml_path'], 'r') do |f|
345
+ return YAML::load(f)
346
+ end
347
+ else
348
+ puts 'No save file exists.'
349
+ nil
350
+ end
351
+ elsif mode.eql? 'M'
352
+ if File.exist?(GameOptions.data['save_file_marshal_path'])
353
+ File.open(GameOptions.data['save_file_marshal_path'], 'r') do |f|
354
+ return Marshal::load(f)
355
+ end
356
+ else
357
+ puts 'No save file exists.'
358
+ nil
359
+ end
360
+ end
361
+ end
362
+ end
363
+
364
+ def overwrite_save?
365
+ mode = GameOptions.data['save_file_mode']
366
+ save_file_path = ''
367
+
368
+ if mode.eql? 'Y'
369
+ save_file_path = GameOptions.data['save_file_yaml_path']
370
+ elsif mode.eql? 'M'
371
+ save_file_path = GameOptions.data['save_file_marshal_path']
372
+ end
373
+
374
+ if File.exist?(save_file_path)
375
+ print 'Overwrite existing save file? (y/n) '
376
+ answer = gets.chomp.downcase
377
+
378
+ case answer
379
+ when 'y'
380
+ puts 'New game started! Press any key to continue.'
381
+ gets
382
+ return true
383
+ else
384
+ puts 'New game aborted.'
385
+ return false
386
+ end
387
+ end
388
+ true
389
+ end
390
+
288
391
  def play_intro_tune
289
392
  Music::cue([
290
393
  { frequencies: 'A3,E4,C#5,E5', duration: 300 },
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.9.37'
5
+ VERSION = '0.9.39'
6
6
  end
@@ -16,12 +16,13 @@ module Gemwarrior
16
16
  WORLD_DIM_WIDTH = 10
17
17
  WORLD_DIM_HEIGHT = 10
18
18
 
19
- attr_accessor :monsters, :locations, :player
19
+ attr_accessor :monsters, :locations, :player, :duration
20
20
 
21
21
  def initialize
22
22
  self.monsters = init_monsters
23
23
  self.locations = init_locations
24
24
  self.player = nil
25
+ self.duration = nil
25
26
  end
26
27
 
27
28
  def print_vars
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.9.37
4
+ version: 0.9.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os