gemwarrior 0.6.3 → 0.6.4

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: 5dd2a134a899cfbfd6ac8cf1a0a21e39f22abe86
4
- data.tar.gz: f8db94e677447ffa3568ebfe94181f4be0a504de
3
+ metadata.gz: 8cd1829a08b6e83220b459bbf729652871e0e81d
4
+ data.tar.gz: 43625f3347022e2f25edafa561de8adc0201eaa2
5
5
  SHA512:
6
- metadata.gz: baf985a9731cff030b8cbf27693680eb063dee3a748d3bb541f4bd93eca8db3b7772b496d73d3ce3675ec6244269ba961a197fd398f22be153d29dac10f86d08
7
- data.tar.gz: b4cadec0839733de6a0d064e0063b8aca37cf47980b0db968494f014d43be0b124aeff8df3cc454f1da07b1bca924e550f53fcbeb16e5749729118c53356f666
6
+ metadata.gz: 6cafe13f7ec0d4d08e50859ba1a2774afa6b715fb264745957d11ff14f2c97f853ab6c872d64d712acb3756aa6aa2c48324c43ddc426ff1a331efdc53ddefd8a
7
+ data.tar.gz: 61332501f1680a1289723a2c7379d84ced6eb8195723640b41de1be6fdefa95c7469b0541da12cc311b0bbd30c62212e28724831feb44c4bda63c0a73838bb7d
@@ -8,13 +8,17 @@ require_relative '../lib/gemwarrior/game'
8
8
  GAME_NAME = "Gem Warrior"
9
9
 
10
10
  def parse_options
11
- options = {:god_mode => false, :beast_mode => false}
11
+ options = {:debug_mode => false, :god_mode => false, :beast_mode => false}
12
12
 
13
13
  optparse = OptionParser.new do |opts|
14
14
  opts.on('-v', '--version', 'Display version number and exit') do
15
15
  puts "#{GAME_NAME} v#{Gemwarrior::VERSION}"
16
16
  exit
17
17
  end
18
+
19
+ opts.on('-d', '--debug', 'Turn debug on') do
20
+ options[:debug_mode] = true
21
+ end
18
22
 
19
23
  opts.on('-g', '--god', 'Set godmode to true on load') do
20
24
  options[:god_mode] = true
@@ -14,12 +14,12 @@ module Gemwarrior
14
14
  status_text << "ATK: #{atk_lo.to_s.rjust(2)}-#{atk_hi.to_s.rjust(2)} "
15
15
  status_text << "DEF: #{defense.to_s.rjust(2)} "
16
16
  status_text << "DEX: #{dexterity.to_s.rjust(2)} "
17
- status_text << "INV: #{inventory.list_contents} "
18
17
  status_text << "ROX: #{rox.to_s.rjust(3)} "
19
18
  status_text << "XP: #{xp.to_s.rjust(3)} "
20
- status_text << "FACE: #{face.ljust(10)} "
21
- status_text << "HANDS: #{hands.ljust(11)} "
22
- status_text << "MOOD: #{mood.ljust(10)}\n"
19
+ status_text << "FACE: #{face.ljust(12)} "
20
+ status_text << "HANDS: #{hands.ljust(12)} "
21
+ status_text << "MOOD: #{mood.ljust(12)}"
22
+ status_text << "INV: #{inventory.list_contents}\n"
23
23
  end
24
24
  end
25
25
  end
@@ -10,7 +10,7 @@ module Gemwarrior
10
10
  self.description = 'Tiny, but fierce, color-changing rodent.'
11
11
  self.face = 'ugly'
12
12
  self.hands = 'gnarled'
13
- self.mood = 'unsurprisingly unchipper'
13
+ self.mood = 'unchipper'
14
14
 
15
15
  self.level = rand(1..2)
16
16
  self.hp_cur = rand((level * 2)..(level * 3))
@@ -51,7 +51,7 @@ module Gemwarrior
51
51
  self.beast_mode = options.fetch(:beast_mode)
52
52
  end
53
53
 
54
- def check_self(show_pic = true)
54
+ def check_self(debug_mode = false, show_pic = true)
55
55
  unless show_pic == false
