Add dummy player

This commit is contained in:
Jonas Zeunert
2022-06-06 22:20:04 +02:00
parent 33a0fd931a
commit 05a8020689
4 changed files with 27 additions and 6 deletions

View File

@@ -4,10 +4,11 @@ from lamps.Lamp import CREDIT
from itertools import cycle
class GameState:
def __init__(self, players, highscore, specialDisplay, currentPlayerID = 0):
def __init__(self, players, highscore, specialDisplay, dummyPlayer, currentPlayerID = 0):
CREDIT.activate()
self.players = cycle(players)
self._currentPlayer = None
self.dummyPlayer = dummyPlayer
self._currentPlayer = dummyPlayer
self.gameStateID = currentPlayerID
self.highscore = highscore
self.credits = 3
@@ -27,8 +28,11 @@ class GameState:
def currentPlayer(self, player):
logging.info("Set active player to player " + str(player.id))
self._currentPlayer = player
self._currentPlayer = self.dummyPlayer
PLAYER_LAMPS.deactivateCurrent()
PLAYER_LAMPS.activateNext()
self.currentPlayer.activate()
self._currentPlayer = player

12
displays/DummyDisplay.py Normal file
View File

@@ -0,0 +1,12 @@
from displays.Display import Display
class DummyDisplay(Display):
def __init__(self):
super(DummyDisplay, self).__init__("DummyDisplay")
def printContent(self, content):
pass
def printScore(self, score):
pass

View File

@@ -28,8 +28,9 @@ class GameFactory:
banks = [targets['Left Bank'], targets['Right Bank'], targets['Top Bank']]
players = self.createPlayers(banks)
dummyPlayer = self.gameStateFactory.createDummyPlayerState()
gameState = GameState(players, self.getHighScore(), self.specialDisplay, players[0].id)
gameState = GameState(players, self.getHighScore(), self.specialDisplay, dummyPlayer, players[0].id)
eventFactory = EventFactory(targets, gameState)
events = eventFactory.allEvents()

View File

@@ -1,10 +1,14 @@
from config import *
from PlayerState import PlayerState
from displays.DummyDisplay import DummyDisplay
class PlayerStateFactory:
def __init__(self, specialDisplay):
self.specialDisplay = specialDisplay
def createPlayerState(self, display, id, banks):
return PlayerState(display, self.specialDisplay, id, BALLS_PER_GAME, banks)
return PlayerState(display, self.specialDisplay, id, BALLS_PER_GAME, banks)
def createDummyPlayerState(self):
display = DummyDisplay()
return PlayerState(display, display, -1, -1, None)