Merge pull request #85 from skizzerz/fiximpatience
Impatience and pacifism totem improvements
This commit is contained in:
commit
6aeb149241
@ -844,26 +844,49 @@ def chk_decision(cli, force = ""):
|
||||
pl = var.list_players()
|
||||
avail = len(pl) - len(var.WOUNDED) - len(var.ASLEEP)
|
||||
votesneeded = avail // 2 + 1
|
||||
not_lynching = set(var.NO_LYNCH)
|
||||
not_lynching = var.NO_LYNCH[:]
|
||||
for p in var.PACIFISTS:
|
||||
if p in pl and p not in var.WOUNDED and p not in var.ASLEEP:
|
||||
not_lynching.add(p)
|
||||
not_lynching.append(p)
|
||||
|
||||
# .remove() will only remove the first instance, which means this plays nicely with pacifism countering this
|
||||
for p in var.IMPATIENT:
|
||||
if p in not_lynching:
|
||||
not_lynching.remove(p)
|
||||
|
||||
# remove duplicates
|
||||
not_lynching = set(not_lynching)
|
||||
|
||||
# we only need 50%+ to not lynch, instead of an actual majority, because a tie would time out day anyway
|
||||
# don't check for ABSTAIN_ENABLED here since we may have a case where the majority of people have pacifism totems or something
|
||||
if len(not_lynching) >= math.ceil(avail / 2):
|
||||
for p in not_lynching:
|
||||
if p not in var.NO_LYNCH:
|
||||
cli.msg(botconfig.CHANNEL, "\u0002{0}\u0002 meekly votes to not lynch anyone today.".format(p))
|
||||
cli.msg(botconfig.CHANNEL, "The villagers have agreed to not lynch anybody today.")
|
||||
var.ABSTAINED = True
|
||||
transition_night(cli)
|
||||
return
|
||||
aftermessage = None
|
||||
votelist = copy.deepcopy(var.VOTES)
|
||||
impatient_voters = []
|
||||
for votee, voters in votelist.items():
|
||||
numvotes = 0
|
||||
random.shuffle(var.IMPATIENT)
|
||||
for v in var.IMPATIENT:
|
||||
if v in pl and v not in voters and v != votee and v not in var.WOUNDED and v not in var.ASLEEP:
|
||||
voters = [v] + voters
|
||||
for v in voters:
|
||||
# don't add them in if they have the same number or more of pacifism totems
|
||||
# this matters for desperation totem on the votee
|
||||
imp_count = sum([1 if p == v else 0 for p in var.IMPATIENT])
|
||||
pac_count = sum([1 if p == v else 0 for p in var.PACIFISTS])
|
||||
if pac_count >= imp_count:
|
||||
continue
|
||||
|
||||
# yes, this means that one of the impatient people will get desperation totem'ed if they didn't
|
||||
# already !vote earlier. sucks to suck. >:)
|
||||
voters.append(v)
|
||||
impatient_voters.append(v)
|
||||
for v in voters[:]:
|
||||
weight = 1
|
||||
imp_count = sum([1 if p == v else 0 for p in var.IMPATIENT])
|
||||
pac_count = sum([1 if p == v else 0 for p in var.PACIFISTS])
|
||||
@ -876,6 +899,9 @@ def chk_decision(cli, force = ""):
|
||||
numvotes += weight
|
||||
|
||||
if numvotes >= votesneeded or votee == force:
|
||||
for p in impatient_voters:
|
||||
cli.msg(botconfig.CHANNEL, "\u0002{0}\u0002 impatiently votes for \u0002{1}\u0002.".format(p, votee))
|
||||
|
||||
# roles that prevent any lynch from happening
|
||||
if votee in var.ROLES["mayor"] and votee not in var.REVEALED_MAYORS:
|
||||
lmsg = ("While being dragged to the gallows, \u0002{0}\u0002 reveals that they " +
|
||||
@ -2821,7 +2847,7 @@ def no_lynch(cli, nick, chan, rest):
|
||||
var.VOTES[voter].remove(nick)
|
||||
if not var.VOTES[voter]:
|
||||
del var.VOTES[voter]
|
||||
if nick not in var.NO_LYNCH and nick not in var.IMPATIENT:
|
||||
if nick not in var.NO_LYNCH:
|
||||
var.NO_LYNCH.append(nick)
|
||||
cli.msg(chan, "\u0002{0}\u0002 votes to not lynch anyone today.".format(nick))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user