|
@@ -0,0 +1,74 @@
|
|
|
|
+#!/usr/bin/python3
|
|
|
|
+
|
|
|
|
+import sys
|
|
|
|
+import random
|
|
|
|
+import readchar
|
|
|
|
+import subprocess
|
|
|
|
+from datetime import datetime
|
|
|
|
+import logging
|
|
|
|
+import logging
|
|
|
|
+logging.basicConfig(level=logging.DEBUG)
|
|
|
|
+
|
|
|
|
+videos_filename = 'videos.txt'
|
|
|
|
+
|
|
|
|
+def play_video():
|
|
|
|
+ global videos
|
|
|
|
+ if len(videos) < 1:
|
|
|
|
+ with open(videos_filename, 'r') as fh:
|
|
|
|
+ videos = fh.readlines()
|
|
|
|
+ random.shuffle(videos)
|
|
|
|
+ logging.info(f"{len(videos)} videos geladen")
|
|
|
|
+
|
|
|
|
+ logging.debug(f"noch { len(videos) } videos vorhanden")
|
|
|
|
+ subprocess.run(["mpv", "--fs", videos.pop()])
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+def bis_zum_naechsten_zehner():
|
|
|
|
+ x = random.randint(1,8)
|
|
|
|
+ y = random.randint(1,9)
|
|
|
|
+ print("von {} zum n Zehner?".format(10 * x + y))
|
|
|
|
+ c = readchar.readkey()
|
|
|
|
+
|
|
|
|
+ if c == "x":
|
|
|
|
+ return "x"
|
|
|
|
+
|
|
|
|
+ try:
|
|
|
|
+ e = (y + int(c)) % 10
|
|
|
|
+ except:
|
|
|
|
+ e = 1
|
|
|
|
+
|
|
|
|
+ if e == 0:
|
|
|
|
+ return True
|
|
|
|
+ else:
|
|
|
|
+ return False
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+videos = []
|
|
|
|
+zeiten = []
|
|
|
|
+
|
|
|
|
+while True:
|
|
|
|
+
|
|
|
|
+ start = datetime.now()
|
|
|
|
+ e = bis_zum_naechsten_zehner()
|
|
|
|
+ ende = datetime.now()
|
|
|
|
+
|
|
|
|
+ if e == "x":
|
|
|
|
+ break
|
|
|
|
+
|
|
|
|
+ logging.info(zeiten)
|
|
|
|
+
|
|
|
|
+ if e:
|
|
|
|
+ print("RICHTIG")
|
|
|
|
+ zeiten.insert(0, (ende - start).total_seconds())
|
|
|
|
+ else:
|
|
|
|
+ print("FALSCH")
|
|
|
|
+ zeiten = []
|
|
|
|
+
|
|
|
|
+ zeiten = zeiten[0:10]
|
|
|
|
+
|
|
|
|
+ logging.info(f"{len(zeiten)} Richtige in {sum(zeiten)} Sekunden")
|
|
|
|
+
|
|
|
|
+ if len(zeiten) >= 10 and sum(zeiten) <= 30:
|
|
|
|
+ print("JUHU!")
|
|
|
|
+ play_video()
|
|
|
|
+ zeiten = []
|