Add replay ball

This commit is contained in:
Jonas Zeunert
2022-08-31 14:50:11 +02:00
parent 401b3a332b
commit 4da7a3110d
7 changed files with 64 additions and 28 deletions

View File

@@ -21,6 +21,8 @@ from solenoids.BottomLeftBankSolenoid import BottomLeftBankSolenoid
from solenoids.BottomRightBankSolenoid import BottomRightBankSolenoid
from solenoids.TopCentralBankSolenoid import TopCentralBankSolenoid
from solenoids.MainFlipper import MainFlipper
TUNNEL_SCORES = [20000, 30000, 50000]
BONUS_MULTIPLIER = [1, 10, 20, 50]
UPPER_PLAYFIELD_TIME = [5, 10, 20, 30]
@@ -46,9 +48,9 @@ class PlayerState:
tunnelScore = 0
tunnelLit = 0
ballsLeft = 0
replayBall = False
hasBallScored = False
isActive = False
hasHighscore = False
redSpecial = 0
redSpecialLit = False
@@ -66,6 +68,10 @@ class PlayerState:
upperPlayfieldTimeIter = iter(UPPER_PLAYFIELD_TIME)
upperPlayfieldTime = 0
replayBall = False
bonusTime = config.BEGINNING_BONUS_TIME
replayBallTimer = None
def __init__(self, display, specialDisplay, id, ballsToPlay, banks):
self.banks = banks
self.display = display
@@ -76,8 +82,6 @@ class PlayerState:
self.enableTiming()
self.bonusTime = config.BEGINNING_BONUS_TIME
self.specialDisplay.printBallsToPlay(self.ballsLeft)
self.specialDisplay.printGameTimeBonus(self.bonusTime)
@@ -286,7 +290,26 @@ class PlayerState:
def setReplayBall(self):
if not self.isActive:
return
self.replayBall = True
self.replayBallTimer = Timer(interval=1, function=self.updateReplayBall)
def updateReplayBall(self):
self.bonusTime -= 1
self.printSpecial()
if self.bonusTime == 0:
self.stopReplayBall()
return
self.replayBallTimer = Timer(interval = 1, function=self.updateReplayBall)
def stopReplayBall(self):
if not self.isActive:
return
self.replayBall = False
self.replayBallTimer = None
MainFlipper().deactivate()
def addPoints(self, points):
if points == 0: