This commit is contained in:
Jonas Zeunert
2020-02-04 00:13:08 +01:00
parent c5a250d040
commit 53d55d16f5
5 changed files with 37 additions and 3 deletions

View File

@@ -6,9 +6,6 @@ class EventHandler:
def __init__(self, targets):
self.isRunning = True
self.targets = targets
self.createAllTargets()
async def handleEvents(self):
self.isRunning = True

View File

@@ -1,12 +1,43 @@
from src.config import *
from src.networking.Networking import Networking
from src.displays.PlayerDisplay import PlayerDisplay
from src.displays.SpecialDisplay import SpecialDisplay
from src.targets import *
from src.EventHandler import EventHandler
from src.events.PointEvent import PointEvent
class GameFactory:
def createGame(self):
targets = self.createAllTargets()
eventHandler = EventHandler(targets)
displayNames = Networking.getDisplays()
playerDisplays = self.createPlayerDisplays(displayNames)
playerState = PlayerState()
pointEvent = PointEvent()
for target in self.targets:
target.on(target.hit_key,
pass
def createPlayerDisplays(self, displayNames):
result = []
for displayName in displayNames:
if("Player" in displayName):
display = PlayerDisplay(displayName)
result.append(display)
return result
def createPlayerStates(self, playerDisplays, specialDisplay, ballsPerGame = BALLS_PER_GAME, beginningUpperPlayfieldTime = BEGINNING_UPPER_PLAYFIELD_TIME, beginningBonusTime = BEGINNING_BONUS_TIME):
result = []
for i in range(len(playerDisplays)):
playerState = PlayerState(playerDisplays[i], specialDisplay, i, ballsPerGame, beginningUpperPlayfieldTime, beginningBonusTime)
result.append(playerState)
return result
def createAllTargets(self):
result = dict
glo = globals() # Save globals so the dict does not change during execution of the script
@@ -14,4 +45,5 @@ class GameFactory:
target = glo[key]
if(key.endswith('Target') and type(target) == 'class'):
result[key] = target()
# todo check with driver?
return result

5
src/config.py Normal file
View File

@@ -0,0 +1,5 @@
# Game Config
## Player State config
BALLS_PER_GAME = 3
BEGINNING_UPPER_PLAYFIELD_TIME = 5
BEGINNING_BONUS_TIME = 0

0
src/lamps/Lamp.py Normal file
View File

0
src/lamps/LampGroup.py Normal file
View File