bla
This commit is contained in:
@@ -22,6 +22,7 @@ class StartGameEvent(Event):
|
|||||||
def restart_timer(self):
|
def restart_timer(self):
|
||||||
if self.timer is not None:
|
if self.timer is not None:
|
||||||
self.timer.cancel()
|
self.timer.cancel()
|
||||||
|
|
||||||
self.timer = Timer(interval=config.PLAYER_CHOOSE_INTERVAL, function=self.player_choose_ended)
|
self.timer = Timer(interval=config.PLAYER_CHOOSE_INTERVAL, function=self.player_choose_ended)
|
||||||
self.timer.start()
|
self.timer.start()
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
from displays.PlayerDisplay import PlayerDisplay
|
from displays.PlayerDisplay import PlayerDisplay
|
||||||
from displays.SpecialDisplay import SpecialDisplay
|
from displays.SpecialDisplay import SpecialDisplay
|
||||||
|
import config
|
||||||
class DisplayFactory:
|
class DisplayFactory:
|
||||||
def __init__(self, displayNames):
|
def __init__(self, displayNames):
|
||||||
self.displayNames = 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)
|
||||||
|
|
||||||
|
return displays
|
||||||
def createSpecialDisplay(self):
|
def createSpecialDisplay(self):
|
||||||
name = next(displayName['name'] for displayName in self.displayNames if "Special" in displayName['name'])
|
name = next(displayName['name'] for displayName in self.displayNames if "Special" in displayName['name'])
|
||||||
return SpecialDisplay(name)
|
return SpecialDisplay(name)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class GameFactory:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
displayNames = networking.getDisplays()['displays']
|
displayNames = networking.getDisplays()['displays']
|
||||||
self.displayFactory = DisplayFactory(displayNames)
|
self.displayFactory = DisplayFactory(displayNames)
|
||||||
|
self.displays = self.displayFactory.createDisplays()
|
||||||
self.specialDisplay = self.displayFactory.createSpecialDisplay()
|
self.specialDisplay = self.displayFactory.createSpecialDisplay()
|
||||||
|
|
||||||
self.playerCount = len(displayNames)
|
self.playerCount = len(displayNames)
|
||||||
@@ -22,7 +23,7 @@ class GameFactory:
|
|||||||
self.targets = TargetFactory.createAllTargets()
|
self.targets = TargetFactory.createAllTargets()
|
||||||
banks = [self.targets['Left Bank'], self.targets['Right Bank'], self.targets['Top Bank']]
|
banks = [self.targets['Left Bank'], self.targets['Right Bank'], self.targets['Top Bank']]
|
||||||
|
|
||||||
self.playerStateFactory = PlayerStateFactory(self.specialDisplay, banks, self.displayFactory)
|
self.playerStateFactory = PlayerStateFactory(self.specialDisplay, banks, self.displays)
|
||||||
|
|
||||||
|
|
||||||
def createGame(self):
|
def createGame(self):
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ from PlayerState import PlayerState
|
|||||||
from displays.DummyDisplay import DummyDisplay
|
from displays.DummyDisplay import DummyDisplay
|
||||||
|
|
||||||
class PlayerStateFactory:
|
class PlayerStateFactory:
|
||||||
def __init__(self, specialDisplay, banks, displayFactory):
|
def __init__(self, specialDisplay, banks, displays):
|
||||||
self.specialDisplay = specialDisplay
|
self.specialDisplay = specialDisplay
|
||||||
self.banks = banks
|
self.banks = banks
|
||||||
self.displayFactory = displayFactory
|
self.displays = displays
|
||||||
|
|
||||||
def createPlayerState(self, id):
|
def createPlayerState(self, id):
|
||||||
display = self.displayFactory.createPlayerDisplay(id)
|
return PlayerState(self.displays[id], self.specialDisplay, id, BALLS_PER_GAME, self.banks)
|
||||||
return PlayerState(display, self.specialDisplay, id, BALLS_PER_GAME, self.banks)
|
|
||||||
|
|
||||||
def createDummyPlayerState(self):
|
def createDummyPlayerState(self):
|
||||||
display = DummyDisplay()
|
display = DummyDisplay()
|
||||||
|
|||||||
Reference in New Issue
Block a user