public override int PreventDamage(PreventDamageParameters p) { if (p.IsCombat) return p.Amount; return 0; }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target.IsPlayer()) { return(0); } var targetCard = p.Target.Card(); if (targetCard.Controller != _player) { return(0); } if (_filter(targetCard) == false) { return(0); } if (p.QueryOnly) { return(p.Amount); } var mp = new ModifierParameters { SourceCard = targetCard, }; var modifier = new AddCounters(_counter, p.Amount); targetCard.AddModifier(modifier, mp); return(p.Amount); }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target.IsPlayer()) return 0; var targetCard = p.Target.Card(); if (targetCard.Controller != _player) return 0; if (_filter(targetCard) == false) return 0; if (p.QueryOnly) return p.Amount; var mp = new ModifierParameters { SourceCard = targetCard, }; var modifier = new AddCounters(_counter, p.Amount); targetCard.AddModifier(modifier, mp); return p.Amount; }
public int PreventDamage(PreventDamageParameters preventDamageParameters) { var amount = preventDamageParameters.CanBePrevented ? preventDamageParameters.Amount : 0; // Nothing to prevent return(Prevent(amount, (prevention) => prevention.PreventDamage(preventDamageParameters))); }
public override int PreventDamage(PreventDamageParameters p) { if (p.IsCombat && _filter(p.Source)) { return(p.Amount); } return(0); }
public override int PreventDamage(PreventDamageParameters p) { if (p.IsCombat) { return(p.Amount); } return(0); }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target != _creatureOrPlayer) return 0; if (!_sourceFilter(p.Source)) return 0; return Math.Min(p.Amount, _maxAmount); }
public override int PreventDamage(PreventDamageParameters p) { if (p.Source != _source) return 0; if (!p.IsCombat && _preventCombatOnly) return 0; return p.Amount; }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target != _creatureOrPlayer) return 0; var prevented = Math.Min(_amount, p.Amount); if (!p.QueryOnly) _amount.Value -= prevented; return prevented; }
public override int PreventDamage(PreventDamageParameters p) { if (_combatOnly && !p.IsCombat) return 0; if (p.Source == Modifier.SourceCard) return p.Amount; if (p.Target == Modifier.SourceCard) return p.Amount; return 0; }
public int CalculatePreventedReceivedDamageAmount(int totalAmount, Card source, bool isCombat = false) { var p = new PreventDamageParameters { Amount = totalAmount, Source = source, Target = this, IsCombat = isCombat, QueryOnly = true }; return(Game.PreventDamage(p)); }
public override int PreventDamage(PreventDamageParameters p) { if (p.Source != _source) { return(0); } if (!p.IsCombat && _preventCombatOnly) { return(0); } return(p.Amount); }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target != _creatureOrPlayer) { return(0); } if (!_sourceFilter(p.Source)) { return(0); } return(Math.Min(p.Amount, _maxAmount)); }
public override int PreventDamage(PreventDamageParameters p) { if (_isDepleted == false && p.Source == _source && p.Target == _creatureOrPlayer) { if (!p.QueryOnly) { _isDepleted.Value = true; } return(p.Amount); } return(0); }
public override int PreventDamage(PreventDamageParameters p) { if (_isDepleted == false && p.Source == _source && p.Target == _creatureOrPlayer) { if (_onlyOnce && !p.QueryOnly) { _isDepleted.Value = true; } return p.Amount; } return 0; }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target != _target) { return(0); } if (!_sourceSelector(p.Source, Ctx(p))) { return(0); } return(_amount(_target, Ctx(p))); }
public override int PreventDamage(PreventDamageParameters p) { if (p.Target != _creatureOrPlayer) { return(0); } var prevented = Math.Min(_amount, p.Amount); if (!p.QueryOnly) { _amount.Value -= prevented; } return(prevented); }
public int CalculatePreventedDamageAmount(int totalAmount, Card source, bool isCombat = false) { if (HasProtectionFrom(source)) { return(totalAmount); } var damage = new PreventDamageParameters { Amount = totalAmount, QueryOnly = true, Source = source, IsCombat = isCombat, Target = this, }; return(Game.PreventDamage(damage)); }
public override int PreventDamage(PreventDamageParameters p) { if (_combatOnly && !p.IsCombat) { return(0); } if (p.Source == Modifier.SourceCard) { return(p.Amount); } if (p.Target == Modifier.SourceCard) { return(p.Amount); } return(0); }
public void ReceiveDamage(Damage damage) { var p = new PreventDamageParameters { Amount = damage.Amount, Source = damage.Source, Target = this, IsCombat = damage.IsCombat, CanBePrevented = damage.CanBePrevented, QueryOnly = false }; var prevented = Game.PreventDamage(p); damage.Amount -= prevented; if (damage.Amount == 0) { return; } var wasRedirected = Game.RedirectDamage(damage, this) || RedirectDamageToPlaneswalker(damage); if (wasRedirected) { return; } var preventedLifeloss = Game.PreventLifeloss(damage.Amount, this, queryOnly: false); Life -= (damage.Amount - preventedLifeloss); if (damage.Source.Has().Lifelink) { var controller = damage.Source.Controller; controller.Life += damage.Amount; } Publish(new DamageDealtEvent(this, damage)); }
public override int PreventDamage(PreventDamageParameters p) { var ctx = Ctx(p); var player = p.Target as Player; var peramenentSelector = p.Target as Card; if (player != null && !_playerSelector(player, ctx)) { return(0); } if (peramenentSelector != null && !_permanentSelector(peramenentSelector, ctx)) { return(0); } if (!_sourceSelector(p.Source, ctx)) { return(0); } return(_amount(p.Target, ctx)); }
public int PreventDamage(PreventDamageParameters preventDamageParameters) { return Prevent(preventDamageParameters.Amount, (prevention) => prevention.PreventDamage(preventDamageParameters)); }
public virtual int PreventDamage(PreventDamageParameters p) { return 0; }
public int CalculatePreventedDamageAmount(int totalAmount, Card source, bool isCombat = false) { if (HasProtectionFrom(source)) { return totalAmount; } var damage = new PreventDamageParameters { Amount = totalAmount, QueryOnly = true, Source = source, IsCombat = isCombat, Target = this, }; return Game.PreventDamage(damage); }
public virtual int PreventDamage(PreventDamageParameters p) { return(0); }
public int PreventDamage(PreventDamageParameters preventDamageParameters) { return(Prevent(preventDamageParameters.Amount, (prevention) => prevention.PreventDamage(preventDamageParameters))); }
public int PreventDamage(PreventDamageParameters p) { return(_damagePreventions.PreventDamage(p)); }
public int CalculatePreventedReceivedDamageAmount(int totalAmount, Card source, bool isCombat = false) { var p = new PreventDamageParameters { Amount = totalAmount, Source = source, Target = this, IsCombat = isCombat, QueryOnly = true }; return Game.PreventDamage(p); }
public void ReceiveDamage(Damage damage) { var p = new PreventDamageParameters { Amount = damage.Amount, Source = damage.Source, Target = this, IsCombat = damage.IsCombat, QueryOnly = false }; var prevented = Game.PreventDamage(p); damage.Amount -= prevented; if (damage.Amount == 0) return; var wasRedirected = Game.RedirectDamage(damage, this); if (wasRedirected) return; var preventedLifeloss = Game.PreventLifeloss(damage.Amount, this, queryOnly: false); Life -= (damage.Amount - preventedLifeloss); if (damage.Source.Has().Lifelink) { var controller = damage.Source.Controller; controller.Life += damage.Amount; } Publish(new DamageDealtEvent(this, damage)); }
protected Context Ctx(PreventDamageParameters p) { return(new Context(p, this, Game)); }
public Context(PreventDamageParameters pdp, DamagePrevention damagePrevention, Game game) { _pdp = pdp; _damagePrevention = damagePrevention; _game = game; }