/// <summary> /// True if target is valid /// </summary> /// <param name="_target">CardTarget to test</param> /// <param name="_source">The original card providing this targeting conditions</param> public override bool Accept(object _target, CardInstance _source) { if (TypeOfTarget == TargetType.Player) { Player p = _target as Player; if (p == null) { return(false); } //TODO: more constrains surely for player return(true); } CardInstance c = _target as CardInstance; if (c == null) { if (_target is MagicAction) { c = (_target as MagicAction).CardSource; } else { return(base.Accept(_target, _source)); } } if (TypeOfTarget == TargetType.Spell && !(_target is Spell)) { return(false); } if (TypeOfTarget == TargetType.Activated) { if (!(_target is AbilityActivation)) { return(false); } if (!(_target as AbilityActivation).Source.IsActivatedAbility) { return(false); } } if (TypeOfTarget == TargetType.Triggered) { if (!(_target is AbilityActivation)) { return(false); } if (!(_target as AbilityActivation).Source.IsTriggeredAbility) { return(false); } } if (TypeOfTarget == TargetType.Self && _target != _source) { return(false); } if (TypeOfTarget == TargetType.Kicked && !c.Kicked) { return(false); } if (TypeOfTarget == TargetType.Permanent && c.CurrentGroup.GroupName != CardGroupEnum.InPlay) { return(false); } if (TypeOfTarget == TargetType.EquipedBy || TypeOfTarget == TargetType.EnchantedBy) { if (_target is CardInstance) { return(_source.AttachedTo == _target); } return(false); } else if (TypeOfTarget == TargetType.Attached) { if (_target is CardInstance) { return((_target as CardInstance).AttachedTo == _source); } return(false); } if (!CanBeTargetted && _target == _source) { return(false); } if (!(c.Model.Types >= ValidCardTypes)) { return(false); } if (ValidCardColors != null) { foreach (ManaTypes mc in ValidCardColors) { if (!c.HasColor(mc)) { return(false); } } } if (CombatState == CombatImplication.Attacking) { if (!c.Controler.AttackingCreature.Contains(c)) { return(false); } } else if (CombatState == CombatImplication.Blocking) { if (!c.Controler.BlockingCreature.Contains(c)) { return(false); } } if (ValidGroup != null) { if (!ValidGroup.Contains(c.CurrentGroup.GroupName)) { return(false); } } //TODO: power constrains //TODO: abilities check //TODO: having attached cards if (HavingAttachedCards != null) { foreach (CardInstance ac in c.AttachedCards) { if (ac.Model.Types >= HavingAttachedCards) { return(true); } } return(false); } //_source could be null when action is triggered by engine, not spell if (_source == null) { //controler have to be current player if (c.Controler != MagicEngine.CurrentEngine.cp) { return(false); } return(true); } if (Controler == ControlerType.You) { if (_source.Controler != c.Controler) { return(false); } } else if (Controler == ControlerType.Opponent) { if (_source.Controler == c.Controler) { return(false); } } return(true); }