lib/gemwarrior/world.rb in gemwarrior-0.9.8 vs lib/gemwarrior/world.rb in gemwarrior-0.9.9
- old
+ new
@@ -1,17 +1,18 @@
# lib/gemwarrior/world.rb
# World where the locations, monsters, items, etc. exist
require 'yaml'
+require 'pry'
require_relative 'entities/item'
require_relative 'entities/location'
module Gemwarrior
class World
# CONSTANTS
- LOCATION_DATA_FILE = "data/locations.yml"
+ LOCATION_DATA_FILE = File.expand_path('../../../data/locations.yml', __FILE__)
WORLD_DIM_WIDTH = 10
WORLD_DIM_HEIGHT = 10
## ERRORS
ERROR_LIST_PARAM_INVALID = 'That is not something that can be listed.'
@@ -246,15 +247,15 @@
end
return bosses
end
def init_monsters
- Dir.glob('lib/gemwarrior/entities/monsters/*.rb').each do |item|
- require_relative item[item.index('/', item.index('/')+1)+1..item.length]
+ Dir.glob(File.expand_path('../entities/monsters/*.rb', __FILE__)).each do |item|
+ require_relative item
end
- Dir.glob('lib/gemwarrior/entities/monsters/bosses/*.rb').each do |item|
- require_relative item[item.index('/', item.index('/')+1)+1..item.length]
+ Dir.glob(File.expand_path('../entities/monsters/bosses/*.rb', __FILE__)).each do |item|
+ require_relative item
end
self.monsters = [
Alexandrat.new,
Amberoo.new,
@@ -270,11 +271,11 @@
Garynetty.new
]
end
def init_locations
- Dir.glob('lib/gemwarrior/entities/items/*.rb').each do |item|
- require_relative item[item.index('/', item.index('/')+1)+1..item.length]
+ Dir.glob(File.expand_path('../entities/items/*.rb', __FILE__)).each do |item|
+ require_relative item
end
locations = []
location_data = YAML.load_file(LOCATION_DATA_FILE)