Implement [JUD] Infectious Rage (#10187)

* Implement [JUD] Infectious Rage

* Fix ClassCastException by using last known info

* Add game log message for random choice. Still need to investigate filter.

* Clarify filter and add comments

* Address review comments (3/4)

* Check zone change counter
This commit is contained in:
xenohedron 2023-04-20 21:40:24 -04:00 committed by GitHub
parent d3ec7e44a3
commit 1ac9ec65cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 149 additions and 23 deletions

View file

@ -0,0 +1,35 @@
package mage.filter.predicate.permanent;
import mage.filter.Filter;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.util.TargetAddress;
/**
* @author duncant
*/
public class PermanentCanBeAttachedToPredicate implements ObjectSourcePlayerPredicate<Permanent> {
protected Permanent aura;
public PermanentCanBeAttachedToPredicate(Permanent aura) {
super();
this.aura = aura;
}
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
// TODO: Is it possible to add functionality to exclude objects the aura can't enchant (e.g. protection from)?
Permanent potentialAttachment = input.getObject();
for (TargetAddress addr : TargetAddress.walk(aura)) {
Target target = addr.getTarget(aura);
Filter filter = target.getFilter();
return filter.match(potentialAttachment, game);
}
return false;
}
}