tf2_line_parser 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ccca85756ff65c53f9ae713abb9b065ff9fbd5fc4141bd936c7f36726f35ddb
4
- data.tar.gz: b791765db72f6cbb01c19ebe2ed85b408633359fe6ce463e713e914162ebf41c
3
+ metadata.gz: 8e3baffd4d9ebddf470c688dcc95d494a7067f97a751840a11937037a4c628c4
4
+ data.tar.gz: 06ff3fdc7686e001118279e09c66cbec031984076255edd5a125933f88a63e12
5
5
  SHA512:
6
- metadata.gz: 46b65da5de6c037e0b092149837f0dc8614a3c3f79ea64f82bda2ab0263e81b14763c86bd71d74feaaa15401d42538eb7bb3fd030848e811b09177492187471b
7
- data.tar.gz: a77d21150501dff565387b89bbdb07017d5739705fb30e1e442aef90bcddfab79071da01a92e88011dec8997530cd73aa2e18875d3c7982767a0a44bdce6504a
6
+ metadata.gz: d821617dfb99fe6a74ab3d109b6394a6ed76bcc729e7bfd3dba2eaaacf0a607be3765a318ce6cf8e3da2ac8c6d91d243e324a689729978a30598b8a07997a103
7
+ data.tar.gz: '047989cfbe3fd4fb6257d059c79aa2046692e18cca068b76873864f5c740a209ebc765ea9f01983156581ce1187754f33c9eee61fc44e83b6da8b09f6e70f7ef'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tf2_line_parser (0.6.0)
4
+ tf2_line_parser (0.6.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,8 +4,8 @@ module TF2LineParser
4
4
  module Events
5
5
  class Airshot < Damage
6
6
  def self.regex
7
- # Airshot can appear after weapon, with optional height at the end
8
- @regex ||= /#{regex_time} #{regex_player} triggered "damage" #{regex_damage_against}\(damage "(?'value'\d+)"\)#{regex_realdamage}#{regex_weapon}#{regex_airshot}#{regex_height}/.freeze
7
+ # Airshot can appear after weapon, with optional crit/healing between weapon and airshot
8
+ @regex ||= /#{regex_time} #{regex_player} triggered "damage" #{regex_damage_against}\(damage "(?'value'\d+)"\)#{regex_realdamage}#{regex_weapon}#{regex_healing}#{regex_crit}#{regex_airshot}#{regex_height}/.freeze
9
9
  end
10
10
 
11
11
  def self.regex_airshot
@@ -17,7 +17,7 @@ module TF2LineParser
17
17
  end
18
18
 
19
19
  def self.attributes
20
- @attributes ||= %i[time player_section target_section realdamage weapon airshot]
20
+ @attributes ||= %i[time player_section target_section realdamage weapon healing crit airshot]
21
21
  end
22
22
 
23
23
  def self.regex_results(matched_line)
@@ -27,6 +27,8 @@ module TF2LineParser
27
27
  value = matched_line['value']
28
28
  realdamage = matched_line['realdamage']
29
29
  weapon = matched_line['weapon']
30
+ healing = matched_line['healing']
31
+ crit = matched_line['crit']
30
32
  airshot = matched_line['airshot']
31
33
 
32
34
  # Parse player section
@@ -38,10 +40,10 @@ module TF2LineParser
38
40
  target_name, target_uid, target_steamid, target_team = parse_target_section(target_section)
39
41
  end
40
42
 
41
- [time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, airshot]
43
+ [time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, airshot]
42
44
  end
43
45
 
44
- def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, airshot)
46
+ def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, airshot)
45
47
  @time = parse_time(time)
46
48
  @player = Player.new(player_name, player_uid, player_steamid, player_team)
47
49
  @target = Player.new(target_name, target_uid, target_steamid, target_team) if target_name
@@ -49,8 +51,8 @@ module TF2LineParser
49
51
  @damage = @value
50
52
  @realdamage = realdamage.to_i if realdamage && !realdamage.empty?
51
53
  @weapon = weapon
52
- @healing = nil
53
- @crit = nil
54
+ @healing = healing.to_i if healing
55
+ @crit = crit
54
56
  @headshot = nil
55
57
  @airshot = (airshot.to_i == 1)
56
58
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TF2LineParser
4
+ module Events
5
+ class FeignDeath < PVPEvent
6
+ def self.regex
7
+ @regex ||= /#{regex_time} #{regex_player} killed #{regex_target} #{regex_weapon} #{regex_customkill}/.freeze
8
+ end
9
+
10
+ def self.regex_weapon
11
+ @regex_weapon ||= 'with "(?\'weapon\'\w*)"'
12
+ end
13
+
14
+ def self.regex_customkill
15
+ @regex_customkill ||= /\(customkill "feign_death"\)/.freeze
16
+ end
17
+
18
+ def self.attributes
19
+ @attributes ||= %i[time player_section target_section weapon]
20
+ end
21
+
22
+ def initialize(time, player_name, player_uid, player_steam_id, player_team, target_name, target_uid, target_steam_id, target_team, weapon)
23
+ @time = parse_time(time)
24
+ @player = Player.new(player_name, player_uid, player_steam_id, player_team)
25
+ @target = Player.new(target_name, target_uid, target_steam_id, target_team)
26
+ @weapon = weapon
27
+ end
28
+ end
29
+ end
30
+ end
@@ -26,6 +26,7 @@ module TF2LineParser
26
26
  @weapon = weapon
27
27
  @customkill = customkill
28
28
  end
29
+
29
30
  end
30
31
  end
31
32
  end
@@ -53,8 +53,12 @@ module TF2LineParser
53
53
  'position_report' => [Events::PositionReport],
54
54
  }.freeze
55
55
 
56
- # Fallback types when no keyword matches
56
+ # Fallback types when no keyword matches - ordered by specificity
57
57
  FALLBACK_TYPES = [
58
+ Events::FeignDeath, Events::Kill, Events::PositionReport,
59
+ Events::TeamSay, Events::Say, Events::PickupItem,
60
+ Events::JoinedTeam, Events::EnteredGame, Events::RoleChange,
61
+ Events::Spawn, Events::Suicide, Events::Connect, Events::Disconnect,
58
62
  Events::CurrentScore, Events::FinalScore, Events::RconCommand,
59
63
  Events::ConsoleSay, Events::Unknown
60
64
  ].freeze
@@ -105,34 +109,7 @@ module TF2LineParser
105
109
  end
106
110
  end
107
111
 
108
- # Check other common patterns with simple string operations
109
- if line.include?('" killed "')
110
- [Events::Kill]
111
- elsif line.include?('position_report')
112
- [Events::PositionReport]
113
- elsif line.include?('" say_team "')
114
- [Events::TeamSay]
115
- elsif line.include?('" say "')
116
- [Events::Say]
117
- elsif line.include?('picked up item')
118
- [Events::PickupItem]
119
- elsif line.include?('joined team "')
120
- [Events::JoinedTeam]
121
- elsif line.include?('entered the game')
122
- [Events::EnteredGame]
123
- elsif line.include?('changed role to')
124
- [Events::RoleChange]
125
- elsif line.include?('spawned as "')
126
- [Events::Spawn]
127
- elsif line.include?('committed suicide')
128
- [Events::Suicide]
129
- elsif line.include?('connected, address')
130
- [Events::Connect]
131
- elsif line.include?('disconnected (reason')
132
- [Events::Disconnect]
133
- else
134
- FALLBACK_TYPES
135
- end
112
+ FALLBACK_TYPES
136
113
  end
137
114
 
138
115
  def try_parse_types(line, types)
@@ -157,7 +134,7 @@ module TF2LineParser
157
134
  if suffix.include?('(headshot "')
158
135
  [Events::HeadshotDamage]
159
136
  elsif suffix.include?('(airshot "')
160
- [Events::Airshot]
137
+ [Events::Airshot, Events::Damage]
161
138
  else
162
139
  [Events::Damage]
163
140
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TF2LineParser
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.2'
5
5
  end
@@ -5,3 +5,4 @@ L 12/18/2025 - 22:10:55: "fy<14><[U:1:442791013]><Blue>" triggered "damage" agai
5
5
  L 12/18/2025 - 22:12:57: "tantwo<17><[U:1:191375689]><Blue>" triggered "damage" against "keicam<9><[U:1:163231154]><Red>" (damage "105") (weapon "quake_rl") (airshot "1") (height "318")
