Fix commander decision making
This commit is contained in:
@@ -29,7 +29,8 @@ class Commander:
|
||||
# Should change this to follow strategy pattern, for different implementations of
|
||||
# making a decision on the votes.
|
||||
print("Making a decision")
|
||||
votes = self._votes
|
||||
votes = self._votes.values()
|
||||
print(type(votes))
|
||||
dif_votes = {}
|
||||
|
||||
for vote in votes:
|
||||
@@ -82,12 +83,13 @@ class Commander:
|
||||
print("Received a vote!")
|
||||
# Voter is sending in their vote.
|
||||
print(messageD.data["vote"])
|
||||
print("From: ", messageD.sender)
|
||||
if self._taking_votes:
|
||||
# Commander must have requested their taking votes, and the timeout
|
||||
# has not occurred.
|
||||
# Only add vote to list if the client has not already voted.
|
||||
if messageD.sender not in self._votes:
|
||||
self._votes[messageD.sender] = messageD.data["vote"]
|
||||
self._votes[messageD.sender] = int(messageD.data["vote"])
|
||||
|
||||
elif messageD.type == "disconnected":
|
||||
print("Voter disconnected :(")
|
||||
|
||||
Reference in New Issue
Block a user