class Object

Constants

TEA_ZONE_ID

Public Instance Methods

calc_end_phase(fight) click to toggle source
# File lib/purtea/cli.rb, line 19
def calc_end_phase(fight) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  return '???' unless fight.zone_id == TEA_ZONE_ID

  return 'N/A' if fight.boss_percentage.nil? || fight.fight_percentage.nil?

  if fight.boss_percentage.zero? && fight.fight_percentage >= 80.0
    return 'Living Liquid (LL)'
  end

  if fight.boss_percentage.positive? && fight.fight_percentage > 75.0
    return 'Living Liquid (LL)'
  end

  if fight.boss_percentage.zero? && float_comp(fight.fight_percentage, 75.0)
    return 'Limit Cut (LC)'
  end

  if fight.fight_percentage >= 50.0 && fight.fight_percentage <= 75.0 &&
     fight.boss_percentage >= 0.0
    return 'Brute Justice / Cruise Chaser (BJ/CC)'
  end

  if fight.fight_percentage <= 50.0 && fight.fight_percentage >= 30.0
    return 'Alexander Prime (AP)'
  end

  'Perfect Alexander (PA)'
end
float_comp(first, second) click to toggle source
# File lib/purtea/cli.rb, line 15
def float_comp(first, second)
  (first - second).abs < Float::EPSILON
end
format_percentage(percentage) click to toggle source
# File lib/purtea/cli.rb, line 7
def format_percentage(percentage)
  if percentage.nil?
    'N/A'
  else
    format('%.2f%%', percentage)
  end
end
parse_fight(fight) click to toggle source
# File lib/purtea/cli.rb, line 48
def parse_fight(fight) # rubocop:disable Metrics/AbcSize
  [
    fight.id,
    fight.encounter_id,
    fight.zone_id,
    fight.zone_name,
    fight.name,
    fight.difficulty,
    format_percentage(fight.boss_percentage),
    format_percentage(fight.fight_percentage),
    fight.start_at.strftime(Purtea::FFLogs::Fight::ISO_FORMAT),
    fight.end_at.strftime(Purtea::FFLogs::Fight::ISO_FORMAT),
    fight.duration.strftime('%H:%M:%S'),
    calc_end_phase(fight),
    fight.kill? ? 'Y' : 'N'
  ]
end