Creating the base of the trick class

This commit is contained in:
Anonymus Raccoon
2020-04-25 13:27:26 +02:00
parent c685049c17
commit 5fd2a823f0
3 changed files with 57 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
from trick import Trick
class TestTrick(Trick):
def run(self):
print("Test succeed")
+30 -1
View File
@@ -4,6 +4,7 @@ import pyxhook
from term_utils import Term
from command_helper import CommandHelper
from trick import Trick
class AnonymousGoose:
@@ -22,11 +23,18 @@ class AnonymousGoose:
self.keyboard_listener.cancel()
def run(self):
next_trick_time = 5
while not self.should_exit:
try:
if CommandHelper.run("killall htop") == 0 or CommandHelper.run("killall top") == 0:
Term.print_all("You tough that this will be as easy as this?\n")
time.sleep(1)
next_trick_time -= 1
if next_trick_time <= 0:
trick = Trick.get_random_trick()
next_trick_time = trick.delay
trick.run()
self.tricks.append(trick)
except KeyboardInterrupt:
...
@@ -44,6 +52,27 @@ class AnonymousGoose:
if __name__ == "__main__":
goose = AnonymousGoose()
term = Term()
term.print("Test")
term.print("""
`:-.......``
+:o+++:---::
`/--::/o/-+s+.
`/::/so/:-:-:`
`s:----------.
/:+oo//soo/o
`+o/://///+.
/do:-:m--
oNNmy-o`
`-. `-/sdmNNNNNs`
sNNmmNNNNNNNNNNNNd`
:NNNNNNNNNNNNNNNNN-
-NNNNNNNNNNNNNNNd
oNNNNNNNNNNNNNm.
+NNNNNNNNNNNN/
oNNNNNdssmNd`
oNNy- .y`
:o .s
`s` -sso+/`
`ss+:. .-.`
.--:.` """"")
goose.run()
goose.stop()
+21
View File
@@ -0,0 +1,21 @@
import random
from abc import ABC, abstractmethod
class Trick(ABC):
def __init__(self):
self.name = "Undefined"
self.delay = 1
@abstractmethod
def run(self):
raise NotImplementedError
@staticmethod
def get_random_trick():
from Tricks.test import TestTrick
tricks = [
TestTrick
]
return random.choice(tricks)()