Class: H3m::Map
- Inherits:
-
Object
- Object
- H3m::Map
- Defined in:
- lib/h3m/map.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Map representation.
Instance Method Summary collapse
- #description ⇒ Object
- #difficulty ⇒ Object
- #file ⇒ Object
- #has_subterranean? ⇒ Boolean
-
#initialize(path) ⇒ Map
constructor
A new instance of Map.
- #name ⇒ Object
- #record ⇒ Object
- #size ⇒ Object
-
#version ⇒ Symbol
Get extension.
Constructor Details
#initialize(path) ⇒ Map
Returns a new instance of Map.
16 17 18 19 |
# File 'lib/h3m/map.rb', line 16 def initialize(path) @path = path @gzip_file = File.new(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Map representation
Example:
>> map = H3m::Map.new("some-map-file.h3m")
>> map.version
=> :SoD
14 15 16 |
# File 'lib/h3m/map.rb', line 14 def path @path end |
Instance Method Details
#description ⇒ Object
52 53 54 |
# File 'lib/h3m/map.rb', line 52 def description record.map_desc end |
#difficulty ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# 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 ⇒ Object
21 22 23 |
# File 'lib/h3m/map.rb', line 21 def file @file ||= Zlib::GzipReader.new(@gzip_file) end |
#has_subterranean? ⇒ Boolean
68 69 70 |
# File 'lib/h3m/map.rb', line 68 def has_subterranean? record.map_has_subterranean != 0 end |
#name ⇒ Object
48 49 50 |
# File 'lib/h3m/map.rb', line 48 def name record.map_name end |
#record ⇒ Object
72 73 74 |
# File 'lib/h3m/map.rb', line 72 def record @record ||= H3m::MapRecord.read(file) end |
#size ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# 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 ⇒ Symbol
Get extension
27 28 29 30 31 32 33 34 35 |
# 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 |