gemwarrior 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ced3d65d4786800951217d7551ac484b61c7fe6a
4
- data.tar.gz: 4606dd2f869d32b9722f0b1825ea8873b7baa0b8
3
+ metadata.gz: 5dd2a134a899cfbfd6ac8cf1a0a21e39f22abe86
4
+ data.tar.gz: f8db94e677447ffa3568ebfe94181f4be0a504de
5
5
  SHA512:
6
- metadata.gz: 79eb6e5bb961674f038aebcc10c3e1d82e4db8e3f6ededf54cb5689120c45de358f025c21d9427d9503a7713f7b9df23c2f2f76d3baffccee17a148a0b393321
7
- data.tar.gz: 3e305cb3f6382ff8492083b717e4cfcfbec428aff9a36154149f696de6e97923e43e9859baeb531b5ecacc151dc97923a736aaea79518f7860e16cba14b5b8b4
6
+ metadata.gz: baf985a9731cff030b8cbf27693680eb063dee3a748d3bb541f4bd93eca8db3b7772b496d73d3ce3675ec6244269ba961a197fd398f22be153d29dac10f86d08
7
+ data.tar.gz: b4cadec0839733de6a0d064e0063b8aca37cf47980b0db968494f014d43be0b124aeff8df3cc454f1da07b1bca924e550f53fcbeb16e5749729118c53356f666
@@ -1,11 +1,16 @@
1
1
  # lib/gemwarrior/battle.rb
2
2
  # Monster battle
3
3
 
4
+ require_relative 'misc/player_levels'
5
+
4
6
  module Gemwarrior
5
7
  class Battle
8
+ include PlayerLevels
9
+
6
10
  # CONSTANTS
7
11
  ## ERRORS
8
12
  ERROR_ATTACK_OPTION_INVALID = 'That will not do anything against the monster.'
13
+ BEAST_MODE_ATTACK = 100
9
14
 
10
15
  attr_accessor :world, :player, :monster
11
16
 
@@ -35,11 +40,6 @@ module Gemwarrior
35
40
  player_death
36
41
  end
37
42
 
38
- puts
39
- puts "PLAYER :: #{player.hp_cur.to_s.rjust(3)} HP"
40
- puts "MONSTER :: #{monster.hp_cur.to_s.rjust(3)} HP"
41
- puts "[Fight/Attack][Look][Run]".colorize(:color => :yellow)
42
-
43
43
  if player_near_death?
44
44
  puts "You are almost dead!\n".colorize(:yellow)
45
45
  end
@@ -47,6 +47,11 @@ module Gemwarrior
47
47
  puts "#{monster.name} is almost dead!\n".colorize(:yellow)
48
48
  end
49
49
 
50
+ puts
51
+ puts "PLAYER :: #{player.hp_cur.to_s.rjust(3)} HP"
52
+ puts "MONSTER :: #{monster.hp_cur.to_s.rjust(3)} HP"
53
+ puts "[Fight/Attack][Look][Run]".colorize(:color => :yellow)
54
+
50
55
  puts 'What do you do?'
51
56
  cmd = gets.chomp.downcase
52
57
 
@@ -108,7 +113,12 @@ module Gemwarrior
108
113
  0
109
114
  else
110
115
  if entity.eql?(monster)
111
- rand(player.atk_lo..player.atk_hi)
116
+ if player.beast_mode
117
+ atk_range = BEAST_MODE_ATTACK..BEAST_MODE_ATTACK
118
+ else
119
+ atk_range = player.atk_lo..player.atk_hi
120
+ end
121
+ rand(atk_range)
112
122
  else
113
123
  rand(monster.atk_lo..monster.atk_hi)
114
124
  end
@@ -169,6 +179,11 @@ module Gemwarrior
169
179
  exit(0)
170
180
  else
171
181
  puts 'You just beat a boss monster. Way to go!'
182
+ puts " XP : #{monster.xp}".colorize(:green)
183
+ puts " ROX: #{monster.rox}".colorize(:green)
184
+ print_battle_line
185
+ update_player_stats
186
+ world.location_by_coords(player.cur_coords).remove_monster(monster.name)
172
187
  end
173
188
  else
174
189
  puts 'You get the following spoils of war:'
@@ -181,8 +196,33 @@ module Gemwarrior
181
196
  end
182
197
 
183
198
  def update_player_stats
199
+ old_player_level = PlayerLevels::check_level(player.xp)
200
+
184
201
  player.xp = player.xp + monster.xp
185
202
  player.rox = player.rox + monster.rox
