New targeting check system for cards

At the moment I'm trying to revise the targeting restrictions, which are at the moment handled by the function "canTarget(final Card spell, final Card target)" in CardFactoryUtil. This function is flawed, because the SpellAbility is represented by its source card, and thus can't handle situations where the activator/caster is not the controller of the source card (which can happen with cards like Samite Sanctuary, Scandalmonger or Ornate Kanzashi) which is important for Hexproof.
I will start with adding a canTarget function to the card class that takes a spell ability as parameter and slowly try to redirect the checks to this. Any help would be appreciated (especially in cases where cleanup is necessary anyway).
I will start with adding a canTarget function to the card class that takes a spell ability as parameter and slowly try to redirect the checks to this. Any help would be appreciated (especially in cases where cleanup is necessary anyway).