27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
namespace KernelPanic.Combat
|
|
{
|
|
/// <summary>
|
|
/// Shared explicit card-Shield resolution. Effects choose whether their base reward receives
|
|
/// source and magnitude bonuses; eligibility and explicit multipliers are applied here once.
|
|
/// </summary>
|
|
internal static class CardShieldExecutor
|
|
{
|
|
internal static int ScaleAmount(int baseAmount, CombatContext context) =>
|
|
UpgradeMath.ScaleShield(UpgradeMath.ApplySourceFlatBonus(baseAmount, context), context.Card);
|
|
|
|
internal static void Execute(CombatContext context, int amount, string label = "card")
|
|
{
|
|
if (!context.CombatManager.CanPlayerReceiveCardShield(context.Card))
|
|
{
|
|
context.CombatManager.ReportEffectResult($"shield blocked: {amount}");
|
|
return;
|
|
}
|
|
|
|
int before = context.Source.Shield;
|
|
context.CombatManager.GrantPlayerShield(context.ScaleExplicitShield(amount), label);
|
|
Core.GameEvents.RaiseCardContribution(new Core.CardContributionEvent(context.Card,
|
|
shieldGranted: System.Math.Max(0, context.Source.Shield - before)));
|
|
}
|
|
}
|
|
}
|