Skip to content

Commit

Permalink
Fix win condition check
Browse files Browse the repository at this point in the history
  • Loading branch information
NikoCat233 committed Dec 22, 2024
1 parent c113d70 commit d2dbccb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Patches/CheckGameEndPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -647,21 +647,25 @@ public static bool CheckGameEndByLivingPlayers(out GameOverReason reason)
else
{
if (impCount >= 1) return false; // Both Imp and NK or Coven are alive, the game must continue

if (totalNKAlive >= 1 && covenCount >= 1) return false; // Both Coven and NK are alive, the game must continue

// One of NK or Coven all dead here, check nk and coven count > crew

if (crewCount <= covenCount && totalNKAlive == 0) // Imps dead, NK dead, Crew <= Coven, Coven wins
{
reason = GameOverReason.ImpostorByKill;
ResetAndSetWinner(CustomWinner.Coven);
return true;
}
if (covenCount >= 1) return false; // Both Coven and NK are alive, the game must continue
if (crewCount > totalNKAlive) return false; // Imps are dead, but Crew still outnumbers NK (the game must continue)
if (crewCount > covenCount) return false; // Imps are dead, but Crew still outnumbers Coven (the game must continue)
else // Imps dead, Crew <= NK, Checking if All nk alive are in 1 team

else if (crewCount <= totalNKAlive && covenCount == 0) // Imps dead, Coven dead, Crew <= NK, Check NK win
{
var winners = neutralRoleCounts.Where(kvp => kvp.Value == totalNKAlive).ToArray();
var winnnerLength = winners.Length;
if (winnnerLength == 1)
{
// Only 1 NK team alive, NK wins
try
{
var winnerRole = winners.First().Key.GetNeutralCustomRoleFromCountType();
Expand All @@ -671,15 +675,19 @@ public static bool CheckGameEndByLivingPlayers(out GameOverReason reason)
}
catch
{
Logger.Warn("Error while trying to end game as single NK", "CheckGameEndByLivingPlayers");
return false;
}

return true;
}
else if (winnnerLength == 0)
else
{
return false; // Not all alive neutrals were in one team
}
return true;
}

else return false; // Crew > Coven or NK, the game must continue
}
}
}
Expand Down

0 comments on commit d2dbccb

Please sign in to comment.