Fix #9560 and replace various custom effects with GainControlAllEffect

This commit is contained in:
Alex W. Jackson 2022-09-24 00:39:48 -04:00
parent 55b75a5839
commit 0b200748e5
12 changed files with 124 additions and 460 deletions

View file

@ -1,28 +1,21 @@
package mage.cards.a;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.effects.common.continuous.GainControlAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/**
*
* @author nick.myers
* @author awjackson
*/
public final class AuraThief extends CardImpl {
@ -32,51 +25,23 @@ public final class AuraThief extends CardImpl {
this.subtype.add(SubType.ILLUSION);
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
// When Aura Thief dies, you gain control of all enchantments. You don't get
// to move Auras.
this.addAbility(new DiesSourceTriggeredAbility(new AuraThiefDiesTriggeredEffect()));
// When Aura Thief dies, you gain control of all enchantments. (You don't get to move Auras.)
this.addAbility(new DiesSourceTriggeredAbility(
new GainControlAllEffect(Duration.Custom, StaticFilters.FILTER_PERMANENT_ENCHANTMENTS)
.setText("you gain control of all enchantments. <i>(You don't get to move Auras.)</i>")
));
}
private AuraThief(final AuraThief card) {
super(card);
}
@Override
public AuraThief copy() {
return new AuraThief(this);
}
}
class AuraThiefDiesTriggeredEffect extends OneShotEffect {
public AuraThiefDiesTriggeredEffect() {
super(Outcome.Benefit);
this.staticText = "gain control of all enchantments. <i>(You don't get to move Auras.)</i>";
}
public AuraThiefDiesTriggeredEffect(final AuraThiefDiesTriggeredEffect effect) {
super(effect);
}
@Override
public AuraThiefDiesTriggeredEffect copy() {
return new AuraThiefDiesTriggeredEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
boolean ret = false;
for(Permanent enchantment : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_ENCHANTMENT, source.getControllerId(), source, game)) {
ContinuousEffect gainControl = new GainControlTargetEffect(Duration.EndOfGame);
gainControl.setTargetPointer(new FixedTarget(enchantment.getId(), game));
game.addEffect(gainControl, source);
ret = true;
}
return ret;
}
}

View file

