parent
2c4ade2454
commit
ac9bc89699
@ -1038,20 +1038,12 @@ def stop_game(cli, winner = ""):
|
|||||||
pass
|
pass
|
||||||
cli.msg(chan, " ".join(roles_msg))
|
cli.msg(chan, " ".join(roles_msg))
|
||||||
|
|
||||||
reset_modes_timers(cli)
|
|
||||||
|
|
||||||
# Set temporary phase to deal with disk lag
|
|
||||||
var.PHASE = "writing files"
|
|
||||||
|
|
||||||
plrl = []
|
plrl = []
|
||||||
|
winners = []
|
||||||
for role,ppl in var.ORIGINAL_ROLES.items():
|
for role,ppl in var.ORIGINAL_ROLES.items():
|
||||||
for x in ppl:
|
for x in ppl:
|
||||||
if x != None:
|
if x != None:
|
||||||
plrl.append((x, role))
|
plrl.append((x, role))
|
||||||
|
|
||||||
var.LOGGER.saveToFile()
|
|
||||||
|
|
||||||
winners = []
|
|
||||||
for plr, rol in plrl:
|
for plr, rol in plrl:
|
||||||
#if plr not in var.USERS.keys(): # they died TODO: when a player leaves, count the game as lost for them
|
#if plr not in var.USERS.keys(): # they died TODO: when a player leaves, count the game as lost for them
|
||||||
# if plr in var.DEAD_USERS.keys():
|
# if plr in var.DEAD_USERS.keys():
|
||||||
@ -1064,25 +1056,21 @@ def stop_game(cli, winner = ""):
|
|||||||
elif plr in var.PLAYERS.keys():
|
elif plr in var.PLAYERS.keys():
|
||||||
acc = var.PLAYERS[plr]["account"]
|
acc = var.PLAYERS[plr]["account"]
|
||||||
else:
|
else:
|
||||||
continue #probably fjoin'd fake
|
acc = "*" #probably fjoin'd fake
|
||||||
|
|
||||||
|
won = False
|
||||||
|
iwon = False
|
||||||
# determine if this player's team won
|
# determine if this player's team won
|
||||||
if plr in [p for r in var.WOLFTEAM_ROLES for p in var.ORIGINAL_ROLES[r]]: # the player was wolf-aligned
|
if plr in [p for r in var.WOLFTEAM_ROLES for p in var.ORIGINAL_ROLES[r]]: # the player was wolf-aligned
|
||||||
if winner == "wolves":
|
if winner == "wolves":
|
||||||
won = True
|
won = True
|
||||||
else:
|
|
||||||
won = False
|
|
||||||
elif plr in [p for r in var.TRUE_NEUTRAL_ROLES for p in var.ORIGINAL_ROLES[r]]:
|
elif plr in [p for r in var.TRUE_NEUTRAL_ROLES for p in var.ORIGINAL_ROLES[r]]:
|
||||||
# true neutral roles never have a team win (with exception of monsters), only individual wins
|
# true neutral roles never have a team win (with exception of monsters), only individual wins
|
||||||
if winner == "monsters" and plr in var.ORIGINAL_ROLES["monster"]:
|
if winner == "monsters" and plr in var.ORIGINAL_ROLES["monster"]:
|
||||||
won = True
|
won = True
|
||||||
else:
|
|
||||||
won = False
|
|
||||||
else:
|
else:
|
||||||
if winner == "villagers":
|
if winner == "villagers":
|
||||||
won = True
|
won = True
|
||||||
else:
|
|
||||||
won = False
|
|
||||||
|
|
||||||
survived = var.list_players()
|
survived = var.list_players()
|
||||||
if plr.startswith("(dced)"):
|
if plr.startswith("(dced)"):
|
||||||
@ -1094,15 +1082,20 @@ def stop_game(cli, winner = ""):
|
|||||||
elif plr in var.ORIGINAL_ROLES["monster"] and plr in survived and winner == "monsters":
|
elif plr in var.ORIGINAL_ROLES["monster"] and plr in survived and winner == "monsters":
|
||||||
iwon = True
|
iwon = True
|
||||||
# del_player() doesn't get called on lynched fool, so both will survive even in that case
|
# del_player() doesn't get called on lynched fool, so both will survive even in that case
|
||||||
elif plr in var.LOVERS and plr in survived and var.LOVERS[plr] in survived:
|
elif plr in var.LOVERS and plr in survived:
|
||||||
|
for lvr in var.LOVERS[plr]:
|
||||||
|
if lvr in survived and not winner.startswith("@") and winner != "monsters":
|
||||||
|
iwon = True
|
||||||
|
break
|
||||||
|
elif lvr in survived and winner.startswith("@") and winner == "@" + lvr:
|
||||||
|
iwon = True
|
||||||
|
break
|
||||||
|
elif lvr in survived and winner == "monsters" and lvr in var.ORIGINAL_ROLES["monster"]:
|
||||||
|
iwon = True
|
||||||
|
break
|
||||||
|
if plr in var.ORIGINAL_ROLES["crazed shaman"]:
|
||||||
if not winner.startswith("@") and winner != "monsters":
|
if not winner.startswith("@") and winner != "monsters":
|
||||||
iwon = True
|
iwon = True
|
||||||
elif winner.startswith("@") and winner[1:] == var.LOVERS[plr]:
|
|
||||||
iwon = True
|
|
||||||
elif winner == "monsters" and var.LOVERS[plr] in var.ORIGINAL_ROLES["monster"]:
|
|
||||||
iwon = True
|
|
||||||
elif plr in var.ORIGINAL_ROLES["crazed shaman"] and not winner.startswith("@") and winner != "monsters":
|
|
||||||
iwon = True
|
|
||||||
elif plr in var.ORIGINAL_ROLES["vengeful ghost"]:
|
elif plr in var.ORIGINAL_ROLES["vengeful ghost"]:
|
||||||
if plr in survived:
|
if plr in survived:
|
||||||
iwon = True
|
iwon = True
|
||||||
@ -1112,8 +1105,6 @@ def stop_game(cli, winner = ""):
|
|||||||
elif var.VENGEFUL_GHOSTS[plr] == "wolves" and winner == "villagers":
|
elif var.VENGEFUL_GHOSTS[plr] == "wolves" and winner == "villagers":
|
||||||
won = True
|
won = True
|
||||||
iwon = True
|
iwon = True
|
||||||
else:
|
|
||||||
iwon = False
|
|
||||||
elif plr in var.ORIGINAL_ROLES["lycan"]:
|
elif plr in var.ORIGINAL_ROLES["lycan"]:
|
||||||
if plr in var.LYCANS and winner == "wolves":
|
if plr in var.LYCANS and winner == "wolves":
|
||||||
won = True
|
won = True
|
||||||
@ -1121,33 +1112,38 @@ def stop_game(cli, winner = ""):
|
|||||||
won = True
|
won = True
|
||||||
else:
|
else:
|
||||||
won = False
|
won = False
|
||||||
iwon = won and plr in survived
|
if not iwon:
|
||||||
else:
|
iwon = won and plr in survived
|
||||||
|
elif not iwon:
|
||||||
iwon = won and plr in survived # survived, team won = individual win
|
iwon = won and plr in survived # survived, team won = individual win
|
||||||
|
|
||||||
if acc != "*":
|
if acc != "*":
|
||||||
var.update_role_stats(acc, rol, won, iwon)
|
var.update_role_stats(acc, rol, won, iwon)
|
||||||
|
|
||||||
if (won or iwon) and plr.startswith("(dced)"):
|
if won or iwon:
|
||||||
winners.append(plr[6:])
|
|
||||||
else:
|
|
||||||
winners.append(plr)
|
winners.append(plr)
|
||||||
|
|
||||||
size = len(var.list_players()) + len(var.DEAD)
|
size = len(survived) + len(var.DEAD)
|
||||||
# Only update if someone actually won, "" indicates everyone died or abnormal game stop
|
# Only update if someone actually won, "" indicates everyone died or abnormal game stop
|
||||||
if winner != "":
|
if winner != "":
|
||||||
var.update_game_stats(size, winner)
|
var.update_game_stats(size, winner)
|
||||||
|
|
||||||
# spit out the list of winners
|
# spit out the list of winners
|
||||||
winners.sort()
|
winners.sort()
|
||||||
if len(winners) == 1:
|
if len(winners) == 1:
|
||||||
cli.msg(chan, "The winner is \u0002{0}\u0002.".format(winners[0]))
|
cli.msg(chan, "The winner is \u0002{0}\u0002.".format(winners[0]))
|
||||||
elif len(winners) == 2:
|
elif len(winners) == 2:
|
||||||
cli.msg(chan, "The winners are \u0002{0}\u0002 and \u0002{1}\u0002.".format())
|
cli.msg(chan, "The winners are \u0002{0}\u0002 and \u0002{1}\u0002.".format(winners[0], winners[1]))
|
||||||
elif len(winners) == 3:
|
elif len(winners) > 2:
|
||||||
cli.msg(chan, "The winners are {0}, and \u0002{1}\u0002.".format(
|
nicklist = ["\u0002" + x + "\u0002" for x in winners[0:-1]]
|
||||||
", ".join(map(lambda x: "\u0002{0}\u0002".format(x), winners[0:-1]))))
|
cli.msg(chan, "The winners are {0}, and \u0002{1}\u0002.".format(", ".join(nicklist), winners[-1]))
|
||||||
|
|
||||||
|
reset_modes_timers(cli)
|
||||||
|
|
||||||
|
# Set temporary phase to deal with disk lag
|
||||||
|
var.PHASE = "writing files"
|
||||||
|
|
||||||
|
var.LOGGER.saveToFile()
|
||||||
reset(cli)
|
reset(cli)
|
||||||
|
|
||||||
# This must be after reset(cli)
|
# This must be after reset(cli)
|
||||||
@ -1162,20 +1158,12 @@ def stop_game(cli, winner = ""):
|
|||||||
|
|
||||||
def chk_win(cli, end_game = True):
|
def chk_win(cli, end_game = True):
|
||||||
""" Returns True if someone won """
|
""" Returns True if someone won """
|
||||||
|
|
||||||
chan = botconfig.CHANNEL
|
chan = botconfig.CHANNEL
|
||||||
lpl = len(var.list_players())
|
lpl = len(var.list_players())
|
||||||
|
|
||||||
if lpl == 0:
|
|
||||||
#cli.msg(chan, "No more players remaining. Game ended.")
|
|
||||||
reset_modes_timers(cli)
|
|
||||||
reset(cli)
|
|
||||||
return True
|
|
||||||
|
|
||||||
if var.PHASE == "join":
|
if var.PHASE == "join":
|
||||||
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"])
|
lrealwolves = len(var.list_players(var.WOLF_ROLES)) - len(var.ROLES["wolf cub"])
|
||||||
if var.PHASE == "day":
|
if var.PHASE == "day":
|
||||||
@ -1201,7 +1189,7 @@ def chk_win(cli, end_game = True):
|
|||||||
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 = ""
|
winner = ""
|
||||||
if lwolves == lpl / 2:
|
elif lwolves == lpl / 2:
|
||||||
if len(var.ROLES["monster"]) > 0:
|
if len(var.ROLES["monster"]) > 0:
|
||||||
plural = "s" if len(var.ROLES["monster"]) > 1 else ""
|
plural = "s" if len(var.ROLES["monster"]) > 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. " +
|
||||||
|
Loading…
Reference in New Issue
Block a user