lkjfds
This commit is contained in:
24
GameState.py
24
GameState.py
@@ -1,16 +1,17 @@
|
||||
import logging
|
||||
|
||||
import config
|
||||
from lamps.LampGroup import PLAYER_LAMPS
|
||||
from lamps.Lamp import CREDIT
|
||||
from itertools import cycle
|
||||
from time import sleep
|
||||
from lamps.LampGroup import *
|
||||
import asyncio
|
||||
|
||||
class GameState:
|
||||
players = None
|
||||
credits = config.BALLS_PER_GAME
|
||||
isPlaying = False
|
||||
isStarted = False
|
||||
isIdle = True
|
||||
|
||||
def __init__(self, playerStateFactory, highscore, specialDisplay, currentPlayerID = 0):
|
||||
CREDIT.activate()
|
||||
@@ -22,6 +23,7 @@ class GameState:
|
||||
self.highscore = highscore
|
||||
self.specialDisplay = specialDisplay
|
||||
self.specialDisplay.printCredits(self.credits)
|
||||
self.startIdleLoop()
|
||||
|
||||
def nextPlayer(self):
|
||||
self.currentPlayer = next(self.players)
|
||||
@@ -42,14 +44,24 @@ class GameState:
|
||||
logging.info("Game ended")
|
||||
|
||||
def startIdleLoop(self):
|
||||
asyncio.run(self.idleLoop())
|
||||
pass
|
||||
|
||||
def stopIdleLoop(self):
|
||||
self.isIdle = False
|
||||
pass
|
||||
|
||||
def idleLoop(self):
|
||||
|
||||
pass
|
||||
async def idleLoop(self):
|
||||
all_cabinet_lamps = [BONUS_LAMPS, BONUS_MULTIPLIER_LAMPS, CHAMP_LAMPS,
|
||||
UPPER_PLAYFIELD_TIME_LAMPS, TUNNEL_NUMBER_LAMPS,
|
||||
TUNNEL_LAMPS, TUNNEL_SCORE_LAMPS]
|
||||
while True:
|
||||
for lamps in all_cabinet_lamps:
|
||||
for _ in lamps.lamps:
|
||||
lamps.cycle()
|
||||
if not self.isIdle:
|
||||
return
|
||||
time.sleep(0.5)
|
||||
|
||||
def createPlayers(self, playerCount):
|
||||
players = []
|
||||
@@ -77,6 +89,4 @@ class GameState:
|
||||
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)
|
||||
Reference in New Issue
Block a user