created eventhandler
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class Bank(Target):
|
class Bank(Target):
|
||||||
def __init__(self, targets):
|
def __init__(self, targets):
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class BankTarget(Target):
|
class BankTarget(Target):
|
||||||
def __init__(self, points):
|
def __init__(self, points):
|
||||||
23
src/EventHandler.py
Normal file
23
src/EventHandler.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import asyncio
|
||||||
|
from src.networking.Networking import Networking
|
||||||
|
|
||||||
|
from src.targets import *
|
||||||
|
|
||||||
|
class EventHandler:
|
||||||
|
def __init__(self):
|
||||||
|
self.isRunning = True
|
||||||
|
self.targets = dict
|
||||||
|
self.createAllTargets()
|
||||||
|
|
||||||
|
def createAllTargets(self):
|
||||||
|
glo = globals() # Save globals so the dict does not change during execution of the script
|
||||||
|
for key in glo:
|
||||||
|
target = glo[key]
|
||||||
|
if(key.endswith('Target') and type(target) == 'class'):
|
||||||
|
self.targets[key] = target()
|
||||||
|
|
||||||
|
async def handleEvents(self):
|
||||||
|
while(self.isRunning):
|
||||||
|
event = Networking.getInputEvent()
|
||||||
|
self.targets[event].hit()
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class FifthFixedTarget(Target):
|
class FifthFixedTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class FirstFixedTarget(Target):
|
class FirstFixedTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
# A standup target. When lit, it scores the Orange Special (operator
|
# A standup target. When lit, it scores the Orange Special (operator
|
||||||
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 300,000
|
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 300,000
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
# A standup target. When lit, it scores the Red Special (operator
|
# A standup target. When lit, it scores the Red Special (operator
|
||||||
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 1,000,000
|
# adjustable) for Nothing, Extra Ball, Replay, Super Bonus, or 1,000,000
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class FourthFixedTarget(Target):
|
class FourthFixedTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class LeftDropTarget(Target):
|
class LeftDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class LeftInlaneTarget(Target):
|
class LeftInlaneTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class LeftLaneButton1Target(Target):
|
class LeftLaneButton1Target(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton2Target(Target):
|
class LeftLaneButton2Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton3Target(Target):
|
class LeftLaneButton3Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton4Target(Target):
|
class LeftLaneButton4Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftLaneButton5Target(Target):
|
class LeftLaneButton5Target(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class LeftOutlaneTarget(Target):
|
class LeftOutlaneTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class LeftPopBumperTarget(Target):
|
class LeftPopBumperTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class LeftSlingshotTarget(Target):
|
class LeftSlingshotTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class MiddleDropTarget(Target):
|
class MiddleDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class MiddleLeftDropTarget(Target):
|
class MiddleLeftDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class MiddleRightDropTarget(Target):
|
class MiddleRightDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class OutholeTarget(Target):
|
class OutholeTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class ReboundContactTarget(Target):
|
class ReboundContactTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class RightDropTarget(Target):
|
class RightDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightInlaneTarget(Target):
|
class RightInlaneTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightOutlaneKickerTarget(Target):
|
class RightOutlaneKickerTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightOutlaneTarget(Target):
|
class RightOutlaneTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class RightPopBumperTarget(Target):
|
class RightPopBumperTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class RightSlingshotTarget(Target):
|
class RightSlingshotTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class SecondFixedTarget(Target):
|
class SecondFixedTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class SpinnerTarget(Target):
|
class SpinnerTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class ThirdFixedTarget(Target):
|
class ThirdFixedTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class UPLeftDropTarget(Target):
|
class UPLeftDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class UPMiddleDropTarget(Target):
|
class UPMiddleDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class UPMiddleLeftDropTarget(Target):
|
class UPMiddleLeftDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
class UPMiddleRightDropTarget(Target):
|
class UPMiddleRightDropTarget(Target):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class UPRightDropTarget(Target):
|
class UPRightDropTarget(Target):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from src.targets.Target import Target
|
from src.Target import Target
|
||||||
|
|
||||||
|
|
||||||
class UpperPlayfieldRollUnderTarget(Target):
|
class UpperPlayfieldRollUnderTarget(Target):
|
||||||
|
|||||||
15
src/targets/__init__.py
Normal file
15
src/targets/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
__all__ = []
|
||||||
|
|
||||||
|
import pkgutil
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
for loader, name, is_pkg in pkgutil.walk_packages(__path__):
|
||||||
|
module = loader.find_module(name).load_module(name)
|
||||||
|
|
||||||
|
for name, value in inspect.getmembers(module):
|
||||||
|
if name.startswith('__'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
globals()[name] = value
|
||||||
|
__all__.append(name)
|
||||||
|
|
||||||
Reference in New Issue
Block a user