tf2_line_parser 0.6.1 → 0.6.3

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: d62fb60bbb31b6578bbf54b7f5101f8f7fc93689c432494a08679f3e9d48cdca
4
- data.tar.gz: 9a94a4deffdcda33dddffd7efdaf4c08f3b8e97a17758fd5c46c705cf67ddb77
3
+ metadata.gz: f62b3222dd89877b6ce919788a689fb437bfbc7ca75a981f4d35fade570ec629
4
+ data.tar.gz: 4ddd3fcfea754c47b36fd4fd726f210cc9a5b407fa88273029c475e8388f0940
5
5
  SHA512:
6
- metadata.gz: 1f4c05bec771e0abc994ae0d83f63e6ccda3bd7cf3296defe2690603c1754cbd474836714de8abf45aa368251a974431663287077033f277a1ad1abf6154bf24
7
- data.tar.gz: 190f40d4da42c17ef659af94bcba4d890e98f5fec17ca6f1e472f3095f9058e138a22bac59a710804343a9758f7c2f9d53336bf213ca55e5e25635731da62d6c
6
+ metadata.gz: 99198496cdaf2a68406b0a106b189133c02bf753d816738d99a2f7abd0065d6f0df640f3fce4fb1604ba49898d18b2855015b80e4ae5b7ddb1b03163b2fb05f6
7
+ data.tar.gz: c509657ae00cbf328d70b1685aee1d4dd9e0119a328331534b7bad6f47c656d2ce9b58c54caf8903c51c95afba28c9ae9d7d9e2b8a5574b3d763295baa162972
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tf2_line_parser (0.6.1)
4
+ tf2_line_parser (0.6.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -38,7 +38,7 @@ module TF2LineParser
38
38
  # ordered by how common the messages are
39
39
  @types ||= [ShotFired, ShotHit, PositionReport, HeadshotDamage, Airshot, Damage, AirshotHeal, Heal, PickupItem, Assist, Kill, CaptureBlock, PointCapture, ChargeDeployed,
40
40
  MedicDeath, MedicDeathEx, EmptyUber, ChargeReady, ChargeEnded, FirstHealAfterSpawn, LostUberAdvantage, BuiltObject, PlayerExtinguished, JoinedTeam, EnteredGame, RoleChange, Spawn, Suicide, KilledObject, Say, TeamSay, Domination, Revenge, RoundWin, CurrentScore,
41
- RoundLength, RoundStart, RoundSetupBegin, RoundSetupEnd, MiniRoundStart, MiniRoundSelected, WorldIntermissionWinLimit, IntermissionWinLimit, Connect, Disconnect, RconCommand, ConsoleSay, MatchEnd, FinalScore,
41
+ RoundLength, RoundStart, RoundSetupBegin, RoundSetupEnd, MiniRoundStart, MiniRoundSelected, MiniRoundLength, MiniRoundWin, WorldIntermissionWinLimit, IntermissionWinLimit, Connect, Disconnect, RconCommand, ConsoleSay, MatchEnd, FinalScore,
42
42
  RoundStalemate, Unknown].freeze
43
43
  end
44
44
 
@@ -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
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TF2LineParser
4
+ module Events
5
+ class MiniRoundLength < RoundEventWithVariables
6
+ def self.round_type
7
+ @round_type ||= 'Mini_Round_Length'
8
+ end
9
+
10
+ def self.round_variable_regex
11
+ @round_variable_regex ||= /\(seconds "(?'length'.*)"\)/.freeze
12
+ end
13
+
14
+ def self.round_variable
15
+ @round_variable ||= :length
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TF2LineParser
4
+ module Events
5
+ class MiniRoundWin < RoundEventWithVariables
6
+ def self.round_type
7
+ @round_type ||= 'Mini_Round_Win'
8
+ end
9
+
10
+ def self.round_variable_regex
11
+ @round_variable_regex ||= /\(winner "(?'team'Red|Blue)"\)/.freeze
12
+ end
13
+
14
+ def self.round_variable
15
+ @round_variable ||= :team
16
+ end
17
+ end
18
+ end
19
+ end
@@ -43,6 +43,8 @@ module TF2LineParser
43
43
  'Round_Setup_End' => [Events::RoundSetupEnd],
44
44
  'Mini_Round_Start' => [Events::MiniRoundStart],
45
45
  'Mini_Round_Selected' => [Events::MiniRoundSelected],
46
+ 'Mini_Round_Length' => [Events::MiniRoundLength],
47
+ 'Mini_Round_Win' => [Events::MiniRoundWin],
46
48
  'Intermission_Win_Limit' => [Events::WorldIntermissionWinLimit, Events::IntermissionWinLimit],
47
49
  'Round_Stalemate' => [Events::RoundStalemate],
48
50
  'Game_Over' => [Events::MatchEnd],
@@ -53,8 +55,12 @@ module TF2LineParser
53
55
  'position_report' => [Events::PositionReport],
54
56
  }.freeze