203
+
204
+ new_player_level = PlayerLevels::check_level(player.xp)
205
+
206
+ if new_player_level > old_player_level
207
+ puts 'You leveled up!'
208
+ new_stats = PlayerLevels::get_level_stats(new_player_level)
209
+
210
+ player.level = new_stats[:level]
211
+ puts "You are now level #{player.level}!"
212
+ player.hp_cur = new_stats[:hp_max]
213
+ player.hp_max = new_stats[:hp_max]
214
+ puts "You now have #{player.hp_max} hit points!"
215
+ player.stam_cur = new_stats[:stam_max]
216
+ player.stam_max = new_stats[:stam_max]
217
+ puts "You now have #{player.stam_max} stamina points!"
218
+ player.atk_lo = new_stats[:atk_lo]
219
+ player.atk_hi = new_stats[:atk_hi]
220
+ puts "You now have an attack of #{player.atk_lo}-#{player.atk_hi}!"
221
+ player.defense = new_stats[:defense]
222
+ puts "You now have #{player.defense} defensive points!"
223
+ player.dexterity = new_stats[:dexterity]
224
+ puts "You now have #{player.dexterity} dexterity points!"
225
+ end
186
226
  end
187
227
 
188
228
  def player_near_death?
@@ -43,6 +43,7 @@ module Gemwarrior
43
43
 
44
44
  def remove_monster(name)
45
45
  monsters_abounding.reject! { |monster| monster.name == name }
46
+ bosses_abounding.reject! { |monster| monster.name == name }
46
47
  end
47
48
 
48
49
  def has_loc_to_the?(direction)
@@ -0,0 +1,31 @@
1
+ # lib/gemwarrior/entities/monsters/garynetty.rb
2
+ # Garrynetty monster
3
+
4
+ require_relative '../../monster'
5
+
6
+ module Gemwarrior
7
+ class Garynetty < Monster
8
+ def initialize
9
+ self.name = 'Garynetty'
10
+ self.description = 'Conservative, yet odd, the Garynetty is not messing around.'
11
+ self.face = 'irregular'
12
+ self.hands = 'sharp'
13
+ self.mood = 'abrasive'
14
+
15
+ self.level = rand(12..15)
16
+ self.hp_cur = rand((level * 2.5).floor..(level * 3.5).floor)
17
+ self.hp_max = hp_cur
18
+ self.atk_lo = rand((level * 2)..(level * 2.5).floor)
19
+ self.atk_hi = rand((level * 2.5).floor..(level * 3).floor)
20
+ self.defense = rand(7..9)
21
+ self.dexterity = rand(10..12)
22
+
23
+ self.inventory = Inventory.new
24
+ self.rox = rand((level * 2)..(level * 3))
25
+ self.xp = rand((level * 3)..(level * 4))
26
+
27
+ self.battlecry = '...?!'
28
+ self.is_boss = true
29
+ end
30
+ end
31
+ end
@@ -3,9 +3,12 @@
3
3
 
4
4
  require_relative 'creature'
5
5
  require_relative '../battle'
6
+ require_relative '../misc/player_levels'
6
7
 
7
8
  module Gemwarrior
8
9
  class Player < Creature
10
+ include PlayerLevels
11
+
9
12
  # CONSTANTS
10
13
  ## CHARACTER ATTRIBUTES
11
14
  CHAR_UPPER_POOL = (65..90).map{ |i| i.chr }
@@ -31,8 +34,8 @@ module Gemwarrior
31
34
  self.xp = options.fetch(:xp)
32
35
  self.hp_cur = options.fetch(:hp_cur)
33
36
  self.hp_max = options.fetch(:hp_max)
34
- self.atk_lo = options.fetch(:beast_mode) ? 40 : options.fetch(:atk_lo)
35
- self.atk_hi = options.fetch(:beast_mode) ? 40 : options.fetch(:atk_hi)
37
+ self.atk_lo = options.fetch(:atk_lo)
38
+ self.atk_hi = options.fetch(:atk_hi)
36
39
 
37
40
  self.defense = options.fetch(:defense)
38
41
  self.dexterity = options.fetch(:dexterity)
@@ -53,30 +56,30 @@ module Gemwarrior
53
56
  print_char_pic
54
57
  end
55
58
 
56
- cur_weapon_name = ''
57
- if inventory.weapon.nil?
58
- cur_weapon_name = '(unarmed)'
59
- else
60
- cur_weapon_name = inventory.weapon.name
59
+ weapon_slot = ''
60
+ if has_weapon_equipped?
61
+ weapon_slot = inventory.weapon.name
61
62
  self.atk_lo = inventory.weapon.atk_lo
