diff --git a/FaustBot/Modules/MathRunObserver.py b/FaustBot/Modules/MathRunObserver.py index ce63d54..bb87d90 100644 --- a/FaustBot/Modules/MathRunObserver.py +++ b/FaustBot/Modules/MathRunObserver.py @@ -10,7 +10,7 @@ class MathRunObserver(PrivMsgObserverPrototype): @staticmethod def help(): - return '.startmath startet eine Reihe von Aufgaben. .stopmath beendet sie. Lösungen mit ".s Lösung" eingeben.' + return '".startmath" startet eine Reihe von Aufgaben. ".stopmath" beendet sie. Lösungen mit ".s Lösung" eingeben.' def __init__(self): super().__init__() @@ -21,16 +21,18 @@ class MathRunObserver(PrivMsgObserverPrototype): self.oldSolution = 0 def update_on_priv_msg(self, data, connection: Connection): - if data['message'].find('.s ') != -1 : + if data['message'].startswith('.s ') and not data['message'].startswith('.startmath') and not data['message'].startswith('.stopmath'): self.solution(data, connection) - if data['message'].find('.startmath') != -1: + if data['message'].startswith('.startmath'): self.start_math(data, connection) + if data['message'].startswith('.stopmath'): + self.stop_math(data, connection) def solution(self, data, connection): nick = data["nick"] solutionByPlayer = data['message'].split()[1] if solutionByPlayer is None: - connection.send_back("Sorry du hast keine Lösung angegeben " + nick, data) + connection.send_back("Du hast keine Lösung angegeben " + nick, data) return if solutionByPlayer == str(self.solutionForGame): connection.send_channel("Korrekte Lösung " + nick) @@ -63,9 +65,13 @@ class MathRunObserver(PrivMsgObserverPrototype): self.stop_Timer(data, connection) def stop_math(self, data, connection): + for player in self.players.keys(): - connection.send_channel(player + " hat\t" + str(self.players[player]) + "\t Punkte") - connection.send_channel("Spiel beendet") + if self.players[player] == 1: + connection.send_channel(player + " hat\t" + str(self.players[player]) + "\tPunkt") + else: + connection.send_channel(player + " hat\t" + str(self.players[player]) + "\tPunkte") + connection.send_channel("Mathrun beendet") self.players = {} self.solutionForGame = 0 self.type = 0 @@ -73,4 +79,5 @@ class MathRunObserver(PrivMsgObserverPrototype): def stop_Timer(self, data, connection): sleep(120) - self.stop_math(data, connection) \ No newline at end of file + if self.running: + self.stop_math(data, connection) \ No newline at end of file