From d820ab1f1ce2d1dfc3ba8cc8fa42a85da70a2794 Mon Sep 17 00:00:00 2001 From: Mike Mueller Date: Sun, 4 Mar 2012 22:55:52 -0800 Subject: [PATCH] Remove some useless checks. Some solution length logic was previously moved to handle_message. Some of the code in _valid_solution became nonsensical (not broken, just weird). Cleaned up. --- plugin.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/plugin.py b/plugin.py index 3ba3c72..8fff3c9 100644 --- a/plugin.py +++ b/plugin.py @@ -314,20 +314,18 @@ class WordChain(BaseGame): if len(words) != len(self.solution): return False # Check for incorrect start/end words - if len(words) == len(self.solution): - if words[0] != self.solution[0]: - self.send('%s: %s is not the starting word.' % (nick, words[0])) - return False - if words[-1] != self.solution[-1]: - self.send('%s: %s is not the final word.' % (nick, words[-1])) - return False - # Add the start/end words (if not present) to simplify the test logic - if len(words) == len(self.solution) - 2: - words = [self.solution[0]] + words + [self.solution[-1]] + if words[0] != self.solution[0]: + self.send('%s: %s is not the starting word.' % (nick, words[0])) + return False + if words[-1] != self.solution[-1]: + self.send('%s: %s is not the final word.' % (nick, words[-1])) + return False + # Check dictionary for word in words: if word not in self.words: self.send("%s: %s is not a word I know." % (nick, word)) return False + # Enforce pairwise relationships for i in range(0, len(words)-1): if words[i+1] not in self._get_successors(words[i]): self.send("%s: %s does not follow from %s." %