This commit is contained in:
Jonas Zeunert
2022-08-30 19:14:21 +02:00
parent d980934216
commit 762cb03912
4 changed files with 14 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ class GameState:
players = None
credits = config.BALLS_PER_GAME
isPlaying = False
isStarted = False
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
CREDIT.activate()
@@ -26,7 +27,7 @@ class GameState:
self.currentPlayer = next(self.players)
def startGame(self, playerCount):
self.isPlaying = True
self.isStarted = True
self.createPlayers(playerCount)
self.nextPlayer()

View File

@@ -4,11 +4,16 @@ from solenoids.MainFlipper import MainFlipper
class StartBallEvent(Event):
def __init__(self):
def __init__(self, gameState = None):
self.gameState = gameState
self.flipper = MainFlipper()
super().__init__("Start Ball Event")
def trigger(self, target):
if self.gameState is not None:
if self.gameState.isPlaying or not self.gameState.isStarted:
return
super().trigger(target)
self.flipper.activate()
OutHoleSolenoid().trigger()

View File

@@ -27,7 +27,7 @@ class StartGameEvent(Event):
self.timer.start()
def trigger(self, target):
if self.gameState.isPlaying:
if self.gameState.isStarted:
return
super().trigger(target)

View File

@@ -8,6 +8,7 @@ from events.RightKickerEvent import RightKickerEvent
from events.EnterUpperPlayfieldEvent import EnterUpperPlayfieldEvent
from events.StartGameEvent import StartGameEvent
from events.EndGameEvent import EndGameEvent
from events.StartBallEvent import StartBallEvent
from events.BottomRightBankEvent import BottomRightBankEvent
from events.BottomLeftBankEvent import BottomLeftBankEvent
from events.TopCentralBankEvent import TopCentralBankEvent
@@ -93,6 +94,10 @@ class EventFactory:
self.__registerEventToTarget(event, self.targets['Credit'])
return event
def createStartBallEvent(self):
event = StartBallEvent(self.gameState)
self.__registerEventToTarget(event, self.targets['Credit'])
return event
def createBottomLeftBankEvent(self):
event = BottomLeftBankEvent(self.gameState)
self.__registerEventToTarget(event, self.targets["Left Bank"])