Skip to content

Commit d2a30a1

Browse files
committed
Adds support for msg.sent_to_all and msg.sent_to_allies flags and updates the tests accordingly
1 parent 36a6c6f commit d2a30a1

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

sc2reader/objects.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class Message(object):
127127

128128
def __init__(self, time, player, target, text):
129129
self.time, self.player, self.target, self.text = time, player, target, text
130+
self.sent_to_all = (self.target == 0)
131+
self.sent_to_allies = (self.target == 2)
130132

131133
def __str__(self):
132134
time = ((self.time/16)/60, (self.time/16)%60)

test_replays/test_all.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@
88
from sc2reader import Replay
99
from sc2reader.exceptions import ParseError
1010

11-
# Helper functions
12-
def sent_to_all(msg):
13-
return msg.target == 0
14-
15-
def find(f, seq):
16-
for item in seq:
17-
if item is None:
18-
continue
19-
if f(item):
20-
return item
21-
22-
2311
# Parsing should fail for an empty file.
2412
def test_empty():
2513
# Todo: Are we happy with it raising a ValueError? Should it be rather ParseError or something else?
@@ -96,7 +84,7 @@ def test_1():
9684
assert replay.messages[11].player.name == "Boom"
9785

9886
for msg in replay.messages:
99-
assert sent_to_all(msg) == True
87+
assert msg.sent_to_all == True
10088

10189
def test_private_category():
10290
replay = Replay("test_replays/build17811/2.sc2replay")

0 commit comments

Comments
 (0)