made a few changes to how Manascape Refractor and Quicksilver Elemental were implemented

This commit is contained in:
Evan Kranzler 2020-04-24 20:55:04 -04:00
parent 5af57d29e8
commit 4b92209fe1
2 changed files with 29 additions and 80 deletions

View file

@ -1,13 +1,12 @@
package mage.cards.m;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.AsThoughManaEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.mana.*;
import mage.abilities.mana.BasicManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -17,10 +16,11 @@ import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.ManaPoolItem;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.Collection;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author AsterAether
@ -30,15 +30,14 @@ public final class ManascapeRefractor extends CardImpl {
public ManascapeRefractor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}");
// Manascape Refractor enters the battlefield tapped.
this.addAbility(new EntersBattlefieldTappedAbility());
// Manascape Refractor has all activated abilities of all lands on the battlefield.
this.addAbility(new SimpleStaticAbility(new ManascapeRefractorGainAbilitiesEffect()));
// You may spend mana as though it were mana of any color to pay the activation costs of Manascape Refractor's abilities.
ManascapeRefractorSpendAnyManaEffect manaEffect = new ManascapeRefractorSpendAnyManaEffect();
manaEffect.setTargetPointer(new FixedTarget(this.getId()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, manaEffect));
this.addAbility(new SimpleStaticAbility(new ManascapeRefractorSpendAnyManaEffect()));
}
private ManascapeRefractor(final ManascapeRefractor card) {
@ -52,6 +51,7 @@ public final class ManascapeRefractor extends CardImpl {
}
class ManascapeRefractorGainAbilitiesEffect extends ContinuousEffectImpl {
private static final FilterPermanent filter = new FilterLandPermanent();
static {
@ -73,28 +73,18 @@ class ManascapeRefractorGainAbilitiesEffect extends ContinuousEffectImpl {
if (perm == null) {
return true;
}
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(
filter, source.getControllerId(), source.getSourceId(), game
)) {
for (Ability ability : permanent.getAbilities()) {
if (ability instanceof ActivatedAbility) {
boolean addAbility = true;
for (Ability existingAbility : perm.getAbilities()) {
if (existingAbility instanceof RedManaAbility && ability instanceof RedManaAbility) {
addAbility = false;
} else if (existingAbility instanceof BlueManaAbility && ability instanceof BlueManaAbility) {
addAbility = false;
} else if (existingAbility instanceof GreenManaAbility && ability instanceof GreenManaAbility) {
addAbility = false;
} else if (existingAbility instanceof WhiteManaAbility && ability instanceof WhiteManaAbility) {
addAbility = false;
} else if (existingAbility instanceof BlackManaAbility && ability instanceof BlackManaAbility) {
addAbility = false;
}
}
if (addAbility)
perm.addAbility(ability, source.getSourceId(), game);
}
for (Ability ability : game.getState()
.getBattlefield()
.getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)
.stream()
.map(permanent -> permanent.getAbilities(game))
.flatMap(Collection::stream)
.collect(Collectors.toList())) {
if (!(ability instanceof BasicManaAbility)
|| perm.getAbilities(game)
.stream()
.noneMatch(ability.getClass()::isInstance)) {
perm.addAbility(ability, source.getSourceId(), game);
}
}
return true;
@ -108,12 +98,12 @@ class ManascapeRefractorGainAbilitiesEffect extends ContinuousEffectImpl {
class ManascapeRefractorSpendAnyManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public ManascapeRefractorSpendAnyManaEffect() {
ManascapeRefractorSpendAnyManaEffect() {
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "You may spend mana as though it were mana of any color to pay the activation costs of {this}'s abilities.";
}
public ManascapeRefractorSpendAnyManaEffect(final ManascapeRefractorSpendAnyManaEffect effect) {
private ManascapeRefractorSpendAnyManaEffect(final ManascapeRefractorSpendAnyManaEffect effect) {
super(effect);
}
@ -130,10 +120,7 @@ class ManascapeRefractorSpendAnyManaEffect extends AsThoughEffectImpl implements
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
objectId = CardUtil.getMainCardId(game, objectId); // for split cards
if (objectId.equals(getTargetPointer().getFirst(game, source))) {
return affectedControllerId.equals(source.getControllerId());
}
return false;
return objectId.equals(source.getSourceId()) && affectedControllerId.equals(source.getControllerId());
}
@Override

View file

@ -17,7 +17,6 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.ManaPoolItem;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
@ -35,18 +34,15 @@ public final class QuicksilverElemental extends CardImpl {
this.toughness = new MageInt(4);
// {U}: Quicksilver Elemental gains all activated abilities of target creature until end of turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new QuicksilverElementalEffect(), new ManaCostsImpl("{U}"));
Ability ability = new SimpleActivatedAbility(new QuicksilverElementalEffect(), new ManaCostsImpl("{U}"));
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
// You may spend blue mana as though it were mana of any color to pay the activation costs of Quicksilver Elemental's abilities.
QuickSilverElementalBlueManaEffect effect2 = new QuickSilverElementalBlueManaEffect();
effect2.setTargetPointer(new FixedTarget(this.getId()));
Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, effect2);
this.addAbility(ability2);
this.addAbility(new SimpleStaticAbility(new QuickSilverElementalBlueManaEffect()));
}
public QuicksilverElemental(final QuicksilverElemental card) {
private QuicksilverElemental(final QuicksilverElemental card) {
super(card);
}
@ -63,7 +59,7 @@ class QuicksilverElementalEffect extends OneShotEffect {
staticText = "{this} gains all activated abilities of target creature until end of turn";
}
QuicksilverElementalEffect(final QuicksilverElementalEffect effect) {
private QuicksilverElementalEffect(final QuicksilverElementalEffect effect) {
super(effect);
}
@ -89,44 +85,14 @@ class QuicksilverElementalEffect extends OneShotEffect {
}
}
//class QuicksilverElementalEffect extends ContinuousEffectImpl {
//
// public QuicksilverElementalEffect() {
// super(Duration.EndOfTurn, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
// staticText = "{this} gains all activated abilities of target creature until end of turn";
// }
//
// public QuicksilverElementalEffect(final QuicksilverElementalEffect effect) {
// super(effect);
// }
//
// @Override
// public QuicksilverElementalEffect copy() {
// return new QuicksilverElementalEffect(this);
// }
//
// @Override
// public boolean apply(Game game, Ability source) {
// Permanent permanent = game.getPermanent(source.getSourceId());
// Permanent creature = game.getPermanent(source.getTargets().getFirstTarget());
//
// if (permanent != null && creature != null) {
// for (ActivatedAbility ability : creature.getAbilities().getActivatedAbilities(Zone.BATTLEFIELD)) {
// permanent.addAbility(ability, source.getSourceId(), game);
// }
// }
// return false;
// }
//}
class QuickSilverElementalBlueManaEffect extends AsThoughEffectImpl implements AsThoughManaEffect {
public QuickSilverElementalBlueManaEffect() {
QuickSilverElementalBlueManaEffect() {
super(AsThoughEffectType.SPEND_OTHER_MANA, Duration.Custom, Outcome.Benefit);
staticText = "You may spend blue mana as though it were mana of any color to pay the activation costs of {this}'s abilities";
}
public QuickSilverElementalBlueManaEffect(final QuickSilverElementalBlueManaEffect effect) {
private QuickSilverElementalBlueManaEffect(final QuickSilverElementalBlueManaEffect effect) {
super(effect);
}
@ -143,11 +109,7 @@ class QuickSilverElementalBlueManaEffect extends AsThoughEffectImpl implements A
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
objectId = CardUtil.getMainCardId(game, objectId); // for split cards
if (objectId.equals(getTargetPointer().getFirst(game, source))) {
return affectedControllerId.equals(source.getControllerId());
}
return false;
return objectId.equals(source.getSourceId()) && affectedControllerId.equals(source.getControllerId());
}
@Override