class H3m::Map

Attributes

path[R]

Map representation

Example:

>> map = H3m::Map.new("some-map-file.h3m")
>> map.version
=> :SoD

Public Class Methods

new(path) click to toggle source
# File lib/h3m/map.rb, line 16
def initialize(path)
  @path = path
  @gzip_file = File.new(path)
end

Public Instance Methods

description() click to toggle source
# File lib/h3m/map.rb, line 52
def description
  record.map_desc
end
difficulty() click to toggle source
# File lib/h3m/map.rb, line 56
def difficulty
  @difficulty ||= case record.map_difficulty
    when 0 then :easy
    when 1 then :normal
    when 2 then :hard
    when 3 then :expert
    when 4 then :impossible
    else
      raise MapError, "unknown map difficulty"
  end
end
file() click to toggle source
# File lib/h3m/map.rb, line 21
def file
  @file ||= Zlib::GzipReader.new(@gzip_file)
end
has_subterranean?() click to toggle source
# File lib/h3m/map.rb, line 68
def has_subterranean?
  record.map_has_subterranean != 0
end
name() click to toggle source
# File lib/h3m/map.rb, line 48
def name
  record.map_name
end
record() click to toggle source
# File lib/h3m/map.rb, line 72
def record
  @record ||= H3m::MapRecord.read(file)
end
size() click to toggle source
# File lib/h3m/map.rb, line 37
def size
  @size ||= case record.map_size
    when 36  then :S
    when 72  then :M
    when 108 then :L
    when 144 then :XL
    else
      raise MapError, "unknown map size"
  end
end
version() click to toggle source

Get extension @return [Symbol] :SoD, :AB or :RoE

# File lib/h3m/map.rb, line 27
def version
  @version ||= case record.heroes_version
    when 0x0E then :RoE
    when 0x15 then :AB
    when 0x1C then :SoD
    else
      raise MapError, "unknown map version"
  end
end