ich will fertig werden

This commit is contained in:
Jonas Zeunert
2022-09-01 00:45:17 +02:00
parent 0dea250e44
commit 175265be84
2 changed files with 5 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import asyncio
import threading import threading
class GameState: class GameState:
playerCount = 0
players = None players = None
credits = config.BALLS_PER_GAME credits = config.BALLS_PER_GAME
isPlaying = False isPlaying = False
@@ -44,9 +45,11 @@ class GameState:
def endGame(self): def endGame(self):
self.writeHighscore() self.writeHighscore()
self.players = None self.players = None
self.playerCount = 0
self._currentPlayer = self.dummyPlayer self._currentPlayer = self.dummyPlayer
self.isPlaying = False self.isPlaying = False
self.isStarted = False self.isStarted = False
logging.info("Game ended") logging.info("Game ended")
self.startIdleLoop() self.startIdleLoop()
@@ -89,6 +92,7 @@ class GameState:
self.deactivate_all() self.deactivate_all()
def createPlayers(self, playerCount): def createPlayers(self, playerCount):
self.playerCount = playerCount
players = [] players = []
for i in range(playerCount): for i in range(playerCount):
player = self.playerStateFactory.createPlayerState(i) player = self.playerStateFactory.createPlayerState(i)

View File

@@ -41,7 +41,7 @@ class EndBallEvent(Event):
self.scorePoints() self.scorePoints()
self.gameState.currentPlayer.deactivate() self.gameState.currentPlayer.deactivate()
if self.gameState.currentPlayer.ballsLeft == 0 and self.gameState.currentPlayer.id == len(self.gameState.players): if self.gameState.currentPlayer.ballsLeft == 0 and self.gameState.currentPlayer.id == len(self.gameState.players) - 1:
self.gameState.endGame() self.gameState.endGame()
return return