Files
flippr-game/lamps/LampGroup.py
Jonas Zeunert 5fb8bb54f0 kjdsa
2022-08-31 17:28:24 +02:00

128 lines
2.7 KiB
Python

from lamps.Lamp import Lamp
from itertools import cycle
import random
import time
class LampGroup:
def __init__(self, lamps):
self.lamps = lamps
self.currentLampPtr = 0
self.lamp_cycle = cycle(lamps)
self.currentLamp = None
self.deactivate()
def activate(self):
for lamp in self.lamps:
lamp.activate()
def deactivate(self):
self.currentLampPtr = 0
for lamp in self.lamps:
lamp.deactivate()
def activate_one(self, id):
self.lamps[id].activate()
def activateNext(self):
self.lamps[self.currentLampPtr].activate()
if self.currentLampPtr == len(self.lamps) - 1:
return
self.currentLampPtr += 1
def deactivateCurrent(self):
self.lamps[self.currentLampPtr].deactivate()
if self.currentLampPtr == 0:
return
self.currentLampPtr -= 1
def toggleRandom(self, sleepTime):
random_lamp = random.choice(self.lamps)
random_lamp.activate()
time.sleep(sleepTime)
random_lamp.deactivate()
def cycle(self):
if self.currentLamp:
self.currentLamp.deactivate()
self.currentLamp = next(self.lamp_cycle)
self.currentLamp.activate()
PLAYER_LAMPS = LampGroup([
Lamp("Can Play 1"),
Lamp("Can Play 2"),
Lamp("Can Play 3"),
Lamp("Can Play 4")
])
CHAMP_LAMPS = LampGroup([
Lamp("C Of Champ"),
Lamp("H Of Champ"),
Lamp("A Of Champ"),
Lamp("M Of Champ"),
Lamp("P Of Champ")
])
UPPER_PLAYFIELD_TIME_LAMPS = LampGroup([
Lamp("Lamp 5 Sec"),
Lamp("Lamp 10 Sec"),
Lamp("Lamp 20 Sec"),
Lamp("Lamp 30 Sec")
])
TUNNEL_NUMBER_LAMPS = LampGroup([
Lamp("Lamp 1"),
Lamp("Lamp 2"),
Lamp("Lamp 3"),
Lamp("Lamp 4"),
Lamp("Lamp 5"),
])
TUNNEL_LAMPS = LampGroup([
Lamp("1st Button"),
Lamp("2nd Button"),
Lamp("3rd Button"),
Lamp("4th Button"),
Lamp("5th Button")
])
TUNNEL_SCORE_LAMPS = LampGroup([
Lamp("Tunnel Lamp 20000 Points"),
Lamp("Tunnel Lamp 30000 Points"),
Lamp("Tunnel Lamp 50000 Points")
])
BONUS_MULTIPLIER_LAMPS = LampGroup([
Lamp("Bonus Multiplier x10"),
Lamp("Bonus Multiplier x20"),
Lamp("Bonus Multiplier x50")
])
BONUS_LAMPS = LampGroup([
Lamp("Bonus 1000"),
Lamp("Bonus 2000"),
Lamp("Bonus 3000"),
Lamp("Bonus 4000"),
Lamp("Bonus 5000"),
Lamp("Bonus 6000"),
Lamp("Bonus 7000"),
Lamp("Bonus 8000"),
Lamp("Bonus 9000"),
Lamp("Bonus 10000"),
Lamp("Bonus 11000"),
Lamp("Bonus 12000"),
Lamp("Bonus 13000"),
Lamp("Bonus 14000"),
Lamp("Bonus 15000"),
Lamp("Bonus 16000"),
Lamp("Bonus 17000"),
Lamp("Bonus 18000"),
Lamp("Bonus 19000"),
Lamp("Bonus 20000")
])