56
56
  print_char_pic
57
57
  end
@@ -74,10 +74,12 @@ module Gemwarrior
74
74
  self_text << "ATTACK : #{self.atk_lo}-#{self.atk_hi}\n"
75
75
  self_text << "DEXTERITY : #{self.dexterity}\n"
76
76
  self_text << "DEFENSE : #{self.defense}\n"
77
- self_text << "GOD_MODE : #{self.god_mode}\n"
78
- self_text << "BEAST_MODE: #{self.beast_mode}\n\n"
77
+ if debug_mode
78
+ self_text << "GOD_MODE : #{self.god_mode}\n"
79
+ self_text << "BEAST_MODE: #{self.beast_mode}\n"
80
+ end
79
81
 
80
- self_text << "#{self.description}\n\n"
82
+ self_text << "\n#{self.description}\n\n"
81
83
 
82
84
  self_text << "Current status - breathing, wearing clothing, and with a few other specific characteristics: face is #{self.face}, hands are #{self.hands}, and general mood is #{self.mood}.\n"
83
85
  end
@@ -14,8 +14,7 @@ module Gemwarrior
14
14
 
15
15
  GO_PARAMS = 'Options: north, east, south, west'
16
16
  CHANGE_PARAMS = 'Options: name'
17
- LIST_PARAMS = 'Options: monsters, items, locations'
18
- DEBUG_PARAMS = 'Options: vars, map, stat'
17
+ DEBUG_LIST_PARAMS = 'Options: monsters, items, locations'
19
18
  DEBUG_STAT_PARAMS = 'Options: atk_lo, atk_hi, strength, dexterity'
20
19
 
21
20
  ## ERRORS
@@ -33,24 +32,33 @@ module Gemwarrior
33
32
  ERROR_CHANGE_PARAM_INVALID = 'You cannot change that...yet.'
34
33
  ERROR_LIST_PARAM_MISSING = 'You cannot just "list". You gotta choose something to list.'
35
34
  ERROR_LIST_PARAM_INVALID = 'You cannot list that...yet.'
36
- ERROR_DEBUG_PARAM_MISSING = 'You cannot just "debug". You gotta choose a debug command.'
37
- ERROR_DEBUG_PARAM_INVALID = 'You cannot debug that...yet.'
38
35
  ERROR_DEBUG_STAT_PARAM_MISSING = 'You cannot just "change stats". You gotta choose a stat to change.'
39
36
  ERROR_DEBUG_STAT_PARAM_INVALID = 'You cannot change that stat...yet.'
40
37
 
41
- attr_accessor :world, :commands, :aliases, :descriptions, :devcmds, :devaliases, :extras
38
+ attr_accessor :world,
39
+ :commands, :aliases, :extras, :cmd_descriptions,
40
+ :devcommands, :devaliases, :devcmd_descriptions
42
41
 
43
42
  def initialize(world)
44
43
  self.world = world
45
- self.devcmds = %w(debug)
46
- self.devaliases = %w(db)
47
- self.commands = %w(character inventory list rest look take drop equip unequip go attack change help quit quit!)
48
- self.aliases = %w(c i ls r l t d e ue g a ch h q qq)
44
+
45
+ self.devcommands = %w(god beast list vars map stat)
46
+ self.devaliases = %w(gd bs ls v m s)
47
+ self.devcmd_descriptions = [
48
+ 'Toggle god mode (i.e. invincible)',
49
+ 'Toggle beast mode (i.e. super strength)',
50
+ 'List all instances of a specific entity type',
51
+ 'List all the variables in the world',
52
+ 'Show a map of the world',
53
+ 'Change player stat'
54
+ ]
55
+
56
+ self.commands = %w(character inventory rest look take drop equip unequip go attack change help quit quit!)
57
+ self.aliases = %w(c i r l t d e ue g a ch h q qq)
49
58
  self.extras = %w(exit exit! x x)
