Class: Purtea::FFLogs::Fight

Inherits:
Object
  • Object
show all
Defined in:
lib/purtea/fflogs/fight.rb

Overview

Describes a fight entry in FF Logs.

Constant Summary collapse

ISO_FORMAT =
'%Y-%m-%dT%H:%M:%S%:z'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, report_start_ms) ⇒ Fight

rubocop:disable Metrics/AbcSize



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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

Instance Attribute Details

#boss_percentageObject (readonly)

Returns the value of attribute boss_percentage.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def boss_percentage
  @boss_percentage
end

#difficultyObject (readonly)

Returns the value of attribute difficulty.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def difficulty
  @difficulty
end

#durationObject (readonly)

Returns the value of attribute duration.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def duration
  @duration
end

#encounter_idObject (readonly)

Returns the value of attribute encounter_id.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def encounter_id
  @encounter_id
end

#end_atObject (readonly)

Returns the value of attribute end_at.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def end_at
  @end_at
end

#fight_percentageObject (readonly)

Returns the value of attribute fight_percentage.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def fight_percentage
  @fight_percentage
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def name
  @name
end

#start_atObject (readonly)

Returns the value of attribute start_at.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def start_at
  @start_at
end

#zone_idObject (readonly)

Returns the value of attribute zone_id.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def zone_id
  @zone_id
end

#zone_nameObject (readonly)

Returns the value of attribute zone_name.



9
10
11
# File 'lib/purtea/fflogs/fight.rb', line 9

def zone_name
  @zone_name
end

Instance Method Details

#kill?Boolean

rubocop:enable Metrics/AbcSize

Returns:

  • (Boolean)


30
31
32
# File 'lib/purtea/fflogs/fight.rb', line 30

def kill?
  @kill
end

#to_sObject



34
35
36
37
38
39
40
41
# 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