From a21c272c8b0c682362746af87da2f487cc747117 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 7 Aug 2020 18:11:27 +0100 Subject: [PATCH] Prevent players double joining match making system --- houdini/handlers/games/match.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/houdini/handlers/games/match.py b/houdini/handlers/games/match.py index dab4fda..6ad8aaf 100644 --- a/houdini/handlers/games/match.py +++ b/houdini/handlers/games/match.py @@ -57,9 +57,10 @@ class MatchMaking: mm.tick -= 1 def add_penguin(self, p): - mm = MatchMaker(penguin=p, tick=self._match_every) - self._penguins.append(mm) - self._penguins.sort(key=operator.attrgetter('penguin.' + self._match_by)) + if p not in self._penguins: + mm = MatchMaker(penguin=p, tick=self._match_every) + self._penguins.append(mm) + self._penguins.sort(key=operator.attrgetter('penguin.' + self._match_by)) def remove_penguin(self, p): self._penguins = [mm for mm in self._penguins if mm.penguin != p]