25 lines
965 B
Python
25 lines
965 B
Python
from displays.PlayerDisplay import PlayerDisplay
|
|
from displays.SpecialDisplay import SpecialDisplay
|
|
import config
|
|
import logging
|
|
class DisplayFactory:
|
|
def __init__(self, displayNames):
|
|
self.displayNames = displayNames
|
|
|
|
def createDisplays(self):
|
|
displays = [None] * config.MAX_PLAYERS
|
|
for displayName in self.displayNames:
|
|
if "Player" in displayName:
|
|
id = displayName.replace("Player", "")
|
|
displays[id] = PlayerDisplay(displayName)
|
|
print(displays)
|
|
return displays
|
|
|
|
def createSpecialDisplay(self):
|
|
name = next(displayName['name'] for displayName in self.displayNames if "Special" in displayName['name'])
|
|
return SpecialDisplay(name)
|
|
|
|
def createPlayerDisplay(self, id):
|
|
name = next(displayName['name'] for displayName in self.displayNames if "Player" in displayName['name'] and str(id) in displayName['name'])
|
|
return PlayerDisplay(name)
|