From 3b9840d6b9b00aa7f352f64dfd7e979c28a84b61 Mon Sep 17 00:00:00 2001 From: James Scott Date: Sun, 16 Dec 2012 20:10:37 -0500 Subject: [PATCH] fixes? --- plugin.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/plugin.py b/plugin.py index 4d9eb31..6730e88 100644 --- a/plugin.py +++ b/plugin.py @@ -113,18 +113,16 @@ class Cah(callbacks.Plugin): for canidateNumber, count in votes.iteritems(): canidate = canidatesById[canidateNumber] - if winningCanidate == None: - winningCanidate = (canidate, count) - elif winningCanidate[1] < count: - winningCanidate = (canidate, count) - ties = [] - elif winningCanidate[1] == count: - if len(ties) == 0: - ties.append(winningCanidate) - ties.append((canidate, count)) - if len(ties) > 0: - return (ties[randint(0, len(ties) -1)], True) - return (winningCanidate, False) + if len(winningCanidate) == None: + winningCanidate = [(canidate, count)] + elif winningCanidate[0][1] < count: + winningCanidate = ((canidate, count)] + elif winningCanidate[0][1] == count: + winningCanidate.append((canidate, count)) + + if len(winningCanidate) > 0: + return (winningCanidate[randint(0, len(ties) -1)], True) + return (winningCanidate[0], False) ###### END UTIL METHODS #######