62
63
  self.atk_hi = inventory.weapon.atk_hi
64
+ else
65
+ weapon_slot = '(unarmed)'
63
66
  end
64
67
 
65
- self_text = "NAME : #{name}\n"
66
- self_text = "POSITION : #{cur_coords.values.to_a}\n"
67
- self_text << "WEAPON : #{cur_weapon_name}\n"
68
- self_text << "LEVEL : #{level}\n"
69
- self_text << "EXPERIENCE: #{xp}\n"
70
- self_text << "HIT POINTS: #{hp_cur}/#{hp_max}\n"
71
- self_text << "ATTACK : #{atk_lo}-#{atk_hi}\n"
72
- self_text << "DEXTERITY : #{dexterity}\n"
73
- self_text << "DEFENSE : #{defense}\n"
74
- self_text << "GOD_MODE : #{god_mode}\n"
75
- self_text << "BEAST_MODE: #{beast_mode}\n\n"
68
+ self_text = "NAME : #{self.name}\n"
69
+ self_text << "POSITION : #{self.cur_coords.values.to_a}\n"
70
+ self_text << "WEAPON : #{weapon_slot}\n"
71
+ self_text << "LEVEL : #{self.level}\n"
72
+ self_text << "EXPERIENCE: #{self.xp}\n"
73
+ self_text << "HIT POINTS: #{self.hp_cur}/#{self.hp_max}\n"
74
+ self_text << "ATTACK : #{self.atk_lo}-#{self.atk_hi}\n"
75
+ self_text << "DEXTERITY : #{self.dexterity}\n"
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"
76
79
 
77
- self_text << "#{description}\n\n"
80
+ self_text << "#{self.description}\n\n"
78
81
 
79
- self_text << "Current status - breathing, wearing clothing, and with a few other specific characteristics: face is #{face}, hands are #{hands}, and general mood is #{mood}.\n"
82
+ 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"
80
83
  end
81
84
 
82
85
  def rest
@@ -139,12 +142,32 @@ module Gemwarrior
139
142
  battle.start
140
143
  end
141
144
 
145
+ def has_weapon_equipped?
146
+ self.inventory.weapon
147
+ end
148
+
142
149
  def cur_weapon_name
143
- unless inventory.weapon.nil?
150
+ if has_weapon_equipped?
144
151
  return " with your #{inventory.weapon.name}"
152
+ else
153
+ return nil
145
154
  end
146
155
  end
147
156
 
157
+ def switch_beast_mode
158
+ if self.beast_mode
159
+ binding.pry
160
+ self.beast_mode = false
161
+ self.atk_lo = has_weapon_equipped? ? self.inventory.weapon.atk_lo : PlayerLevels::get_level_stats(self.level)[:atk_lo]
162
+ self.atk_hi = has_weapon_equipped? ? self.inventory.weapon.atk_hi : PlayerLevels::get_level_stats(self.level)[:atk_hi]
163
+ else
164
+ self.beast_mode = true
165
+ self.atk_lo = BEAST_MODE_ATTACK
166
+ binding.pry
167
+ self.atk_hi = BEAST_MODE_ATTACK
168
+ end
169
+ end
170
+
148
171
  private
149
172
 
150
173
  # TRAVEL
@@ -5,6 +5,7 @@ require 'colorize'
5
5
  require 'matrext'
6
6
 
7
7
  require_relative 'entities/player'
8
+ require_relative 'misc/player_levels'
8
9
  require_relative 'world'
9
10
  require_relative 'evaluator'
10
11
  require_relative 'repl'
@@ -12,19 +13,11 @@ require_relative 'inventory'
12
13
 
13
14
  module Gemwarrior
14
15
  class Game
16
+ include PlayerLevels
17
+
15
18
  # CONSTANTS
16
19
  ## PLAYER DEFAULTS
17
20
  PLAYER_DESC_DEFAULT = 'Picked to do battle against a wizened madman for a shiny something or other for world-saving purposes.'
18
- PLAYER_LEVEL_DEFAULT = 1
19
- PLAYER_XP_DEFAULT = 0
20
- PLAYER_HP_CUR_DEFAULT = 30
21
- PLAYER_HP_MAX_DEFAULT = 30
22
- PLAYER_STAM_CUR_DEFAULT = 20
23
- PLAYER_STAM_MAX_DEFAULT = 20
24
- PLAYER_ATK_LO_DEFAULT = 1
25
- PLAYER_ATK_HI_DEFAULT = 2
26
- PLAYER_DEFENSE_DEFAULT = 5
27
- PLAYER_DEXTERITY_DEFAULT = 5
28
21
  PLAYER_INVENTORY_DEFAULT = Inventory.new
