don't log loss in player stats when game is fstopped

This commit is contained in:
jacob1 2014-11-26 19:09:17 -05:00
parent 34ad806341
commit 9f7dbaa7c7

View File

@ -1129,129 +1129,129 @@ def stop_game(cli, winner = ""):
elif len(lovers) > 2:
cli.msg(chan, "The lovers were {0}, and {1}".format(", ".join(lovers[0:-1]), lovers[-1]))
plrl = {}
winners = []
for role,ppl in var.ORIGINAL_ROLES.items():
if role in var.TEMPLATE_RESTRICTIONS.keys():
continue
for x in ppl:
if x != None:
if role == "amnesiac" and x in var.AMNESIACS:
plrl[x] = var.FINAL_ROLES[x]
elif role != "amnesiac" and x in var.FINAL_ROLES: # role swap
plrl[x] = var.FINAL_ROLES[x]
else:
plrl[x] = role
for plr, rol in plrl.items():
orol = rol # original role, since we overwrite rol in case of clone
splr = plr # plr stripped of the (dced) bit at the front, since other dicts don't have that
if plr.startswith("(dced)") and plr[6:] in var.DCED_PLAYERS.keys():
acc = var.DCED_PLAYERS[plr[6:]]["account"]
splr = plr[6:]
elif plr in var.PLAYERS.keys():
acc = var.PLAYERS[plr]["account"]
else:
acc = "*" #probably fjoin'd fake
if rol == "clone":
# see if they became a different role
if splr in var.FINAL_ROLES:
rol = var.FINAL_ROLES[splr]
won = False
iwon = False
# determine if this player's team won
if rol in var.WOLFTEAM_ROLES: # the player was wolf-aligned
if winner == "wolves":
won = True
elif rol in var.TRUE_NEUTRAL_ROLES:
# true neutral roles never have a team win (with exception of monsters), only individual wins
if winner == "monsters" and rol == "monster":
won = True
elif rol in ("amnesiac", "vengeful ghost"):
if var.DEFAULT_ROLE == "villager" and winner == "villagers":
won = True
elif var.DEFAULT_ROLE == "cultist" and winner == "wolves":
won = True
else:
if winner == "villagers":
won = True
survived = var.list_players()
if plr.startswith("(dced)"):
# You get NOTHING! You LOSE! Good DAY, sir!
won = False
iwon = False
elif rol == "fool" and "@" + splr == winner:
iwon = True
winner = "fool"
elif rol == "monster" and splr in survived and winner == "monsters":
iwon = True
elif splr in var.LOVERS and splr in survived:
for lvr in var.LOVERS[splr]:
if lvr in plrl:
lvrrol = plrl[lvr]
elif ("(dced)" + lvr) in plrl:
lvrrol = plrl["(dced)" + lvr]
if lvrrol == "clone" and lvr in var.FINAL_ROLES:
lvrrol = var.FINAL_ROLES[lvr]
if lvr in survived and not winner.startswith("@") and winner != "monsters":
iwon = True
break
elif lvr in survived and winner.startswith("@") and winner == "@" + lvr and var.LOVER_WINS_WITH_FOOL:
iwon = True
break
elif lvr in survived and winner == "monsters" and lvrrol == "monster":
iwon = True
break
if plr.startswith("(dced)"):
won = False
iwon = False
elif rol == "crazed shaman" or rol == "clone":
# For clone, this means they ended game while being clone and not some other role
if splr in survived and not winner.startswith("@") and winner != "monsters":
iwon = True
elif rol == "vengeful ghost":
if not winner.startswith("@") and winner != "monsters":
if won and splr in survived:
iwon = True
elif splr in var.VENGEFUL_GHOSTS and var.VENGEFUL_GHOSTS[splr] == "villagers" and winner == "wolves":
won = True
iwon = True
elif splr in var.VENGEFUL_GHOSTS and var.VENGEFUL_GHOSTS[splr] == "wolves" and winner == "villagers":
won = True
iwon = True
elif rol == "lycan" or splr in var.LYCANS:
if splr in var.LYCANS and winner == "wolves":
won = True
elif splr not in var.LYCANS and winner == "villagers":
won = True
else:
won = False
if not iwon:
iwon = won and splr in survived
elif rol == "jester" and splr in var.JESTERS:
iwon = True
elif not iwon:
iwon = won and splr in survived # survived, team won = individual win
if acc != "*":
var.update_role_stats(acc, orol, won, iwon)
for role in var.TEMPLATE_RESTRICTIONS.keys():
if plr in var.ORIGINAL_ROLES[role]:
var.update_role_stats(acc, role, won, iwon)
if splr in var.LOVERS:
var.update_role_stats(acc, "lover", won, iwon)
if won or iwon:
winners.append(splr)
size = len(survived) + len(var.DEAD)
# Only update if someone actually won, "" indicates everyone died or abnormal game stop
if winner != "":
var.update_game_stats(var.CURRENT_ROLESET, size, winner)
plrl = {}
winners = []
for role,ppl in var.ORIGINAL_ROLES.items():
if role in var.TEMPLATE_RESTRICTIONS.keys():
continue
for x in ppl:
if x != None:
if role == "amnesiac" and x in var.AMNESIACS:
plrl[x] = var.FINAL_ROLES[x]
elif role != "amnesiac" and x in var.FINAL_ROLES: # role swap
plrl[x] = var.FINAL_ROLES[x]
else:
plrl[x] = role
for plr, rol in plrl.items():
orol = rol # original role, since we overwrite rol in case of clone
splr = plr # plr stripped of the (dced) bit at the front, since other dicts don't have that
if plr.startswith("(dced)") and plr[6:] in var.DCED_PLAYERS.keys():
acc = var.DCED_PLAYERS[plr[6:]]["account"]
splr = plr[6:]
elif plr in var.PLAYERS.keys():
acc = var.PLAYERS[plr]["account"]
else:
acc = "*" #probably fjoin'd fake
if rol == "clone":
# see if they became a different role
if splr in var.FINAL_ROLES:
rol = var.FINAL_ROLES[splr]
won = False
iwon = False
# determine if this player's team won
if rol in var.WOLFTEAM_ROLES: # the player was wolf-aligned
if winner == "wolves":
won = True
elif rol in var.TRUE_NEUTRAL_ROLES:
# true neutral roles never have a team win (with exception of monsters), only individual wins
if winner == "monsters" and rol == "monster":
won = True
elif rol in ("amnesiac", "vengeful ghost"):
if var.DEFAULT_ROLE == "villager" and winner == "villagers":
won = True
elif var.DEFAULT_ROLE == "cultist" and winner == "wolves":
won = True
else:
if winner == "villagers":
won = True
survived = var.list_players()
if plr.startswith("(dced)"):
# You get NOTHING! You LOSE! Good DAY, sir!
won = False
iwon = False
elif rol == "fool" and "@" + splr == winner:
iwon = True
winner = "fool"
elif rol == "monster" and splr in survived and winner == "monsters":
iwon = True
elif splr in var.LOVERS and splr in survived:
for lvr in var.LOVERS[splr]:
lvrrol = "" #somehow lvrrol wasn't set and caused a crash once
if lvr in plrl:
lvrrol = plrl[lvr]
elif ("(dced)" + lvr) in plrl:
lvrrol = plrl["(dced)" + lvr]
if lvrrol == "clone" and lvr in var.FINAL_ROLES:
lvrrol = var.FINAL_ROLES[lvr]
if lvr in survived and not winner.startswith("@") and winner != "monsters":
iwon = True
break
elif lvr in survived and winner.startswith("@") and winner == "@" + lvr and var.LOVER_WINS_WITH_FOOL:
iwon = True
break
elif lvr in survived and winner == "monsters" and lvrrol == "monster":
iwon = True
break
if plr.startswith("(dced)"):
won = False
iwon = False
elif rol == "crazed shaman" or rol == "clone":
# For clone, this means they ended game while being clone and not some other role
if splr in survived and not winner.startswith("@") and winner != "monsters":
iwon = True
elif rol == "vengeful ghost":
if not winner.startswith("@") and winner != "monsters":
if won and splr in survived:
iwon = True
elif splr in var.VENGEFUL_GHOSTS and var.VENGEFUL_GHOSTS[splr] == "villagers" and winner == "wolves":
won = True
iwon = True
elif splr in var.VENGEFUL_GHOSTS and var.VENGEFUL_GHOSTS[splr] == "wolves" and winner == "villagers":
won = True
iwon = True
elif rol == "lycan" or splr in var.LYCANS:
if splr in var.LYCANS and winner == "wolves":
won = True
elif splr not in var.LYCANS and winner == "villagers":
won = True
else:
won = False
if not iwon:
iwon = won and splr in survived
elif rol == "jester" and splr in var.JESTERS:
iwon = True
elif not iwon:
iwon = won and splr in survived # survived, team won = individual win
if acc != "*":
var.update_role_stats(acc, orol, won, iwon)
for role in var.TEMPLATE_RESTRICTIONS.keys():
if plr in var.ORIGINAL_ROLES[role]:
var.update_role_stats(acc, role, won, iwon)
if splr in var.LOVERS:
var.update_role_stats(acc, "lover", won, iwon)
if won or iwon:
winners.append(splr)
var.update_game_stats(var.CURRENT_ROLESET, len(survived) + len(var.DEAD), winner)
# spit out the list of winners
winners.sort()