@ -17,7 +17,7 @@ import mage.filter.FilterPermanent;
*/
public final class Brand extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("all permanents you own");
private static final FilterPermanent filter = new FilterPermanent("permanents you own");
static {
filter.add(TargetController.YOU.getOwnerPredicate());

View file

@ -25,7 +25,7 @@ import mage.filter.predicate.permanent.TokenPredicate;
*/
public final class EchoOfDeathsWail extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent(SubType.RAT, "all Rat tokens");
private static final FilterPermanent filter = new FilterPermanent(SubType.RAT, "Rat tokens");
static {
filter.add(TokenPredicate.TRUE);

View file

@ -19,10 +19,8 @@ import mage.cards.CardSetInfo;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreatureOrPlaneswalkerPermanent;
import mage.filter.predicate.Predicate;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreatureOrPlaneswalker;
/**
@ -32,13 +30,11 @@ import mage.target.common.TargetCreatureOrPlaneswalker;
public final class GeyadroneDihada extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("permanents with corruption counters on them");
private static final FilterCreatureOrPlaneswalkerPermanent filter2 = new FilterCreatureOrPlaneswalkerPermanent("other creature or planeswalker");
private static final FilterPermanent filter3 = new FilterPermanent("each permanent with a corruption counter on it");
private static final FilterPermanent filter2 = new FilterCreatureOrPlaneswalkerPermanent("other creature or planeswalker");
static {
filter.add(CorruptionCounterPredicate.instance);
filter.add(CounterType.CORRUPTION.getPredicate());
filter2.add(AnotherPredicate.instance);
filter3.add(CorruptionCounterPredicate.instance);
}
public GeyadroneDihada(UUID ownerId, CardSetInfo setInfo) {
@ -56,7 +52,7 @@ public final class GeyadroneDihada extends CardImpl {
ability.addEffect(new GainLifeEffect(2).concatBy("and"));
ability.addEffect(new AddCountersTargetEffect(CounterType.CORRUPTION.createInstance(), Outcome.Detriment)
.setText("Put a corruption counter on up to one other target creature or planeswalker"));
ability.addTarget(new TargetCreatureOrPlaneswalker(0, 1, filter2, false));
ability.addTarget(new TargetPermanent(0, 1, filter2));
this.addAbility(ability);
// 3: Gain control of target creature or planeswalker until end of tun. Untap it and put a corruption counter on it. It gains haste until end of turn.
@ -68,7 +64,10 @@ public final class GeyadroneDihada extends CardImpl {
this.addAbility(ability);
// 7: Gain control of each permanent with a corruption counter on it.
this.addAbility(new LoyaltyAbility(new GainControlAllEffect(Duration.Custom, filter3), -7));
this.addAbility(new LoyaltyAbility(
new GainControlAllEffect(Duration.Custom, filter).setText("gain control of each permanent with a corruption counter on it"),
-7
));
}
private GeyadroneDihada(final GeyadroneDihada card) {
@ -80,12 +79,3 @@ public final class GeyadroneDihada extends CardImpl {
return new GeyadroneDihada(this);
}
}
enum CorruptionCounterPredicate implements Predicate<Permanent> {
instance;
@Override
public boolean apply(Permanent input, Game game) {
return input.getCounters(game).getCount(CounterType.CORRUPTION) > 0;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.g;
import java.util.UUID;
@ -23,8 +22,8 @@ import mage.filter.predicate.mageobject.AbilityPredicate;
*/
public final class GruulCharm extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures without flying");
private static final FilterPermanent filter2 = new FilterPermanent("all permanents you own");
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures without flying");
private static final FilterPermanent filter2 = new FilterPermanent("permanents you own");
private static final FilterCreaturePermanent filter3 = new FilterCreaturePermanent("creature with flying");
static {
@ -41,7 +40,7 @@ public final class GruulCharm extends CardImpl {
this.getSpellAbility().addEffect(new CantBlockAllEffect(filter, Duration.EndOfTurn));
// or gain control of all permanents you own;
this.getSpellAbility().addMode(new Mode(new GainControlAllEffect(Duration.EndOfGame, filter2)));
this.getSpellAbility().addMode(new Mode(new GainControlAllEffect(Duration.Custom, filter2)));
// or Gruul Charm deals 3 damage to each creature with flying.
this.getSpellAbility().addMode(new Mode(new DamageAllEffect(3, filter3)));

View file

@ -1,40 +1,32 @@
package mage.cards.k;
import java.util.List;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.UntapAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityControlledEffect;
import mage.abilities.effects.common.continuous.GainControlAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.filter.common.FilterCreaturePermanent;
/**
*
* @author jeffwadsworth
* @author awjackson
*/
public final class KarrthusTyrantOfJund extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Dragon creatures you control");
static {
filter.add(AnotherPredicate.instance);
filter.add(SubType.DRAGON.getPredicate());
}
private static final FilterPermanent filter = new FilterPermanent(SubType.DRAGON, "Dragons");
private static final FilterPermanent filter2 = new FilterCreaturePermanent(SubType.DRAGON, "Dragon creatures");
public KarrthusTyrantOfJund(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{B}{R}{G}");
@ -45,16 +37,19 @@ public final class KarrthusTyrantOfJund extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Haste
this.addAbility(HasteAbility.getInstance());
// When Karrthus, Tyrant of Jund enters the battlefield, gain control of all Dragons, then untap all Dragons.
this.addAbility(new EntersBattlefieldTriggeredAbility(new KarrthusEffect()));
Ability ability = new EntersBattlefieldTriggeredAbility(new GainControlAllEffect(Duration.Custom, filter));
ability.addEffect(new UntapAllEffect(filter).concatBy(", then"));
this.addAbility(ability);
// Other Dragon creatures you control have haste.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.WhileOnBattlefield, filter, true)));
this.addAbility(new SimpleStaticAbility(new GainAbilityControlledEffect(
HasteAbility.getInstance(), Duration.WhileOnBattlefield, filter2, true
)));
}
private KarrthusTyrantOfJund(final KarrthusTyrantOfJund card) {
@ -66,65 +61,3 @@ public final class KarrthusTyrantOfJund extends CardImpl {
return new KarrthusTyrantOfJund(this);
}
}
class KarrthusEffect extends OneShotEffect {
public KarrthusEffect() {
super(Outcome.GainControl);
this.staticText = "gain control of all Dragons, then untap all Dragons";
}
public KarrthusEffect(final KarrthusEffect effect) {
super(effect);
}
@Override
public KarrthusEffect copy() {
return new KarrthusEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
FilterPermanent filter = new FilterPermanent();
filter.add(SubType.DRAGON.getPredicate());
List<Permanent> dragons = game.getBattlefield().getAllActivePermanents(filter, game);
for (Permanent dragon : dragons) {
ContinuousEffect effect = new KarrthusControlEffect(source.getControllerId());
effect.setTargetPointer(new FixedTarget(dragon.getId(), game));
game.addEffect(effect, source);
}
for (Permanent dragon : dragons) {
dragon.untap(game);
}
return true;
}
}
class KarrthusControlEffect extends ContinuousEffectImpl {
private UUID controllerId;
public KarrthusControlEffect(UUID controllerId) {
super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
this.controllerId = controllerId;
}
public KarrthusControlEffect(final KarrthusControlEffect effect) {
super(effect);
this.controllerId = effect.controllerId;
}
@Override
public KarrthusControlEffect copy() {
return new KarrthusControlEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent dragon = game.getPermanent(targetPointer.getFirst(game, source));
if (dragon != null && controllerId != null) {
return dragon.changeControllerId(controllerId, game, source);
}
return false;
}
}

View file

@ -1,38 +1,58 @@
package mage.cards.m;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.UntapAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.continuous.GainControlAllEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
/**
*
* @author jeffwadsworth
* @author awjackson
*/
public final class MobRule extends CardImpl {
private static final FilterPermanent filter4orMore = new FilterCreaturePermanent("creatures with power 4 or greater");
private static final FilterPermanent filter3orLess = new FilterCreaturePermanent("creatures with power 3 or less");
static {
filter4orMore.add(new PowerPredicate(ComparisonType.MORE_THAN, 3));
filter3orLess.add(new PowerPredicate(ComparisonType.FEWER_THAN, 4));
}
public MobRule(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{R}{R}");
// Choose one
// Gain control of all creatures with power 4 or greater until end of turn. Untap those creatures. They gain haste until end of turn.
this.getSpellAbility().addEffect(new MobRuleEffect(ComparisonType.MORE_THAN, 3));
this.getSpellAbility().addEffect(new GainControlAllEffect(Duration.EndOfTurn, filter4orMore));
this.getSpellAbility().addEffect(new UntapAllEffect(filter4orMore).setText("untap those creatures"));
this.getSpellAbility().addEffect(new GainAbilityAllEffect(
HasteAbility.getInstance(),
Duration.EndOfTurn,
filter4orMore,
"they gain haste until end of turn"
));
// Gain control of all creatures with power 3 or less until end of turn. Untap those creatures. They gain haste until end of turn.
Mode mode = new Mode(new MobRuleEffect(ComparisonType.FEWER_THAN, 4));
Mode mode = new Mode(new GainControlAllEffect(Duration.EndOfTurn, filter3orLess));
mode.addEffect(new UntapAllEffect(filter3orLess).setText("untap those creatures"));
mode.addEffect(new GainAbilityAllEffect(
HasteAbility.getInstance(),
Duration.EndOfTurn,
filter3orLess,
"they gain haste until end of turn"
));
this.getSpellAbility().addMode(mode);
}
@ -45,85 +65,3 @@ public final class MobRule extends CardImpl {
return new MobRule(this);
}
}
class MobRuleEffect extends OneShotEffect {
ComparisonType type = null;
int power = 0;
public MobRuleEffect(ComparisonType type, int power) {
super(Outcome.GainControl);
this.type = type;
this.power = power;
if (type == ComparisonType.MORE_THAN) {
this.staticText = "Gain control of all creatures with power 4 or greater until end of turn. Untap those creatures. They gain haste until end of turn";
} else {
this.staticText = "Gain control of all creatures with power 3 or less until end of turn. Untap those creatures. They gain haste until end of turn";
}
}
public MobRuleEffect(final MobRuleEffect effect) {
super(effect);
this.type = effect.type;
this.power = effect.power;
}
@Override
public MobRuleEffect copy() {
return new MobRuleEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
boolean applied = false;
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new PowerPredicate(type, power));
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(filter, game);
for (Permanent creature : creatures) {
ContinuousEffect effect = new MobRuleControlAllEffect(source.getControllerId());
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
applied = true;
}
for (Permanent creature : creatures) {
creature.untap(game);
applied = true;
}
for (Permanent creature : creatures) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
applied = true;
}
return applied;
}
}
class MobRuleControlAllEffect extends ContinuousEffectImpl {
private final UUID controllerId;
public MobRuleControlAllEffect(UUID controllerId) {
super(Duration.EndOfTurn, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
this.controllerId = controllerId;
}
public MobRuleControlAllEffect(final MobRuleControlAllEffect effect) {
super(effect);
this.controllerId = effect.controllerId;
}
@Override
public MobRuleControlAllEffect copy() {
return new MobRuleControlAllEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent creature = game.getPermanent(targetPointer.getFirst(game, source));
if (creature != null && controllerId != null) {
return creature.changeControllerId(controllerId, game, source);
}
return false;
}
}

View file

@ -37,7 +37,7 @@ public final class RowanFearlessSparkmage extends CardImpl {
// +1: Up to one target creature gets +3/+0 and gains first strike until end of turn.
Ability ability = new LoyaltyAbility(new BoostTargetEffect(
3, 0, Duration.EndOfTurn
).setText("Up to one target creature gets +3/+0"), 1);
).setText("up to one target creature gets +3/+0"), 1);
ability.addEffect(new GainAbilityTargetEffect(
FirstStrikeAbility.getInstance(), Duration.EndOfTurn
).setText("and gains first strike until end of turn"));
@ -46,19 +46,21 @@ public final class RowanFearlessSparkmage extends CardImpl {
// 2: Rowan, Fearless Sparkmage deals 1 damage to each of up to two target creatures. Those creatures can't block this turn.
ability = new LoyaltyAbility(new DamageTargetEffect(1)
.setText("{this} deals 1 damage to each of up to two target creatures."), -2);
.setText("{this} deals 1 damage to each of up to two target creatures"), -2);
ability.addEffect(new CantBlockTargetEffect(Duration.EndOfTurn)
.setText("Those creatures can't block this turn."));
.setText("those creatures can't block this turn"));
ability.addTarget(new TargetCreaturePermanent(0, 2));
this.addAbility(ability);
// 9: Gain control of all creatures until end of turn. Untap them. They gain haste until end of turn.
ability = new LoyaltyAbility(new GainControlAllEffect(Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_ALL_CREATURES)
.setText("gain control of all creatures until end of turn."), -9);
ability.addEffect(new UntapAllEffect(StaticFilters.FILTER_PERMANENT_ALL_CREATURES).setText("Untap them."));
ability = new LoyaltyAbility(new GainControlAllEffect(Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_CREATURES), -9);
ability.addEffect(new UntapAllEffect(StaticFilters.FILTER_PERMANENT_CREATURES).setText("untap them"));
ability.addEffect(new GainAbilityAllEffect(
HasteAbility.getInstance(), Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_ALL_CREATURES
).setText("They gain haste until end of turn"));
HasteAbility.getInstance(),
Duration.EndOfTurn,
StaticFilters.FILTER_PERMANENT_CREATURES,
"they gain haste until end of turn"
));
this.addAbility(ability);
}

