Class: Adam::Kill

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

Overview

Instances of the Kill class represent a kill in the EVE Online universe.

Accessors:

  • eve_id - The EVE ID of the killmail. This is only populated if the kill was derived from a kill log.

  • time - A time object set to the time of the kill.

  • solar_system - A solar system object (see the SolarSystem class).

  • victim - A victim object (see the Victim class).

  • solar_system - A solar system object (see the SolarSystem class).

  • involved_parties - An array of involved party objects (see the InvolvedParty class).

  • loot - An array of loot objects (see the Loot class).

Defined Under Namespace

Classes: InvolvedParty, Loot, SolarSystem, Victim

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Kill

Returns a new instance of Kill.

Yields:

  • (_self)

Yield Parameters:

  • _self (Adam::Kill)

    the object that the method was called on



18
19
20
# File 'lib/adam/kill.rb', line 18

def initialize
  yield self if block_given?
end

Instance Attribute Details

#eve_idObject

Returns the value of attribute eve_id.



16
17
18
# File 'lib/adam/kill.rb', line 16

def eve_id
  @eve_id
end

#involved_partiesObject

Returns the value of attribute involved_parties.



16
17
18
# File 'lib/adam/kill.rb', line 16

def involved_parties
  @involved_parties
end

#lootObject

Returns the value of attribute loot.



16
17
18
# File 'lib/adam/kill.rb', line 16

def loot
  @loot
end

#solar_systemObject

Returns the value of attribute solar_system.



16
17
18
# File 'lib/adam/kill.rb', line 16

def solar_system
  @solar_system
end

#timeObject

Returns the value of attribute time.



16
17
18
# File 'lib/adam/kill.rb', line 16

def time
  @time
end

#victimObject

Returns the value of attribute victim.



16
17
18
# File 'lib/adam/kill.rb', line 16

def victim
  @victim
end

Instance Method Details

#digestObject

Calculates the message digest of the killmail.



107
108
109
110
111
112
# File 'lib/adam/kill.rb', line 107

def digest
  string = "#{time}#{victim.pilot}#{victim.ship}#{solar_system.name}#{victim.damage_taken}"
  involved_parties.sort! { |x, y| x.damage_done <=> y.damage_done }
  involved_parties.each { |p| string << "#{p.pilot}#{p.damage_done}" }
  Digest::MD5.hexdigest(string)
end

#to_killmailObject Also known as: to_s

Reverse-engineer the killmail. This is particularly useful if it was originally derived from a kill log.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/adam/kill.rb', line 24

def to_killmail

  killmail = ""
  killmail << time.strftime("%Y.%m.%d %H:%M\n")
  killmail << "\n"
  killmail << "Victim: #{victim.pilot}\n"
  killmail << "Corp: #{victim.corporation}\n"
  killmail << "Alliance: #{victim.alliance}\n" if victim.alliance
  killmail << "Alliance: Unknown\n" if victim.alliance.nil?
  killmail << "Faction: #{victim.faction}\n" if victim.faction
  killmail << "Faction: NONE\n" if victim.faction.nil?
  killmail << "Destroyed: #{victim.ship}\n"
  killmail << "System: #{solar_system.name}\n"
  killmail << "Security: #{solar_system.security_status.round(2)}\n"
  killmail << "Damage Taken: #{victim.damage_taken}\n"
  killmail << "\n"
  killmail << "Involved parties:\n"
  killmail << "\n"
  
  involved_parties.each do |involved_party|
    
    if involved_party.pc?
      killmail << "Name: #{involved_party.pilot} (laid the final blow)\n" if involved_party.final_blow
      killmail << "Name: #{involved_party.pilot}\n" unless involved_party.final_blow
      killmail << "Security: #{involved_party.security_status.round(2)}\n"
      killmail << "Corp: #{involved_party.corporation}\n"
      killmail << "Alliance: #{involved_party.alliance}\n" if involved_party.alliance
      killmail << "Alliance: NONE\n" if involved_party.alliance.nil?
      killmail << "Faction: #{involved_party.faction}\n" if involved_party.faction
      killmail << "Faction: NONE\n" if involved_party.faction.nil?
      killmail << "Ship: #{involved_party.ship}\n"
      killmail << "Weapon: #{involved_party.weapon}\n"
      killmail << "Damage Done: #{involved_party.damage_done}\n"
      killmail << "\n"
    end
        
    if involved_party.npc?
      killmail << "Name: #{involved_party.ship} / #{involved_party.corporation or involved_party.faction} (laid the final blow)\n" if involved_party.final_blow
      killmail << "Name: #{involved_party.ship} / #{involved_party.corporation or involved_party.faction}\n" unless involved_party.final_blow
      killmail << "Damage Done: #{involved_party.damage_done}\n"
      killmail << "\n" 
    end
    
  end

  destroyed_items = loot.select { |l| l.dropped == false }
  unless destroyed_items.empty?
    killmail << "\n"
    killmail << "Destroyed items:\n"
    killmail << "\n"
    destroyed_items.each do |loot|
      killmail << "#{loot.name}"
      killmail << ", Qty: #{loot.quantity}" if loot.quantity > 1
      killmail << " (Cargo)"        if loot.location == :cargo_bay
      killmail << " (Drone Bay)"    if loot.location == :drone_bay
      killmail << " (Implant)"      if loot.location == :implant
      killmail << " (Copy) (Cargo)" if loot.location == :copy
      killmail << "\n"
    end
  end

  dropped_items = loot.select { |l| l.dropped == true }
  unless dropped_items.empty?
    killmail << "\n"
    killmail << "Dropped items:\n"
    killmail << "\n"
    dropped_items.each do |loot|
      killmail << "#{loot.name}"
      killmail << ", Qty: #{loot.quantity}" if loot.quantity > 1
      killmail << " (Cargo)"        if loot.location == :cargo_bay
      killmail << " (Drone Bay)"    if loot.location == :drone_bay
      killmail << " (Implant)"      if loot.location == :implant
      killmail << " (Copy) (Cargo)" if loot.location == :copy
      killmail << "\n"
    end
  end

  killmail
end