moved targets

This commit is contained in:
Jonas Zeunert
2020-01-23 21:37:11 +01:00
parent a4d2822f49
commit d3996200b2
3 changed files with 0 additions and 0 deletions

21
src/targets/Bank.py Normal file
View File

@@ -0,0 +1,21 @@
class Bank(Target):
def __init__(self, targets):
self.targets = targets
self.__register_targets__()
def __target_hit__(self, target):
if all(target.is_hit for target in self.targets):
self.__all_targets_hit__()
def __all_targets_hit__(self):
self.__reset_all_targets__()
super.hit()
pass
def __reset_all_targets__(self):
for target in self.targets:
target.reset()
def __register_targets__(self):
for target in self.targets:
target.on(target.hit_key, self.__target_hit__)

15
src/targets/BankTarget.py Normal file
View File

@@ -0,0 +1,15 @@
from Target import Target
class BankTarget(Target):
def __init__(self, points):
super(points)
self.is_hit = False
def hit(self):
self.is_hit = True
super.hit()
#notify Bank
def reset(self):
self.is_hit = False

10
src/targets/Target.py Normal file
View File

@@ -0,0 +1,10 @@
class Target(Observable):
def __init__(self, points, name):
self.points = points
self.name = name
self.hit_key = "hit"
def hit(self):
#notify Observers
#notify Gamestate
self.trigger(self.hit_key, self)