View file

@ -1,59 +1,29 @@
package mage.cards.t;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EndOfCombatTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.effects.common.continuous.GainControlAllEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.BlockedAttackerWatcher;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.BlockingOrBlockedBySourcePredicate;
import java.util.UUID;
/**
* @author jeffwadsworth
* <p>
* 5/1/2009 The ability grants you control of all creatures that are blocking it
* as the ability resolves. This will include any creatures that were put onto
* the battlefield blocking it.
* <p>
* 5/1/2009 Any blocking creatures that regenerated during combat will have been
* removed from combat. Since such creatures are no longer in combat, they
* cannot be blocking The Wretched, which means you won't be able to gain
* control of them.
* <p>
* 5/1/2009 If The Wretched itself regenerated during combat, then it will have
* been removed from combat. Since it is no longer in combat, there cannot be
* any creatures blocking it, which means you won't be able to gain control of
* any creatures.
* <p>
* 10/1/2009 The Wretched's ability triggers only if it's still on the
* battlefield when the end of combat step begins (after the combat damage
* step). For example, if it's blocked by a 7/7 creature and is destroyed, its
* ability won't trigger at all.
* <p>
* 10/1/2009 If The Wretched leaves the battlefield, you no longer control it,
* so the duration of its control-change effect ends.
* <p>
* 10/1/2009 If you lose control of The Wretched before its ability resolves,
* you won't gain control of the creatures blocking it at all.
* <p>
* 10/1/2009 Once the ability resolves, it doesn't care whether the permanents
* you gained control of remain creatures, only that they remain on the
* battlefield.
* @author awjackson
*/
public final class TheWretched extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures blocking {this}");
static {
filter.add(BlockingOrBlockedBySourcePredicate.BLOCKING);
}
public TheWretched(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}{B}");
this.subtype.add(SubType.DEMON);
@ -61,7 +31,7 @@ public final class TheWretched extends CardImpl {
this.toughness = new MageInt(5);
// At end of combat, gain control of all creatures blocking The Wretched for as long as you control The Wretched.
this.addAbility(new EndOfCombatTriggeredAbility(new TheWretchedEffect(), false), new BlockedAttackerWatcher());
this.addAbility(new EndOfCombatTriggeredAbility(new GainControlAllEffect(Duration.WhileControlled, filter), false));
}
private TheWretched(final TheWretched card) {
@ -73,47 +43,3 @@ public final class TheWretched extends CardImpl {
return new TheWretched(this);
}
}
class TheWretchedEffect extends OneShotEffect {
TheWretchedEffect() {
super(Outcome.Benefit);
staticText = "gain control of all creatures blocking {this} for as long as you control {this}";
}
TheWretchedEffect(final TheWretchedEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent theWretched = source.getSourcePermanentIfItStillExists(game);
if (theWretched == null
|| !theWretched.isAttacking()
|| !source.isControlledBy(theWretched.getControllerId())) {
return false;
}
// Check if control of source has changed since ability triggered????? (does it work is it neccessary???)
for (CombatGroup combatGroup : game.getCombat().getGroups()) {
if (!combatGroup.getAttackers().contains(source.getSourceId())) {
continue;
}
for (UUID creatureId : combatGroup.getBlockers()) {
Permanent blocker = game.getPermanent(creatureId);
if (blocker == null
|| blocker.getBlocking() <= 0) {
continue;
}
ContinuousEffect effect = new GainControlTargetEffect(Duration.WhileControlled, source.getControllerId());
effect.setTargetPointer(new FixedTarget(blocker.getId(), game));
game.addEffect(effect, source);
}
}
return true;
}
@Override
public TheWretchedEffect copy() {
return new TheWretchedEffect(this);
}
}

View file

@ -1,34 +1,29 @@
package mage.cards.t;
import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.dynamicvalue.common.CardsInTargetHandCount;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.UntapAllEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.continuous.GainControlAllEffect;
import mage.abilities.effects.common.discard.DiscardControllerEffect;
import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import java.util.List;
import java.util.UUID;
/**
* @author North
* @author awjackson
*/
public final class TibaltTheFiendBlooded extends CardImpl {
@ -40,19 +35,27 @@ public final class TibaltTheFiendBlooded extends CardImpl {
this.setStartingLoyalty(2);
// +1: Draw a card, then discard a card at random.
LoyaltyAbility ability = new LoyaltyAbility(new DrawCardSourceControllerEffect(1), 1);
Effect effect = new DiscardControllerEffect(1, true);
effect.setText(", then discard a card at random");
ability.addEffect(effect);
Ability ability = new LoyaltyAbility(new DrawCardSourceControllerEffect(1), 1);
ability.addEffect(new DiscardControllerEffect(1, true).concatBy(", then"));
this.addAbility(ability);
// -4: Tibalt, the Fiend-Blooded deals damage equal to the number of cards in target player's hand to that player.
effect = new DamageTargetEffect(CardsInTargetHandCount.instance, true);
Effect effect = new DamageTargetEffect(CardsInTargetHandCount.instance);
effect.setText("{this} deals damage equal to the number of cards in target player's hand to that player");
ability = new LoyaltyAbility(effect, -4);
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
// -6: Gain control of all creatures until end of turn. Untap them. They gain haste until end of turn.
this.addAbility(new LoyaltyAbility(new TibaltTheFiendBloodedThirdEffect(), -6));
ability = new LoyaltyAbility(new GainControlAllEffect(Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_CREATURES), -6);
ability.addEffect(new UntapAllEffect(StaticFilters.FILTER_PERMANENT_CREATURES).setText("untap them"));
ability.addEffect(new GainAbilityAllEffect(
HasteAbility.getInstance(),
Duration.EndOfTurn,
StaticFilters.FILTER_PERMANENT_CREATURES,
"they gain haste until end of turn"
));
this.addAbility(ability);
}
private TibaltTheFiendBlooded(final TibaltTheFiendBlooded card) {
@ -64,95 +67,3 @@ public final class TibaltTheFiendBlooded extends CardImpl {
return new TibaltTheFiendBlooded(this);
}
}
class TibaltTheFiendBloodedFirstEffect extends OneShotEffect {
public TibaltTheFiendBloodedFirstEffect() {
super(Outcome.Benefit);
this.staticText = "Draw a card, then discard a card at random";
}
public TibaltTheFiendBloodedFirstEffect(final TibaltTheFiendBloodedFirstEffect effect) {
super(effect);
}
@Override
public TibaltTheFiendBloodedFirstEffect copy() {
return new TibaltTheFiendBloodedFirstEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.drawCards(1, source, game);
Card card = player.getHand().getRandom(game);
player.discard(card, false, source, game);
return true;
}
return false;
}
}
class TibaltTheFiendBloodedThirdEffect extends OneShotEffect {
public TibaltTheFiendBloodedThirdEffect() {
super(Outcome.GainControl);
this.staticText = "Gain control of all creatures until end of turn. Untap them. They gain haste until end of turn";
}
public TibaltTheFiendBloodedThirdEffect(final TibaltTheFiendBloodedThirdEffect effect) {
super(effect);
}
@Override
public TibaltTheFiendBloodedThirdEffect copy() {
return new TibaltTheFiendBloodedThirdEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game);
for (Permanent permanent : permanents) {
permanent.untap(game);
ContinuousEffect effect = new TibaltTheFiendBloodedControlEffect(source.getControllerId());
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return true;
}
}
class TibaltTheFiendBloodedControlEffect extends ContinuousEffectImpl {
private final UUID controllerId;
public TibaltTheFiendBloodedControlEffect(UUID controllerId) {
super(Duration.EndOfTurn, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl);
this.controllerId = controllerId;
}
public TibaltTheFiendBloodedControlEffect(final TibaltTheFiendBloodedControlEffect effect) {
super(effect);
this.controllerId = effect.controllerId;
}
@Override
public TibaltTheFiendBloodedControlEffect copy() {
return new TibaltTheFiendBloodedControlEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
if (permanent != null && controllerId != null) {
return permanent.changeControllerId(controllerId, game, source);
}
return false;
}
}

View file

@ -28,7 +28,7 @@ import mage.game.permanent.token.SurvivorToken;
public final class VarchildBetrayerOfKjeldor extends CardImpl {
private static final FilterCreaturePermanent filter1 = new FilterCreaturePermanent(SubType.SURVIVOR, "Survivors your opponents control");
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent(SubType.SURVIVOR, "all Survivors");
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent(SubType.SURVIVOR, "Survivors");
static {
filter1.add(TargetController.OPPONENT.getControllerPredicate());

View file

@ -30,7 +30,7 @@ public class GainControlAllEffect extends OneShotEffect {
this.filter = filter;
this.duration = duration;
this.controllingPlayerId = controllingPlayerId;
this.staticText = "gain control of " + filter.getMessage();
this.staticText = "gain control of all " + filter.getMessage() + (duration.toString().isEmpty() ? "" : ' ' + duration.toString());
}
public GainControlAllEffect(final GainControlAllEffect effect) {
@ -50,7 +50,7 @@ public class GainControlAllEffect extends OneShotEffect {
for (Permanent permanent : game.getBattlefield()
.getActivePermanents(filter,
source.getControllerId(), source, game)) {
ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, controllingPlayerId);
ContinuousEffect effect = new GainControlTargetEffect(duration, controllingPlayerId);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}