Class: Wowlog::ColumnParser

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

Overview


Basic class for all column parser


Constant Summary collapse

UNIT_FLAG_MAP =
{
  0x00000001 => 'AFFILIATION_MINE',
  0x00000002 => 'AFFILIATION_PARTY',
  0x00000004 => 'AFFILIATION_RAID',
  0x00000008 => 'AFFILIATION_OUTSIDER',
  0x00000010 => 'REACTION_FRIENDLY',
  0x00000020 => 'REACTION_NEUTRAL',
  0x00000040 => 'REACTION_HOSTILE',
  0x00000100 => 'CONTROL_PLAYER',
  0x00000200 => 'CONTROL_NPC',
  0x00000400 => 'TYPE_PLAYER',
  0x00000800 => 'TYPE_NPC',
  0x00001000 => 'TYPE_PET',
  0x00002000 => 'TYPE_GUARDIAN',
  0x00004000 => 'TYPE_OBJECT',
}
OBJECT_SPECIAL_MASK =
0xFFFF0000
UNIT_SPECIAL_FLAG_MAP =
{
  0x00010000 => 'TARGET',
  0x00020000 => 'FOCUS',
  0x00040000 => 'MAINTANK',
  0x00080000 => 'MAINASSIST',
  0x00100000 => 'RAIDTARGET1',
  0x00200000 => 'RAIDTARGET2',
  0x00400000 => 'RAIDTARGET3',
  0x00800000 => 'RAIDTARGET4',
  0x01000000 => 'RAIDTARGET5',
  0x02000000 => 'RAIDTARGET6',
  0x04000000 => 'RAIDTARGET7',
  0x08000000 => 'RAIDTARGET8',
  0x80000000 => 'NONE',
}
SCHOOL_FLAG_MAP =
{
  0x1 => 'Physical',
  0x2 => 'Holy',
  0x4 => 'Fire',
  0x8 => 'Nature',
  0x10 => 'Frost',
  0x20 => 'Shadow',
  0x40 => 'Arcane',
}
PT_MAP =
{
  -2 => 'health',
  0 => 'mana',
  1 => 'rage',
  2 => 'focus',
  3 => 'energy',
  4 => 'pet happiness',
  5 => 'runes',
  6 => 'runic power'
}

Instance Method Summary collapse

Constructor Details

#initializeColumnParser

Returns a new instance of ColumnParser.



99
100
101
# File 'lib/wowlog.rb', line 99

def initialize
  @flag_cache = {}
end

Instance Method Details

#int(v) ⇒ Object



127
# File 'lib/wowlog.rb', line 127

def int(v); return v.to_i; end

#parse(cols, obj = {}) ⇒ Object



128
# File 'lib/wowlog.rb', line 128

def parse(cols, obj = {}); return cols, obj; end

#parse_school_flag(val) ⇒ Object



118
119
120
121
122
# File 'lib/wowlog.rb', line 118

def parse_school_flag(val)
  f = val.hex
  res = SCHOOL_FLAG_MAP.select { |k, v| (f & k) > 0 }
  return res.values
end

#parse_unit_flag(val) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/wowlog.rb', line 103

def parse_unit_flag(val)
  f = val.hex
  return [] if f == 0
  return @flag_cache[f] unless @flag_cache[f].nil?

  res = []
  UNIT_FLAG_MAP.each { |k, v| res.push(v) if (f & k) > 0 }
  if (f & OBJECT_SPECIAL_MASK) > 0
    UNIT_SPECIAL_FLAG_MAP.each { |k, v| res.push(v) if (f & k) > 0 }
  end

  @flag_cache[f] = res
  return res
end

#resolv_power_type(pt) ⇒ Object



124
# File 'lib/wowlog.rb', line 124

def resolv_power_type(pt); return PT_MAP[pt]; end