Fix KeyError in chk_win
This fixes the error with wolf cub that has been appearing for a while now, and also prevents similar errors from happening with monster and traitor in the same function.
This commit is contained in:
parent
6e372566c6
commit
f646844aad
@ -1293,7 +1293,10 @@ def chk_win(cli, end_game = True):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
lwolves = len(var.list_players(var.WOLFCHAT_ROLES))
|
lwolves = len(var.list_players(var.WOLFCHAT_ROLES))
|
||||||
lrealwolves = len(var.list_players(var.WOLF_ROLES)) - len(var.ROLES["wolf cub"])
|
cubs = len(var.ROLES["wolf cub"]) if "wolf cub" in var.ROLES else 0
|
||||||
|
lrealwolves = len(var.list_players(var.WOLF_ROLES)) - cubs
|
||||||
|
monsters = len(var.ROLES["monster"]) if "monster" in var.ROLES else 0
|
||||||
|
traitors = len(var.ROLES["traitor"]) if "traitor" in var.ROLES else 0
|
||||||
if var.PHASE == "day":
|
if var.PHASE == "day":
|
||||||
for p in var.WOUNDED:
|
for p in var.WOUNDED:
|
||||||
try:
|
try:
|
||||||
@ -1318,8 +1321,8 @@ def chk_win(cli, end_game = True):
|
|||||||
message = "Game over! There are no players remaining. Nobody wins."
|
message = "Game over! There are no players remaining. Nobody wins."
|
||||||
winner = "none"
|
winner = "none"
|
||||||
elif lwolves == lpl / 2:
|
elif lwolves == lpl / 2:
|
||||||
if len(var.ROLES["monster"]) > 0:
|
if monsters > 0:
|
||||||
plural = "s" if len(var.ROLES["monster"]) > 1 else ""
|
plural = "s" if monsters > 1 else ""
|
||||||
message = ("Game over! There are the same number of wolves as uninjured villagers. " +
|
message = ("Game over! There are the same number of wolves as uninjured villagers. " +
|
||||||
"The wolves overpower the villagers but then get destroyed by the monster{0}, " +
|
"The wolves overpower the villagers but then get destroyed by the monster{0}, " +
|
||||||
"causing the monster{0} to win.").format(plural)
|
"causing the monster{0} to win.").format(plural)
|
||||||
@ -1329,8 +1332,8 @@ def chk_win(cli, end_game = True):
|
|||||||
"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 monsters > 0:
|
||||||
plural = "s" if len(var.ROLES["monster"]) > 1 else ""
|
plural = "s" if monsters > 1 else ""
|
||||||
message = ("Game over! There are more wolves than uninjured villagers. " +
|
message = ("Game over! There are more wolves than uninjured villagers. " +
|
||||||
"The wolves overpower the villagers but then get destroyed by the monster{0}, " +
|
"The wolves overpower the villagers but then get destroyed by the monster{0}, " +
|
||||||
"causing the monster{0} to win.").format(plural)
|
"causing the monster{0} to win.").format(plural)
|
||||||
@ -1339,9 +1342,9 @@ def chk_win(cli, end_game = True):
|
|||||||
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 and len(var.ROLES["wolf cub"]) == 0:
|
elif lrealwolves == 0 and traitors == 0 and cubs == 0:
|
||||||
if len(var.ROLES["monster"]) > 0:
|
if monsters > 0:
|
||||||
plural = "s" if len(var.ROLES["monster"]) > 1 else ""
|
plural = "s" if monsters > 1 else ""
|
||||||
message = ("Game over! All the wolves are dead! As the villagers start preparing the BBQ, " +
|
message = ("Game over! All the wolves are dead! As the villagers start preparing the BBQ, " +
|
||||||
"the monster{0} quickly kill{1} the remaining villagers, " +
|
"the monster{0} quickly kill{1} the remaining villagers, " +
|
||||||
"causing the monster{0} to win.").format(plural, "" if plural else "s")
|
"causing the monster{0} to win.").format(plural, "" if plural else "s")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user