Fix TypeError from list+tuple and s/sum/count/ where able

This commit is contained in:
skizzerz 2015-06-08 19:22:09 -05:00
parent 6604de63e3
commit 02a35b8d20

View File

@ -1374,8 +1374,8 @@ def hurry_up(cli, gameid, change):
voters.append(v) voters.append(v)
for v in voters: for v in voters:
weight = 1 weight = 1
imp_count = sum(1 if p == v else 0 for p in var.IMPATIENT) imp_count = var.IMPATIENT.count(v)
pac_count = sum(1 if p == v else 0 for p in var.PACIFISTS) pac_count = var.PACIFISTS.count(v)
if pac_count > imp_count: if pac_count > imp_count:
weight = 0 # more pacifists than impatience totems weight = 0 # more pacifists than impatience totems
elif imp_count == pac_count and v not in var.VOTES[votee]: elif imp_count == pac_count and v not in var.VOTES[votee]:
@ -1455,8 +1455,8 @@ def chk_decision(cli, force = ""):
if v in pl and v not in voters and v != votee and v not in var.WOUNDED and v not in var.ASLEEP: if v in pl and v not in voters and v != votee and v not in var.WOUNDED and v not in var.ASLEEP:
# don't add them in if they have the same number or more of pacifism totems # don't add them in if they have the same number or more of pacifism totems
# this matters for desperation totem on the votee # this matters for desperation totem on the votee
imp_count = sum(1 if p == v else 0 for p in var.IMPATIENT) imp_count = var.IMPATIENT.count(v)
pac_count = sum(1 if p == v else 0 for p in var.PACIFISTS) pac_count = var.PACIFISTS.count(v)
if pac_count >= imp_count: if pac_count >= imp_count:
continue continue
@ -1466,8 +1466,8 @@ def chk_decision(cli, force = ""):
impatient_voters.append(v) impatient_voters.append(v)
for v in voters[:]: for v in voters[:]:
weight = 1 weight = 1
imp_count = sum(1 if p == v else 0 for p in var.IMPATIENT) imp_count = var.IMPATIENT.count(v)
pac_count = sum(1 if p == v else 0 for p in var.PACIFISTS) pac_count = var.PACIFISTS.count(v)
if pac_count > imp_count: if pac_count > imp_count:
weight = 0 # more pacifists than impatience totems weight = 0 # more pacifists than impatience totems
elif imp_count == pac_count and v not in var.VOTES[votee]: elif imp_count == pac_count and v not in var.VOTES[votee]:
@ -3193,8 +3193,8 @@ def transition_day(cli, gameid=0):
if v in var.DYING: if v in var.DYING:
# this person is dying no matter what # this person is dying no matter what
continue continue
numkills = sum(1 for n in victims if n == v) numkills = victims.count(v)
numtotems = sum(1 for n in var.PROTECTED if n == v) numtotems = var.PROTECTED.count(v)
if numtotems >= numkills: if numtotems >= numkills:
protected[v] = "totem" protected[v] = "totem"
if numtotems > numkills: if numtotems > numkills:
@ -4099,7 +4099,7 @@ def retract(cli, nick, chan, rest):
if chan == nick: # PM, use different code if chan == nick: # PM, use different code
role = var.get_role(nick) role = var.get_role(nick)
if role not in var.WOLF_ROLES + ("hunter",) and nick not in var.VENGEFUL_GHOSTS.keys(): if role not in var.WOLF_ROLES + ["hunter"] and nick not in var.VENGEFUL_GHOSTS.keys():
return return
if role == "wolf cub": if role == "wolf cub":
return return