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

@@ -14,8 +14,8 @@ class GameState:
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
CREDIT.activate()
self.highscore = highscore
self.playerStateFactory = playerStateFactory
#self.players = cycle(players)
self.dummyPlayer = playerStateFactory.createDummyPlayerState()
self._currentPlayer = self.dummyPlayer
self.gameStateID = currentPlayerID
@@ -34,6 +34,23 @@ class GameState:
logging.info("Game Started")
def endGame(self):
self.writeHighscore()
self.players = None
self.isPlaying = False
self.isStarted = False
logging.info("Game ended")
def startIdleLoop(self):
pass
def stopIdleLoop(self):
pass
def idleLoop(self):
pass
def createPlayers(self, playerCount):
players = []
for i in range(playerCount):
@@ -56,3 +73,10 @@ class GameState:
self._currentPlayer = player
def writeHighscore(self):
for player in self.players:
if player.hasHighscore:
with open(config.HIGHSCORE_FILE, "w+") as file:
file.seek(0)
file.truncate()
file.write(player.score)