mirror of
https://github.com/zoriya/AnonymousGoose.git
synced 2026-06-02 22:11:32 +00:00
Allowing tricks to be reverted
This commit is contained in:
@@ -10,5 +10,12 @@ class TestTrick(Trick):
|
||||
def delay(self):
|
||||
return 1
|
||||
|
||||
@property
|
||||
def is_reversible(self):
|
||||
return False
|
||||
|
||||
def revert(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
print("Test succeed")
|
||||
|
||||
@@ -21,6 +21,8 @@ class AnonymousGoose:
|
||||
def __del__(self):
|
||||
if not self.stopped:
|
||||
self.keyboard_listener.cancel()
|
||||
for trick in self.tricks:
|
||||
trick.revert()
|
||||
|
||||
def run(self):
|
||||
next_trick_time = 5
|
||||
@@ -34,7 +36,8 @@ class AnonymousGoose:
|
||||
trick = Trick.get_random_trick()
|
||||
next_trick_time = trick.delay
|
||||
trick.run()
|
||||
self.tricks.append(trick)
|
||||
if trick.is_reversible:
|
||||
self.tricks.append(trick)
|
||||
except KeyboardInterrupt:
|
||||
...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user