Added Docker Stuff + Rearranged Files and Folders
This commit is contained in:
24
code/module/rainer_board.py
Normal file
24
code/module/rainer_board.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import random
|
||||
|
||||
|
||||
class rainerSpruche():
|
||||
|
||||
def __init__(self, spruchDatei):
|
||||
|
||||
with open(spruchDatei, 'r') as f:
|
||||
self.zitate = [line.strip() for line in f]
|
||||
|
||||
self.letzte_zahl = []
|
||||
|
||||
def randomSpruch(self):
|
||||
self.aktuelle_zahl = random.randint(0, len(self.zitate)-1)
|
||||
mögliche_zahlen = list(range(len(self.zitate)))
|
||||
while self.aktuelle_zahl in self.letzte_zahl:
|
||||
mögliche_zahlen.remove(self.aktuelle_zahl)
|
||||
if len(mögliche_zahlen) == 0:
|
||||
mögliche_zahlen = list(range(len(self.zitate)))
|
||||
self.aktuelle_zahl = random.choice(mögliche_zahlen)
|
||||
if len(self.letzte_zahl) >= 3:
|
||||
self.letzte_zahl.pop(0)
|
||||
self.letzte_zahl.append(self.aktuelle_zahl)
|
||||
return(self.zitate[self.aktuelle_zahl])
|
||||
Reference in New Issue
Block a user