50
- self.descriptions = [
59
+ self.cmd_descriptions = [
51
60
  'Display character information',
52
61
  'Look in your inventory',
53
- 'List all the objects of a type that exist in the world',
54
62
  'Take a load off and regain HP',
55
63
  'Look around your current location',
56
64
  'Take item',
@@ -82,91 +90,85 @@ module Gemwarrior
82
90
  command = tokens.first.downcase
83
91
  param1 = tokens[1]
84
92
  param2 = tokens[2]
85
- param3 = tokens[3]
86
93
 
87
- case command
88
94
  # dev commands
89
- when 'debug', 'db'
90
- if param1.nil?
91
- puts ERROR_DEBUG_PARAM_MISSING
92
- DEBUG_PARAMS
93
- else
94
- case param1
95
- when 'vars', 'v'
96
- world.print_all_vars
97
- when 'godmode', 'iddqd', 'god', 'g'
98
- world.player.god_mode = !world.player.god_mode
99
- when 'beastmode', 'beast', 'b'
100
- world.player.beast_mode = !world.player.beast_mode
101
- when 'map', 'm'
102
- world.print_map
103
- when 'stat'
104
- if param2.nil?
105
- puts ERROR_DEBUG_STAT_PARAM_MISSING
106
- DEBUG_STAT_PARAMS
107
- else
108
- case param2
109
- when 'atk_lo'
110
- unless param3.nil?
111
- param3 = param3.to_i
112
- if param3.is_a? Numeric
113
- if param3 >= 0
114
- world.player.atk_lo = param3
115
- end
95
+ if world.debug_mode
96
+ case command
97
+ when 'god', 'gd'
98
+ return world.player.god_mode = !world.player.god_mode
99
+ when 'beast', 'bs'
100
+ return world.player.beast_mode = !world.player.beast_mode
101
+ when 'vars', 'v'
102
+ world.print_all_vars
103
+ when 'list', 'ls'
104
+ if param1.nil?
105
+ puts ERROR_LIST_PARAM_MISSING
106
+ return DEBUG_LIST_PARAMS
107
+ else
108
+ return world.list(param1)
109
+ end
110
+ when 'map', 'm'
111
+ world.print_map
112
+ when 'stat', 'st'
113
+ if param1.nil?
114
+ puts ERROR_DEBUG_STAT_PARAM_MISSING
115
+ return DEBUG_STAT_PARAMS
116
+ else
117
+ case param1
118
+ when 'atk_lo'
119
+ unless param2.nil?
120
+ param2.to_i!
121
+ if param2.is_a? Numeric
122
+ if param2 >= 0
123
+ world.player.atk_lo = param2
116
124
  end
117
125
  end
118
- when 'atk_hi'
119
- unless param3.nil?
120
- param3 = param3.to_i
121
- if param3.is_a? Numeric
122
- if param3 >= 0
123
- world.player.atk_hi = param3
124
- end
126
+ end
127
+ when 'atk_hi'
128
+ unless param2.nil?
129
+ param2.to_i!
130
+ if param2.is_a? Numeric
131
+ if param2 >= 0
132
+ world.player.atk_hi = param2
125
133
  end
126
134
  end
127
- when 'strength', 'str', 'st'
128
- unless param3.nil?
129
- param3 = param3.to_i
130
- if param3.is_a? Numeric
131
- if param3 >= 0
132
- world.player.atk_lo = param3
133
- world.player.atk_hi = param3
134
- end
135
+ end
136
+ when 'strength', 'str', 'st'
137
+ unless param2.nil?
138
+ param2.to_i!
139
+ if param2.is_a? Numeric
140
+ if param2 >= 0
141
+ world.player.atk_lo = param2
142
+ world.player.atk_hi = param2
135
143
  end
136
144
  end
137
- when 'dexterity', 'dex', 'd'
138
- unless param3.nil?
139
- param3 = param3.to_i
140
- if param3.is_a? Numeric
141
- if param3 >= 0
142
- world.player.dexterity = param3
143
- end
145
+ end
146
+ when 'dexterity', 'dex', 'd'
147
+ unless param2.nil?
148
+ param2.to_i!
149
+ if param2.is_a? Numeric
150
+ if param2 >= 0
151
+ world.player.dexterity = param2
144
152
  end
145
153
  end
146
- else
147
- ERROR_DEBUG_STAT_PARAM_INVALID
148
154
  end
155
+ else
156
+ return ERROR_DEBUG_STAT_PARAM_INVALID
149
157
  end
150
- else
151
- ERROR_DEBUG_PARAM_INVALID
152
158
  end
153
159
  end
160
+ end
161
+
154
162
  # normal commands
163
+ case command
155
164
  when 'character', 'c'
156
- world.player.check_self
165
+ world.player.check_self(world.debug_mode)
157
166
  when 'inventory', 'i'
158
167
  if param1
159
168
  world.player.inventory.describe_item(param1)
160
169
  else
161
170
  world.player.list_inventory
162
171
  end
163
- when 'list', 'ls'
164
- if param1.nil?
165
- puts ERROR_LIST_PARAM_MISSING
166
- LIST_PARAMS
167
- else
168
- world.list(param1)
169
- end
170
172
  when 'rest', 'r'
171
173
  world.player.rest
172
174
  when 'look', 'l'
@@ -266,16 +268,30 @@ module Gemwarrior
266
268
  i = 0
267
269
  print_separator
268
270
  commands.each do |cmd|
269
- puts " #{cmd.ljust(9)}, #{aliases[i].ljust(2)} -- #{descriptions[i]}"
271
+ puts " #{cmd.ljust(9)}, #{aliases[i].ljust(2)} -- #{cmd_descriptions[i]}"
270
272
  i = i + 1
271
273
  end
272
274
  print_separator
275
+ puts " DEBUG COMMANDS"
276
+ print_separator
277
+ if world.debug_mode
278
+ i = 0
279
+ devcommands.each do |cmd|
280
+ puts " #{cmd.ljust(9)}, #{devaliases[i].ljust(2)} -- #{devcmd_descriptions[i]}"
281
+ i = i + 1
282
+ end
283
+ print_separator
284
+ end
273
285
  end
274
286
 
275
287
  def input_valid?(input)
276
288
  tokens = input.split
277
289
  command = tokens[0]
278
- commands_and_aliases = commands | aliases | devcmds | devaliases | extras
290
+ commands_and_aliases = commands | aliases | extras
291
+
292
+ if world.debug_mode
293
+ commands_and_aliases = commands_and_aliases | devcommands | devaliases
294
+ end
279
295
 
280
296
  if commands_and_aliases.include?(command.downcase)
281
297
  if tokens.size.between?(1,4)
@@ -25,10 +25,11 @@ module Gemwarrior
25
25
 
26
26
  def initialize(options)
27
27
  # create new world and player
28
- self.world = World.new
29
-
28
+ self.world = World.new
29
+
30
30
  start_stats = PlayerLevels::get_level_stats(1)
31
31
 
32
+ world.debug_mode = options.fetch(:debug_mode)
32
33
  world.player = Player.new({
33
34
  :description => PLAYER_DESC_DEFAULT,
34
35
  :level => start_stats[:level],
@@ -44,6 +45,7 @@ module Gemwarrior
44
45
  :inventory => PLAYER_INVENTORY_DEFAULT,
45
46
  :rox => PLAYER_ROX_DEFAULT,
46
47
  :cur_coords => world.location_coords_by_name('Home'),
48
+
47
49
  :god_mode => options.fetch(:god_mode),
48
50
  :beast_mode => options.fetch(:beast_mode)
49
51
  })
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = "0.6.3"
5
+ VERSION = "0.6.4"
6
6
  end
@@ -15,12 +15,12 @@ module Gemwarrior
15
15
  ERROR_LIST_PARAM_INVALID = 'That is not something that can be listed.'
16
16
  ERROR_LOCATION_DESCRIBE_ENTITY_INVALID = 'You do not see that here.'
17
17
 
18
- attr_accessor :monsters, :locations, :player
18
+ attr_accessor :monsters, :locations, :player, :debug_mode
19
19
 
20
20
  def initialize
21
- self.monsters = init_monsters
22
- self.locations = init_locations
23
- self.player = nil
21
+ self.monsters = init_monsters
22
+ self.locations = init_locations
23
+ self.player = nil
24
24
  end
25
25
 
26
26
  def print_all_vars
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.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick