Fix syntax errors and some other miscellaneous issues

This commit is contained in:
skizzerz 2014-07-14 01:06:41 -05:00
parent 77a6bfe3db
commit a10e706474
2 changed files with 85 additions and 78 deletions

View File

@ -1144,8 +1144,8 @@ def chk_win(cli, end_game = True):
"causing the monster{0} to win.").format(plural) "causing the monster{0} to win.").format(plural)
winner = "monsters" winner = "monsters"
else: else:
message = "Game over! There are the same number of wolves as " + message = ("Game over! There are the same number of wolves as " +
"uninjured villagers. The wolves overpower the villagers and win." "uninjured villagers. The wolves overpower the villagers and win.")
winner = "wolves" winner = "wolves"
elif lwolves > lpl / 2: elif lwolves > lpl / 2:
if len(var.ROLES["monster"]) > 0: if len(var.ROLES["monster"]) > 0:
@ -1155,8 +1155,8 @@ def chk_win(cli, end_game = True):
"causing the monster{0} to win.").format(plural) "causing the monster{0} to win.").format(plural)
winner = "monsters" winner = "monsters"
else: else:
message = "Game over! There are more wolves than "+ message = ("Game over! There are more wolves than "+
"uninjured villagers. The wolves overpower the villagers and win." "uninjured villagers. The wolves overpower the villagers and win.")
winner = "wolves" winner = "wolves"
elif lrealwolves == 0 and len(var.ROLES["traitor"]) == 0: elif lrealwolves == 0 and len(var.ROLES["traitor"]) == 0:
if len(var.ROLES["monster"]) > 0: if len(var.ROLES["monster"]) > 0:
@ -1166,8 +1166,8 @@ def chk_win(cli, end_game = True):
"causing the monster{0} to win.").format(plural) "causing the monster{0} to win.").format(plural)
winner = "monsters" winner = "monsters"
else: else:
message = "Game over! All the wolves are dead! The villagers " + message = ("Game over! All the wolves are dead! The villagers " +
"chop them up, BBQ them, and have a hearty meal." "chop them up, BBQ them, and have a hearty meal.")
winner = "villagers" winner = "villagers"
elif lrealwolves == 0: elif lrealwolves == 0:
for t in var.ROLES["traitor"]: for t in var.ROLES["traitor"]:
@ -1211,6 +1211,7 @@ def del_player(cli, nick, forced_death = False, devoice = True, end_game = True)
ret = True ret = True
if nick != None: if nick != None:
# handle roles that trigger on death # handle roles that trigger on death
if var.PHASE in ("night", "day"):
if nick in var.LOVERS: if nick in var.LOVERS:
others = copy.copy(var.LOVERS[nick]) others = copy.copy(var.LOVERS[nick])
var.LOVERS[nick].clear() var.LOVERS[nick].clear()
@ -2017,11 +2018,11 @@ def chk_nightdone(cli):
actedcount = len(var.SEEN + var.HVISITED.keys() + var.GUARDED.keys() + var.KILLS.keys() + actedcount = len(var.SEEN + var.HVISITED.keys() + var.GUARDED.keys() + var.KILLS.keys() +
var.OTHER_KILLS.keys() + var.OBSERVED + var.PASSED + var.HEXED + var.OTHER_KILLS.keys() + var.OBSERVED + var.PASSED + var.HEXED +
var.SHAMANS + var.MATCHMAKERS + var.TARGETED.keys() + var.CLONED.keys()) var.SHAMANS + var.MATCHMAKERS + var.TARGETED.keys() + var.CLONED.keys())
nightroles = var.ROLES["seer"] + var.ROLES["oracle"] + var.ROLES["harlot"] + nightroles = (var.ROLES["seer"] + var.ROLES["oracle"] + var.ROLES["harlot"] +
var.ROLES["guardian angel"] + var.ROLES["bodyguard"] + var.ROLES["wolf"] + var.ROLES["guardian angel"] + var.ROLES["bodyguard"] + var.ROLES["wolf"] +
var.ROLES["werecrow"] + var.ROLES["sorcerer"] + var.ROLES["clone"] + var.ROLES["werecrow"] + var.ROLES["sorcerer"] + var.ROLES["clone"] +
var.ROLES["hunter"] + var.VENGEFUL_GHOSTS.keys() + var.ROLES["hag"] + var.ROLES["hunter"] + var.VENGEFUL_GHOSTS.keys() + var.ROLES["hag"] +
var.ROLES["shaman"] + var.ROLES["crazed shaman"] + var.ROLES["assassin"] var.ROLES["shaman"] + var.ROLES["crazed shaman"] + var.ROLES["assassin"])
playercount = len([p for p in nightroles if p not in var.SILENCED]) playercount = len([p for p in nightroles if p not in var.SILENCED])
if (var.PHASE == "night" and actedcount >= playercount): if (var.PHASE == "night" and actedcount >= playercount):
@ -2724,7 +2725,7 @@ def see(cli, nick, rest):
victimrole = var.get_role(victim) victimrole = var.get_role(victim)
if victimrole in ("wolf", "werecrow", "monster", "mad scientist", "wolf cub") or victim in var.ROLES["cursed villager"]: if victimrole in ("wolf", "werecrow", "monster", "mad scientist", "wolf cub") or victim in var.ROLES["cursed villager"]:
victimrole = "wolf" victimrole = "wolf"
elif victimrole in ("traitor", "hag", "sorcerer", "village elder", "time lord", "matchmaker", "villager", "cultist", "minion", "vengeful ghost", "lycan", "clone", "fool") elif victimrole in ("traitor", "hag", "sorcerer", "village elder", "time lord", "matchmaker", "villager", "cultist", "minion", "vengeful ghost", "lycan", "clone", "fool"):
victimrole = var.DEFAULT_ROLE victimrole = var.DEFAULT_ROLE
elif role == "oracle": # Oracles never see specific roles, only generalizations elif role == "oracle": # Oracles never see specific roles, only generalizations
victimrole = var.DEFAULT_ROLE victimrole = var.DEFAULT_ROLE
@ -3037,7 +3038,7 @@ def transition_night(cli):
pm(cli, wolf, "Players: "+", ".join(pl)) pm(cli, wolf, "Players: "+", ".join(pl))
if wolf in var.WOLF_GUNNERS.keys(): if wolf in var.WOLF_GUNNERS.keys():
pm(cli, wolf, "You have a \u0002gun\u0002 with {0} bullet{1}.".format(var.WOLF_GUNNERS[wolf], "s" if var.WOLF_GUNNERS[wolf] > 1 else "") pm(cli, wolf, "You have a \u0002gun\u0002 with {0} bullet{1}.".format(var.WOLF_GUNNERS[wolf], "s" if var.WOLF_GUNNERS[wolf] > 1 else ""))
for seer in var.list_players(["seer", "oracle"]): for seer in var.list_players(["seer", "oracle"]):
pl = ps[:] pl = ps[:]
@ -3129,7 +3130,7 @@ def transition_night(cli):
"It is your job to determine all the wolves and traitors. "+ "It is your job to determine all the wolves and traitors. "+
"Your job is during the day, and you can see the true "+ "Your job is during the day, and you can see the true "+
"identity of all players, even traitors.\n"+ "identity of all players, even traitors.\n"+
'{0}Use "id <nick>" in PM to identify any player during the day.') '{0}Use "id <nick>" in PM to identify any player during the day.').format(warning))
else: else:
cli.notice(dttv, "You are a \02detective\02.") # !simple cli.notice(dttv, "You are a \02detective\02.") # !simple
pm(cli, dttv, "Players: " + ", ".join(pl)) pm(cli, dttv, "Players: " + ", ".join(pl))
@ -3169,7 +3170,7 @@ def transition_night(cli):
tmsg += 'The player who is given this totem will be unable to vote during the day tomorrow.' tmsg += 'The player who is given this totem will be unable to vote during the day tomorrow.'
elif totem == "silence": elif totem == "silence":
tmsg += 'The player who is given this totem will be unable to use any special powers during the day tomorrow and the night after.' tmsg += 'The player who is given this totem will be unable to use any special powers during the day tomorrow and the night after.'
elif totem == "desperation" elif totem == "desperation":
tmsg += 'If the player who is given this totem is lynched, the last player to vote them will also die.' tmsg += 'If the player who is given this totem is lynched, the last player to vote them will also die.'
else: else:
tmsg += 'No description for this totem is available. This is a bug, so please report this to the admins.' tmsg += 'No description for this totem is available. This is a bug, so please report this to the admins.'
@ -3528,7 +3529,7 @@ def start(cli, nick, chann_, rest):
var.ORIGINAL_ROLES = copy.deepcopy(var.ROLES) # Make a copy var.ORIGINAL_ROLES = copy.deepcopy(var.ROLES) # Make a copy
# Handle amnesiac # Handle amnesiac
for amnesiac in var.ROLES["amnesiac"] for amnesiac in var.ROLES["amnesiac"]:
role = var.get_role(amnesiac) role = var.get_role(amnesiac)
tpls = var.get_templates(amnesiac) tpls = var.get_templates(amnesiac)
var.ROLES[role].remove(amnesiac) var.ROLES[role].remove(amnesiac)
@ -3965,18 +3966,18 @@ def listroles(cli, nick, chan, rest):
if pl > 0: if pl > 0:
txt += '{0}: There are \u0002{1}\u0002 playing. '.format(nick, pl) txt += '{0}: There are \u0002{1}\u0002 playing. '.format(nick, pl)
for i in var.ROLE_INDEX: for i in range(0, len(var.ROLE_INDEX)):
if (i <= pl): if (var.ROLE_INDEX[i] <= pl):
txt += BOLD txt += BOLD
txt += "[" + str(i) + "] " txt += "[" + str(var.ROLE_INDEX[i]) + "] "
if (i <= pl): if (var.ROLE_INDEX[i] <= pl):
txt += BOLD txt += BOLD
for r, l in var.ROLE_GUIDE.items(): for r, l in var.ROLE_GUIDE.items():
if l[i] - old[r] != 0: if l[i] - old[r] != 0:
if l[i] > 1: if l[i] > 1:
txt += "{0}({1}), ".format(r, l[i]) txt += "{0}({1}), ".format(r, l[i])
else else:
txt += "{0], ".format(r) txt += "{0}, ".format(r)
old[r] = l[i] old[r] = l[i]
txt = txt[:-2] + " " txt = txt[:-2] + " "
@ -4475,3 +4476,5 @@ if botconfig.ALLOWED_NORMAL_MODE_COMMANDS and not botconfig.DEBUG_MODE:
if (pmcomd not in before_debug_mode_pmcommands and if (pmcomd not in before_debug_mode_pmcommands and
pmcomd not in botconfig.ALLOWED_NORMAL_MODE_COMMANDS): pmcomd not in botconfig.ALLOWED_NORMAL_MODE_COMMANDS):
del PM_COMMANDS[pmcomd] del PM_COMMANDS[pmcomd]
# vim: set expandtab:sw=4:ts=4:

View File

@ -176,7 +176,9 @@ def plural(role):
elif role == "person": return "people" elif role == "person": return "people"
else: return role + "s" else: return role + "s"
def list_players(roles = ROLES.keys()): def list_players(roles = None):
if roles == None:
roles = ROLES.keys()
return [p for r in roles for p in ROLES[r]] return [p for r in roles for p in ROLES[r]]
def list_players_and_roles(): def list_players_and_roles():
@ -421,3 +423,5 @@ def get_game_totals():
return "No games have been played." return "No games have been played."
else: else:
return "Total games ({0}) | {1}".format(total, ", ".join(size_totals)) return "Total games ({0}) | {1}".format(total, ", ".join(size_totals))
# vim : set expandtab:sw=4:ts=4: