From ee2a4ef2cfe47b134e36c90de41d00a092c5f1f6 Mon Sep 17 00:00:00 2001 From: skizzerz Date: Sat, 11 Jul 2015 12:16:50 -0500 Subject: [PATCH] Fix protection not working against assassin sometimes --- src/wolfgame.py | 61 ++++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/src/wolfgame.py b/src/wolfgame.py index 2b77067..a7bb6af 100644 --- a/src/wolfgame.py +++ b/src/wolfgame.py @@ -3186,32 +3186,45 @@ def transition_day(cli, gameid=0): # Logic out stacked kills and protections. If we get down to 1 kill remaining that is valid and the victim is in bywolves, # we re-add them to onlybywolves to indicate that the other kill attempts were guarded against (and the wolf kill is what went through) # If protections >= kills, we keep track of which protection message to show (prot totem > GA > bodyguard) - for v in victims_set: - numkills = victims.count(v) - numtotems = var.PROTECTED.count(v) - if numtotems >= numkills: - protected[v] = "totem" - if numtotems > numkills: - for i in range(0, numtotems - numkills): - var.ACTIVE_PROTECTIONS[v].append("totem") - numkills -= numtotems - for g in var.ROLES["guardian angel"]: - if var.GUARDED.get(g) == v: - numkills -= 1 - if numkills <= 0 and v not in protected: - protected[v] = "angel" - elif numkills <= 0: + pl = var.list_players() + for v in pl: + if v in victims_set: + numkills = victims.count(v) + numtotems = var.PROTECTED.count(v) + if numtotems >= numkills: + protected[v] = "totem" + if numtotems > numkills: + for i in range(0, numtotems - numkills): + var.ACTIVE_PROTECTIONS[v].append("totem") + numkills -= numtotems + for g in var.ROLES["guardian angel"]: + if var.GUARDED.get(g) == v: + numkills -= 1 + if numkills <= 0 and v not in protected: + protected[v] = "angel" + elif numkills <= 0: + var.ACTIVE_PROTECTIONS[v].append("angel") + for g in var.ROLES["bodyguard"]: + if var.GUARDED.get(g) == v: + numkills -= 1 + if numkills <= 0 and v not in protected: + protected[v] = "bodyguard" + elif numkills <= 0: + var.ACTIVE_PROTECTIONS[v].append("bodyguard") + numkills -= 1 + if numkills == 1 and v in bywolves: + onlybywolves.add(v) + else: + # player wasn't targeted, but apply protections on them + numtotems = var.PROTECTED.count(v) + for i in range(0, numtotems): + var.ACTIVE_PROTECTIONS[v].append("totem") + for g in var.ROLES["guardian angel"]: + if var.GUARDED.get(g) == v: var.ACTIVE_PROTECTIONS[v].append("angel") - for g in var.ROLES["bodyguard"]: - if var.GUARDED.get(g) == v: - numkills -= 1 - if numkills <= 0 and v not in protected: - protected[v] = "bodyguard" - elif numkills <= 0: + for g in var.ROLES["bodyguard"]: + if var.GUARDED.get(g) == v: var.ACTIVE_PROTECTIONS[v].append("bodyguard") - numkills -= 1 - if numkills == 1 and v in bywolves: - onlybywolves.add(v) fallenkills = set() brokentotem = set()