Class: Avm::MaysMagicalSchool::Builders::YamlStages::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/mays_magical_school/builders/yaml_stages/stage.rb

Instance Method Summary collapse

Instance Method Details

#objectsObject



34
35
36
37
38
# File 'lib/avm/mays_magical_school/builders/yaml_stages/stage.rb', line 34

def objects
  stage.objects.map do |obj|
    { type: obj.type, x: obj.coord.x, y: obj.coord.y }
  end
end

#performObject



14
15
16
17
# File 'lib/avm/mays_magical_school/builders/yaml_stages/stage.rb', line 14

def perform
  target_path.parent.mkpath
  ::EacRubyUtils::Yaml.dump_file(target_path, target_data)
end

#target_dataObject



19
20
21
22
23
24
# File 'lib/avm/mays_magical_school/builders/yaml_stages/stage.rb', line 19

def target_data
  {
    objects: objects,
    terrain: terrains_to_s
  }
end

#target_pathObject



26
27
28
# File 'lib/avm/mays_magical_school/builders/yaml_stages/stage.rb', line 26

def target_path
  builder.yaml_stages_dir.join("#{number}.yaml")
end

#terrains_to_sObject



30
31
32
# File 'lib/avm/mays_magical_school/builders/yaml_stages/stage.rb', line 30

def terrains_to_s
  stage.size.y.times.map { |y| terrains_row_to_s(y) + "\n" }.join
end