6
6
  L 12/18/2025 - 22:12:58: "tantwo<17><[U:1:191375689]><Blue>" triggered "damage" against "keicam<9><[U:1:163231154]><Red>" (damage "99") (realdamage "9") (weapon "quake_rl") (airshot "1") (height "427")
7
7
  L 12/18/2025 - 22:15:21: "fy<14><[U:1:442791013]><Blue>" triggered "damage" against "gibusmain<19><[U:1:258908204]><Red>" (damage "109") (realdamage "66") (weapon "tf_projectile_rocket") (airshot "1") (height "228")
8
+ L 03/21/2026 - 22:02:55: "Bass Windu<15><[U:1:156982175]><Blue>" triggered "damage" against "auto<14><[U:1:101982160]><Red>" (damage "152") (weapon "rocketlauncher_directhit") (crit "mini") (airshot "1") (height "242")
@@ -89,7 +89,7 @@ module TF2LineParser
89
89
  weapon = 'tf_projectile_rocket'
90
90
  airshot = '1'
91
91
  expect(Events::Airshot).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything,
92
- anything, anything, anything, nil, weapon, airshot)
92
+ anything, anything, anything, nil, weapon, nil, nil, airshot)
93
93
  parse(line).inspect
94
94
  end
95
95
 
@@ -120,6 +120,23 @@ module TF2LineParser
120
120
  expect(result.airshot).to eq(true)
121
121
  end
122
122
 
123
+ it 'recognizes airshots with crit' do
124
+ line = airshot_log_lines[7]
125
+ result = parse(line)
126
+ expect(result).to be_a(Events::Airshot)
127
+ expect(result.player.name).to eq('Bass Windu')
128
+ expect(result.player.steam_id).to eq('[U:1:156982175]')
129
+ expect(result.player.team).to eq('Blue')
130
+ expect(result.target.name).to eq('auto')
131
+ expect(result.target.steam_id).to eq('[U:1:101982160]')
132
+ expect(result.target.team).to eq('Red')
133
+ expect(result.damage).to eq(152)
134
+ expect(result.realdamage).to be_nil
135
+ expect(result.weapon).to eq('rocketlauncher_directhit')
136
+ expect(result.crit).to eq('mini')
137
+ expect(result.airshot).to eq(true)
138
+ end
139
+
123
140
  it 'recognizes airshot heals (Crusader Crossbow mid-air)' do
124
141
  line = airshot_log_lines[2]
125
142
  result = parse(line)
@@ -302,6 +319,16 @@ module TF2LineParser
302
319
  parse(line)
303
320
  end
304
321
 
322
+ it 'parses feign death as FeignDeath event (not Kill)' do
323
+ line = 'L 03/21/2026 - 22:08:05: "samir<32><[U:1:78482761]><Blue>" killed "vliwa<34><[U:1:68439644]><Red>" with "bleed_kill" (customkill "feign_death") (attacker_position "-1733 541 48") (victim_position "-3796 324 295")'
324
+ result = parse(line)
325
+ expect(result).to be_a(Events::FeignDeath)
326
+ expect(result).not_to be_a(Events::Kill)
327
+ expect(result.player.name).to eq('samir')
328
+ expect(result.target.name).to eq('vliwa')
329
+ expect(result.weapon).to eq('bleed_kill')
330
+ end
331
+
305
332
  it 'recognizes an assist' do
306
333
  line = log_lines[1451]
307
334
  player_name = 'broder jukebox'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf2_line_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arie
@@ -98,6 +98,7 @@ files:
98
98
  - lib/tf2_line_parser/events/empty_uber.rb
99
99
  - lib/tf2_line_parser/events/entered_game.rb
100
100
  - lib/tf2_line_parser/events/event.rb
101
+ - lib/tf2_line_parser/events/feign_death.rb
101
102
  - lib/tf2_line_parser/events/final_score.rb
102
103
  - lib/tf2_line_parser/events/first_heal_after_spawn.rb
103
104
  - lib/tf2_line_parser/events/headshot_damage.rb