Lots of end-game message stuff.
The lover of a fool can win with the fool. The lover of a monster can win with monsters. List winners at end of game. Idlers are the scum of the earth and never win. Displays a message if everyone died (originally by nyuszika7h, replicated here due to merge conflicts).
This commit is contained in:
parent
86abaf7f1b
commit
2c4ade2454
@ -1051,6 +1051,7 @@ def stop_game(cli, winner = ""):
|
|||||||
|
|
||||||
var.LOGGER.saveToFile()
|
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():
|
||||||
@ -1065,40 +1066,45 @@ def stop_game(cli, winner = ""):
|
|||||||
else:
|
else:
|
||||||
continue #probably fjoin'd fake
|
continue #probably fjoin'd fake
|
||||||
|
|
||||||
if acc == "*":
|
|
||||||
continue # not logged in during game start
|
|
||||||
# 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
|
||||||
elif winner == "":
|
|
||||||
break; # abnormal game stop
|
|
||||||
else:
|
else:
|
||||||
won = False
|
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 == "":
|
if winner == "monsters" and plr in var.ORIGINAL_ROLES["monster"]:
|
||||||
break
|
|
||||||
elif winner == "monsters" and plr in var.ORIGINAL_ROLES["monster"]:
|
|
||||||
won = True
|
won = True
|
||||||
else:
|
else:
|
||||||
won = False
|
won = False
|
||||||
else:
|
else:
|
||||||
if winner == "villagers":
|
if winner == "villagers":
|
||||||
won = True
|
won = True
|
||||||
elif winner == "":
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
won = False
|
won = False
|
||||||
|
|
||||||
if plr in var.ORIGINAL_ROLES["fool"] and "@" + plr == winner:
|
survived = var.list_players()
|
||||||
|
if plr.startswith("(dced)"):
|
||||||
|
# You get NOTHING! You LOSE! Good DAY, sir!
|
||||||
|
won = False
|
||||||
|
iwon = False
|
||||||
|
elif plr in var.ORIGINAL_ROLES["fool"] and "@" + plr == winner:
|
||||||
iwon = True
|
iwon = True
|
||||||
elif plr in var.LOVERS and plr in var.list_players() and not winner.startswith("@") 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
|
||||||
|
elif plr in var.LOVERS and plr in survived and var.LOVERS[plr] in survived:
|
||||||
|
if not winner.startswith("@") and winner != "monsters":
|
||||||
|
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":
|
elif plr in var.ORIGINAL_ROLES["crazed shaman"] and not winner.startswith("@") and winner != "monsters":
|
||||||
iwon = True
|
iwon = True
|
||||||
elif plr in var.ORIGINAL_ROLES["vengeful ghost"]:
|
elif plr in var.ORIGINAL_ROLES["vengeful ghost"]:
|
||||||
if plr in var.list_players():
|
if plr in survived:
|
||||||
iwon = True
|
iwon = True
|
||||||
elif var.VENGEFUL_GHOSTS[plr] == "villagers" and winner == "wolves":
|
elif var.VENGEFUL_GHOSTS[plr] == "villagers" and winner == "wolves":
|
||||||
won = True
|
won = True
|
||||||
@ -1113,15 +1119,34 @@ def stop_game(cli, winner = ""):
|
|||||||
won = True
|
won = True
|
||||||
elif plr not in var.LYCANS and winner == "villagers":
|
elif plr not in var.LYCANS and winner == "villagers":
|
||||||
won = True
|
won = True
|
||||||
iwon = won and plr in var.list_players()
|
else:
|
||||||
|
won = False
|
||||||
|
iwon = won and plr in survived
|
||||||
else:
|
else:
|
||||||
iwon = won and plr in var.list_players() # survived, team won = individual win
|
iwon = won and plr in survived # survived, team won = individual win
|
||||||
|
|
||||||
var.update_role_stats(acc, rol, won, iwon)
|
if acc != "*":
|
||||||
|
var.update_role_stats(acc, rol, won, iwon)
|
||||||
|
|
||||||
|
if (won or iwon) and plr.startswith("(dced)"):
|
||||||
|
winners.append(plr[6:])
|
||||||
|
else:
|
||||||
|
winners.append(plr)
|
||||||
|
|
||||||
size = len(var.list_players()) + len(var.DEAD)
|
size = len(var.list_players()) + len(var.DEAD)
|
||||||
if winner != "": # Only update if not an abnormal game stop
|
# Only update if someone actually won, "" indicates everyone died or abnormal game stop
|
||||||
|
if winner != "":
|
||||||
var.update_game_stats(size, winner)
|
var.update_game_stats(size, winner)
|
||||||
|
|
||||||
|
# spit out the list of winners
|
||||||
|
winners.sort()
|
||||||
|
if len(winners) == 1:
|
||||||
|
cli.msg(chan, "The winner is \u0002{0}\u0002.".format(winners[0]))
|
||||||
|
elif len(winners) == 2:
|
||||||
|
cli.msg(chan, "The winners are \u0002{0}\u0002 and \u0002{1}\u0002.".format())
|
||||||
|
elif len(winners) == 3:
|
||||||
|
cli.msg(chan, "The winners are {0}, and \u0002{1}\u0002.".format(
|
||||||
|
", ".join(map(lambda x: "\u0002{0}\u0002".format(x), winners[0:-1]))))
|
||||||
|
|
||||||
reset(cli)
|
reset(cli)
|
||||||
|
|
||||||
@ -1173,6 +1198,9 @@ def chk_win(cli, end_game = True):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if lpl < 1:
|
||||||
|
message = "Game over! There are no players remaining. Nobody wins."
|
||||||
|
winner = ""
|
||||||
if lwolves == lpl / 2:
|
if 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 ""
|
||||||
|
Loading…
Reference in New Issue
Block a user