gemwarrior 0.7.5 → 0.7.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gemwarrior +0 -0
- data/data/locations.yml +980 -600
- data/lib/gemwarrior/battle.rb +1 -1
- data/lib/gemwarrior/entities/items/ladder.rb +31 -0
- data/lib/gemwarrior/entities/items/rope.rb +29 -0
- data/lib/gemwarrior/entities/items/snowman.rb +28 -0
- data/lib/gemwarrior/entities/items/tent.rb +4 -0
- data/lib/gemwarrior/entities/location.rb +5 -1
- data/lib/gemwarrior/entities/player.rb +265 -249
- data/lib/gemwarrior/evaluator.rb +402 -393
- data/lib/gemwarrior/misc/version.rb +1 -1
- data/lib/gemwarrior/world.rb +297 -296
- metadata +9 -4
data/lib/gemwarrior/battle.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/ladder.rb
|
2
|
+
# Item::Ladder
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Ladder < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'ladder'
|
10
|
+
self.description = 'Rickety and crudely-fashioned, this ladder descends down into the dropoff, hopefully heading towards something...anything.'
|
11
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = false
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def use(inventory = nil)
|
20
|
+
puts 'You grab onto the shaky, rough-hewn, wooden ladder with all your might and start to descend, being extra careful not to loose your grip, which with every moment becomes shakier and shakier.'
|
21
|
+
puts
|
22
|
+
|
23
|
+
Animation::run({ :phrase => '*** THUMP ***' })
|
24
|
+
|
25
|
+
puts 'The last couple of steps are more slippery than you anticipated, so you end up fumbling them, falling a few feet onto the hard ground below. When you regain your composure, you notice your conveyance for descending is now far above you and it is, unfortunately, your closest known exit.'
|
26
|
+
puts
|
27
|
+
|
28
|
+
{:type => 'move_dangerous', :data => 'Metal Tunnel (South Entrance)'}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/rope.rb
|
2
|
+
# Item::Rope
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Rope < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'rope'
|
10
|
+
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
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = false
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def use(inventory = nil)
|
20
|
+
puts 'You hold on to the rope with both hands and begin to climb upwards towards the small opening in the ceiling.'
|
21
|
+
puts
|
22
|
+
|
23
|
+
puts 'After a few minutes you pull yourself up onto a field of pure driven snow. Without warning, the rope and opening in the floor vanish.'
|
24
|
+
puts
|
25
|
+
|
26
|
+
{:type => 'move', :data => 'Snow Fields (Southeast)'}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/snowman.rb
|
2
|
+
# Item::Snowman
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Snowman < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'snowman'
|
10
|
+
self.description = 'Standing solemnly in the snow, a man of snow solemnly stands.'
|
11
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = false
|
14
|
+
self.useable = true
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def use(inventory = nil)
|
20
|
+
puts 'You go to touch the snowy softness of the snowman when it magically comes to life! The frozen homunculus grabs you by the wrist and tosses you to the ground, only to follow this up by jumping onto you with its full, freezing, force. Your body, and mind, go numb.'
|
21
|
+
puts
|
22
|
+
|
23
|
+
Animation::run({ :phrase => '*** FOOOOSH ***' })
|
24
|
+
|
25
|
+
{:type => 'move_dangerous', :data => 'Home'}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -36,8 +36,12 @@ module Gemwarrior
|
|
36
36
|
status_text << " #{description}\n".colorize(:white)
|
37
37
|
end
|
38
38
|
|
39
|
+
def has_item?(item_name)
|
40
|
+
items.map(&:name).include?(item_name)
|
41
|
+
end
|
42
|
+
|
39
43
|
def remove_item(item_name)
|
40
|
-
if
|
44
|
+
if has_item?(item_name)
|
41
45
|
items.reject! { |item| item.name == item_name }
|
42
46
|
else
|
43
47
|
ERROR_LOCATION_ITEM_REMOVE_INVALID
|
@@ -1,249 +1,265 @@
|
|
1
|
-
# lib/gemwarrior/entities/player.rb
|
2
|
-
# Player creature
|
3
|
-
|
4
|
-
require_relative 'creature'
|
5
|
-
require_relative '../battle'
|
6
|
-
require_relative '../misc/player_levels'
|
7
|
-
require_relative '../misc/wordlist'
|
8
|
-
|
9
|
-
module Gemwarrior
|
10
|
-
class Player < Creature
|
11
|
-
include PlayerLevels
|
12
|
-
|
13
|
-
# CONSTANTS
|
14
|
-
## CHARACTER ATTRIBUTES
|
15
|
-
CHAR_UPPER_POOL = (65..90).map{ |i| i.chr }
|
16
|
-
CHAR_LOWER_POOL = (97..122).map{ |i| i.chr }
|
17
|
-
CHAR_LOWER_VOWEL_POOL = ['a','e','i','o','u','y']
|
18
|
-
|
19
|
-
FACE_DESC = ['smooth', 'tired', 'ruddy', 'moist', 'shocked', 'handsome', '5 o\'clock-shadowed']
|
20
|
-
HANDS_DESC = ['worn', 'balled into fists', 'relaxed', 'cracked', 'tingly', 'mom\'s spaghetti']
|
21
|
-
MOOD_DESC = ['calm', 'excited', 'depressed', 'tense', 'lackadaisical', 'angry', 'positive']
|
22
|
-
|
23
|
-
attr_accessor :stam_cur, :stam_max, :cur_coords,
|
24
|
-
:god_mode, :beast_mode
|
25
|
-
|
26
|
-
def initialize(options)
|
27
|
-
self.name = generate_name
|
28
|
-
self.description = options.fetch(:description)
|
29
|
-
|
30
|
-
self.face = generate_face
|
31
|
-
self.hands = generate_hands
|
32
|
-
self.mood = generate_mood
|
33
|
-
|
34
|
-
self.level = options.fetch(:level)
|
35
|
-
self.xp = options.fetch(:xp)
|
36
|
-
self.hp_cur = options.fetch(:hp_cur)
|
37
|
-
self.hp_max = options.fetch(:hp_max)
|
38
|
-
self.atk_lo = options.fetch(:atk_lo)
|
39
|
-
self.atk_hi = options.fetch(:atk_hi)
|
40
|
-
|
41
|
-
self.defense = options.fetch(:defense)
|
42
|
-
self.dexterity = options.fetch(:dexterity)
|
43
|
-
|
44
|
-
self.inventory = Inventory.new
|
45
|
-
self.rox = options.fetch(:rox)
|
46
|
-
|
47
|
-
self.stam_cur = options.fetch(:stam_cur)
|
48
|
-
self.stam_max = options.fetch(:stam_max)
|
49
|
-
self.cur_coords = options.fetch(:cur_coords)
|
50
|
-
|
51
|
-
self.god_mode = options.fetch(:god_mode)
|
52
|
-
self.beast_mode = options.fetch(:beast_mode)
|
53
|
-
end
|
54
|
-
|
55
|
-
def check_self(debug_mode = false, show_pic = true)
|
56
|
-
unless show_pic == false
|
57
|
-
print_char_pic
|
58
|
-
end
|
59
|
-
|
60
|
-
weapon_slot = ''
|
61
|
-
if has_weapon_equipped?
|
62
|
-
weapon_slot = inventory.weapon.name
|
63
|
-
self.atk_lo = inventory.weapon.atk_lo
|
64
|
-
self.atk_hi = inventory.weapon.atk_hi
|
65
|
-
else
|
66
|
-
weapon_slot = '(unarmed)'
|
67
|
-
end
|
68
|
-
|
69
|
-
self_text = "NAME : #{self.name}\n"
|
70
|
-
self_text << "POSITION : #{self.cur_coords.values.to_a}\n"
|
71
|
-
self_text << "WEAPON : #{weapon_slot}\n"
|
72
|
-
self_text << "LEVEL : #{self.level}\n"
|
73
|
-
self_text << "EXPERIENCE: #{self.xp}\n"
|
74
|
-
self_text << "HIT POINTS: #{self.hp_cur}/#{self.hp_max}\n"
|
75
|
-
self_text << "ATTACK : #{self.atk_lo}-#{self.atk_hi}\n"
|
76
|
-
self_text << "DEXTERITY : #{self.dexterity}\n"
|
77
|
-
self_text << "DEFENSE : #{self.defense}\n"
|
78
|
-
if debug_mode
|
79
|
-
self_text << "GOD_MODE : #{self.god_mode}\n"
|
80
|
-
self_text << "BEAST_MODE: #{self.beast_mode}\n"
|
81
|
-
end
|
82
|
-
|
83
|
-
self_text << "\n#{self.description}\n\n"
|
84
|
-
|
85
|
-
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"
|
86
|
-
end
|
87
|
-
|
88
|
-
def rest(world)
|
89
|
-
cur_loc = world.location_by_coords(cur_coords)
|
90
|
-
|
91
|
-
if cur_loc.has_monster?
|
92
|
-
chance_of_ambush = rand(0..100)
|
93
|
-
|
94
|
-
if chance_of_ambush < 25
|
95
|
-
battle = Battle.new({:world => world, :player => self, :monster => cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)]})
|
96
|
-
return battle.start
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
hours = rand(1..23)
|
101
|
-
minutes = rand(1..59)
|
102
|
-
seconds = rand(1..59)
|
103
|
-
|
104
|
-
hours_text = hours == 1 ? "hour" : "hours"
|
105
|
-
mins_text = minutes == 1 ? "minute" : "minutes"
|
106
|
-
secs_text = seconds == 1 ? "second" : "seconds"
|
107
|
-
|
108
|
-
Animation::run({:phrase => '** Zzzzz **'})
|
109
|
-
|
110
|
-
if self.inventory.has_item?('tent')
|
111
|
-
self.hp_cur = self.hp_max
|
112
|
-
|
113
|
-
return "You
|
114
|
-
else
|
115
|
-
self.hp_cur = self.hp_cur.to_i + rand(10..15)
|
116
|
-
self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
|
117
|
-
|
118
|
-
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}."
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def stamina_dec
|
123
|
-
self.stam_cur = stam_cur - 1
|
124
|
-
end
|
125
|
-
|
126
|
-
def modify_name
|
127
|
-
print "Enter new name: "
|
128
|
-
new_name = gets.chomp!
|
129
|
-
if new_name.length < 3 || new_name.length > 10
|
130
|
-
return "'#{new_name}' is an invalid length. Make it between 3 and 10 characters, please."
|
131
|
-
else
|
132
|
-
name_to_add = ""
|
133
|
-
name_to_add << new_name[0].upcase
|
134
|
-
name_to_add << new_name[1..new_name.length-1].downcase
|
135
|
-
self.name = name_to_add
|
136
|
-
return "New name, '#{name}', accepted."
|
137
|
-
end
|
138
|
-
return nil
|
139
|
-
end
|
140
|
-
|
141
|
-
def list_inventory
|
142
|
-
inventory.list_contents
|
143
|
-
end
|
144
|
-
|
145
|
-
def go(locations, direction)
|
146
|
-
case direction
|
147
|
-
when 'north', 'n'
|
148
|
-
self.cur_coords = {
|
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
|
-
end
|
187
|
-
|
188
|
-
def
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
def
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
def
|
238
|
-
|
239
|
-
end
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
end
|
1
|
+
# lib/gemwarrior/entities/player.rb
|
2
|
+
# Player creature
|
3
|
+
|
4
|
+
require_relative 'creature'
|
5
|
+
require_relative '../battle'
|
6
|
+
require_relative '../misc/player_levels'
|
7
|
+
require_relative '../misc/wordlist'
|
8
|
+
|
9
|
+
module Gemwarrior
|
10
|
+
class Player < Creature
|
11
|
+
include PlayerLevels
|
12
|
+
|
13
|
+
# CONSTANTS
|
14
|
+
## CHARACTER ATTRIBUTES
|
15
|
+
CHAR_UPPER_POOL = (65..90).map{ |i| i.chr }
|
16
|
+
CHAR_LOWER_POOL = (97..122).map{ |i| i.chr }
|
17
|
+
CHAR_LOWER_VOWEL_POOL = ['a','e','i','o','u','y']
|
18
|
+
|
19
|
+
FACE_DESC = ['smooth', 'tired', 'ruddy', 'moist', 'shocked', 'handsome', '5 o\'clock-shadowed']
|
20
|
+
HANDS_DESC = ['worn', 'balled into fists', 'relaxed', 'cracked', 'tingly', 'mom\'s spaghetti']
|
21
|
+
MOOD_DESC = ['calm', 'excited', 'depressed', 'tense', 'lackadaisical', 'angry', 'positive']
|
22
|
+
|
23
|
+
attr_accessor :stam_cur, :stam_max, :cur_coords,
|
24
|
+
:god_mode, :beast_mode
|
25
|
+
|
26
|
+
def initialize(options)
|
27
|
+
self.name = generate_name
|
28
|
+
self.description = options.fetch(:description)
|
29
|
+
|
30
|
+
self.face = generate_face
|
31
|
+
self.hands = generate_hands
|
32
|
+
self.mood = generate_mood
|
33
|
+
|
34
|
+
self.level = options.fetch(:level)
|
35
|
+
self.xp = options.fetch(:xp)
|
36
|
+
self.hp_cur = options.fetch(:hp_cur)
|
37
|
+
self.hp_max = options.fetch(:hp_max)
|
38
|
+
self.atk_lo = options.fetch(:atk_lo)
|
39
|
+
self.atk_hi = options.fetch(:atk_hi)
|
40
|
+
|
41
|
+
self.defense = options.fetch(:defense)
|
42
|
+
self.dexterity = options.fetch(:dexterity)
|
43
|
+
|
44
|
+
self.inventory = Inventory.new
|
45
|
+
self.rox = options.fetch(:rox)
|
46
|
+
|
47
|
+
self.stam_cur = options.fetch(:stam_cur)
|
48
|
+
self.stam_max = options.fetch(:stam_max)
|
49
|
+
self.cur_coords = options.fetch(:cur_coords)
|
50
|
+
|
51
|
+
self.god_mode = options.fetch(:god_mode)
|
52
|
+
self.beast_mode = options.fetch(:beast_mode)
|
53
|
+
end
|
54
|
+
|
55
|
+
def check_self(debug_mode = false, show_pic = true)
|
56
|
+
unless show_pic == false
|
57
|
+
print_char_pic
|
58
|
+
end
|
59
|
+
|
60
|
+
weapon_slot = ''
|
61
|
+
if has_weapon_equipped?
|
62
|
+
weapon_slot = inventory.weapon.name
|
63
|
+
self.atk_lo = inventory.weapon.atk_lo
|
64
|
+
self.atk_hi = inventory.weapon.atk_hi
|
65
|
+
else
|
66
|
+
weapon_slot = '(unarmed)'
|
67
|
+
end
|
68
|
+
|
69
|
+
self_text = "NAME : #{self.name}\n"
|
70
|
+
self_text << "POSITION : #{self.cur_coords.values.to_a}\n"
|
71
|
+
self_text << "WEAPON : #{weapon_slot}\n"
|
72
|
+
self_text << "LEVEL : #{self.level}\n"
|
73
|
+
self_text << "EXPERIENCE: #{self.xp}\n"
|
74
|
+
self_text << "HIT POINTS: #{self.hp_cur}/#{self.hp_max}\n"
|
75
|
+
self_text << "ATTACK : #{self.atk_lo}-#{self.atk_hi}\n"
|
76
|
+
self_text << "DEXTERITY : #{self.dexterity}\n"
|
77
|
+
self_text << "DEFENSE : #{self.defense}\n"
|
78
|
+
if debug_mode
|
79
|
+
self_text << "GOD_MODE : #{self.god_mode}\n"
|
80
|
+
self_text << "BEAST_MODE: #{self.beast_mode}\n"
|
81
|
+
end
|
82
|
+
|
83
|
+
self_text << "\n#{self.description}\n\n"
|
84
|
+
|
85
|
+
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"
|
86
|
+
end
|
87
|
+
|
88
|
+
def rest(world)
|
89
|
+
cur_loc = world.location_by_coords(cur_coords)
|
90
|
+
|
91
|
+
if cur_loc.has_monster?
|
92
|
+
chance_of_ambush = rand(0..100)
|
93
|
+
|
94
|
+
if chance_of_ambush < 25
|
95
|
+
battle = Battle.new({:world => world, :player => self, :monster => cur_loc.monsters_abounding[rand(0..cur_loc.monsters_abounding.length-1)]})
|
96
|
+
return battle.start
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
hours = rand(1..23)
|
101
|
+
minutes = rand(1..59)
|
102
|
+
seconds = rand(1..59)
|
103
|
+
|
104
|
+
hours_text = hours == 1 ? "hour" : "hours"
|
105
|
+
mins_text = minutes == 1 ? "minute" : "minutes"
|
106
|
+
secs_text = seconds == 1 ? "second" : "seconds"
|
107
|
+
|
108
|
+
Animation::run({:phrase => '** Zzzzz **'})
|
109
|
+
|
110
|
+
if self.inventory.has_item?('tent') || world.location_by_coords(cur_coords).has_item?('tent')
|
111
|
+
self.hp_cur = self.hp_max
|
112
|
+
|
113
|
+
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."
|
114
|
+
else
|
115
|
+
self.hp_cur = self.hp_cur.to_i + rand(10..15)
|
116
|
+
self.hp_cur = self.hp_max if self.hp_cur > self.hp_max
|
117
|
+
|
118
|
+
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}."
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def stamina_dec
|
123
|
+
self.stam_cur = stam_cur - 1
|
124
|
+
end
|
125
|
+
|
126
|
+
def modify_name
|
127
|
+
print "Enter new name: "
|
128
|
+
new_name = gets.chomp!
|
129
|
+
if new_name.length < 3 || new_name.length > 10
|
130
|
+
return "'#{new_name}' is an invalid length. Make it between 3 and 10 characters, please."
|
131
|
+
else
|
132
|
+
name_to_add = ""
|
133
|
+
name_to_add << new_name[0].upcase
|
134
|
+
name_to_add << new_name[1..new_name.length-1].downcase
|
135
|
+
self.name = name_to_add
|
136
|
+
return "New name, '#{name}', accepted."
|
137
|
+
end
|
138
|
+
return nil
|
139
|
+
end
|
140
|
+
|
141
|
+
def list_inventory
|
142
|
+
inventory.list_contents
|
143
|
+
end
|
144
|
+
|
145
|
+
def go(locations, direction)
|
146
|
+
case direction
|
147
|
+
when 'north', 'n'
|
148
|
+
self.cur_coords = {
|
149
|
+
:x => cur_coords[:x],
|
150
|
+
:y => cur_coords[:y]+1,
|
151
|
+
:z => cur_coords[:z]
|
152
|
+
}
|
153
|
+
direction_text = '^^^'
|
154
|
+
when 'east', 'e'
|
155
|
+
self.cur_coords = {
|
156
|
+
:x => cur_coords[:x]+1,
|
157
|
+
:y => cur_coords[:y],
|
158
|
+
:z => cur_coords[:z]
|
159
|
+
}
|
160
|
+
direction_text = '>>>'
|
161
|
+
when 'south', 's'
|
162
|
+
self.cur_coords = {
|
163
|
+
:x => cur_coords[:x],
|
164
|
+
:y => cur_coords[:y]-1,
|
165
|
+
:z => cur_coords[:z]
|
166
|
+
}
|
167
|
+
direction_text = 'vvv'
|
168
|
+
when 'west', 'w'
|
169
|
+
self.cur_coords = {
|
170
|
+
:x => cur_coords[:x]-1,
|
171
|
+
:y => cur_coords[:y],
|
172
|
+
:z => cur_coords[:z]
|
173
|
+
}
|
174
|
+
direction_text = '<<<'
|
175
|
+
end
|
176
|
+
print_traveling_text(direction_text)
|
177
|
+
end
|
178
|
+
|
179
|
+
def attack(world, monster)
|
180
|
+
battle = Battle.new({:world => world, :player => self, :monster => monster})
|
181
|
+
battle.start
|
182
|
+
end
|
183
|
+
|
184
|
+
def has_weapon_equipped?
|
185
|
+
self.inventory.weapon
|
186
|
+
end
|
187
|
+
|
188
|
+
def cur_weapon_name
|
189
|
+
if has_weapon_equipped?
|
190
|
+
return " with your #{inventory.weapon.name}"
|
191
|
+
else
|
192
|
+
return nil
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def take_damage(dmg)
|
197
|
+
self.hp_cur = self.hp_cur - dmg.to_i
|
198
|
+
|
199
|
+
if hp_cur <= 0
|
200
|
+
player_death
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def heal_damage(dmg)
|
205
|
+
self.hp_cur = self.hp_cur + dmg.to_i
|
206
|
+
if self.hp_cur > self.hp_max
|
207
|
+
self.hp_cur = self.hp_max
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
private
|
212
|
+
|
213
|
+
def player_death
|
214
|
+
puts 'Your actions have reduced you to death.'.colorize(:red)
|
215
|
+
puts 'Your adventure ends here. Try again next time!'.colorize(:red)
|
216
|
+
exit(0)
|
217
|
+
end
|
218
|
+
|
219
|
+
# TRAVEL
|
220
|
+
def print_traveling_text(direction_text)
|
221
|
+
Animation::run({:oneline => false, :phrase => "* #{direction_text} *"})
|
222
|
+
end
|
223
|
+
|
224
|
+
# CHARACTER
|
225
|
+
def print_char_pic
|
226
|
+
char_pic = ""
|
227
|
+
char_pic << "************\n"
|
228
|
+
char_pic << "* () *\n"
|
229
|
+
char_pic << "* \\-||-/ *\n"
|
230
|
+
char_pic << "* -- *\n"
|
231
|
+
char_pic << "* || *\n"
|
232
|
+
char_pic << "* _||_ *\n"
|
233
|
+
char_pic << "************\n"
|
234
|
+
puts char_pic
|
235
|
+
end
|
236
|
+
|
237
|
+
def print_battle_line
|
238
|
+
puts '**************************************'
|
239
|
+
end
|
240
|
+
|
241
|
+
# INIT
|
242
|
+
def generate_name
|
243
|
+
default_name = []
|
244
|
+
letter_max = rand(5..10)
|
245
|
+
default_name[0] = CHAR_UPPER_POOL[rand(0..25)]
|
246
|
+
default_name[1] = CHAR_LOWER_VOWEL_POOL[rand(0..5)]
|
247
|
+
2.upto(letter_max) do |i|
|
248
|
+
default_name[i] = CHAR_LOWER_POOL[rand(0..25)]
|
249
|
+
end
|
250
|
+
return default_name.join
|
251
|
+
end
|
252
|
+
|
253
|
+
def generate_face
|
254
|
+
FACE_DESC[rand(0..FACE_DESC.length-1)]
|
255
|
+
end
|
256
|
+
|
257
|
+
def generate_hands
|
258
|
+
HANDS_DESC[rand(0..HANDS_DESC.length-1)]
|
259
|
+
end
|
260
|
+
|
261
|
+
def generate_mood
|
262
|
+
MOOD_DESC[rand(0..MOOD_DESC.length-1)]
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|