Skip to content

Commit 32297ce

Browse files
committed
Handle game attributes requiring player attributes
Custom maps can set up game attributes to be enabled only if player conditions are met. I'm 99% sure that only one player (and not all players) need to meet this condition but I could be wrong. I'm sure someone will let me know when it becomes important to them.
1 parent c9cebea commit 32297ce

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

sc2reader/resources.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,18 @@ def use_property(prop, player=None):
842842
break
843843

844844
setting = settings[req[0][1][1]]
845-
value = setting if requirement.is_lobby else setting[player]
846-
if requirement.values[value][0] not in req[1]:
845+
846+
# Lobby properties can require on player properties.
847+
# How does this work? I assume that one player satisfying the
848+
# property requirments is sufficient
849+
if requirement.is_lobby:
850+
values = [setting]
851+
else:
852+
values = [setting[player]] if player != None else setting
853+
854+
# Because of the above complication we resort to a set intersection of
855+
# the applicable values and the set of required values.
856+
if not set(requirement.values[val][0] for val in values) & set(req[1]):
847857
break
848858

849859
else:

0 commit comments

Comments
 (0)