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
@@ -7,14 +7,14 @@ require_relative '../../items/sparklything'
7
7
  module Gemwarrior
8
8
  class Emerald < Monster
9
9
  attr_accessor :defeated_text
10
-
10
+
11
11
  def initialize
12
12
  self.name = 'Emerald'
13
13
  self.description = 'A wily, beefy, tower of a man, champion of both wisdom and strength, sporting a constant glint in his eyes.'
14
14
  self.face = 'gleaming'
15
15
  self.hands = 'tantalizing'
16
16
  self.mood = 'enraged'
17
-
17
+
18
18
  self.level = 15
19
19
  self.hp_cur = rand((level * 2)..(level * 3))
20
20
  self.hp_max = hp_cur
@@ -26,12 +26,12 @@ module Gemwarrior
26
26
  self.inventory = Inventory.new(items = [SparklyThing.new])
27
27
  self.rox = rand((level * 2)..(level * 3))
28
28
  self.xp = rand(level..(level * 2))
29
-
29
+
30
30
  self.battlecry = 'Ha ha ha ha ha! Prepare yourself: today your whole life crumbles!'
31
31
  self.is_boss = true
32
32
  self.defeated_text = defeated_text
33
33
  end
34
-
34
+
35
35
  def defeated_text
36
36
  text = "<^><^><^><^><^><^><^><^><^><^>\n"
37
37
  text << "You beat #{name}! You win!\n"
@@ -11,7 +11,7 @@ module Gemwarrior
11
11
  self.face = 'irregular'
12
12
  self.hands = 'sharp'
13
13
  self.mood = 'abrasive'
14
-
14
+
15
15
  self.level = rand(12..15)
16
16
  self.hp_cur = rand((level * 2.5).floor..(level * 3.5).floor)
17
17
  self.hp_max = hp_cur
@@ -23,7 +23,7 @@ module Gemwarrior
23
23
  self.inventory = Inventory.new
24
24
  self.rox = rand((level * 2)..(level * 3))
25
25
  self.xp = rand((level * 3)..(level * 4))
26
-
26
+
27
27
  self.battlecry = '...?!'
28
28
  self.is_boss = true
29
29
  end
@@ -7,13 +7,13 @@ module Gemwarrior
7
7
  class Citrinaga < Monster
8
8
  def initialize
9
9
  super
10
-
10
+
11
11
  self.name = 'citrinaga'
12
12
  self.description = 'Refreshing in its shiny, gleaming effectiveness at ending your life.'
13
13
  self.face = 'shiny'
14
14
  self.hands = 'glistening'
15
15
  self.mood = 'staid'
16
-
16
+
17
17
  self.level = rand(5..7)
18
18
  self.hp_cur = rand((level * 2)..(level*3))
19
19
  self.hp_max = hp_cur
@@ -24,7 +24,7 @@ module Gemwarrior
24
24
 
25
25
  self.rox = rand((level * 2)..(level * 3))
26
26
  self.xp = rand(level..(level * 3))
27
-
27
+
28
28
  self.battlecry = 'Slice and dice so nice!'
29
29
  end
30
30
  end
@@ -7,13 +7,13 @@ module Gemwarrior
7
7
  class Coraliz < Monster
8
8
  def initialize
9
9
  super
10
-
10
+
11
11
  self.name = 'coraliz'
12
12
  self.description = 'Small blue lizard that slithers around, nipping at your ankles.'
13
13
  self.face = 'spotted'
14
14
  self.hands = 'slippery'
15
15
  self.mood = 'emotionless'
16
-
16
+
17
17
  self.level = rand(5..8)
18
18
  self.hp_cur = rand((level * 2)..(level*3))
19
19
  self.hp_max = hp_cur
@@ -24,7 +24,7 @@ module Gemwarrior
24
24
 
25
25
  self.rox = rand((level * 2)..(level * 3))
26
26
  self.xp = rand(level..(level * 3))
27
-
27
+
28
28
  self.battlecry = 'Where am I? You\'ll never guess!'
29
29
  end
30
30
  end
@@ -7,13 +7,13 @@ module Gemwarrior
7
7
  class Cubicat < Monster
8
8
  def initialize
9
9
  super
10
-
10
+
11
11
  self.name = 'cubicat'
12
12
  self.description = 'Perfectly geometrically cubed feline, fresh from its woven enclosure, claws at the ready.'