55
57
 
56
- # Fallback types when no keyword matches
58
+ # Fallback types when no keyword matches - ordered by specificity
57
59
  FALLBACK_TYPES = [
60
+ Events::FeignDeath, Events::Kill, Events::PositionReport,
61
+ Events::TeamSay, Events::Say, Events::PickupItem,
62
+ Events::JoinedTeam, Events::EnteredGame, Events::RoleChange,
63
+ Events::Spawn, Events::Suicide, Events::Connect, Events::Disconnect,
58
64
  Events::CurrentScore, Events::FinalScore, Events::RconCommand,
59
65
  Events::ConsoleSay, Events::Unknown
60
66
  ].freeze
@@ -105,34 +111,7 @@ module TF2LineParser
105
111
  end
106
112
  end
107
113
 
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
114
+ FALLBACK_TYPES
136
115
  end
137
116
 
138
117
  def try_parse_types(line, types)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TF2LineParser
4
- VERSION = '0.6.1'
4
+ VERSION = '0.6.3'
5
5
  end
@@ -319,6 +319,16 @@ module TF2LineParser
319
319
  parse(line)
320
320
  end
321
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
+
322
332
  it 'recognizes an assist' do
323
333
  line = log_lines[1451]
324
334
  player_name = 'broder jukebox'
@@ -466,6 +476,20 @@ module TF2LineParser
466
476
  parse(line)
467
477
  end
468
478
 
479
+ it 'recognizes mini round length' do
480
+ line = 'L 03/28/2026 - 02:06:43: World triggered "Mini_Round_Length" (seconds "835.50")'
481
+ length = '835.50'
482
+ expect(Events::MiniRoundLength).to receive(:new).with(anything, length)
483
+ parse(line)
484
+ end
485
+
486
+ it 'recognizes mini round win' do
487
+ line = 'L 03/28/2026 - 02:06:43: World triggered "Mini_Round_Win" (winner "Blue")'
488
+ team = 'Blue'
489
+ expect(Events::MiniRoundWin).to receive(:new).with(anything, team)
490
+ parse(line)
491
+ end
492
+
469
493
  it 'recognizes intermission win limit' do
470
494
  line = 'L 02/07/2013 - 21:52:41: Team "RED" triggered "Intermission_Win_Limit" due to mp_windifference'
471
495
  team = 'RED'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf2_line_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arie
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-03-22 00:00:00.000000000 Z
10
+ date: 2026-03-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: coveralls_reborn
@@ -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
@@ -110,8 +111,10 @@ files:
110
111
  - lib/tf2_line_parser/events/match_end.rb
111
112
  - lib/tf2_line_parser/events/medic_death.rb
112
113
  - lib/tf2_line_parser/events/medic_death_ex.rb
114
+ - lib/tf2_line_parser/events/mini_round_length.rb
113
115
  - lib/tf2_line_parser/events/mini_round_selected.rb
114
116
  - lib/tf2_line_parser/events/mini_round_start.rb
117
+ - lib/tf2_line_parser/events/mini_round_win.rb
115
118
  - lib/tf2_line_parser/events/pickup_item.rb
116
119
  - lib/tf2_line_parser/events/player_action_event.rb
117
120
  - lib/tf2_line_parser/events/player_extinguished.rb