(final String restriction, final Player sourceController, final Card source, CardTraitBase spellAbility)
| 5744 | |
| 5745 | // Takes one argument like Permanent.Blue+withFlying |
| 5746 | @Override |
| 5747 | public final boolean isValid(final String restriction, final Player sourceController, final Card source, CardTraitBase spellAbility) { |
| 5748 | // Inclusive restrictions are Card types |
| 5749 | final String[] incR = restriction.split("\\.", 2); |
| 5750 | |
| 5751 | boolean testFailed = false; |
| 5752 | if (incR[0].startsWith("!")) { |
| 5753 | testFailed = true; // a bit counter logical)) |
| 5754 | incR[0] = incR[0].substring(1); // consume negation sign |
| 5755 | } |
| 5756 | |
| 5757 | // need to filter out prepared spells for other cards |
| 5758 | if (getCurrentStateName() == CardStateName.PreparedSpell && isInZone(ZoneType.Exile)) { |
| 5759 | return testFailed; |
| 5760 | } |
| 5761 | |
| 5762 | if (incR[0].equals("Spell")) { |
| 5763 | if (!isSpell()) { |
| 5764 | return testFailed; |
| 5765 | } |
| 5766 | } else if (incR[0].equals("Permanent")) { |
| 5767 | if (!isPermanent()) { |
| 5768 | return testFailed; |
| 5769 | } |
| 5770 | } else if (incR[0].equals("Effect")) { |
| 5771 | if (!isImmutable()) { |
| 5772 | return testFailed; |
| 5773 | } |
| 5774 | } else if (incR[0].equals("Emblem")) { |
| 5775 | if (!isEmblem()) { |
| 5776 | return testFailed; |
| 5777 | } |
| 5778 | } else if (incR[0].equals("Boon")) { |
| 5779 | if (!isBoon()) { |
| 5780 | return testFailed; |
| 5781 | } |
| 5782 | } else if (incR[0].equals("card") || incR[0].equals("Card")) { |
| 5783 | if (isImmutable()) { |
| 5784 | return testFailed; |
| 5785 | } |
| 5786 | } else if (incR[0].equals("Any")) { |
| 5787 | if (!(isCreature() || isPlaneswalker() || isBattle())) { |
| 5788 | return false; |
| 5789 | } |
| 5790 | //todo further check for Effect API and other replacement Effect |
| 5791 | /*if (spellAbility == null) |
| 5792 | return false; |
| 5793 | ApiType apiType = ((SpellAbility) spellAbility).getApi(); |
| 5794 | if (!(ApiType.DealDamage.equals(apiType) || ApiType.PreventDamage.equals(apiType))) |
| 5795 | return false;*/ |
| 5796 | } else if (!getType().hasStringType(incR[0])) { |
| 5797 | return testFailed; // Check for wrong type |
| 5798 | } |
| 5799 | |
| 5800 | if (incR.length > 1) { |
| 5801 | final String excR = incR[1]; |
| 5802 | final String[] exRs = excR.split("\\+"); // Exclusive Restrictions are ... |
| 5803 | for (String exR : exRs) { |
no test coverage detected