Files
flippr-game/factories/TargetFactory.py
Jonas Zeunert d23dd318b7 schwul
2020-03-12 00:45:49 +01:00

33 lines
1019 B
Python

from targets import *
class TargetFactory:
@staticmethod
def createAllTargets():
result = dict()
glo = globals() # Save globals so the dict does not change during execution of the script
for key in glo:
if type(glo[key]) is not type:
continue
target = glo[key]
if 'Target' in key and 'Bank' not in key and key not in ['Target', 'BankTarget']:
result[key] = target()
elif 'Bank' in key and 'Target' not in key and key not in ['Bank', 'BankTarget']:
targets = TargetFactory.createBankTarget(target, key)
result.update(targets)
# todo check with driver?
return result
@staticmethod
def createBankTarget(target, key):
bankTarget = target()
targets = dict()
targets[key] = bankTarget
for target in bankTarget.targets:
name = type(target).__name__
targets[name] = target
return targets