Skip to content

Commit fdc7934

Browse files
committed
Merge pull request ryanb#32 from pejuko/path
dynamicaly create load_path
2 parents 94dc735 + 7992ca2 commit fdc7934

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/ruby_warrior/level.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ def player_path
2424
end
2525

2626
def load_path
27-
@profile.tower_path + "/level_" + @number.to_s.rjust(3, '0') + ".rb"
27+
File.join(
28+
File.expand_path(File.dirname(__FILE__) + '/../../towers/'),
29+
File.basename(@profile.tower_path) + "/level_" +
30+
@number.to_s.rjust(3, '0') + ".rb"
31+
)
2832
end
2933

3034
def load_level

lib/ruby_warrior/profile.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def epic_score_with_grade
6262
end
6363

6464
def tower
65-
Tower.new(@tower_path)
65+
Tower.new(File.basename @tower_path)
6666
end
6767

6868
def current_level

lib/ruby_warrior/tower.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class Tower
33
attr_reader :path
44

55
def initialize(path)
6-
@path = path
6+
@path = File.join(File.expand_path(File.dirname(__FILE__) + '/../../towers/'), path)
77
end
88

99
def name

0 commit comments

Comments
 (0)