tf2_line_parser 0.5.2 → 0.6.0
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/tf2_line_parser/events/airshot.rb +5 -3
- data/lib/tf2_line_parser/events/damage.rb +6 -4
- data/lib/tf2_line_parser/events/headshot_damage.rb +5 -3
- data/lib/tf2_line_parser/events/point_capture.rb +19 -3
- data/lib/tf2_line_parser/version.rb +1 -1
- data/spec/lib/tf2_line_parser/parser_spec.rb +45 -44
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ccca85756ff65c53f9ae713abb9b065ff9fbd5fc4141bd936c7f36726f35ddb
|
|
4
|
+
data.tar.gz: b791765db72f6cbb01c19ebe2ed85b408633359fe6ce463e713e914162ebf41c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46b65da5de6c037e0b092149837f0dc8614a3c3f79ea64f82bda2ab0263e81b14763c86bd71d74feaaa15401d42538eb7bb3fd030848e811b09177492187471b
|
|
7
|
+
data.tar.gz: a77d21150501dff565387b89bbdb07017d5739705fb30e1e442aef90bcddfab79071da01a92e88011dec8997530cd73aa2e18875d3c7982767a0a44bdce6504a
|
data/Gemfile.lock
CHANGED
|
@@ -17,7 +17,7 @@ module TF2LineParser
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def self.attributes
|
|
20
|
-
@attributes ||= %i[time player_section target_section weapon airshot]
|
|
20
|
+
@attributes ||= %i[time player_section target_section realdamage weapon airshot]
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def self.regex_results(matched_line)
|
|
@@ -25,6 +25,7 @@ module TF2LineParser
|
|
|
25
25
|
player_section = matched_line['player_section']
|
|
26
26
|
target_section = matched_line['target_section']
|
|
27
27
|
value = matched_line['value']
|
|
28
|
+
realdamage = matched_line['realdamage']
|
|
28
29
|
weapon = matched_line['weapon']
|
|
29
30
|
airshot = matched_line['airshot']
|
|
30
31
|
|
|
@@ -37,15 +38,16 @@ module TF2LineParser
|
|
|
37
38
|
target_name, target_uid, target_steamid, target_team = parse_target_section(target_section)
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
[time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, weapon, airshot]
|
|
41
|
+
[time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, airshot]
|
|
41
42
|
end
|
|
42
43
|
|
|
43
|
-
def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, weapon, airshot)
|
|
44
|
+
def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, airshot)
|
|
44
45
|
@time = parse_time(time)
|
|
45
46
|
@player = Player.new(player_name, player_uid, player_steamid, player_team)
|
|
46
47
|
@target = Player.new(target_name, target_uid, target_steamid, target_team) if target_name
|
|
47
48
|
@value = value.to_i
|
|
48
49
|
@damage = @value
|
|
50
|
+
@realdamage = realdamage.to_i if realdamage && !realdamage.empty?
|
|
49
51
|
@weapon = weapon
|
|
50
52
|
@healing = nil
|
|
51
53
|
@crit = nil
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module TF2LineParser
|
|
4
4
|
module Events
|
|
5
5
|
class Damage < Event
|
|
6
|
-
attr_reader :damage, :crit, :headshot, :healing
|
|
6
|
+
attr_reader :damage, :realdamage, :crit, :headshot, :healing
|
|
7
7
|
|
|
8
8
|
def self.regex
|
|
9
9
|
@regex ||= /#{regex_time} #{regex_player} triggered "damage" #{regex_damage_against}\(damage "(?'value'\d+)"\)#{regex_realdamage}#{regex_weapon}#{regex_healing}#{regex_crit}#{regex_headshot}/.freeze
|
|
@@ -34,7 +34,7 @@ module TF2LineParser
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def self.attributes
|
|
37
|
-
@attributes ||= %i[time player_section target_section value weapon healing crit headshot]
|
|
37
|
+
@attributes ||= %i[time player_section target_section value realdamage weapon healing crit headshot]
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def self.regex_results(matched_line)
|
|
@@ -42,6 +42,7 @@ module TF2LineParser
|
|
|
42
42
|
player_section = matched_line['player_section']
|
|
43
43
|
target_section = matched_line['target_section']
|
|
44
44
|
value = matched_line['value']
|
|
45
|
+
realdamage = matched_line['realdamage']
|
|
45
46
|
weapon = matched_line['weapon']
|
|
46
47
|
healing = matched_line['healing']
|
|
47
48
|
crit = matched_line['crit']
|
|
@@ -56,15 +57,16 @@ module TF2LineParser
|
|
|
56
57
|
target_name, target_uid, target_steamid, target_team = parse_target_section(target_section)
|
|
57
58
|
end
|
|
58
59
|
|
|
59
|
-
[time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, weapon, healing, crit, headshot]
|
|
60
|
+
[time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, headshot]
|
|
60
61
|
end
|
|
61
62
|
|
|
62
|
-
def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, weapon, healing, crit, headshot)
|
|
63
|
+
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)
|
|
63
64
|
@time = parse_time(time)
|
|
64
65
|
@player = Player.new(player_name, player_uid, player_steamid, player_team)
|
|
65
66
|
@target = Player.new(target_name, target_uid, target_steamid, target_team) if target_name
|
|
66
67
|
@value = value.to_i
|
|
67
68
|
@damage = @value
|
|
69
|
+
@realdamage = realdamage.to_i if realdamage && !realdamage.empty?
|
|
68
70
|
@weapon = weapon
|
|
69
71
|
@healing = healing.to_i if healing
|
|
70
72
|
@crit = crit
|
|
@@ -12,7 +12,7 @@ module TF2LineParser
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def self.attributes
|
|
15
|
-
@attributes ||= %i[time player_section target_section value weapon healing crit headshot]
|
|
15
|
+
@attributes ||= %i[time player_section target_section value realdamage weapon healing crit headshot]
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def self.regex_results(matched_line)
|
|
@@ -20,6 +20,7 @@ module TF2LineParser
|
|
|
20
20
|
player_section = matched_line['player_section']
|
|
21
21
|
target_section = matched_line['target_section']
|
|
22
22
|
value = matched_line['value']
|
|
23
|
+
realdamage = matched_line['realdamage']
|
|
23
24
|
weapon = matched_line['weapon']
|
|
24
25
|
healing = matched_line['healing']
|
|
25
26
|
crit = matched_line['crit']
|
|
@@ -34,15 +35,16 @@ module TF2LineParser
|
|
|
34
35
|
target_name, target_uid, target_steamid, target_team = parse_target_section(target_section)
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
[time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, weapon, healing, crit, headshot]
|
|
38
|
+
[time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, realdamage, weapon, healing, crit, headshot]
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
def initialize(time, player_name, player_uid, player_steamid, player_team, target_name, target_uid, target_steamid, target_team, value, weapon, healing, crit, headshot)
|
|
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)
|
|
41
42
|
@time = parse_time(time)
|
|
42
43
|
@player = Player.new(player_name, player_uid, player_steamid, player_team)
|
|
43
44
|
@target = Player.new(target_name, target_uid, target_steamid, target_team) if target_name
|
|
44
45
|
@value = value.to_i
|
|
45
46
|
@damage = @value
|
|
47
|
+
@realdamage = realdamage.to_i if realdamage && !realdamage.empty?
|
|
46
48
|
@weapon = weapon
|
|
47
49
|
@healing = healing.to_i if healing
|
|
48
50
|
@crit = crit
|
|
@@ -3,19 +3,35 @@
|
|
|
3
3
|
module TF2LineParser
|
|
4
4
|
module Events
|
|
5
5
|
class PointCapture < Event
|
|
6
|
+
CAPPERS_REGEX = /\(player\d+\s+"(?<player_section>[^"]*<[^>]*><[^>]*><[^>]*>)"\)/
|
|
7
|
+
|
|
8
|
+
attr_reader :cappers
|
|
9
|
+
|
|
6
10
|
def self.regex
|
|
7
|
-
@regex ||= /#{regex_time} Team "(?'team'Red|Blue)" triggered "pointcaptured" \(cp "(?'cp_number'\d+)"\) \(cpname "(?'cp_name'
|
|
11
|
+
@regex ||= /#{regex_time} Team "(?'team'Red|Blue)" triggered "pointcaptured" \(cp "(?'cp_number'\d+)"\) \(cpname "(?'cp_name'[^"]*)"\) \(numcappers "(?'numcappers'\d+)"\)(?'cappers_section'.*)/.freeze
|
|
8
12
|
end
|
|
9
13
|
|
|
10
14
|
def self.attributes
|
|
11
|
-
@attributes ||= %i[time team cp_number cp_name]
|
|
15
|
+
@attributes ||= %i[time team cp_number cp_name numcappers cappers_section]
|
|
12
16
|
end
|
|
13
17
|
|
|
14
|
-
def initialize(time, team, cap_number, cap_name)
|
|
18
|
+
def initialize(time, team, cap_number, cap_name, _numcappers, cappers_section)
|
|
15
19
|
@time = parse_time(time)
|
|
16
20
|
@team = team
|
|
17
21
|
@cap_number = cap_number
|
|
18
22
|
@cap_name = cap_name
|
|
23
|
+
@cappers = parse_cappers(cappers_section)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def parse_cappers(section)
|
|
29
|
+
return [] unless section
|
|
30
|
+
|
|
31
|
+
section.scan(CAPPERS_REGEX).map do |match|
|
|
32
|
+
name, uid, steam_id, team = self.class.parse_player_section(match[0])
|
|
33
|
+
Player.new(name, uid, steam_id, team) if name
|
|
34
|
+
end.compact
|
|
19
35
|
end
|
|
20
36
|
end
|
|
21
37
|
end
|
|
@@ -38,33 +38,29 @@ module TF2LineParser
|
|
|
38
38
|
player_steam_id = 'STEAM_0:1:16347045'
|
|
39
39
|
player_team = 'Red'
|
|
40
40
|
value = '69'
|
|
41
|
+
realdamage = nil
|
|
41
42
|
weapon = nil
|
|
42
43
|
healing = nil
|
|
43
44
|
crit = nil
|
|
44
45
|
headshot = nil
|
|
45
46
|
expect(Events::Damage).to receive(:new).with(anything, player_name, player_uid, player_steam_id, player_team, nil, nil,
|
|
46
|
-
nil, nil, value, weapon, healing, crit, headshot)
|
|
47
|
+
nil, nil, value, realdamage, weapon, healing, crit, headshot)
|
|
47
48
|
parse(line)
|
|
48
49
|
end
|
|
49
50
|
|
|
50
51
|
it 'recognizes new steam id log lines with detailed damage' do
|
|
51
52
|
line = new_log_lines[0]
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
crit = nil
|
|
64
|
-
headshot = nil
|
|
65
|
-
expect(Events::Damage).to receive(:new).with(anything, player_name, player_uid, player_steam_id, player_team, target_name,
|
|
66
|
-
target_uid, target_steam_id, target_team, value, weapon, healing, crit, headshot)
|
|
67
|
-
parse(line)
|
|
53
|
+
result = parse(line)
|
|
54
|
+
expect(result).to be_a(Events::Damage)
|
|
55
|
+
expect(result.player.name).to eq('iM yUKi intel @i52')
|
|
56
|
+
expect(result.player.steam_id).to eq('[U:1:3825470]')
|
|
57
|
+
expect(result.player.team).to eq('Blue')
|
|
58
|
+
expect(result.target.name).to eq('mix^ enigma @ i52')
|
|
59
|
+
expect(result.target.steam_id).to eq('[U:1:33652944]')
|
|
60
|
+
expect(result.target.team).to eq('Red')
|
|
61
|
+
expect(result.damage).to eq(78)
|
|
62
|
+
expect(result.realdamage).to eq(67)
|
|
63
|
+
expect(result.weapon).to eq('tf_projectile_rocket')
|
|
68
64
|
end
|
|
69
65
|
|
|
70
66
|
it 'recognizes detailed damage' do
|
|
@@ -78,12 +74,13 @@ module TF2LineParser
|
|
|
78
74
|
target_steam_id = 'STEAM_0:0:43087158'
|
|
79
75
|
target_team = 'Red'
|
|
80
76
|
value = '102'
|
|
77
|
+
realdamage = nil
|
|
81
78
|
weapon = 'tf_projectile_pipe'
|
|
82
79
|
healing = nil
|
|
83
80
|
crit = nil
|
|
84
81
|
headshot = nil
|
|
85
82
|
expect(Events::Damage).to receive(:new).with(anything, player_name, player_uid, player_steam_id, player_team, target_name,
|
|
86
|
-
target_uid, target_steam_id, target_team, value, weapon, healing, crit, headshot)
|
|
83
|
+
target_uid, target_steam_id, target_team, value, realdamage, weapon, healing, crit, headshot)
|
|
87
84
|
parse(line)
|
|
88
85
|
end
|
|
89
86
|
|
|
@@ -92,7 +89,7 @@ module TF2LineParser
|
|
|
92
89
|
weapon = 'tf_projectile_rocket'
|
|
93
90
|
airshot = '1'
|
|
94
91
|
expect(Events::Airshot).to receive(:new).with(anything, anything, anything, anything, anything, anything, anything,
|
|
95
|
-
anything, anything, anything, weapon, airshot)
|
|
92
|
+
anything, anything, anything, nil, weapon, airshot)
|
|
96
93
|
parse(line).inspect
|
|
97
94
|
end
|
|
98
95
|
|
|
@@ -107,6 +104,7 @@ module TF2LineParser
|
|
|
107
104
|
expect(result.target.steam_id).to eq('[U:1:468872526]')
|
|
108
105
|
expect(result.target.team).to eq('Red')
|
|
109
106
|
expect(result.damage).to eq(105)
|
|
107
|
+
expect(result.realdamage).to eq(88)
|
|
110
108
|
expect(result.weapon).to eq('quake_rl')
|
|
111
109
|
expect(result.airshot).to eq(true)
|
|
112
110
|
end
|
|
@@ -117,6 +115,7 @@ module TF2LineParser
|
|
|
117
115
|
expect(result).to be_a(Events::Airshot)
|
|
118
116
|
expect(result.player.name).to eq('tantwo')
|
|
119
117
|
expect(result.damage).to eq(105)
|
|
118
|
+
expect(result.realdamage).to be_nil
|
|
120
119
|
expect(result.weapon).to eq('quake_rl')
|
|
121
120
|
expect(result.airshot).to eq(true)
|
|
122
121
|
end
|
|
@@ -160,28 +159,24 @@ module TF2LineParser
|
|
|
160
159
|
crit = nil
|
|
161
160
|
headshot = '1'
|
|
162
161
|
expect(Events::HeadshotDamage).to receive(:new).with(anything, anything, anything, anything, anything, anything,
|
|
163
|
-
anything, anything, anything, anything, weapon, healing, crit, headshot)
|
|
162
|
+
anything, anything, anything, anything, anything, weapon, healing, crit, headshot)
|
|
164
163
|
parse(line).inspect
|
|
165
164
|
end
|
|
166
165
|
|
|
167
|
-
it '
|
|
166
|
+
it 'parses realdamage' do
|
|
168
167
|
line = detailed_log_lines[65]
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
headshot = nil
|
|
182
|
-
expect(Events::Damage).to receive(:new).with(anything, player_name, player_uid, player_steam_id, player_team, target_name,
|
|
183
|
-
target_uid, target_steam_id, target_team, value, weapon, healing, crit, headshot)
|
|
184
|
-
parse(line)
|
|
168
|
+
result = parse(line)
|
|
169
|
+
expect(result).to be_a(Events::Damage)
|
|
170
|
+
expect(result.damage).to eq(98)
|
|
171
|
+
expect(result.realdamage).to be_a(Integer)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'returns nil realdamage when not present' do
|
|
175
|
+
line = log_lines[1001]
|
|
176
|
+
result = parse(line)
|
|
177
|
+
expect(result).to be_a(Events::Damage)
|
|
178
|
+
expect(result.damage).to eq(69)
|
|
179
|
+
expect(result.realdamage).to be_nil
|
|
185
180
|
end
|
|
186
181
|
|
|
187
182
|
it 'recognizes damage with multiple optional fields' do
|
|
@@ -195,12 +190,13 @@ module TF2LineParser
|
|
|
195
190
|
target_steam_id = 'STEAM_0:0:29650428'
|
|
196
191
|
target_team = 'Blue'
|
|
197
192
|
value = '150'
|
|
193
|
+
realdamage = '100'
|
|
198
194
|
weapon = 'sniperrifle'
|
|
199
195
|
healing = '25'
|
|
200
196
|
crit = nil
|
|
201
197
|
headshot = nil
|
|
202
198
|
expect(Events::Damage).to receive(:new).with(anything, player_name, player_uid, player_steam_id, player_team, target_name,
|
|
203
|
-
target_uid, target_steam_id, target_team, value, weapon, healing, crit, headshot)
|
|
199
|
+
target_uid, target_steam_id, target_team, value, realdamage, weapon, healing, crit, headshot)
|
|
204
200
|
parse(line)
|
|
205
201
|
end
|
|
206
202
|
|
|
@@ -220,7 +216,7 @@ module TF2LineParser
|
|
|
220
216
|
crit = 'crit'
|
|
221
217
|
headshot = nil
|
|
222
218
|
expect(Events::Damage).to receive(:new).with(anything, player_name, player_uid, player_steam_id, player_team, target_name,
|
|
223
|
-
target_uid, target_steam_id, target_team, value, weapon, healing, crit, headshot)
|
|
219
|
+
target_uid, target_steam_id, target_team, value, nil, weapon, healing, crit, headshot)
|
|
224
220
|
parse(line)
|
|
225
221
|
end
|
|
226
222
|
|
|
@@ -232,11 +228,16 @@ module TF2LineParser
|
|
|
232
228
|
|
|
233
229
|
it 'recognizes a point capture' do
|
|
234
230
|
line = log_lines[1360]
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
expect(
|
|
239
|
-
|
|
231
|
+
result = parse(line)
|
|
232
|
+
expect(result).to be_a(Events::PointCapture)
|
|
233
|
+
expect(result.team).to eq('Blue')
|
|
234
|
+
expect(result.cap_number).to eq('2')
|
|
235
|
+
expect(result.cap_name).to eq('#Badlands_cap_cp3')
|
|
236
|
+
expect(result.cappers).to be_an(Array)
|
|
237
|
+
expect(result.cappers.length).to eq(4)
|
|
238
|
+
expect(result.cappers.first.name).to eq('broder Zebbosai')
|
|
239
|
+
expect(result.cappers.first.steam_id).to eq('STEAM_0:0:20805809')
|
|
240
|
+
expect(result.cappers.first.team).to eq('Blue')
|
|
240
241
|
end
|
|
241
242
|
|
|
242
243
|
it 'recognizes a round win' do
|
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.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arie
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-03-22 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: coveralls_reborn
|