29
22
  PLAYER_ROX_DEFAULT = 0
30
23
 
@@ -34,18 +27,20 @@ module Gemwarrior
34
27
  # create new world and player
35
28
  self.world = World.new
36
29
 
30
+ start_stats = PlayerLevels::get_level_stats(1)
31
+
37
32
  world.player = Player.new({
38
33
  :description => PLAYER_DESC_DEFAULT,
39
- :level => PLAYER_LEVEL_DEFAULT,
40
- :xp => PLAYER_XP_DEFAULT,
41
- :hp_cur => PLAYER_HP_CUR_DEFAULT,
42
- :hp_max => PLAYER_HP_MAX_DEFAULT,
43
- :stam_cur => PLAYER_STAM_CUR_DEFAULT,
44
- :stam_max => PLAYER_STAM_MAX_DEFAULT,
45
- :atk_lo => PLAYER_ATK_LO_DEFAULT,
46
- :atk_hi => PLAYER_ATK_HI_DEFAULT,
47
- :defense => PLAYER_DEFENSE_DEFAULT,
48
- :dexterity => PLAYER_DEXTERITY_DEFAULT,
34
+ :level => start_stats[:level],
35
+ :xp => start_stats[:xp_start],
36
+ :hp_cur => start_stats[:hp_max],
37
+ :hp_max => start_stats[:hp_max],
38
+ :stam_cur => start_stats[:stam_max],
39
+ :stam_max => start_stats[:stam_max],
40
+ :atk_lo => start_stats[:atk_lo],
41
+ :atk_hi => start_stats[:atk_hi],
42
+ :defense => start_stats[:defense],
43
+ :dexterity => start_stats[:dexterity],
49
44
  :inventory => PLAYER_INVENTORY_DEFAULT,
50
45
  :rox => PLAYER_ROX_DEFAULT,
51
46
  :cur_coords => world.location_coords_by_name('Home'),
@@ -2,5 +2,77 @@
2
2
  # Stats table for each level the player can reach
3
3
 
4
4
  module Gemwarrior
5
- #todo
5
+ module PlayerLevels
6
+ def self.get_level_stats(level)
7
+ case level
8
+ when 1
9
+ {
10
+ :level => 1, :xp_start => 0,
11
+ :hp_max => 30, :stam_max => 20,
12
+ :atk_lo => 1, :atk_hi => 2,
13
+ :defense => 5, :dexterity => 5
14
+ }
15
+ when 2
16
+ {
17
+ :level => 2, :xp_start => 50,
18
+ :hp_max => 35, :stam_max => 25,
19
+ :atk_lo => 2, :atk_hi => 3,
20
+ :defense => 6, :dexterity => 6
21
+ }
22
+ when 3
23
+ {
24
+ :level => 3, :xp_start => 120,
25
+ :hp_max => 45, :stam_max => 30,
26
+ :atk_lo => 3, :atk_hi => 5,
27
+ :defense => 7, :dexterity => 8
28
+ }
29
+ when 4
30
+ {
31
+ :level => 4, :xp_start => 250,
32
+ :hp_max => 55, :stam_max => 35,
33
+ :atk_lo => 5, :atk_hi => 6,
34
+ :defense => 8, :dexterity => 9
35
+ }
36
+ when 5
37
+ {
38
+ :level => 5, :xp_start => 600,
39
+ :hp_max => 70, :stam_max => 45,
40
+ :atk_lo => 7, :atk_hi => 8,
41
+ :defense => 10, :dexterity => 11
42
+ }
43
+ when 6
44
+ {
45
+ :level => 6, :xp_start => 1000,
46
+ :hp_max => 85, :stam_max => 60,
47
+ :atk_lo => 8, :atk_hi => 10,
48
+ :defense => 13, :dexterity => 13
49
+ }
50
+ when 7
51
+ {
52
+ :level => 7, :xp_start => 1500,
53
+ :hp_max => 100, :stam_max => 80,
54
+ :atk_lo => 10, :atk_hi => 12,
55
+ :defense => 15, :dexterity => 16
56
+ }
57
+ end
58
+ end
59
+
60
+ def self.check_level(xp)
61
+ if xp < 50
62
+ 1
63
+ elsif xp < 120
64
+ 2
65
+ elsif xp < 250
66
+ 3
67
+ elsif xp < 600
68
+ 4
69
+ elsif xp < 1000
70
+ 5
71
+ elsif xp < 1500
72
+ 6
73
+ elsif xp < 10000
74
+ 7
75
+ end
76
+ end
77
+ end
6
78
  end
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = "0.6.2"
5
+ VERSION = "0.6.3"
6
6
  end
@@ -195,6 +195,7 @@ module Gemwarrior
195
195
  require_relative 'entities/monsters/cubicat'
196
196
  require_relative 'entities/monsters/diaman'
197
197
  require_relative 'entities/monsters/bosses/emerald'
198
+ require_relative 'entities/monsters/bosses/garynetty'
198
199
 
199
200
  self.monsters = [
200
201
  Alexandrat.new,
@@ -207,7 +208,8 @@ module Gemwarrior
207
208
  Coraliz.new,
208
209
  Cubicat.new,
209
210
  Diaman.new,
210
- Emerald.new
211
+ Emerald.new,
212
+ Garynetty.new
211
213
  ]
212
214
  end
213
215
 
@@ -287,12 +289,52 @@ module Gemwarrior
287
289
  :name => 'Forest',
288
290
  :description => 'Trees exist here, in droves.',
289
291
  :coords => {:x => 4, :y => 0},
290
- :locs_connected => {:north => false, :east => true, :south => false, :west => false},
292
+ :locs_connected => {:north => false, :east => true, :south => false, :west => true},
291
293
  :danger_level => :low,
292
294
  :items => [Feather.new, Tree.new],
293
295
  :bosses_abounding => []
294
296
  })
