Files
flippr-game/events/EndBallEvent.py
Jonas Zeunert cfdcbcb5bd bugfixes
2022-06-02 21:28:44 +02:00

29 lines
901 B
Python

from Event import Event
from events.EndGameEvent import EndGameEvent
from events.StartBallEvent import StartBallEvent
class EndBallEvent(Event):
def __init__(self, gameState):
self.gameState = gameState
super().__init__("End Of Ball Event")
def trigger(self, target):
super().trigger(target)
if self.gameState.currentPlayer.replayBall or not self.gameState.currentPlayer.hasBallScored:
StartBallEvent().trigger(None)
return
self.gameState.currentPlayer.removeBall()
self.scorePoints()
self.gameState.currentPlayer.reset()
if self.gameState.currentPlayer.ballsLeft == 0:
EndGameEvent().trigger(None)
def scorePoints(self):
bonus = self.gameState.currentPlayer.bonus * self.gameState.currentPlayer.bonusMultiplier * 1000
self.gameState.currentPlayer.addPoints(bonus)