class Purtea::FFLogs::Fight

Describes a fight entry in FF Logs.

Constants

ISO_FORMAT

Attributes

boss_percentage[R]
difficulty[R]
duration[R]
encounter_id[R]
end_at[R]
fight_percentage[R]
id[R]
name[R]
start_at[R]
zone_id[R]
zone_name[R]

Public Class Methods

new(data, report_start_ms) click to toggle source

rubocop:disable Metrics/AbcSize

# File lib/purtea/fflogs/fight.rb, line 14
def initialize(data, report_start_ms)
  @id = data.id
  @encounter_id = data.encounter_id
  @zone_id = data.game_zone.id
  @name = data.name
  @zone_name = data.game_zone.name
  @difficulty = data.difficulty
  @boss_percentage = data.boss_percentage
  @fight_percentage = data.fight_percentage
  @start_at = parse_fight_timestamp report_start_ms, data.start_time
  @end_at = parse_fight_timestamp report_start_ms, data.end_time
  @kill = data.kill
  @duration = parse_duration @start_at, @end_at
end

Public Instance Methods

kill?() click to toggle source

rubocop:enable Metrics/AbcSize

# File lib/purtea/fflogs/fight.rb, line 30
def kill?
  @kill
end
to_s() click to toggle source
# File lib/purtea/fflogs/fight.rb, line 34
def to_s
  start_f = start_at.strftime(ISO_FORMAT)
  end_f = end_at.strftime(ISO_FORMAT)
  duration = Time.at(end_at - start_at).utc.strftime('%H:%M:%S')
  kw = kill? ? 'CLEAR' : 'WIPE'
  "[#{@id}] #{start_f} -> #{end_f} [#{duration}] " \
    "#{boss_percentage}% (#{fight_percentage}%) - #{kw}"
end

Private Instance Methods

parse_duration(start_at, end_at) click to toggle source
# File lib/purtea/fflogs/fight.rb, line 49
def parse_duration(start_at, end_at)
  Time.at(end_at - start_at).utc
end
parse_fight_timestamp(report_start_ms, time) click to toggle source
# File lib/purtea/fflogs/fight.rb, line 45
def parse_fight_timestamp(report_start_ms, time)
  Time.at(0, report_start_ms + time, :millisecond)
end