mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
Updated Teferi's Response to use FilterControlledLandPermanent.
This commit is contained in:
parent
c94be5f4d3
commit
57dfa70837
2 changed files with 29 additions and 108 deletions
|
@ -64,15 +64,17 @@ public class SurestrikeTrident extends CardImpl {
|
|||
this.subtype.add("Equipment");
|
||||
|
||||
// Equipped creature has first strike and "{tap}, Unattach Surestrike Trident: This creature deals damage equal to its power to target player."
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.EQUIPMENT)));
|
||||
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.EQUIPMENT));
|
||||
DynamicValue xValue = new SourcePermanentPowerCount();
|
||||
Effect effect = new DamageTargetEffect(xValue);
|
||||
effect.setText("This creature deals damage equal to its power to target player");
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapSourceCost());
|
||||
ability.addTarget(new TargetPlayer());
|
||||
ability.addCost(new SurestrikeTridentUnattachCost());
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(ability, AttachmentType.EQUIPMENT, Duration.WhileOnBattlefield)));
|
||||
Ability gainedAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapSourceCost());
|
||||
gainedAbility.addTarget(new TargetPlayer());
|
||||
gainedAbility.addCost(new SurestrikeTridentUnattachCost(getName(), getId()));
|
||||
effect = new GainAbilityAttachedEffect(gainedAbility, AttachmentType.EQUIPMENT);
|
||||
effect.setText("and \"{T}, Unattach {this}: This creature deals damage equal to its power to target player.\"");
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(ability);
|
||||
|
||||
// Equip {4}
|
||||
this.addAbility(new EquipAbility(Outcome.Benefit, new GenericManaCost(4)));
|
||||
|
@ -90,21 +92,25 @@ public class SurestrikeTrident extends CardImpl {
|
|||
|
||||
class SurestrikeTridentUnattachCost extends CostImpl {
|
||||
|
||||
public SurestrikeTridentUnattachCost() {
|
||||
this.text = "Unattach Surestrike Trident";
|
||||
protected UUID sourceEquipmentId;
|
||||
|
||||
public SurestrikeTridentUnattachCost(String name, UUID sourceId) {
|
||||
this.text = "Unattach " + name;
|
||||
this.sourceEquipmentId = sourceId;
|
||||
}
|
||||
|
||||
public SurestrikeTridentUnattachCost(final SurestrikeTridentUnattachCost cost) {
|
||||
super(cost);
|
||||
this.sourceEquipmentId = cost.sourceEquipmentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null) {
|
||||
for (UUID attachmentId :permanent.getAttachments()) {
|
||||
for (UUID attachmentId : permanent.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.getName().equals("Surestrike Trident")) {
|
||||
if (attachment != null && attachment.getId().equals(sourceEquipmentId)) {
|
||||
paid = permanent.removeAttachment(attachmentId, game);
|
||||
if (paid) {
|
||||
break;
|
||||
|
@ -120,9 +126,9 @@ class SurestrikeTridentUnattachCost extends CostImpl {
|
|||
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
|
||||
Permanent permanent = game.getPermanent(sourceId);
|
||||
if (permanent != null) {
|
||||
for (UUID attachmentId :permanent.getAttachments()) {
|
||||
for (UUID attachmentId : permanent.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.getName().equals("Surestrike Trident") ) {
|
||||
if (attachment != null && attachment.getId().equals(sourceEquipmentId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.sets.invasion;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -37,16 +35,13 @@ import mage.cards.CardImpl;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Rarity;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterStackObject;
|
||||
import mage.filter.common.FilterControlledLandPermanent;
|
||||
import mage.filter.predicate.other.TargetsPermanentPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackAbility;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetObject;
|
||||
import mage.target.Targets;
|
||||
import mage.target.TargetStackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,13 +49,19 @@ import mage.target.Targets;
|
|||
*/
|
||||
public class TeferisResponse extends CardImpl {
|
||||
|
||||
private final static FilterStackObject filter = new FilterStackObject("spell or ability an opponent controls that targets a land you control");
|
||||
|
||||
static {
|
||||
filter.add(new TargetsPermanentPredicate(new FilterControlledLandPermanent()));
|
||||
}
|
||||
|
||||
public TeferisResponse(UUID ownerId) {
|
||||
super(ownerId, 78, "Teferi's Response", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{1}{U}");
|
||||
this.expansionSetCode = "INV";
|
||||
|
||||
// Counter target spell or ability an opponent controls that targets a land you control. If a permanent's ability is countered this way, destroy that permanent.
|
||||
this.getSpellAbility().addEffect(new TeferisResponseEffect());
|
||||
this.getSpellAbility().addTarget(new TargetStackObjectTargetingControlledLand());
|
||||
this.getSpellAbility().addTarget(new TargetStackObject(filter));
|
||||
|
||||
// Draw two cards.
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(2));
|
||||
|
@ -76,92 +77,6 @@ public class TeferisResponse extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class TargetStackObjectTargetingControlledLand extends TargetObject {
|
||||
|
||||
public TargetStackObjectTargetingControlledLand() {
|
||||
this.minNumberOfTargets = 1;
|
||||
this.maxNumberOfTargets = 1;
|
||||
this.zone = Zone.STACK;
|
||||
this.targetName = "spell or ability an opponent controls that targets a land you control";
|
||||
}
|
||||
|
||||
public TargetStackObjectTargetingControlledLand(final TargetStackObjectTargetingControlledLand target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter getFilter() {
|
||||
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
StackObject stackObject = game.getStack().getStackObject(id);
|
||||
if ((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
return canChoose(sourceControllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceControllerId, Game game) {
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) && stackObject.getControllerId() != sourceControllerId) {
|
||||
Targets objectTargets = stackObject.getStackAbility().getTargets();
|
||||
if(!objectTargets.isEmpty()) {
|
||||
for (Target target : objectTargets) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
|
||||
if (targetedPermanent != null && targetedPermanent.getCardType().contains(CardType.LAND) && targetedPermanent.getControllerId().equals(sourceControllerId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId,
|
||||
Game game) {
|
||||
return possibleTargets(sourceControllerId, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceControllerId, Game game) {
|
||||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
if (((stackObject instanceof Spell) || (stackObject instanceof StackAbility)) && stackObject.getControllerId() != sourceControllerId) {
|
||||
Targets objectTargets = stackObject.getStackAbility().getTargets();
|
||||
if(!objectTargets.isEmpty()) {
|
||||
for (Target target : objectTargets) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Permanent targetedPermanent = game.getPermanentOrLKIBattlefield(targetId);
|
||||
if (targetedPermanent != null && targetedPermanent.getCardType().contains(CardType.LAND) && targetedPermanent.getControllerId().equals(sourceControllerId)) {
|
||||
possibleTargets.add(stackObject.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return possibleTargets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetStackObjectTargetingControlledLand copy() {
|
||||
return new TargetStackObjectTargetingControlledLand(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TeferisResponseEffect extends OneShotEffect {
|
||||
|
||||
public TeferisResponseEffect() {
|
||||
|
|
Loading…
Reference in a new issue