using System.Linq; using KernelPanic.Core; namespace KernelPanic.Combat { public sealed class CompilationDrawEffect : ICardEffect { internal const int RequiredCompilation = 2; internal const int DrawCount = 1; public void Execute(CombatContext context) { if (context.CombatManager.Compilation.Level >= RequiredCompilation) new DrawEffect(DrawCount).Execute(context); } } public sealed class MakeJ4Effect : ICardEffect { internal const int RequiredCompilation = 3; internal const int BaseDamage = 8; internal const int CompiledDamage = 11; public void Execute(CombatContext context) { int amount = context.CombatManager.Compilation.Level >= RequiredCompilation ? CompiledDamage : BaseDamage; new DealDamageEffect(amount, amount, Language.C).Execute(context); } } public sealed class HaskellFilterEffect : ICardEffect { internal const int BaseDamage = 4; internal const int ConditionalDamage = 6; public void Execute(CombatContext context) { bool harmful = context.Targets.Any(target => target != null && !target.IsDefeated && target.Statuses.Any(status => !StatusEffectController.GetDescriptor(status.Type).IsBeneficial)); int amount = harmful ? ConditionalDamage : BaseDamage; new DealDamageEffect(amount, amount, Language.Haskell).Execute(context); } } public sealed class HaskellMaybeEffect : ICardEffect { internal const int HealAmount = 3; internal const int ShieldAmount = 4; public void Execute(CombatContext context) { if (context.Source.CurrentUptime >= context.Source.MaxUptime) { new ShieldEffect(ShieldAmount).Execute(context); return; } if (!context.CombatManager.CanPlayerReceiveCardHeal(context.Card)) { context.CombatManager.ReportEffectResult("heal blocked"); return; } int amount = UpgradeMath.ScaleAmount(UpgradeMath.ApplySourceFlatBonus(HealAmount, context), context.Card); int before = context.Source.CurrentUptime; context.Source.CurrentUptime = System.Math.Min(context.Source.MaxUptime, CardScaling.Add(before, amount)); context.CombatManager.ReportEffectResult($"maybe: restored {context.Source.CurrentUptime - before} Uptime"); } } }