Changed an attribute name to avoid confusion
This commit is contained in:
@ -233,7 +233,7 @@ class ExpansionsManager:
|
|||||||
Manager of the availability of the expansions.
|
Manager of the availability of the expansions.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
includedExpansions: tuple of str
|
includeExpansions: tuple of str
|
||||||
Container of the expansions to try making available
|
Container of the expansions to try making available
|
||||||
activeExpansions: dict of Expansion
|
activeExpansions: dict of Expansion
|
||||||
Container of the relevent expansions
|
Container of the relevent expansions
|
||||||
@ -248,7 +248,7 @@ class ExpansionsManager:
|
|||||||
# (attributed players / types)
|
# (attributed players / types)
|
||||||
# TODO Allow to get a list of expansions with a specific tag/player
|
# TODO Allow to get a list of expansions with a specific tag/player
|
||||||
|
|
||||||
def __init__(self, playersManager: PlayersManager, includedExpansions: tuple[str]=None):
|
def __init__(self, playersManager: PlayersManager, includeExpansions: tuple[str]=None):
|
||||||
"""
|
"""
|
||||||
Arguments:
|
Arguments:
|
||||||
tryInclude: bool=False, tryActivate: bool=False
|
tryInclude: bool=False, tryActivate: bool=False
|
||||||
@ -257,10 +257,10 @@ class ExpansionsManager:
|
|||||||
self.playersManager = playersManager
|
self.playersManager = playersManager
|
||||||
self._playersLookUp = {}
|
self._playersLookUp = {}
|
||||||
self._cfg = playersManager.config["expansions"]
|
self._cfg = playersManager.config["expansions"]
|
||||||
if includedExpansions is not None:
|
if includeExpansions is not None:
|
||||||
self._includedExpansions = tuple(includedExpansions)
|
self._includeExpansions = tuple(includeExpansions)
|
||||||
else:
|
else:
|
||||||
self._includedExpansions = ()
|
self._includeExpansions = ()
|
||||||
# Convert the required lists into tuples
|
# Convert the required lists into tuples
|
||||||
for expansionID in self._cfg["expansions"]:
|
for expansionID in self._cfg["expansions"]:
|
||||||
for key in self.keysConvert2Tuple:
|
for key in self.keysConvert2Tuple:
|
||||||
@ -288,18 +288,18 @@ class ExpansionsManager:
|
|||||||
return f"ExpansionsManager has {len(self._activeExpansions)} active expansions"
|
return f"ExpansionsManager has {len(self._activeExpansions)} active expansions"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def includedExpansions(self):
|
def includeExpansions(self):
|
||||||
""" Dictionnary of the included expansions. """
|
""" Dictionnary of the included expansions. """
|
||||||
return self._includedExpansions
|
return self._includeExpansions
|
||||||
|
|
||||||
@includedExpansions.setter
|
@includeExpansions.setter
|
||||||
def includedExpansions(self, newIncluded: tuple[str]):
|
def includeExpansions(self, newIncluded: tuple[str]):
|
||||||
self._includedExpansions = tuple(newIncluded)
|
self._includeExpansions = tuple(newIncluded)
|
||||||
self._includeChanged()
|
self._includeChanged()
|
||||||
|
|
||||||
@includedExpansions.deleter
|
@includeExpansions.deleter
|
||||||
def includedExpansions(self):
|
def includeExpansions(self):
|
||||||
self._includedExpansions = ()
|
self._includeExpansions = ()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config(self):
|
def config(self):
|
||||||
@ -319,7 +319,7 @@ class ExpansionsManager:
|
|||||||
"""
|
"""
|
||||||
activePlayers = set(self.playersManager.keys())
|
activePlayers = set(self.playersManager.keys())
|
||||||
possiblyValidExpansions = [
|
possiblyValidExpansions = [
|
||||||
expansionID for expansionID in self._includedExpansions
|
expansionID for expansionID in self._includeExpansions
|
||||||
if hasattr(expansionsLib, self._getClassFillMissing(expansionID)) and
|
if hasattr(expansionsLib, self._getClassFillMissing(expansionID)) and
|
||||||
not self._getPlayersFillMissing(expansionID).isdisjoint(activePlayers)
|
not self._getPlayersFillMissing(expansionID).isdisjoint(activePlayers)
|
||||||
]
|
]
|
||||||
@ -352,7 +352,7 @@ class ExpansionsManager:
|
|||||||
|
|
||||||
# Compute the expansions involved in the modification
|
# Compute the expansions involved in the modification
|
||||||
possiblyValidExpansions = set(self._listPossiblyValidExpansions())
|
possiblyValidExpansions = set(self._listPossiblyValidExpansions())
|
||||||
previousExpansions = set(self._includedExpansions)
|
previousExpansions = set(self._includeExpansions)
|
||||||
# Remove irrelevant expansions
|
# Remove irrelevant expansions
|
||||||
expansionsToRemove = previousExpansions.difference(possiblyValidExpansions)
|
expansionsToRemove = previousExpansions.difference(possiblyValidExpansions)
|
||||||
for expansionID in expansionsToRemove:
|
for expansionID in expansionsToRemove:
|
||||||
@ -368,7 +368,7 @@ class ExpansionsManager:
|
|||||||
|
|
||||||
def _activePlayerAdded(self, playerName):
|
def _activePlayerAdded(self, playerName):
|
||||||
# Find the expansions that are to be created
|
# Find the expansions that are to be created
|
||||||
possibleAddition = set(self._includedExpansions).difference(self._activeExpansions)
|
possibleAddition = set(self._includeExpansions).difference(self._activeExpansions)
|
||||||
filteredAddition = [
|
filteredAddition = [
|
||||||
expansionID for expansionID in possibleAddition
|
expansionID for expansionID in possibleAddition
|
||||||
if hasattr(expansionsLib, self._getClassFillMissing(expansionID)) and
|
if hasattr(expansionsLib, self._getClassFillMissing(expansionID)) and
|
||||||
|
|||||||
Reference in New Issue
Block a user