Class: TF2LineParser::Events::HeadshotDamage
- Defined in:
- lib/tf2_line_parser/events/headshot_damage.rb
Instance Attribute Summary
Attributes inherited from Damage
#crit, #damage, #headshot, #healing, #realdamage
Attributes inherited from Event
#airshot, #cap_name, #cap_number, #customkill, #healing, #item, #length, #message, #method, #player, #role, #score, #target, #team, #time, #type, #ubercharge, #unknown, #value, #weapon
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, headshot) ⇒ HeadshotDamage
constructor
A new instance of HeadshotDamage.
Methods inherited from Damage
regex_crit, regex_damage_against, regex_healing, regex_realdamage, regex_weapon
Methods inherited from Event
parse_player_section, parse_target_section, #parse_time, regex_cap, regex_console, regex_message, regex_player, regex_target, regex_time, time_format, types
Constructor Details
#initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, headshot) ⇒ HeadshotDamage
Returns a new instance of HeadshotDamage.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/tf2_line_parser/events/headshot_damage.rb', line 41 def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, headshot) @time = parse_time(time) @player = Player.new(player_name, player_uid, player_steamid, player_team) @target = Player.new(target_name, target_uid, target_steamid, target_team) if target_name @value = value.to_i @damage = @value @realdamage = realdamage.to_i if realdamage && !realdamage.empty? @weapon = weapon @healing = healing.to_i if healing @crit = crit @headshot = true # Always true for HeadshotDamage events end |
Class Method Details
.attributes ⇒ Object
14 15 16 |
# File 'lib/tf2_line_parser/events/headshot_damage.rb', line 14 def self.attributes @attributes ||= %i[time player_section target_section value realdamage weapon healing crit headshot] end |
.regex ⇒ Object
6 7 8 |
# File 'lib/tf2_line_parser/events/headshot_damage.rb', line 6 def self.regex @regex ||= /#{regex_time} #{regex_player} triggered "damage" #{regex_damage_against}\(damage "(?'value'\d+)"\)#{regex_realdamage}#{regex_weapon}#{regex_healing}#{regex_crit} #{regex_headshot}$/.freeze end |
.regex_headshot ⇒ Object
10 11 12 |
# File 'lib/tf2_line_parser/events/headshot_damage.rb', line 10 def self.regex_headshot @regex_headshot ||= '\(headshot "(?\'headshot\'\d+)"\)' end |
.regex_results(matched_line) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tf2_line_parser/events/headshot_damage.rb', line 18 def self.regex_results(matched_line) time = matched_line['time'] player_section = matched_line['player_section'] target_section = matched_line['target_section'] value = matched_line['value'] realdamage = matched_line['realdamage'] weapon = matched_line['weapon'] healing = matched_line['healing'] crit = matched_line['crit'] headshot = matched_line['headshot'] # Parse player section player_name, player_uid, player_steamid, player_team = parse_player_section(player_section) # Parse target section if present target_name, target_uid, target_steamid, target_team = nil, nil, nil, nil if target_section target_name, target_uid, target_steamid, target_team = parse_target_section(target_section) end [time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, headshot] end |