13
13
  self.face = 'striking'
14
14
  self.hands = 'grippy'
15
15
  self.mood = 'salacious'
16
-
16
+
17
17
  self.level = rand(6..8)
18
18
  self.hp_cur = rand((level * 2)..(level * 3))
19
19
  self.hp_max = hp_cur
@@ -24,7 +24,7 @@ module Gemwarrior
24
24
 
25
25
  self.rox = rand((level * 2)..(level * 3))
26
26
  self.xp = rand(level..(level * 2))
27
-
27
+
28
28
  self.battlecry = 'I don\'t really care, as long as you die!'
29
29
  end
30
30
  end
@@ -7,13 +7,13 @@ module Gemwarrior
7
7
  class Diaman < Monster
8
8
  def initialize
9
9
  super
10
-
10
+
11
11
  self.name = 'diaman'
12
12
  self.description = 'Crystalline structure in the form of a man, lumbering toward you, with outstretched, edged pincers.'
13
13
  self.face = 'bright'
14
14
  self.hands = 'jagged'
15
15
  self.mood = 'adamant'
16
-
16
+
17
17
  self.level = rand(8..10)
18
18
  self.hp_cur = rand((level * 2)..(level * 3))
19
19
  self.hp_max = hp_cur
@@ -24,7 +24,7 @@ module Gemwarrior
24
24
 
25
25
  self.rox = rand((level * 2)..(level * 3))
26
26
  self.xp = rand(level..(level * 2))
27
-
27
+
28
28
  self.battlecry = 'Precious human, prepare to be lost to the annals of time!'
29
29
  end
30
30
  end
@@ -1,263 +1,275 @@
1
- # lib/gemwarrior/entities/player.rb
2
- # Player creature
3
-
4
- require_relative 'creature'
5
- require_relative '../battle'
6
- require_relative '../misc/name_generator'
7
- require_relative '../misc/player_levels'
8
- require_relative '../misc/wordlist'
9
-
10
- module Gemwarrior
11
- class Player < Creature
12
- include PlayerLevels
13
-
14
- attr_accessor :stam_cur, :stam_max, :cur_coords,
15
- :god_mode, :beast_mode, :use_wordnik
16
-
17
- def initialize(options)
18
- self.name = generate_name
19
- self.description = options.fetch(:description)
20
- self.use_wordnik = options.fetch(:use_wordnik)
21
-
22
- self.face = generate_face(use_wordnik)
23
- self.hands = generate_hands(use_wordnik)
24
- self.mood = generate_mood(use_wordnik)
25
-
26
- self.level = options.fetch(:level)
27
- self.xp = options.fetch(:xp)
28
- self.hp_cur = options.fetch(:hp_cur)
29
- self.hp_max = options.fetch(:hp_max)
30
- self.atk_lo = options.fetch(:atk_lo)
31
- self.atk_hi = options.fetch(:atk_hi)
32
-
33
- self.defense = options.fetch(:defense)
34
- self.dexterity = options.fetch(:dexterity)
35
-
36
- self.inventory = Inventory.new
37
- self.rox = options.fetch(:rox)
38
-
39
- self.stam_cur = options.fetch(:stam_cur)
40
- self.stam_max = options.fetch(:stam_max)
41
- self.cur_coords = options.fetch(:cur_coords)
42
-
43
- self.god_mode = options.fetch(:god_mode)
44
- self.beast_mode = options.fetch(:beast_mode)
45
- end
46
-
47
- def check_self(debug_mode = false, show_pic = true)
48
- unless show_pic == false
49
- print_char_pic
50
- end
51
-
52
- weapon_slot = ''
53
- if has_weapon_equipped?
54
- weapon_slot = inventory.weapon.name
55
- self.atk_lo = inventory.weapon.atk_lo
56
- self.atk_hi = inventory.weapon.atk_hi
57
- else
58
- weapon_slot = '(unarmed)'
59
- end
60
-
61
- self_text = "NAME : #{self.name}\n"
62
- self_text << "POSITION : #{self.cur_coords.values.to_a}\n"
63
- self_text << "WEAPON : #{weapon_slot}\n"
64
- self_text << "LEVEL : #{self.level}\n"
65
- self_text << "EXPERIENCE: #{self.xp}\n"
66
- self_text << "HIT POINTS: #{self.hp_cur}/#{self.hp_max}\n"
67
- self_text << "ATTACK : #{self.atk_lo}-#{self.atk_hi}\n"
68
- self_text << "DEXTERITY : #{self.dexterity}\n"
69
- self_text << "DEFENSE : #{self.defense}\n"
70
- if debug_mode
71
- self_text << "GOD_MODE : #{self.god_mode}\n"
72
- self_text << "BEAST_MODE: #{self.beast_mode}\n"
73
- end
74
-
75
- self_text << "\n#{self.description}\n\n"
76
-
77
- 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"
78
- end
79
-
80
- def rest(world)
81
- cur_loc = world.location_by_coords(cur_coords)
82
-
83
- if cur_loc.has_monster?
84
- chance_of_ambush = rand(0..100)
85
-
86
- if chance_of_ambush < 25
87
- battle = Battle.new({:world => world, :player => self, :monster => cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)]})
88
- return battle.start(is_arena = false, is_event = true)
89
- end
90
- end
91
-
92
- hours = rand(1..23)
93
- minutes = rand(1..59)
94
- seconds = rand(1..59)
95
-
96
- hours_text = hours == 1 ? "hour" : "hours"
97
- mins_text = minutes == 1 ? "minute" : "minutes"
98
- secs_text = seconds == 1 ? "second" : "seconds"
99
-
100
- Animation::run({:phrase => '** Zzzzz **'})
101
-
102
- if self.inventory.has_item?('tent') || world.location_by_coords(cur_coords).has_item?('tent')
103
- self.hp_cur = self.hp_max
104
-
105
- return "You brandish your trusty magical canvas, and with a flick of the wrist your home for the evening is set up. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up, fully rested, ready for adventure."
106
- else
107
- self.hp_cur = self.hp_cur.to_i + rand(10..15)
108
- self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
109
-
110
- return "You lie down somewhere quasi-flat and after a few moments, due to extreme exhaustion, you fall into a deep, yet troubled, slumber. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up with a start. Upon getting to your feet you look around, notice you feel somewhat better, and wonder why you dreamt about #{WordList.new(world.use_wordnik, 'noun-plural').get_random_value}."
111
- end
112
- end
113
-
114
- def stamina_dec
115
- self.stam_cur = stam_cur - 1
116
- end
117
-
118
- def modify_name
119
- print "Enter new name: "
120
-
121
- new_name = gets.chomp!
122
-
123
- if new_name.length <= 0
124
- return "You continue on as #{name}."
125
- elsif new_name.length < 3 || new_name.length > 10
126
- return "'#{new_name}' is an invalid length. Make it between 3 and 10 characters, please."
127
- else
128
- name_to_add = ""
129
- name_to_add << new_name[0].upcase
130
- name_to_add << new_name[1..new_name.length-1].downcase
131
- self.name = name_to_add
132
- return "New name, '#{name}', accepted."
133
- end
134
- end
135
-
136
- def list_inventory
137
- inventory.list_contents
138
- end
139
-
140
- def go(locations, direction, sound)
141
- case direction
142
- when 'north', 'n'
143
- self.cur_coords = {
144
- :x => cur_coords[:x],
145
- :y => cur_coords[:y]+1,
146
- :z => cur_coords[:z]
147
- }
148
- direction_text = '^^^'
149
- when 'east', 'e'
150
- self.cur_coords = {
151
- :x => cur_coords[:x]+1,
152
- :y => cur_coords[:y],
153
- :z => cur_coords[:z]
154
- }
155
- direction_text = '>>>'
156
- when 'south', 's'
157
- self.cur_coords = {
158
- :x => cur_coords[:x],
159
- :y => cur_coords[:y]-1,
160
- :z => cur_coords[:z]
161
- }
162
- direction_text = 'vvv'
163
- when 'west', 'w'
164
- self.cur_coords = {
165
- :x => cur_coords[:x]-1,
166
- :y => cur_coords[:y],
167
- :z => cur_coords[:z]
168
- }
169
- direction_text = '<<<'
170
- end
171
- print_traveling_text(direction_text, sound)
172
- end
173
-
174
- def attack(world, monster)
175
- battle = Battle.new({:world => world, :player => self, :monster => monster})
176
- battle.start
177
- end
178
-
179
- def has_weapon_equipped?
180
- self.inventory.weapon
181
- end
182
-
183
- def cur_weapon_name
184
- if has_weapon_equipped?
185
- return " with your #{inventory.weapon.name}"
186
- else
187
- return nil
188
- end
189
- end
190
-
191
- def take_damage(dmg)
192
- self.hp_cur = self.hp_cur - dmg.to_i
193
-
194
- if hp_cur <= 0
195
- player_death
196
- end
197
- end
198
-
199
- def heal_damage(dmg)
200
- self.hp_cur = self.hp_cur + dmg.to_i
201
- if self.hp_cur > self.hp_max
202
- self.hp_cur = self.hp_max
203
- end
204
- end
205
-
206
- private
207
-
208
- def player_death
209
- puts 'Your actions have reduced you to death.'.colorize(:red)
210
- puts 'Your adventure ends here. Try again next time!'.colorize(:red)
211
- exit(0)
212
- end
213
-
214
- # TRAVEL
215
- def print_traveling_text(direction_text, sound)
216
- Animation::run({:oneline => false, :phrase => "* #{direction_text} *"})
217
- if sound
218
- Music::cue([
219
- {:freq_or_note => 'C3', :duration => 75},
220
- {:freq_or_note => 'D3', :duration => 75},
221
- {:freq_or_note => 'E3', :duration => 75}
222
- ])
223
- end
224
- end
225
-
226
- # CHARACTER
227
- def print_char_pic
228
- char_pic = ""
229
- char_pic << "************\n"
230
- char_pic << "* () *\n"
231
- char_pic << "* \\-||-/ *\n"
232
- char_pic << "* -- *\n"
233
- char_pic << "* || *\n"
234
- char_pic << "* _||_ *\n"
235
- char_pic << "************\n"
236
- puts char_pic
237
- end
238
-
239
- def print_battle_line
240
- puts '**************************************'
241
- end
242
-
243
- # INIT
244
- def generate_name
245
- NameGenerator.new('fantasy').generate_name
246
- end
247
-
248
- def generate_face(use_wordnik)
249
- face_descriptors = WordList.new(use_wordnik, 'adjective')
250
- face_descriptors.get_random_value
251
- end
252
-
253
- def generate_hands(use_wordnik)
254
- hand_descriptors = WordList.new(use_wordnik, 'adjective')
255
- hand_descriptors.get_random_value
256
- end
257
-
258
- def generate_mood(use_wordnik)
259
- mood_descriptors = WordList.new(use_wordnik, 'adjective')
260
- mood_descriptors.get_random_value
261
- end
262
- end
263
- end
1
+ # lib/gemwarrior/entities/player.rb
2
+ # Player creature
3
+
4
+ require_relative 'creature'
5
+ require_relative '../battle'
6
+ require_relative '../misc/name_generator'
7
+ require_relative '../misc/player_levels'
8
+ require_relative '../misc/wordlist'
9
+
10
+ module Gemwarrior
11
+ class Player < Creature
12
+ include PlayerLevels
13
+
14
+ attr_accessor :stam_cur, :stam_max, :cur_coords,
15
+ :god_mode, :beast_mode, :use_wordnik,
16
+ :monsters_killed, :items_taken, :movements_made, :rests_taken
17
+
18
+ def initialize(options)
19
+ self.name = generate_name
20
+ self.description = options.fetch(:description)
21
+ self.use_wordnik = options.fetch(:use_wordnik)
22
+
23
+ self.face = generate_face(use_wordnik)
24
+ self.hands = generate_hands(use_wordnik)
25
+ self.mood = generate_mood(use_wordnik)
26
+
27
+ self.level = options.fetch(:level)
28
+ self.xp = options.fetch(:xp)
29
+ self.hp_cur = options.fetch(:hp_cur)
30
+ self.hp_max = options.fetch(:hp_max)
31
+ self.atk_lo = options.fetch(:atk_lo)
32
+ self.atk_hi = options.fetch(:atk_hi)
33
+
34
+ self.defense = options.fetch(:defense)
35
+ self.dexterity = options.fetch(:dexterity)
36
+
37
+ self.inventory = Inventory.new
38
+ self.rox = options.fetch(:rox)
39
+
40
+ self.stam_cur = options.fetch(:stam_cur)
41
+ self.stam_max = options.fetch(:stam_max)
42
+ self.cur_coords = options.fetch(:cur_coords)
43
+
44
+ self.god_mode = options.fetch(:god_mode)
45
+ self.beast_mode = options.fetch(:beast_mode)
46
+
47
+ self.monsters_killed = 0
48
+ self.items_taken = 0
49
+ self.movements_made = 0
50
+ self.rests_taken = 0
51
+ end
52
+
53
+ def check_self(debug_mode = false, show_pic = true)
54
+ unless show_pic == false
55
+ print_char_pic
56
+ end
57
+
58
+ weapon_slot = ''
59
+ if has_weapon_equipped?
60
+ weapon_slot = inventory.weapon.name
61
+ self.atk_lo = inventory.weapon.atk_lo
62
+ self.atk_hi = inventory.weapon.atk_hi
63
+ else
64
+ weapon_slot = '(unarmed)'
65
+ end
66
+
67
+ self_text = "NAME : #{self.name}\n"
68
+ self_text << "POSITION : #{self.cur_coords.values.to_a}\n"
69
+ self_text << "WEAPON : #{weapon_slot}\n"
70
+ self_text << "LEVEL : #{self.level}\n"
71
+ self_text << "EXPERIENCE: #{self.xp}\n"
72
+ self_text << "HIT POINTS: #{self.hp_cur}/#{self.hp_max}\n"
73
+ self_text << "ATTACK : #{self.atk_lo}-#{self.atk_hi}\n"
74
+ self_text << "DEXTERITY : #{self.dexterity}\n"
75
+ self_text << "DEFENSE : #{self.defense}\n"
76
+ if debug_mode
77
+ self_text << "GOD_MODE : #{self.god_mode}\n"
78
+ self_text << "BEAST_MODE: #{self.beast_mode}\n"
79
+ end
80
+
81
+ self_text << "\n#{self.description}\n\n"
82
+
83
+ 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"
84
+ end
85
+
86
+ def rest(world)
87
+ cur_loc = world.location_by_coords(cur_coords)
88
+
89
+ if cur_loc.should_spawn_monster?
90
+ chance_of_ambush = rand(0..100)
91
+
92
+ if chance_of_ambush < 25
93
+ battle = Battle.new({:world => world, :player => self, :monster => cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)]})
94
+ return battle.start(is_arena = false, is_event = true)
95
+ end
96
+ end
97
+
98
+ # stats
99
+ self.rests_taken += 1
100
+
101
+ hours = rand(1..23)
102
+ minutes = rand(1..59)
103
+ seconds = rand(1..59)
104
+
105
+ hours_text = hours == 1 ? "hour" : "hours"
106
+ mins_text = minutes == 1 ? "minute" : "minutes"
107
+ secs_text = seconds == 1 ? "second" : "seconds"
108
+
109
+ Animation::run({:phrase => '** Zzzzz **'})
110
+
111
+ if self.inventory.has_item?('tent') || world.location_by_coords(cur_coords).has_item?('tent')
112
+ self.hp_cur = self.hp_max
113
+
114
+ return "You brandish your trusty magical canvas, and with a flick of the wrist your home for the evening is set up. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up, fully rested, ready for adventure."
115
+ else
116
+ self.hp_cur = self.hp_cur.to_i + rand(10..15)
117
+ self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
118
+
119
+ return "You lie down somewhere quasi-flat and after a few moments, due to extreme exhaustion, you fall into a deep, yet troubled, slumber. Approximately #{hours} #{hours_text}, #{minutes} #{mins_text}, and #{seconds} #{secs_text} later, you wake up with a start. Upon getting to your feet you look around, notice you feel somewhat better, and wonder why you dreamt about #{WordList.new(world.use_wordnik, 'noun-plural').get_random_value}."
120
+ end
121
+ end
122
+
123
+ def stamina_dec
124
+ self.stam_cur = stam_cur - 1
125
+ end
126
+
127
+ def modify_name
128
+ print "Enter new name: "
129
+
130
+ new_name = gets.chomp!
131
+
132
+ if new_name.length <= 0
133
+ return "You continue on as #{name}."
134
+ elsif new_name.length < 3 || new_name.length > 10
135
+ return "'#{new_name}' is an invalid length. Make it between 3 and 10 characters, please."
136
+ else
137
+ name_to_add = ""
138
+ name_to_add << new_name[0].upcase
139
+ name_to_add << new_name[1..new_name.length-1].downcase
140
+ self.name = name_to_add
141
+ return "New name, '#{name}', accepted."
142
+ end
143
+ end
144
+
145
+ def list_inventory
146
+ inventory.list_contents
147
+ end
148
+
149
+ def go(locations, direction, sound)
150
+ case direction
151
+ when 'north', 'n'
152
+ self.cur_coords = {
153
+ :x => cur_coords[:x],
154
+ :y => cur_coords[:y]+1,
155
+ :z => cur_coords[:z]
156
+ }
157
+ direction_text = '^^^'
158
+ when 'east', 'e'
159
+ self.cur_coords = {
160
+ :x => cur_coords[:x]+1,
161
+ :y => cur_coords[:y],
162
+ :z => cur_coords[:z]
163
+ }
164
+ direction_text = '>>>'
165
+ when 'south', 's'
166
+ self.cur_coords = {
167
+ :x => cur_coords[:x],
168
+ :y => cur_coords[:y]-1,
169
+ :z => cur_coords[:z]
170
+ }
171
+ direction_text = 'vvv'
172
+ when 'west', 'w'
173
+ self.cur_coords = {
174
+ :x => cur_coords[:x]-1,
175
+ :y => cur_coords[:y],
176
+ :z => cur_coords[:z]
177
+ }
178
+ direction_text = '<<<'
179
+ end
180
+ print_traveling_text(direction_text, sound)
181
+
182
+ # stats
183
+ self.movements_made += 1
184
+ end
185
+
186
+ def attack(world, monster)
187
+ battle = Battle.new({:world => world, :player => self, :monster => monster})
188
+ battle.start
189
+ end
190
+
191
+ def has_weapon_equipped?
192
+ self.inventory.weapon
193
+ end
194
+
195
+ def cur_weapon_name
196
+ if has_weapon_equipped?
197
+ return " with your #{inventory.weapon.name}"
198
+ else
199
+ return nil
200
+ end
201
+ end
202
+
203
+ def take_damage(dmg)
204
+ self.hp_cur = self.hp_cur - dmg.to_i
205
+
206
+ if hp_cur <= 0
207
+ player_death
208
+ end
209
+ end
210
+
211
+ def heal_damage(dmg)
212
+ self.hp_cur = self.hp_cur + dmg.to_i
213
+ if self.hp_cur > self.hp_max
214
+ self.hp_cur = self.hp_max
215
+ end
216
+ end
217
+
218
+ private
219
+
220
+ def player_death
221
+ puts 'Your actions have reduced you to death.'.colorize(:red)
222
+ puts 'Your adventure ends here. Try again next time!'.colorize(:red)
223
+ exit(0)
224
+ end
225
+
226
+ # TRAVEL
227
+ def print_traveling_text(direction_text, sound)
228
+ Animation::run({:oneline => false, :phrase => "* #{direction_text} *"})
229
+ if sound
230
+ Music::cue([
231
+ {:freq_or_note => 'C3', :duration => 75},
232
+ {:freq_or_note => 'D3', :duration => 75},
233
+ {:freq_or_note => 'E3', :duration => 75}
234
+ ])
235
+ end
236
+ end
237
+
238
+ # CHARACTER
239
+ def print_char_pic
240
+ char_pic = ""
241
+ char_pic << "************\n"
242
+ char_pic << "* () *\n"
243
+ char_pic << "* \\-||-/ *\n"
244
+ char_pic << "* -- *\n"
245
+ char_pic << "* || *\n"
246
+ char_pic << "* _||_ *\n"
247
+ char_pic << "************\n"
248
+ puts char_pic
249
+ end
250
+
251
+ def print_battle_line
252
+ puts '**************************************'
253
+ end
254
+
255
+ # INIT
256
+ def generate_name
257
+ NameGenerator.new('fantasy').generate_name
258
+ end
259
+
260
+ def generate_face(use_wordnik)
261
+ face_descriptors = WordList.new(use_wordnik, 'adjective')
262
+ face_descriptors.get_random_value
263
+ end
264
+
265
+ def generate_hands(use_wordnik)
266
+ hand_descriptors = WordList.new(use_wordnik, 'adjective')
267
+ hand_descriptors.get_random_value
268
+ end
269
+
270
+ def generate_mood(use_wordnik)
271
+ mood_descriptors = WordList.new(use_wordnik, 'adjective')
272
+ mood_descriptors.get_random_value
273
+ end
274
+ end
275
+ end