gemwarrior 0.5 → 0.5.1
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 +4 -4
- data/README.md +10 -8
- data/bin/gemwarrior +15 -3
- data/lib/gemwarrior/battle.rb +184 -0
- data/lib/gemwarrior/entities/items/stonemite.rb +19 -0
- data/lib/gemwarrior/entities/location.rb +7 -1
- data/lib/gemwarrior/entities/monster.rb +0 -5
- data/lib/gemwarrior/entities/player.rb +13 -160
- data/lib/gemwarrior/evaluator.rb +19 -6
- data/lib/gemwarrior/misc/version.rb +1 -1
- data/lib/gemwarrior/world.rb +66 -6
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8f4d5a687c7e67e55c6e675d53eed0ee81802b1
|
4
|
+
data.tar.gz: 64d4c7673e0956ab01a70933188160c40ef55c9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4004e73feef6f2fb37694c904ab8e3953073af5a8d67e9f868e4643ba3f20b05588bea1428caaa581efdd59079fe5bed86b41a136aef2dafde5d5159441529f4
|
7
|
+
data.tar.gz: 8f9a8949bf9ae1f6c3de960ecd1417dec8597b0b712059b6b681ef288bcfab407cafd7849b594d01e0b1f1388fe266d38c1e4d69738008074d3ca2c9ba44ea95
|
data/README.md
CHANGED
@@ -30,24 +30,26 @@ This is in super-hyper-turbo-edition pre-pre-pre-alpha right now, but a working
|
|
30
30
|
|
31
31
|
`> c` - character check for visual identity
|
32
32
|
`> i [object]` - check your inventory (or an individual item within)
|
33
|
-
`>
|
33
|
+
`> ls [entity_type]` - list entities in the game (monsters, items, locations)
|
34
|
+
`> r` - take a load off and replenish hp
|
34
35
|
`> l [object]` - look at current location and its items and monsters
|
35
|
-
`> ls [entity_type]` - list entities in the game (monsters, items, locations)
|
36
36
|
`> t [object]` - take an item from a location
|
37
|
-
`>
|
38
|
-
`>
|
37
|
+
`> d [object]` - drop an item from your inventory
|
38
|
+
`> e [object]` - equip an item in your inventory as a weapon
|
39
|
+
`> ue [object]` - unequip an item in your inventory
|
39
40
|
`> g [direction]` - go in a direction, if possible
|
40
|
-
`>
|
41
|
-
`> m` - list all the monsters available in the world
|
41
|
+
`> a [monster]` - attack a monster
|
42
42
|
`> ch [attribute]` - change some things about yourself
|
43
|
-
`>
|
43
|
+
`> h` - display available commands
|
44
|
+
`> q` - quit this nonsense w/ prompt
|
45
|
+
`> qq` - quit this nonsense w/o prompt
|
44
46
|
|
45
47
|
To come:
|
46
48
|
|
47
49
|
* ~~Ability to move between locations!~~
|
48
50
|
* ~~Monsters!~~
|
49
51
|
* ~~Ability to fight those monsters!~~
|
50
|
-
* Monsters to fight back
|
52
|
+
* ~~Monsters to fight back!~~
|
51
53
|
* ~~Items you can pick up!~~
|
52
54
|
* Saving!
|
53
55
|
* Loading of said saved state!
|
data/bin/gemwarrior
CHANGED
@@ -5,11 +5,21 @@ require 'optparse'
|
|
5
5
|
require_relative '../lib/gemwarrior/misc/version'
|
6
6
|
require_relative '../lib/gemwarrior/game'
|
7
7
|
|
8
|
+
GAME_NAME = "Gem Warrior"
|
9
|
+
|
8
10
|
def parse_options
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
optparse = OptionParser.new do |opts|
|
14
|
+
opts.on('-v', '--version', 'Display version number and exit') do
|
15
|
+
puts "#{GAME_NAME} v#{Gemwarrior::VERSION}"
|
16
|
+
exit
|
17
|
+
end
|
12
18
|
end
|
19
|
+
|
20
|
+
optparse.parse!()
|
21
|
+
|
22
|
+
return options
|
13
23
|
end
|
14
24
|
|
15
25
|
def print_error(error)
|
@@ -23,6 +33,8 @@ def print_error(error)
|
|
23
33
|
end
|
24
34
|
|
25
35
|
begin
|
36
|
+
options = parse_options
|
37
|
+
|
26
38
|
Gemwarrior::Game.new
|
27
39
|
rescue => error
|
28
40
|
print_error(error)
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# lib/gemwarrior/battle.rb
|
2
|
+
# Monster battle
|
3
|
+
|
4
|
+
module Gemwarrior
|
5
|
+
class Battle
|
6
|
+
# CONSTANTS
|
7
|
+
## ERRORS
|
8
|
+
ERROR_ATTACK_OPTION_INVALID = 'That will not do anything against the monster.'
|
9
|
+
|
10
|
+
attr_accessor :world, :player, :monster
|
11
|
+
|
12
|
+
def initialize(options)
|
13
|
+
self.world = options.fetch(:world)
|
14
|
+
self.player = options.fetch(:player)
|
15
|
+
self.monster = options.fetch(:monster)
|
16
|
+
end
|
17
|
+
|
18
|
+
def start
|
19
|
+
print_battle_line
|
20
|
+
puts "You decide to attack the #{monster.name}!"
|
21
|
+
puts "#{monster.name} cries out: #{monster.battlecry}"
|
22
|
+
|
23
|
+
# first strike!
|
24
|
+
if monster_strikes_first?
|
25
|
+
puts "#{monster.name} strikes first!"
|
26
|
+
monster_attacks_player
|
27
|
+
end
|
28
|
+
|
29
|
+
# main battle loop
|
30
|
+
loop do
|
31
|
+
if (monster.hp_cur <= 0)
|
32
|
+
monster_death
|
33
|
+
return
|
34
|
+
elsif (player.hp_cur <= 0 && !player.god_mode)
|
35
|
+
player_death
|
36
|
+
end
|
37
|
+
|
38
|
+
puts
|
39
|
+
puts "[Fight/Attack][Look][Run]"
|
40
|
+
puts "P :: #{player.hp_cur} HP\n"
|
41
|
+
puts "M :: #{monster.hp_cur} HP\n"
|
42
|
+
|
43
|
+
if ((player.hp_cur.to_f / player.hp_max.to_f) < 0.10)
|
44
|
+
puts "You are almost dead!\n"
|
45
|
+
end
|
46
|
+
if ((monster.hp_cur.to_f / monster.hp_max.to_f) < 0.10)
|
47
|
+
puts "#{monster.name} is almost dead!\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
puts 'What do you do?'
|
51
|
+
cmd = gets.chomp.downcase
|
52
|
+
|
53
|
+
# player action
|
54
|
+
case cmd
|
55
|
+
when 'fight', 'f', 'attack', 'a'
|
56
|
+
puts "You attack #{monster.name}#{player.cur_weapon_name}!"
|
57
|
+
dmg = calculate_damage_to(monster)
|
58
|
+
if dmg > 0
|
59
|
+
puts "You wound it for #{dmg} point(s)!"
|
60
|
+
take_damage(monster, dmg)
|
61
|
+
if (monster.hp_cur <= 0)
|
62
|
+
monster_death
|
63
|
+
return
|
64
|
+
end
|
65
|
+
else
|
66
|
+
puts "You miss entirely!"
|
67
|
+
end
|
68
|
+
when 'look', 'l'
|
69
|
+
puts "#{monster.name}: #{monster.description}"
|
70
|
+
puts "Its got some distinguishing features, too: face is #{monster.face}, hands are #{monster.hands}, and general mood is #{monster.mood}."
|
71
|
+
when 'run', 'r'
|
72
|
+
if player_escape?
|
73
|
+
monster.hp_cur = monster.hp_max
|
74
|
+
puts "You successfully elude #{monster.name}!"
|
75
|
+
return
|
76
|
+
else
|
77
|
+
puts "You were not able to run away! :-("
|
78
|
+
end
|
79
|
+
else
|
80
|
+
puts ERROR_ATTACK_OPTION_INVALID
|
81
|
+
next
|
82
|
+
end
|
83
|
+
|
84
|
+
# monster action
|
85
|
+
monster_attacks_player
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def monster_strikes_first?
|
92
|
+
if (monster.dexterity > player.dexterity)
|
93
|
+
return true
|
94
|
+
else
|
95
|
+
dex_diff = player.dexterity - monster.dexterity
|
96
|
+
rand_dex = rand(0..dex_diff)
|
97
|
+
if rand_dex % 2 > 0
|
98
|
+
return true
|
99
|
+
else
|
100
|
+
return false
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def calculate_damage_to(entity)
|
106
|
+
miss = rand(0..100)
|
107
|
+
if (miss < 15)
|
108
|
+
0
|
109
|
+
else
|
110
|
+
if entity.eql?(monster)
|
111
|
+
rand(player.atk_lo..player.atk_hi)
|
112
|
+
else
|
113
|
+
rand(monster.atk_lo..monster.atk_hi)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def take_damage(entity, dmg)
|
119
|
+
entity.hp_cur = entity.hp_cur.to_i - dmg.to_i
|
120
|
+
end
|
121
|
+
|
122
|
+
def monster_attacks_player
|
123
|
+
puts "#{monster.name} attacks you!"
|
124
|
+
dmg = calculate_damage_to(player)
|
125
|
+
if dmg > 0
|
126
|
+
puts "You are wounded for #{dmg} point(s)!"
|
127
|
+
take_damage(player, dmg)
|
128
|
+
if player.hp_cur <= 0
|
129
|
+
player_death
|
130
|
+
end
|
131
|
+
else
|
132
|
+
puts "#{monster.name} misses entirely!"
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def calculate_monster_damage
|
137
|
+
miss = rand(0..100)
|
138
|
+
if (miss < 15)
|
139
|
+
0
|
140
|
+
else
|
141
|
+
rand(player.atk_lo..player.atk_hi)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def monster_death
|
146
|
+
puts "You have defeated #{monster.name}!"
|
147
|
+
puts "You have received #{monster.xp} XP!"
|
148
|
+
puts "You have found #{monster.rox} barterable rox on your slain opponent!"
|
149
|
+
print_battle_line
|
150
|
+
update_player_stats
|
151
|
+
world.location_by_coords(player.cur_coords).remove_monster(monster.name)
|
152
|
+
end
|
153
|
+
|
154
|
+
def player_death
|
155
|
+
puts "You are dead, slain by the #{monster.name}!"
|
156
|
+
puts 'Your adventure ends here. Try again next time!'
|
157
|
+
print_battle_line
|
158
|
+
exit(0)
|
159
|
+
end
|
160
|
+
|
161
|
+
def update_player_stats
|
162
|
+
player.xp = player.xp + monster.xp
|
163
|
+
player.rox = player.rox + monster.rox
|
164
|
+
end
|
165
|
+
|
166
|
+
def player_escape?
|
167
|
+
if (player.dexterity > monster.dexterity)
|
168
|
+
return true
|
169
|
+
else
|
170
|
+
dex_diff = monster.dexterity - player.dexterity
|
171
|
+
rand_dex = rand(0..dex_diff)
|
172
|
+
if rand_dex % 2 > 0
|
173
|
+
return true
|
174
|
+
else
|
175
|
+
return false
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def print_battle_line
|
181
|
+
puts '**************************************'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# lib/gemwarrior/entities/items/stonemite.rb
|
2
|
+
# Item::Stonemite
|
3
|
+
|
4
|
+
require_relative '../item'
|
5
|
+
|
6
|
+
module Gemwarrior
|
7
|
+
class Stonemite < Item
|
8
|
+
def initialize
|
9
|
+
self.name = 'stonemite'
|
10
|
+
self.description = 'Stubby cave debris that is kind of neat to look at, as it is off-grey and sparkly, but the size makes it unusable as anything but skipping on a lake or tossing to the ground.'
|
11
|
+
self.atk_lo = nil
|
12
|
+
self.atk_hi = nil
|
13
|
+
self.takeable = true
|
14
|
+
self.useable = false
|
15
|
+
self.equippable = false
|
16
|
+
self.equipped = false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -29,7 +29,13 @@ module Gemwarrior
|
|
29
29
|
self.monsters_abounding = []
|
30
30
|
self.checked_for_monsters = false
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
|
+
def status
|
34
|
+
status_text = name.ljust(20).upcase
|
35
|
+
status_text << coords.values.to_a
|
36
|
+
status_text << " #{description}\n"
|
37
|
+
end
|
38
|
+
|
33
39
|
def remove_item(item_name)
|
34
40
|
if items.map(&:name).include?(item_name)
|
35
41
|
items.reject! { |item| item.name == item_name }
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# Player creature
|
3
3
|
|
4
4
|
require_relative 'creature'
|
5
|
+
require_relative '../battle'
|
5
6
|
|
6
7
|
module Gemwarrior
|
7
8
|
class Player < Creature
|
@@ -14,9 +15,6 @@ module Gemwarrior
|
|
14
15
|
FACE_DESC = ['smooth', 'tired', 'ruddy', 'moist', 'shocked', 'handsome', '5 o\'clock-shadowed']
|
15
16
|
HANDS_DESC = ['worn', 'balled into fists', 'relaxed', 'cracked', 'tingly', 'mom\'s spaghetti']
|
16
17
|
MOOD_DESC = ['calm', 'excited', 'depressed', 'tense', 'lackadaisical', 'angry', 'positive']
|
17
|
-
|
18
|
-
## ERRORS
|
19
|
-
ERROR_ATTACK_OPTION_INVALID = 'That will not do anything against the monster.'
|
20
18
|
|
21
19
|
attr_accessor :stam_cur, :stam_max, :cur_coords, :god_mode
|
22
20
|
|
@@ -63,6 +61,7 @@ module Gemwarrior
|
|
63
61
|
end
|
64
62
|
|
65
63
|
self_text = "NAME: #{name}\n"
|
64
|
+
self_text = "XY : #{cur_coords.values.to_a}\n"
|
66
65
|
self_text << "WPN : #{cur_weapon_name}\n"
|
67
66
|
self_text << "LVL : #{level}\n"
|
68
67
|
self_text << "XP : #{xp}\n"
|
@@ -129,106 +128,8 @@ module Gemwarrior
|
|
129
128
|
end
|
130
129
|
|
131
130
|
def attack(world, monster)
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
puts "#{monster.name} cries out: #{monster.battlecry}"
|
136
|
-
|
137
|
-
# first strike!
|
138
|
-
if calculate_first_strike(monster)
|
139
|
-
puts "#{monster.name} strikes first!"
|
140
|
-
player_attacked_by(monster)
|
141
|
-
end
|
142
|
-
|
143
|
-
# main battle loop
|
144
|
-
loop do
|
145
|
-
if (monster.hp_cur <= 0)
|
146
|
-
monster_death(world, monster)
|
147
|
-
return
|
148
|
-
elsif (hp_cur <= 0 && !god_mode)
|
149
|
-
player_death(monster)
|
150
|
-
end
|
151
|
-
|
152
|
-
puts
|
153
|
-
puts "[Fight/Attack][Look][Run]"
|
154
|
-
puts "P :: #{hp_cur} HP\n"
|
155
|
-
puts "M :: #{monster.hp_cur} HP\n"
|
156
|
-
|
157
|
-
if ((monster.hp_cur.to_f / monster.hp_max.to_f) < 0.10)
|
158
|
-
puts "#{monster.name} is almost dead!\n"
|
159
|
-
end
|
160
|
-
|
161
|
-
puts 'What do you do?'
|
162
|
-
cmd = gets.chomp.downcase
|
163
|
-
|
164
|
-
# player action
|
165
|
-
case cmd
|
166
|
-
when 'fight', 'f', 'attack', 'a'
|
167
|
-
puts "You attack #{monster.name}#{cur_weapon_name}!"
|
168
|
-
dmg = calculate_mob_damage
|
169
|
-
if dmg > 0
|
170
|
-
puts "You wound it for #{dmg} point(s)!"
|
171
|
-
monster.take_damage(dmg)
|
172
|
-
if (monster.hp_cur <= 0)
|
173
|
-
monster_death(world, monster)
|
174
|
-
return
|
175
|
-
end
|
176
|
-
else
|
177
|
-
puts "You miss entirely!"
|
178
|
-
end
|
179
|
-
when 'look', 'l'
|
180
|
-
puts "#{monster.name}: #{monster.description}"
|
181
|
-
puts "Its got some distinguishing features, too: face is #{monster.face}, hands are #{monster.hands}, and general mood is #{monster.mood}."
|
182
|
-
when 'run', 'r'
|
183
|
-
if player_escape?(monster)
|
184
|
-
monster.hp_cur = monster.hp_max
|
185
|
-
puts "You successfully elude #{monster.name}!"
|
186
|
-
return
|
187
|
-
else
|
188
|
-
puts "You were not able to run away! :-("
|
189
|
-
end
|
190
|
-
else
|
191
|
-
puts ERROR_ATTACK_OPTION_INVALID
|
192
|
-
end
|
193
|
-
|
194
|
-
# monster action
|
195
|
-
player_attacked_by(monster)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
private
|
200
|
-
|
201
|
-
# COMBAT
|
202
|
-
def update_player_stats(monster)
|
203
|
-
self.xp = xp + monster.xp
|
204
|
-
self.rox = rox + monster.rox
|
205
|
-
end
|
206
|
-
|
207
|
-
def monster_death(world, monster)
|
208
|
-
puts "You have defeated #{monster.name}!"
|
209
|
-
puts "You have received #{monster.xp} XP!"
|
210
|
-
puts "You have found #{monster.rox} barterable rox on your slain opponent!"
|
211
|
-
print_battle_line
|
212
|
-
update_player_stats(monster)
|
213
|
-
world.location_by_coords(cur_coords).remove_monster(monster.name)
|
214
|
-
end
|
215
|
-
|
216
|
-
def player_death(monster)
|
217
|
-
puts "You are dead, slain by the #{monster.name}!"
|
218
|
-
puts 'Your adventure ends here. Try again next time!'
|
219
|
-
print_battle_line
|
220
|
-
exit(0)
|
221
|
-
end
|
222
|
-
|
223
|
-
def player_attacked_by(monster)
|
224
|
-
puts "#{monster.name} attacks you!"
|
225
|
-
dmg = calculate_player_damage(monster)
|
226
|
-
if dmg > 0
|
227
|
-
puts "You are wounded for #{dmg} point(s)!"
|
228
|
-
take_damage(dmg)
|
229
|
-
else
|
230
|
-
puts "#{monster.name} misses entirely!"
|
231
|
-
end
|
131
|
+
battle = Battle.new({:world => world, :player => self, :monster => monster})
|
132
|
+
battle.start
|
232
133
|
end
|
233
134
|
|
234
135
|
def cur_weapon_name
|
@@ -236,56 +137,8 @@ module Gemwarrior
|
|
236
137
|
return " with your #{inventory.weapon.name}"
|
237
138
|
end
|
238
139
|
end
|
239
|
-
|
240
|
-
|
241
|
-
miss = rand(0..100)
|
242
|
-
if (miss < 15)
|
243
|
-
0
|
244
|
-
else
|
245
|
-
rand(atk_lo..atk_hi)
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
def calculate_player_damage(monster)
|
250
|
-
miss = rand(0..100)
|
251
|
-
if (miss < 15)
|
252
|
-
0
|
253
|
-
else
|
254
|
-
rand(monster.atk_lo..monster.atk_hi)
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
def calculate_first_strike(monster)
|
259
|
-
if (monster.dexterity > dexterity)
|
260
|
-
return true
|
261
|
-
else
|
262
|
-
dex_diff = dexterity - monster.dexterity
|
263
|
-
rand_dex = rand(0..dex_diff)
|
264
|
-
if rand_dex % 2 > 0
|
265
|
-
return true
|
266
|
-
else
|
267
|
-
return false
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end
|
271
|
-
|
272
|
-
def player_escape?(monster)
|
273
|
-
if (dexterity > monster.dexterity)
|
274
|
-
return true
|
275
|
-
else
|
276
|
-
dex_diff = monster.dexterity - dexterity
|
277
|
-
rand_dex = rand(0..dex_diff)
|
278
|
-
if rand_dex % 2 > 0
|
279
|
-
return true
|
280
|
-
else
|
281
|
-
return false
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
def take_damage(dmg)
|
287
|
-
self.hp_cur = hp_cur.to_i - dmg.to_i
|
288
|
-
end
|
140
|
+
|
141
|
+
private
|
289
142
|
|
290
143
|
# TRAVEL
|
291
144
|
def print_traveling_text
|
@@ -300,13 +153,13 @@ module Gemwarrior
|
|
300
153
|
# CHARACTER
|
301
154
|
def print_char_pic
|
302
155
|
char_pic = ""
|
303
|
-
char_pic << "
|
304
|
-
char_pic << "*
|
305
|
-
char_pic << "*
|
306
|
-
char_pic << "*
|
307
|
-
char_pic << "*
|
308
|
-
char_pic << "*
|
309
|
-
char_pic << "
|
156
|
+
char_pic << "************\n"
|
157
|
+
char_pic << "* () *\n"
|
158
|
+
char_pic << "* \\-||-/ *\n"
|
159
|
+
char_pic << "* -- *\n"
|
160
|
+
char_pic << "* || *\n"
|
161
|
+
char_pic << "* _||_ *\n"
|
162
|
+
char_pic << "************\n"
|
310
163
|
puts char_pic
|
311
164
|
end
|
312
165
|
|
data/lib/gemwarrior/evaluator.rb
CHANGED
@@ -28,13 +28,15 @@ module Gemwarrior
|
|
28
28
|
ERROR_DROP_PARAM_MISSING = 'You cannot just "drop". You gotta choose something to drop.'
|
29
29
|
ERROR_EQUIP_PARAM_MISSING = 'You cannot just "equip". You gotta choose something to equip.'
|
30
30
|
ERROR_UNEQUIP_PARAM_MISSING = 'You cannot just "unequip". You gotta choose something to unequip.'
|
31
|
+
ERROR_DEBUG_PARAM_MISSING = 'You cannot just "debug". You gotta choose a debug command.'
|
32
|
+
ERROR_DEBUG_PARAM_INVALID = 'You cannot debug that...yet.'
|
31
33
|
|
32
34
|
attr_accessor :world, :commands, :aliases, :descriptions, :devcmds, :devaliases
|
33
35
|
|
34
36
|
def initialize(world)
|
35
37
|
self.world = world
|
36
|
-
self.devcmds = %w(
|
37
|
-
self.devaliases = %w(
|
38
|
+
self.devcmds = %w(debug)
|
39
|
+
self.devaliases = %w(db)
|
38
40
|
self.commands = %w(character inventory list rest look take drop equip unequip go attack change help quit quit!)
|
39
41
|
self.aliases = %w(c i ls r l t d e ue g a ch h q qq)
|
40
42
|
self.descriptions = [
|
@@ -72,10 +74,21 @@ module Gemwarrior
|
|
72
74
|
|
73
75
|
case command
|
74
76
|
# dev commands
|
75
|
-
when '
|
76
|
-
|
77
|
-
|
78
|
-
|
77
|
+
when 'debug', 'db'
|
78
|
+
if param.nil?
|
79
|
+
ERROR_DEBUG_PARAM_MISSING
|
80
|
+
else
|
81
|
+
case param
|
82
|
+
when 'vars', 'v'
|
83
|
+
world.print_all_vars
|
84
|
+
when 'godmode', 'iddqd', 'god', 'g'
|
85
|
+
world.player.god_mode = !world.player.god_mode
|
86
|
+
when 'map', 'm'
|
87
|
+
world.print_map
|
88
|
+
else
|
89
|
+
ERROR_DEBUG_PARAM_INVALID
|
90
|
+
end
|
91
|
+
end
|
79
92
|
# normal commands
|
80
93
|
when 'character', 'c'
|
81
94
|
world.player.check_self
|
data/lib/gemwarrior/world.rb
CHANGED
@@ -7,6 +7,10 @@ require_relative 'entities/location'
|
|
7
7
|
module Gemwarrior
|
8
8
|
class World
|
9
9
|
# CONSTANTS
|
10
|
+
## WORLD DIMENSIONS
|
11
|
+
WORLD_DIM_WIDTH = 10
|
12
|
+
WORLD_DIM_HEIGHT = 10
|
13
|
+
|
10
14
|
## ERRORS
|
11
15
|
ERROR_LIST_PARAM_INVALID = 'That is not something that can be listed.'
|
12
16
|
|
@@ -18,7 +22,7 @@ module Gemwarrior
|
|
18
22
|
self.player = nil
|
19
23
|
end
|
20
24
|
|
21
|
-
def
|
25
|
+
def print_all_vars
|
22
26
|
puts "======================\n"
|
23
27
|
puts "All Variables in World\n"
|
24
28
|
puts "======================\n"
|
@@ -27,7 +31,32 @@ module Gemwarrior
|
|
27
31
|
puts "#{list("items", true)}\n\n"
|
28
32
|
puts "#{list("locations", true)}\n"
|
29
33
|
end
|
30
|
-
|
34
|
+
|
35
|
+
def print_map
|
36
|
+
0.upto(WORLD_DIM_HEIGHT-1) do |count_y|
|
37
|
+
print ' '
|
38
|
+
0.upto(WORLD_DIM_WIDTH-1) do
|
39
|
+
print '___'
|
40
|
+
end
|
41
|
+
print "\n"
|
42
|
+
print "#{(WORLD_DIM_HEIGHT-1) - count_y} "
|
43
|
+
0.upto(WORLD_DIM_WIDTH-1) do |count_x|
|
44
|
+
if location_by_coords({:x => count_x, :y => (WORLD_DIM_HEIGHT-1) - count_y})
|
45
|
+
print '|X|'
|
46
|
+
else
|
47
|
+
print '|_|'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
print "\n"
|
51
|
+
end
|
52
|
+
puts
|
53
|
+
print ' '
|
54
|
+
0.upto(WORLD_DIM_WIDTH-1) do |count_x|
|
55
|
+
print "#{count_x} "
|
56
|
+
end
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
31
60
|
def list(param, details = false)
|
32
61
|
case param
|
33
62
|
when 'players'
|
@@ -163,6 +192,7 @@ module Gemwarrior
|
|
163
192
|
require_relative 'entities/items/feather'
|
164
193
|
require_relative 'entities/items/gun'
|
165
194
|
require_relative 'entities/items/stalactite'
|
195
|
+
require_relative 'entities/items/stonemite'
|
166
196
|
require_relative 'entities/items/stone'
|
167
197
|
require_relative 'entities/items/tree'
|
168
198
|
|
@@ -189,12 +219,42 @@ module Gemwarrior
|
|
189
219
|
})
|
190
220
|
)
|
191
221
|
locations.push(Location.new({
|
192
|
-
:name => 'Cave (
|
193
|
-
:description => 'Now inside the
|
222
|
+
:name => 'Cave (Foyer)',
|
223
|
+
:description => 'Now inside the entrance to the cavern, you confirm that there are stacktites, stonemites, rocksites, and even one or two pebblejites.',
|
194
224
|
:coords => {:x => 7, :y => 0},
|
195
|
-
:locs_connected => {:north =>
|
225
|
+
:locs_connected => {:north => true, :east => true, :south => false, :west => true},
|
196
226
|
:danger_level => :moderate,
|
197
|
-
:items => [Stalactite.new],
|
227
|
+
:items => [Stalactite.new, Stonemite.new],
|
228
|
+
:monsters_available => monsters
|
229
|
+
})
|
230
|
+
)
|
231
|
+
locations.push(Location.new({
|
232
|
+
:name => 'Cave (Nook)',
|
233
|
+
:description => 'A depression in the cave wall casts a shadow over a small rock shelf.',
|
234
|
+
:coords => {:x => 7, :y => 1},
|
235
|
+
:locs_connected => {:north => false, :east => true, :south => true, :west => false},
|
236
|
+
:danger_level => :moderate,
|
237
|
+
:items => [],
|
238
|
+
:monsters_available => monsters
|
239
|
+
})
|
240
|
+
)
|
241
|
+
locations.push(Location.new({
|
242
|
+
:name => 'Cave (Dropoff)',
|
243
|
+
:description => 'Caves do not usually feature sudden chasms spilling down into an unknowable void, but this one does.',
|
244
|
+
:coords => {:x => 8, :y => 1},
|
245
|
+
:locs_connected => {:north => false, :east => false, :south => true, :west => true},
|
246
|
+
:danger_level => :moderate,
|
247
|
+
:items => [],
|
248
|
+
:monsters_available => monsters
|
249
|
+
})
|
250
|
+
)
|
251
|
+
locations.push(Location.new({
|
252
|
+
:name => 'Cave (Causeway)',
|
253
|
+
:description => 'Paths lead north and west, but nothing of interest is in this causeway.',
|
254
|
+
:coords => {:x => 8, :y => 0},
|
255
|
+
:locs_connected => {:north => true, :east => false, :south => false, :west => true},
|
256
|
+
:danger_level => :moderate,
|
257
|
+
:items => [],
|
198
258
|
:monsters_available => monsters
|
199
259
|
})
|
200
260
|
)
|
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:
|
4
|
+
version: 0.5.1
|
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-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: os
|
@@ -158,6 +158,7 @@ files:
|
|
158
158
|
- Rakefile
|
159
159
|
- bin/gemwarrior
|
160
160
|
- gemwarrior.gemspec
|
161
|
+
- lib/gemwarrior/battle.rb
|
161
162
|
- lib/gemwarrior/entities/creature.rb
|
162
163
|
- lib/gemwarrior/entities/entity.rb
|
163
164
|
- lib/gemwarrior/entities/item.rb
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- lib/gemwarrior/entities/items/gun.rb
|
167
168
|
- lib/gemwarrior/entities/items/stalactite.rb
|
168
169
|
- lib/gemwarrior/entities/items/stone.rb
|
170
|
+
- lib/gemwarrior/entities/items/stonemite.rb
|
169
171
|
- lib/gemwarrior/entities/items/tree.rb
|
170
172
|
- lib/gemwarrior/entities/location.rb
|
171
173
|
- lib/gemwarrior/entities/monster.rb
|