gemwarrior 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gemwarrior +15 -9
- data/gemwarrior.gemspec +1 -0
- data/lib/gemwarrior/arena.rb +10 -10
- data/lib/gemwarrior/battle.rb +41 -36
- data/lib/gemwarrior/entities/item.rb +2 -2
- data/lib/gemwarrior/entities/items/arena_master.rb +4 -4
- data/lib/gemwarrior/entities/items/bed.rb +1 -1
- data/lib/gemwarrior/entities/items/couch.rb +1 -1
- data/lib/gemwarrior/entities/items/floor_tile.rb +3 -3
- data/lib/gemwarrior/entities/items/gun.rb +1 -1
- data/lib/gemwarrior/entities/items/herb.rb +1 -1
- data/lib/gemwarrior/entities/items/ladder.rb +2 -2
- data/lib/gemwarrior/entities/items/map.rb +2 -2
- data/lib/gemwarrior/entities/items/massive_door.rb +1 -1
- data/lib/gemwarrior/entities/items/opalaser.rb +1 -1
- data/lib/gemwarrior/entities/items/pond.rb +2 -2
- data/lib/gemwarrior/entities/items/rope.rb +2 -2
- data/lib/gemwarrior/entities/items/snowman.rb +1 -1
- data/lib/gemwarrior/entities/items/sparklything.rb +1 -1
- data/lib/gemwarrior/entities/items/tent.rb +1 -1
- data/lib/gemwarrior/entities/items/tower_switch.rb +1 -1
- data/lib/gemwarrior/entities/items/waterfall.rb +1 -1
- data/lib/gemwarrior/entities/location.rb +19 -19
- data/lib/gemwarrior/entities/monster.rb +2 -2
- data/lib/gemwarrior/entities/monsters/alexandrat.rb +3 -3
- data/lib/gemwarrior/entities/monsters/amberoo.rb +3 -3
- data/lib/gemwarrior/entities/monsters/amethystle.rb +3 -3
- data/lib/gemwarrior/entities/monsters/apatiger.rb +2 -2
- data/lib/gemwarrior/entities/monsters/aquamarine.rb +3 -3
- data/lib/gemwarrior/entities/monsters/bloodstorm.rb +3 -3
- data/lib/gemwarrior/entities/monsters/bosses/emerald.rb +4 -4
- data/lib/gemwarrior/entities/monsters/bosses/garynetty.rb +2 -2
- data/lib/gemwarrior/entities/monsters/citrinaga.rb +3 -3
- data/lib/gemwarrior/entities/monsters/coraliz.rb +3 -3
- data/lib/gemwarrior/entities/monsters/cubicat.rb +3 -3
- data/lib/gemwarrior/entities/monsters/diaman.rb +3 -3
- data/lib/gemwarrior/entities/player.rb +275 -263
- data/lib/gemwarrior/evaluator.rb +448 -448
- data/lib/gemwarrior/game.rb +5 -5
- data/lib/gemwarrior/inventory.rb +14 -10
- data/lib/gemwarrior/misc/animation.rb +1 -1
- data/lib/gemwarrior/misc/music.rb +1 -1
- data/lib/gemwarrior/misc/name_generator.rb +8 -8
- data/lib/gemwarrior/misc/player_levels.rb +1 -1
- data/lib/gemwarrior/misc/timer.rb +50 -0
- data/lib/gemwarrior/misc/wordlist.rb +7 -7
- data/lib/gemwarrior/repl.rb +55 -21
- data/lib/gemwarrior/version.rb +1 -1
- data/lib/gemwarrior/world.rb +21 -21
- 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
|
-
|
18
|
-
|
19
|
-
self.
|
20
|
-
self.
|
21
|
-
|
22
|
-
|
23
|
-
self.
|
24
|
-
self.
|
25
|
-
|
26
|
-
|
27
|
-
self.
|
28
|
-
self.
|
29
|
-
self.
|
30
|
-
self.
|
31
|
-
self.
|
32
|
-
|
33
|
-
|
34
|
-
self.
|
35
|
-
|
36
|
-
|
37
|
-
self.
|
38
|
-
|
39
|
-
|
40
|
-
self.
|
41
|
-
self.
|
42
|
-
|
43
|
-
|
44
|
-
self.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
self_text
|
68
|
-
self_text << "
|
69
|
-
self_text << "
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
self_text << "
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
:
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
:
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
:
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
end
|
190
|
-
|
191
|
-
def
|
192
|
-
self.
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
#
|
227
|
-
def
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
def
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
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
|