add var.GRAVEYARD_LOCK check in chk_win, add more checks for game ending in those
This commit is contained in:
parent
6aeb149241
commit
1519ba3765
@ -1318,78 +1318,82 @@ def chk_win(cli, end_game = True):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
lwolves = len(var.list_players(var.WOLFCHAT_ROLES))
|
with var.GRAVEYARD_LOCK:
|
||||||
cubs = len(var.ROLES["wolf cub"]) if "wolf cub" in var.ROLES else 0
|
if var.PHASE not in ("day", "night"):
|
||||||
lrealwolves = len(var.list_players(var.WOLF_ROLES)) - cubs
|
return False #some other thread already ended game probably
|
||||||
monsters = len(var.ROLES["monster"]) if "monster" in var.ROLES else 0
|
|
||||||
traitors = len(var.ROLES["traitor"]) if "traitor" in var.ROLES else 0
|
lwolves = len(var.list_players(var.WOLFCHAT_ROLES))
|
||||||
if var.PHASE == "day":
|
cubs = len(var.ROLES["wolf cub"]) if "wolf cub" in var.ROLES else 0
|
||||||
for p in var.WOUNDED:
|
lrealwolves = len(var.list_players(var.WOLF_ROLES)) - cubs
|
||||||
try:
|
monsters = len(var.ROLES["monster"]) if "monster" in var.ROLES else 0
|
||||||
role = var.get_role(p)
|
traitors = len(var.ROLES["traitor"]) if "traitor" in var.ROLES else 0
|
||||||
if role in var.WOLFCHAT_ROLES:
|
if var.PHASE == "day":
|
||||||
lwolves -= 1
|
for p in var.WOUNDED:
|
||||||
else:
|
try:
|
||||||
lpl -= 1
|
role = var.get_role(p)
|
||||||
except KeyError:
|
if role in var.WOLFCHAT_ROLES:
|
||||||
pass
|
lwolves -= 1
|
||||||
for p in var.ASLEEP:
|
else:
|
||||||
try:
|
lpl -= 1
|
||||||
role = var.get_role(p)
|
except KeyError:
|
||||||
if role in var.WOLFCHAT_ROLES:
|
pass
|
||||||
lwolves -= 1
|
for p in var.ASLEEP:
|
||||||
else:
|
try:
|
||||||
lpl -= 1
|
role = var.get_role(p)
|
||||||
except KeyError:
|
if role in var.WOLFCHAT_ROLES:
|
||||||
pass
|
lwolves -= 1
|
||||||
|
else:
|
||||||
|
lpl -= 1
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
if lpl < 1:
|
if lpl < 1:
|
||||||
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 monsters > 0:
|
if monsters > 0:
|
||||||
plural = "s" if monsters > 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)
|
||||||
winner = "monsters"
|
winner = "monsters"
|
||||||
|
else:
|
||||||
|
message = ("Game over! There are the same number of wolves as " +
|
||||||
|
"uninjured villagers. The wolves overpower the villagers and win.")
|
||||||
|
winner = "wolves"
|
||||||
|
elif lwolves > lpl / 2:
|
||||||
|
if monsters > 0:
|
||||||
|
plural = "s" if monsters > 1 else ""
|
||||||
|
message = ("Game over! There are more wolves than uninjured villagers. " +
|
||||||
|
"The wolves overpower the villagers but then get destroyed by the monster{0}, " +
|
||||||
|
"causing the monster{0} to win.").format(plural)
|
||||||
|
winner = "monsters"
|
||||||
|
else:
|
||||||
|
message = ("Game over! There are more wolves than "+
|
||||||
|
"uninjured villagers. The wolves overpower the villagers and win.")
|
||||||
|
winner = "wolves"
|
||||||
|
elif lrealwolves == 0 and traitors == 0 and cubs == 0:
|
||||||
|
if monsters > 0:
|
||||||
|
plural = "s" if monsters > 1 else ""
|
||||||
|
message = ("Game over! All the wolves are dead! As the villagers start preparing the BBQ, " +
|
||||||
|
"the monster{0} quickly kill{1} the remaining villagers, " +
|
||||||
|
"causing the monster{0} to win.").format(plural, "" if plural else "s")
|
||||||
|
winner = "monsters"
|
||||||
|
else:
|
||||||
|
message = ("Game over! All the wolves are dead! The villagers " +
|
||||||
|
"chop them up, BBQ them, and have a hearty meal.")
|
||||||
|
winner = "villagers"
|
||||||
|
elif lrealwolves == 0:
|
||||||
|
chk_traitor(cli)
|
||||||
|
return chk_win(cli, end_game)
|
||||||
else:
|
else:
|
||||||
message = ("Game over! There are the same number of wolves as " +
|
return False
|
||||||
"uninjured villagers. The wolves overpower the villagers and win.")
|
if end_game:
|
||||||
winner = "wolves"
|
cli.msg(chan, message)
|
||||||
elif lwolves > lpl / 2:
|
var.LOGGER.logMessage(message)
|
||||||
if monsters > 0:
|
var.LOGGER.logBare(winner.upper(), "WIN")
|
||||||
plural = "s" if monsters > 1 else ""
|
stop_game(cli, winner)
|
||||||
message = ("Game over! There are more wolves than uninjured villagers. " +
|
return True
|
||||||
"The wolves overpower the villagers but then get destroyed by the monster{0}, " +
|
|
||||||
"causing the monster{0} to win.").format(plural)
|
|
||||||
winner = "monsters"
|
|
||||||
else:
|
|
||||||
message = ("Game over! There are more wolves than "+
|
|
||||||
"uninjured villagers. The wolves overpower the villagers and win.")
|
|
||||||
winner = "wolves"
|
|
||||||
elif lrealwolves == 0 and traitors == 0 and cubs == 0:
|
|
||||||
if monsters > 0:
|
|
||||||
plural = "s" if monsters > 1 else ""
|
|
||||||
message = ("Game over! All the wolves are dead! As the villagers start preparing the BBQ, " +
|
|
||||||
"the monster{0} quickly kill{1} the remaining villagers, " +
|
|
||||||
"causing the monster{0} to win.").format(plural, "" if plural else "s")
|
|
||||||
winner = "monsters"
|
|
||||||
else:
|
|
||||||
message = ("Game over! All the wolves are dead! The villagers " +
|
|
||||||
"chop them up, BBQ them, and have a hearty meal.")
|
|
||||||
winner = "villagers"
|
|
||||||
elif lrealwolves == 0:
|
|
||||||
chk_traitor(cli)
|
|
||||||
return chk_win(cli, end_game)
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
if end_game:
|
|
||||||
cli.msg(chan, message)
|
|
||||||
var.LOGGER.logMessage(message)
|
|
||||||
var.LOGGER.logBare(winner.upper(), "WIN")
|
|
||||||
stop_game(cli, winner)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def del_player(cli, nick, forced_death = False, devoice = True, end_game = True, death_triggers = True, killer_role = "", deadlist = [], original = ""):
|
def del_player(cli, nick, forced_death = False, devoice = True, end_game = True, death_triggers = True, killer_role = "", deadlist = [], original = ""):
|
||||||
"""
|
"""
|
||||||
@ -1724,8 +1728,8 @@ def reaper(cli, gameid):
|
|||||||
|
|
||||||
while gameid == var.GAME_ID:
|
while gameid == var.GAME_ID:
|
||||||
with var.GRAVEYARD_LOCK:
|
with var.GRAVEYARD_LOCK:
|
||||||
# Terminate reaper when experiencing disk lag
|
# Terminate reaper when game ends
|
||||||
if var.PHASE == "writing files":
|
if var.PHASE not in ("day", "night"):
|
||||||
return
|
return
|
||||||
if var.WARN_IDLE_TIME or var.PM_WARN_IDLE_TIME or var.KILL_IDLE_TIME: # only if enabled
|
if var.WARN_IDLE_TIME or var.PM_WARN_IDLE_TIME or var.KILL_IDLE_TIME: # only if enabled
|
||||||
to_warn = []
|
to_warn = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user