295
297
  )
298
+ locations.push(Location.new({
299
+ :name => 'Pain Desert (Southeast)',
300
+ :description => 'Horrible terribleness emanates from this desolate land of unkind misery.',
301
+ :coords => {:x => 3, :y => 0},
302
+ :locs_connected => {:north => true, :east => true, :south => false, :west => true},
303
+ :danger_level => :assured,
304
+ :items => [],
305
+ :bosses_abounding => [Garynetty.new]
306
+ })
307
+ )
308
+ locations.push(Location.new({
309
+ :name => 'Pain Desert (Northeast)',
310
+ :description => 'Horrible terribleness emanates from this desolate land of unkind misery.',
311
+ :coords => {:x => 3, :y => 1},
312
+ :locs_connected => {:north => false, :east => false, :south => true, :west => true},
313
+ :danger_level => :assured,
314
+ :items => [],
315
+ :bosses_abounding => [Garynetty.new]
316
+ })
317
+ )
318
+ locations.push(Location.new({
319
+ :name => 'Pain Desert (Northwest)',
320
+ :description => 'Horrible terribleness emanates from this desolate land of unkind misery.',
321
+ :coords => {:x => 2, :y => 1},
322
+ :locs_connected => {:north => false, :east => true, :south => true, :west => false},
323
+ :danger_level => :assured,
324
+ :items => [],
325
+ :bosses_abounding => [Garynetty.new]
326
+ })
327
+ )
328
+ locations.push(Location.new({
329
+ :name => 'Pain Desert (Southwest)',
330
+ :description => 'Horrible terribleness emanates from this desolate land of unkind misery.',
331
+ :coords => {:x => 2, :y => 0},
332
+ :locs_connected => {:north => true, :east => true, :south => false, :west => false},
333
+ :danger_level => :assured,
334
+ :items => [],
335
+ :bosses_abounding => [Garynetty.new]
336
+ })
337
+ )
296
338
  locations.push(Location.new({
297
339
  :name => 'Plains',
298
340
  :description => 'A lot of grass and nothing, but you see a mysterious tower further north, and your home to the south.',
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.6.2
4
+ version: 0.6.3
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-06-10 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -195,6 +195,7 @@ files:
195
195
  - lib/gemwarrior/entities/monsters/aquamarine.rb
196
196
  - lib/gemwarrior/entities/monsters/bloodstorm.rb
197
197
  - lib/gemwarrior/entities/monsters/bosses/emerald.rb
198
+ - lib/gemwarrior/entities/monsters/bosses/garynetty.rb
198
199
  - lib/gemwarrior/entities/monsters/citrinaga.rb
199
200
  - lib/gemwarrior/entities/monsters/coraliz.rb
200
201
  - lib/gemwarrior/entities/monsters/cubicat.rb