Class: RubyWarrior::LevelLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_warrior/level_loader.rb

Instance Method Summary collapse

Constructor Details

#initialize(level) ⇒ LevelLoader

Returns a new instance of LevelLoader.



3
4
5
6
7
# File 'lib/ruby_warrior/level_loader.rb', line 3

def initialize(level)
  @floor = RubyWarrior::Floor.new
  @level = level
  @level.floor = @floor
end

Instance Method Details

#ace_score(score) ⇒ Object



25
26
27
# File 'lib/ruby_warrior/level_loader.rb', line 25

def ace_score(score)
  @level.ace_score = score
end

#clue(clue) ⇒ Object



17
18
19
# File 'lib/ruby_warrior/level_loader.rb', line 17

def clue(clue)
  @level.clue = clue
end

#description(desc) ⇒ Object



9
10
11
# File 'lib/ruby_warrior/level_loader.rb', line 9

def description(desc)
  @level.description = desc
end

#size(width, height) ⇒ Object



29
30
31
32
# File 'lib/ruby_warrior/level_loader.rb', line 29

def size(width, height)
  @floor.width = width
  @floor.height = height
end

#stairs(x, y) ⇒ Object



34
35
36
# File 'lib/ruby_warrior/level_loader.rb', line 34

def stairs(x, y)
  @floor.place_stairs(x, y)
end

#time_bonus(bonus) ⇒ Object



21
22
23
# File 'lib/ruby_warrior/level_loader.rb', line 21

def time_bonus(bonus)
  @level.time_bonus = bonus
end

#tip(tip) ⇒ Object



13
14
15
# File 'lib/ruby_warrior/level_loader.rb', line 13

def tip(tip)
  @level.tip = tip
end

#unit(unit, x, y, facing = :north) {|unit| ... } ⇒ Object

Yields:



38
39
40
41
42
43
# File 'lib/ruby_warrior/level_loader.rb', line 38

def unit(unit, x, y, facing = :north)
  unit = unit_to_constant(unit).new unless unit.kind_of? Units::Base
  @floor.add(unit, x, y, facing)
  yield unit if block_given?
  unit
end

#warrior(*args, &block) ⇒ Object



45
46
47
# File 'lib/ruby_warrior/level_loader.rb', line 45

def warrior(*args, &block)
  @level.setup_warrior unit(Units::Warrior.new, *args, &block)
end