diff --git a/PlayerState.py b/PlayerState.py index ac69588..59b0988 100644 --- a/PlayerState.py +++ b/PlayerState.py @@ -8,11 +8,13 @@ import config from lamps.Lamp import Lamp from lamps.LampGroup import CHAMP_LAMPS from lamps.LampGroup import UPPER_PLAYFIELD_TIME_LAMPS +from lamps.LampGroup import TUNNEL_LAMPS from lamps.LampGroup import BONUS_MULTIPLIER_LAMPS from lamps.LampGroup import BONUS_LAMPS from events.LeaveUpperPlayfieldEvent import LeaveUpperPlayfieldEvent + class PlayerState: display = None specialDisplay = None @@ -136,6 +138,7 @@ class PlayerState: def resetTunnel(self): self.tunnelLit = 0 + TUNNEL_LAMPS.deactivate() def advanceRightOrangeSpecial(self): self.orangeSpecialRight = True @@ -163,8 +166,11 @@ class PlayerState: Lamp("Special Red").activate() def advanceTunnel(self): - if self.tunnelLit <= 5: - self.tunnelLit += 1 + if self.tunnelLit >= 5: + return + + self.tunnelLit += 1 + TUNNEL_LAMPS.activateNext() def advanceBonus(self): if self.bonus >= 20: diff --git a/events/BankEvent.py b/events/BankEvent.py index c82381d..60d78f8 100644 --- a/events/BankEvent.py +++ b/events/BankEvent.py @@ -10,7 +10,3 @@ class BankEvent(Event): def trigger(self, target): super().trigger(target) self.bankSolenoid.trigger() - self.advanceBonus() - - def advanceBonus(self): - self.playerState().advanceBonus() diff --git a/events/BonusEvent.py b/events/BonusEvent.py new file mode 100644 index 0000000..9ce2d4d --- /dev/null +++ b/events/BonusEvent.py @@ -0,0 +1,11 @@ +from Event import Event + + +class BonusEvent(Event): + def __init__(self, playerState): + self.playerState = playerState + super().__init__("Bonus Event") + + def trigger(self, target): + super().trigger(target) + self.playerState.advanceBonus() diff --git a/factories/EventFactory.py b/factories/EventFactory.py index 427c7fb..3c7809a 100644 --- a/factories/EventFactory.py +++ b/factories/EventFactory.py @@ -18,7 +18,30 @@ from events.RedSpecialEvent import RedSpecialEvent from events.OrangeSpecialEvent import OrangeSpecialEvent from events.SpinnerEvent import SpinnerEvent from events.FixedTargetEvent import FixedTargetEvent +from events.BonusEvent import BonusEvent +BONUS_EVENT_TARGETS = [ + "Left Inlane", + "Right Inlane", + "Right Outlane Kicker", + "Canal Button Bottom", + "Canal Button Middle Bottom", + "Canal Button Middle Top", + "Canal Button Top", + "Fixed Target 1", + "Fixed Target 2", + "Fixed Target 3", + "Fixed Target 4", + "Fixed Target 5", + "Left Bank Left", + "Left Bank Middle Left", + "Left Bank Middle Right", + "Left Bank Right", + "Right Bank Left", + "Right Bank Middle", + "Right Bank Right", + +] class EventFactory: def __init__(self, targets, currentPlayer): self.targets = targets @@ -123,5 +146,13 @@ class EventFactory: self.__registerEventToTarget(event, self.targets["Fixed Target 5"]) return event + def createBonusEvent(self): + event = BonusEvent(self.currentPlayer) + self.__registerEventToTargets(event, BONUS_EVENT_TARGETS) + + def __registerEventToTargets(self, event, targetNames): + for targetName in targetNames: + self.__registerEventToTarget(event, self.targets[targetName]) + def __registerEventToTarget(self, event, target): target.on(target.hit_key, event.trigger) diff --git a/lamps/LampGroup.py b/lamps/LampGroup.py index 3ac134b..f7e1189 100644 --- a/lamps/LampGroup.py +++ b/lamps/LampGroup.py @@ -46,6 +46,14 @@ UPPER_PLAYFIELD_TIME_LAMPS = LampGroup([ Lamp("Lamp 30 Sec") ]) +TUNNEL_LAMPS = LampGroup([ + Lamp("1st Button"), + Lamp("2nd Button"), + Lamp("3rd Button"), + Lamp("4th Button"), + Lamp("5th Button") +]) + BONUS_MULTIPLIER_LAMPS = LampGroup([ Lamp("Bonus Multiplier x10"), Lamp("Bonus Multiplier x20"),