mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
* Not of This World - Fixed cost reduction, tooltip wording and the missing possibility to target also abilities.
This commit is contained in:
parent
604f397d65
commit
815c20fa68
1 changed files with 97 additions and 95 deletions
|
|
@ -42,53 +42,39 @@ import mage.target.TargetObject;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.condition.Condition;
|
||||||
|
import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect;
|
||||||
|
import mage.constants.TargetController;
|
||||||
|
import mage.filter.Filter;
|
||||||
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
|
import mage.filter.predicate.mageobject.PowerPredicate;
|
||||||
|
import static mage.filter.predicate.permanent.ControllerControlsIslandPredicate.filter;
|
||||||
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.game.stack.StackAbility;
|
||||||
|
import mage.target.Target;
|
||||||
|
import mage.target.Targets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Rafbill
|
* @author Rafbill
|
||||||
*/
|
*/
|
||||||
public class NotOfThisWorld extends CardImpl<NotOfThisWorld> {
|
public class NotOfThisWorld extends CardImpl<NotOfThisWorld> {
|
||||||
|
|
||||||
public NotOfThisWorld(UUID ownerId) {
|
public NotOfThisWorld(UUID ownerId) {
|
||||||
super(ownerId, 8, "Not of This World", Rarity.UNCOMMON,
|
super(ownerId, 8, "Not of This World", Rarity.UNCOMMON,
|
||||||
new CardType[] { CardType.INSTANT }, "{7}");
|
new CardType[]{CardType.INSTANT}, "{7}");
|
||||||
this.expansionSetCode = "ROE";
|
this.expansionSetCode = "ROE";
|
||||||
this.supertype.add("Tribal");
|
this.supertype.add("Tribal");
|
||||||
this.subtype.add("Eldrazi");
|
this.subtype.add("Eldrazi");
|
||||||
|
|
||||||
// Counter target spell or ability that targets a permanent you control.
|
// Counter target spell or ability that targets a permanent you control.
|
||||||
this.getSpellAbility()
|
this.getSpellAbility().addTarget(
|
||||||
.addTarget(
|
new TargetSpellTargetingControlledPermanent());
|
||||||
new TargetSpellTargetingControlledPermanent(
|
|
||||||
new FilterSpell(
|
|
||||||
"a spell or ability that targets a creature you control with power 7 or greater.")));
|
|
||||||
this.getSpellAbility().addEffect(new CounterTargetEffect());
|
this.getSpellAbility().addEffect(new CounterTargetEffect());
|
||||||
// Not of This World costs {7} less to cast if it targets a spell or
|
// Not of This World costs {7} less to cast if it targets a spell or ability that targets a creature you control with power 7 or greater.
|
||||||
// ability that targets a creature you control with power 7 or greater.
|
this.addAbility(new SimpleStaticAbility(Zone.STACK, new SpellCostReductionSourceEffect(7, NotOfThisWorldCondition.getInstance())));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
|
|
||||||
if (ability.getTargets().isChosen()
|
|
||||||
&& game.getStack().getStackObject(
|
|
||||||
ability.getTargets().getFirstTarget()) != null
|
|
||||||
&& game.getPermanent(game.getStack()
|
|
||||||
.getStackObject(ability.getTargets().getFirstTarget())
|
|
||||||
.getStackAbility().getTargets().getFirstTarget()) != null
|
|
||||||
&& game.getPermanent(
|
|
||||||
game.getStack()
|
|
||||||
.getStackObject(
|
|
||||||
ability.getTargets().getFirstTarget())
|
|
||||||
.getStackAbility().getTargets()
|
|
||||||
.getFirstTarget()).getPower().getValue() >= 7) {
|
|
||||||
|
|
||||||
String adjustedCost = "{0}";
|
|
||||||
ability.getManaCostsToPay().clear();
|
|
||||||
ability.getManaCostsToPay().load(adjustedCost);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public NotOfThisWorld(final NotOfThisWorld card) {
|
public NotOfThisWorld(final NotOfThisWorld card) {
|
||||||
|
|
@ -101,49 +87,29 @@ public class NotOfThisWorld extends CardImpl<NotOfThisWorld> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TargetSpellTargetingControlledPermanent extends
|
class TargetSpellTargetingControlledPermanent extends TargetObject<TargetSpellTargetingControlledPermanent> {
|
||||||
TargetObject<TargetSpellTargetingControlledPermanent> {
|
|
||||||
|
|
||||||
protected FilterSpell filter;
|
|
||||||
|
|
||||||
public TargetSpellTargetingControlledPermanent() {
|
public TargetSpellTargetingControlledPermanent() {
|
||||||
this(1, 1, new FilterSpell());
|
this.minNumberOfTargets = 1;
|
||||||
}
|
this.maxNumberOfTargets = 1;
|
||||||
|
|
||||||
public TargetSpellTargetingControlledPermanent(FilterSpell filter) {
|
|
||||||
this(1, 1, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TargetSpellTargetingControlledPermanent(int numTargets,
|
|
||||||
FilterSpell filter) {
|
|
||||||
this(numTargets, numTargets, filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TargetSpellTargetingControlledPermanent(int minNumTargets,
|
|
||||||
int maxNumTargets, FilterSpell filter) {
|
|
||||||
this.minNumberOfTargets = minNumTargets;
|
|
||||||
this.maxNumberOfTargets = maxNumTargets;
|
|
||||||
this.zone = Zone.STACK;
|
this.zone = Zone.STACK;
|
||||||
this.filter = filter;
|
|
||||||
this.targetName = filter.getMessage();
|
this.targetName = filter.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetSpellTargetingControlledPermanent(
|
public TargetSpellTargetingControlledPermanent(final TargetSpellTargetingControlledPermanent target) {
|
||||||
final TargetSpellTargetingControlledPermanent target) {
|
|
||||||
super(target);
|
super(target);
|
||||||
this.filter = target.filter.copy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FilterSpell getFilter() {
|
public Filter getFilter() {
|
||||||
return filter;
|
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
Spell spell = game.getStack().getSpell(id);
|
StackObject stackObject = game.getStack().getStackObject(id);
|
||||||
if (spell != null) {
|
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
|
||||||
return filter.match(spell, game);
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -155,24 +121,20 @@ class TargetSpellTargetingControlledPermanent extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||||
int count = 0;
|
|
||||||
for (StackObject stackObject : game.getStack()) {
|
for (StackObject stackObject : game.getStack()) {
|
||||||
if (stackObject instanceof Spell
|
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
|
||||||
&& game.getPlayer(sourceControllerId).getInRange()
|
Targets targets = stackObject.getStackAbility().getTargets();
|
||||||
.contains(stackObject.getControllerId())
|
if(!targets.isEmpty()) {
|
||||||
&& filter.match((Spell) stackObject, game)
|
for (Target target : targets) {
|
||||||
&& ((Spell) stackObject).getSpellAbility().getTargets()
|
for (UUID targetId : target.getTargets()) {
|
||||||
.isChosen()
|
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
|
||||||
&& game.getPermanent(((Spell) stackObject)
|
if (targetedPermanent.getControllerId().equals(sourceControllerId)) {
|
||||||
.getSpellAbility().getTargets().getFirstTarget()) != null
|
return true;
|
||||||
&& game.getPermanent(
|
}
|
||||||
((Spell) stackObject).getSpellAbility()
|
}
|
||||||
.getTargets().getFirstTarget())
|
}
|
||||||
.getControllerId() == sourceControllerId) {
|
}
|
||||||
count++;
|
}
|
||||||
if (count >= this.minNumberOfTargets)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -185,23 +147,22 @@ class TargetSpellTargetingControlledPermanent extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||||
Set<UUID> possibleTargets = new HashSet<UUID>();
|
Set<UUID> possibleTargets = new HashSet<>();
|
||||||
for (StackObject stackObject : game.getStack()) {
|
for (StackObject stackObject : game.getStack()) {
|
||||||
if (stackObject instanceof Spell
|
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
|
||||||
&& game.getPlayer(sourceControllerId).getInRange()
|
Targets targets = stackObject.getStackAbility().getTargets();
|
||||||
.contains(stackObject.getControllerId())
|
if(!targets.isEmpty()) {
|
||||||
&& filter.match((Spell) stackObject, game)
|
for (Target target : targets) {
|
||||||
&& ((Spell) stackObject).getSpellAbility().getTargets()
|
for (UUID targetId : target.getTargets()) {
|
||||||
.isChosen()
|
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
|
||||||
&& game.getPermanent(((Spell) stackObject)
|
if (targetedPermanent.getControllerId().equals(sourceControllerId)) {
|
||||||
.getSpellAbility().getTargets().getFirstTarget()) != null
|
possibleTargets.add(stackObject.getId());
|
||||||
&& game.getPermanent(
|
}
|
||||||
((Spell) stackObject).getSpellAbility()
|
}
|
||||||
.getTargets().getFirstTarget())
|
}
|
||||||
.getControllerId() == sourceControllerId) {
|
}
|
||||||
possibleTargets.add(stackObject.getId());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return possibleTargets;
|
return possibleTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -211,3 +172,44 @@ class TargetSpellTargetingControlledPermanent extends
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class NotOfThisWorldCondition implements Condition {
|
||||||
|
|
||||||
|
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control with power 7 or greater");
|
||||||
|
|
||||||
|
static {
|
||||||
|
filter.add(new PowerPredicate(Filter.ComparisonType.GreaterThan, 6));
|
||||||
|
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final NotOfThisWorldCondition fInstance = new NotOfThisWorldCondition();
|
||||||
|
|
||||||
|
public static Condition getInstance() {
|
||||||
|
return fInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
StackObject sourceSpell = game.getStack().getStackObject(source.getSourceId());
|
||||||
|
if (sourceSpell != null && sourceSpell.getStackAbility().getTargets().isChosen()) {
|
||||||
|
StackObject objectToCounter = game.getStack().getStackObject(sourceSpell.getStackAbility().getTargets().getFirstTarget());
|
||||||
|
if (objectToCounter != null) {
|
||||||
|
for (Target target : objectToCounter.getStackAbility().getTargets()) {
|
||||||
|
for (UUID targetId : target.getTargets()) {
|
||||||
|
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
|
||||||
|
if (targetedPermanent != null && filter.match(targetedPermanent, sourceSpell.getSourceId(), sourceSpell.getControllerId(), game)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "it targets a spell or ability that targets a creature you control with power 7 or greater";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue