Skip to content

Commit 3c2212e

Browse files
committed
Fix neuro trying to sacrifice invalid cards
Comes with a bonus fix of preventing neuro from sacrificing too few cards
1 parent c1e4a35 commit 3c2212e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

NeuroInscryption/Communication/Actions/Combat/SacrificeAction.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private IEnumerable<List<string>> GetSacrificeCombinations(int bloodCost)
1919
{
2020
List<Sacrifice> sacrificableSlots = BoardManager.Instance.playerSlots
2121
.Where(p => p.Card && p.Card.CanBeSacrificed)
22-
.Select(p => (playerLanes.Values.First(c => c?.TargetCard == p.Card)!.Identifier, p.Card.HasAbility(Ability.TripleBlood) ? 3 : 1))
22+
.Select(p => (playerLanes.Values.First(c => c?.TargetCard == p.Card)!.Identifier, GetBloodYield(p.Card)))
2323
.ToList();
2424

2525
List<List<Sacrifice>> possibilities = DontOpenJumpscareWarning.GenerateAllPermutationsOfSubsets(sacrificableSlots);
@@ -70,7 +70,9 @@ protected override bool TryDeserialize(JToken? data, [NotNullWhen(true)] out IEn
7070
return false;
7171
}
7272

73-
response = cardIdentifiers.Select(id => playerLanes.Values.FirstOrDefault(c => c?.Identifier == id)!);
74-
return response.All(c => c != null);
73+
response = cardIdentifiers.Select(id => playerLanes.Values.FirstOrDefault(c => c?.Identifier == id)!).ToArray();
74+
return response.All(c => c is { CanBeSacrificed: true }) && response.Sum(card => GetBloodYield(card.TargetCard)) >= cardToPlay.Info.BloodCost;
7575
}
76+
77+
private static int GetBloodYield(PlayableCard card) => card.HasAbility(Ability.TripleBlood) ? 3 : 1;
7678
}

0 commit comments

Comments
 (0)