Browse Source

alles faengt mal an

Thomas Verchow 1 year ago
parent
commit
fe59e3b07d
3 changed files with 88 additions and 17 deletions
  1. 0 17
      requirements.txt
  2. 74 0
      src/hanna_rechnet/hanna-rechnet.py
  3. 14 0
      videos.txt

+ 0 - 17
requirements.txt

@@ -1,17 +0,0 @@
-# =============================================================================
-# DEPRECATION WARNING:
-#
-# The file `requirements.txt` does not influence the package dependencies and
-# will not be automatically created in the next version of PyScaffold (v4.x).
-#
-# Please have look at the docs for better alternatives
-# (`Dependency Management` section).
-# =============================================================================
-#
-# Add your pinned requirements so that they can be easily installed with:
-# pip install -r requirements.txt
-# Remember to also add them in setup.cfg but unpinned.
-# Example:
-# numpy==1.13.3
-# scipy==1.0
-#

+ 74 - 0
src/hanna_rechnet/hanna-rechnet.py

@@ -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 = []

+ 14 - 0
videos.txt

@@ -0,0 +1,14 @@
+https://www.youtube.com/watch?v=1zr7H-wwjYY
+https://www.youtube.com/watch?v=9bZkp7q19f0
+https://www.youtube.com/watch?v=BR22O5Mdawg
+https://www.youtube.com/watch?v=EBsFnwAgpdY
+https://www.youtube.com/watch?v=HBjDZMJUduo
+https://www.youtube.com/watch?v=KQ6zr6kCPj8
+https://www.youtube.com/watch?v=Nfpaah_Mlf8
+https://www.youtube.com/watch?v=XRZ7NIsukJU
+https://www.youtube.com/watch?v=ZPJlyRv_IGI
+https://www.youtube.com/watch?v=dk4NYOjrEJE
+https://www.youtube.com/watch?v=jofNR_WkoCE
+https://www.youtube.com/watch?v=mdIP3hyxi3k
+https://www.youtube.com/watch?v=qmsbP13xu6k
+https://www.youtube.com/watch?v=vH1poPSIvOk