diff --git a/Mage.Sets/src/mage/cards/a/AdaptiveAutomaton.java b/Mage.Sets/src/mage/cards/a/AdaptiveAutomaton.java index 9212ae9e51..272f83c91f 100644 --- a/Mage.Sets/src/mage/cards/a/AdaptiveAutomaton.java +++ b/Mage.Sets/src/mage/cards/a/AdaptiveAutomaton.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -43,8 +44,6 @@ import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * @author nantuko */ @@ -99,9 +98,9 @@ class AdaptiveAutomatonAddSubtypeEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type"); - if (subtype != null && !permanent.hasSubtype(subtype, game)) { - permanent.getSubtype(game).add(subtype); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game); + if (subType != null && !permanent.hasSubtype(subType, game)) { + permanent.getSubtype(game).add(subType); } } return true; diff --git a/Mage.Sets/src/mage/cards/a/AnZerrinRuins.java b/Mage.Sets/src/mage/cards/a/AnZerrinRuins.java index d37541c508..84b4c7113f 100644 --- a/Mage.Sets/src/mage/cards/a/AnZerrinRuins.java +++ b/Mage.Sets/src/mage/cards/a/AnZerrinRuins.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.Mode; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -41,8 +42,6 @@ import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * * @author TheElk801 @@ -87,11 +86,9 @@ class AnZerrinRuinsDontUntapEffect extends DontUntapInControllersUntapStepAllEff @Override public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game)) { - Permanent sourcePerm = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && sourcePerm != null) { - SubType subtype = (SubType) game.getState().getValue(sourcePerm.getId() + "_type"); - if (permanent.hasSubtype(subtype, game)) { + if (permanent != null) { + if (permanent.hasSubtype(ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game), game)) { return true; } } @@ -101,6 +98,6 @@ class AnZerrinRuinsDontUntapEffect extends DontUntapInControllersUntapStepAllEff @Override public String getText(Mode mode) { - return "Creatures of the chosen type don't untap during their controllers' untap steps."; + return "Creatures of the chosen type don't untap during their controllers' untap steps"; } } diff --git a/Mage.Sets/src/mage/cards/a/ArcaneAdaptation.java b/Mage.Sets/src/mage/cards/a/ArcaneAdaptation.java index 1d32c37240..66e364fe3a 100644 --- a/Mage.Sets/src/mage/cards/a/ArcaneAdaptation.java +++ b/Mage.Sets/src/mage/cards/a/ArcaneAdaptation.java @@ -27,6 +27,9 @@ */ package mage.cards.a; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; @@ -43,10 +46,6 @@ import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.players.Player; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; - /** * * @author TheElk801 @@ -91,41 +90,41 @@ class ConspyEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - SubType choice = (SubType) game.getState().getValue(source.getSourceId().toString() + "_type"); - if (controller != null && choice != null) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (controller != null && subType != null) { // Creature cards you own that aren't on the battlefield // in graveyard for (UUID cardId : controller.getGraveyard()) { Card card = game.getCard(cardId); - if (card.isCreature() && !card.hasSubtype(choice, game)) { - game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice); + if (card.isCreature() && !card.hasSubtype(subType, game)) { + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); } } // on Hand for (UUID cardId : controller.getHand()) { Card card = game.getCard(cardId); - if (card.isCreature() && !card.hasSubtype(choice, game)) { - game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice); + if (card.isCreature() && !card.hasSubtype(subType, game)) { + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); } } // in Exile for (Card card : game.getState().getExile().getAllCards(game)) { - if (card.isCreature() && !card.hasSubtype(choice, game)) { - game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice); + if (card.isCreature() && !card.hasSubtype(subType, game)) { + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); } } // in Library (e.g. for Mystical Teachings) for (Card card : controller.getLibrary().getCards(game)) { - if (card.getOwnerId().equals(controller.getId()) && card.isCreature() && !card.hasSubtype(choice, game)) { - game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice); + if (card.getOwnerId().equals(controller.getId()) && card.isCreature() && !card.hasSubtype(subType, game)) { + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); } } // commander in command zone for (UUID commanderId : controller.getCommandersIds()) { if (game.getState().getZone(commanderId) == Zone.COMMAND) { Card card = game.getCard(commanderId); - if (card.isCreature() && !card.hasSubtype(choice, game)) { - game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice); + if (card.isCreature() && !card.hasSubtype(subType, game)) { + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); } } } @@ -135,17 +134,17 @@ class ConspyEffect extends ContinuousEffectImpl { if (stackObject instanceof Spell && stackObject.getControllerId().equals(source.getControllerId()) && stackObject.isCreature() - && !stackObject.hasSubtype(choice, game)) { + && !stackObject.hasSubtype(subType, game)) { Card card = ((Spell) stackObject).getCard(); - game.getState().getCreateCardAttribute(card, game).getSubtype().add(choice); + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); } } // creatures you control List creatures = game.getBattlefield().getAllActivePermanents( new FilterControlledCreaturePermanent(), source.getControllerId(), game); for (Permanent creature : creatures) { - if (creature != null && !creature.hasSubtype(choice, game)) { - creature.getSubtype(game).add(choice); + if (creature != null && !creature.hasSubtype(subType, game)) { + creature.getSubtype(game).add(subType); } } return true; diff --git a/Mage.Sets/src/mage/cards/a/AshesOfTheFallen.java b/Mage.Sets/src/mage/cards/a/AshesOfTheFallen.java index edf3af051d..e804b09955 100644 --- a/Mage.Sets/src/mage/cards/a/AshesOfTheFallen.java +++ b/Mage.Sets/src/mage/cards/a/AshesOfTheFallen.java @@ -27,6 +27,7 @@ */ package mage.cards.a; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; @@ -40,8 +41,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.UUID; - /** * * @author emerald000 @@ -84,12 +83,16 @@ class AshesOfTheFallenEffect extends ContinuousEffectImpl { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); if (controller != null && permanent != null) { - SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type"); - for (UUID cardId : controller.getGraveyard()) { - Card card = game.getCard(cardId); - if (card != null && card.isCreature() && !card.hasSubtype(subtype, game)) { - game.getState().getCreateCardAttribute(card, game).getSubtype().add(subtype); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game); + if (subType != null) { + for (UUID cardId : controller.getGraveyard()) { + Card card = game.getCard(cardId); + if (card != null && card.isCreature() && !card.hasSubtype(subType, game)) { + game.getState().getCreateCardAttribute(card, game).getSubtype().add(subType); + } } + } else { + discard();; } return true; } diff --git a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java index 13d5183be3..49a62db4fc 100644 --- a/Mage.Sets/src/mage/cards/c/CavernOfSouls.java +++ b/Mage.Sets/src/mage/cards/c/CavernOfSouls.java @@ -27,6 +27,9 @@ */ package mage.cards.c; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; import mage.ConditionalMana; import mage.MageObject; import mage.Mana; @@ -50,10 +53,6 @@ import mage.game.stack.Spell; import mage.players.Player; import mage.watchers.Watcher; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - /** * * @author noxx @@ -61,7 +60,7 @@ import java.util.UUID; public class CavernOfSouls extends CardImpl { public CavernOfSouls(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.LAND},""); + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); // As Cavern of Souls enters the battlefield, choose a creature type. this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature))); @@ -91,9 +90,9 @@ class CavernOfSoulsManaBuilder extends ConditionalManaBuilder { @Override public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) { - SubType value = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - if (value != null ) { - creatureType = value; + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { + creatureType = subType; } Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/c/Conspiracy.java b/Mage.Sets/src/mage/cards/c/Conspiracy.java index d26a92a868..9fc41146bc 100644 --- a/Mage.Sets/src/mage/cards/c/Conspiracy.java +++ b/Mage.Sets/src/mage/cards/c/Conspiracy.java @@ -27,8 +27,12 @@ */ package mage.cards.c; +import java.util.Iterator; +import java.util.List; +import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; +import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.ChooseCreatureTypeEffect; @@ -43,10 +47,6 @@ import mage.game.stack.Spell; import mage.game.stack.StackObject; import mage.players.Player; import mage.util.SubTypeList; -import java.util.Iterator; -import java.util.List; -import java.util.UUID; -import mage.abilities.common.AsEntersBattlefieldAbility; /** * @@ -92,33 +92,33 @@ class ConspiracyEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); - SubType choice = (SubType) game.getState().getValue(source.getSourceId().toString() + "_type"); - if (controller != null && choice != null) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (controller != null && subType != null) { // Creature cards you own that aren't on the battlefield // in graveyard for (UUID cardId : controller.getGraveyard()) { Card card = game.getCard(cardId); if (card.isCreature()) { - setCreatureSubtype(card, choice, game); + setCreatureSubtype(card, subType, game); } } // on Hand for (UUID cardId : controller.getHand()) { Card card = game.getCard(cardId); if (card.isCreature()) { - setCreatureSubtype(card, choice, game); + setCreatureSubtype(card, subType, game); } } // in Exile for (Card card : game.getState().getExile().getAllCards(game)) { if (card.getOwnerId().equals(controller.getId()) && card.isCreature()) { - setCreatureSubtype(card, choice, game); + setCreatureSubtype(card, subType, game); } } // in Library (e.g. for Mystical Teachings) for (Card card : controller.getLibrary().getCards(game)) { if (card.getOwnerId().equals(controller.getId()) && card.isCreature()) { - setCreatureSubtype(card, choice, game); + setCreatureSubtype(card, subType, game); } } // commander in command zone @@ -126,7 +126,7 @@ class ConspiracyEffect extends ContinuousEffectImpl { if (game.getState().getZone(commanderId) == Zone.COMMAND) { Card card = game.getCard(commanderId); if (card.isCreature()) { - setCreatureSubtype(card, choice, game); + setCreatureSubtype(card, subType, game); } } } @@ -137,14 +137,14 @@ class ConspiracyEffect extends ContinuousEffectImpl { && stackObject.getControllerId().equals(source.getControllerId()) && stackObject.isCreature()) { Card card = ((Spell) stackObject).getCard(); - setCreatureSubtype(card, choice, game); + setCreatureSubtype(card, subType, game); } } // creatures you control List creatures = game.getBattlefield().getAllActivePermanents( new FilterControlledCreaturePermanent(), source.getControllerId(), game); for (Permanent creature : creatures) { - setCreatureSubtype(creature, choice, game); + setCreatureSubtype(creature, subType, game); } return true; } diff --git a/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java b/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java index f416e043ce..0132fe6494 100644 --- a/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java +++ b/Mage.Sets/src/mage/cards/c/CoverOfDarkness.java @@ -27,6 +27,7 @@ */ package mage.cards.c; +import java.util.UUID; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.ChooseCreatureTypeEffect; @@ -39,8 +40,6 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * * @author LevelX2 @@ -48,8 +47,7 @@ import java.util.UUID; public class CoverOfDarkness extends CardImpl { public CoverOfDarkness(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}"); - + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}"); // As Cover of Darkness enters the battlefield, choose a creature type. this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.AddAbility))); @@ -68,29 +66,37 @@ public class CoverOfDarkness extends CardImpl { } class FilterCoverOfDarkness extends FilterCreaturePermanent { - + + private SubType subType = null; + public FilterCoverOfDarkness() { super("All creatures of the chosen type"); } - + public FilterCoverOfDarkness(final FilterCoverOfDarkness filter) { super(filter); + this.subType = filter.subType; } - + @Override public FilterCoverOfDarkness copy() { return new FilterCoverOfDarkness(this); } - + @Override public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (super.match(permanent, sourceId, playerId, game)) { - SubType subtype = (SubType) game.getState().getValue(sourceId + "_type"); - if (subtype != null && permanent.hasSubtype(subtype, game)) { + if (subType == null) { + subType = ChooseCreatureTypeEffect.getChoosenCreatureType(sourceId, game); + if (subType == null) { + return false; + } + } + if (permanent.hasSubtype(subType, game)) { return true; } } return false; } - + } diff --git a/Mage.Sets/src/mage/cards/d/DoomCannon.java b/Mage.Sets/src/mage/cards/d/DoomCannon.java index 383bf31b35..320de221dc 100644 --- a/Mage.Sets/src/mage/cards/d/DoomCannon.java +++ b/Mage.Sets/src/mage/cards/d/DoomCannon.java @@ -39,8 +39,8 @@ import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; import mage.game.Game; @@ -55,7 +55,7 @@ import mage.target.common.TargetCreatureOrPlayer; public class DoomCannon extends CardImpl { public DoomCannon(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}"); // As Doom Cannon enters the battlefield, choose a creature type. this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.Sacrifice))); @@ -79,29 +79,29 @@ public class DoomCannon extends CardImpl { } class DoomCannonFilter extends FilterControlledCreaturePermanent { - + public DoomCannonFilter() { super("a creature of the chosen type"); } - + public DoomCannonFilter(final DoomCannonFilter filter) { super(filter); } - + @Override public DoomCannonFilter copy() { return new DoomCannonFilter(this); } - + @Override public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (super.match(permanent, sourceId, playerId, game)) { - SubType subtype = (SubType) game.getState().getValue(sourceId + "_type"); - if (subtype != null && permanent.hasSubtype(subtype, game)) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(sourceId, game); + if (subType != null && permanent.hasSubtype(subType, game)) { return true; } } return false; } - + } diff --git a/Mage.Sets/src/mage/cards/d/DoorOfDestinies.java b/Mage.Sets/src/mage/cards/d/DoorOfDestinies.java index a1331d0324..4f7ee84187 100644 --- a/Mage.Sets/src/mage/cards/d/DoorOfDestinies.java +++ b/Mage.Sets/src/mage/cards/d/DoorOfDestinies.java @@ -27,6 +27,7 @@ */ package mage.cards.d; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -38,18 +39,13 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.counters.CounterType; -import mage.filter.FilterSpell; import mage.filter.StaticFilters; -import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.stack.Spell; -import java.util.UUID; - /** * * @author Plopman @@ -57,13 +53,14 @@ import java.util.UUID; public class DoorOfDestinies extends CardImpl { public DoorOfDestinies(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); // As Door of Destinies enters the battlefield, choose a creature type. this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature))); // Whenever you cast a spell of the chosen type, put a charge counter on Door of Destinies. this.addAbility(new AddCounterAbility()); + // Creatures you control of the chosen type get +1/+1 for each charge counter on Door of Destinies. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostCreatureEffectEffect())); } @@ -100,17 +97,13 @@ class AddCounterAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - Permanent doorOfDestinies = game.getPermanent(getSourceId()); - if (doorOfDestinies != null) { - SubType subtype = (SubType) game.getState().getValue(doorOfDestinies.getId() + "_type"); - if (subtype != null) { - FilterSpell filter = new FilterSpell(); - filter.add(new ControllerPredicate(TargetController.YOU)); - filter.add(new SubtypePredicate(subtype)); - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { - return true; - } + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(getSourceId(), game); + if (subType != null) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null + && spell.getControllerId().equals(getControllerId()) + && spell.hasSubtype(subType, game)) { + return true; } } return false; @@ -124,7 +117,6 @@ class AddCounterAbility extends TriggeredAbilityImpl { class BoostCreatureEffectEffect extends ContinuousEffectImpl { - public BoostCreatureEffectEffect() { super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature); staticText = "Creatures you control of the chosen type get +1/+1 for each charge counter on {this}"; diff --git a/Mage.Sets/src/mage/cards/k/KindredCharge.java b/Mage.Sets/src/mage/cards/k/KindredCharge.java index fda4299dfb..029797f0f7 100644 --- a/Mage.Sets/src/mage/cards/k/KindredCharge.java +++ b/Mage.Sets/src/mage/cards/k/KindredCharge.java @@ -95,26 +95,24 @@ class KindredChargeEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { - Object object = game.getState().getValue(sourceObject.getId() + "_type"); - if (object == null) { - return false; - } - String creatureType = object.toString(); - FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type"); - filter.add(new SubtypePredicate(SubType.byDescription(creatureType))); - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) { - if (permanent != null) { - CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); - effect.setTargetPointer(new FixedTarget(permanent, game)); - effect.apply(game, source); - for (Permanent addedToken : effect.getAddedPermanent()) { - Effect exileEffect = new ExileTargetEffect(); - exileEffect.setTargetPointer(new FixedTarget(addedToken, game)); - game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { + FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature you control of the chosen type"); + filter.add(new SubtypePredicate(subType)); + for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) { + if (permanent != null) { + CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); + effect.setTargetPointer(new FixedTarget(permanent, game)); + effect.apply(game, source); + for (Permanent addedToken : effect.getAddedPermanent()) { + Effect exileEffect = new ExileTargetEffect(); + exileEffect.setTargetPointer(new FixedTarget(addedToken, game)); + game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(exileEffect), source); + } } } + return true; } - return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/k/KindredDominance.java b/Mage.Sets/src/mage/cards/k/KindredDominance.java index c8bc222d5d..d518325376 100644 --- a/Mage.Sets/src/mage/cards/k/KindredDominance.java +++ b/Mage.Sets/src/mage/cards/k/KindredDominance.java @@ -28,14 +28,13 @@ package mage.cards.k; import java.util.UUID; - import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.abilities.effects.common.DestroyAllEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; @@ -91,11 +90,13 @@ class KindredDominanceEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject mageObject = game.getObject(source.getSourceId()); if (controller != null & mageObject != null) { - String creatureType = game.getState().getValue(mageObject.getId() + "_type").toString(); - FilterPermanent filter = new FilterCreaturePermanent("creatures"); - filter.add(Predicates.not(new SubtypePredicate(SubType.byDescription(creatureType)))); - return new DestroyAllEffect(filter).apply(game, source); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { + FilterPermanent filter = new FilterCreaturePermanent("creatures"); + filter.add(Predicates.not(new SubtypePredicate(subType))); + return new DestroyAllEffect(filter).apply(game, source); + } } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/k/KindredSummons.java b/Mage.Sets/src/mage/cards/k/KindredSummons.java index 5adea87222..f63cb8d0bd 100644 --- a/Mage.Sets/src/mage/cards/k/KindredSummons.java +++ b/Mage.Sets/src/mage/cards/k/KindredSummons.java @@ -98,19 +98,18 @@ class KindredSummonsEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); if (controller != null && sourceObject != null) { - Object object = game.getState().getValue(sourceObject.getId() + "_type"); - if (object == null) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType == null) { return false; } - String creatureType = object.toString(); FilterControlledCreaturePermanent filterPermanent = new FilterControlledCreaturePermanent("creature you control of the chosen type"); - filterPermanent.add(new SubtypePredicate(SubType.byDescription(creatureType))); + filterPermanent.add(new SubtypePredicate(subType)); int numberOfCards = game.getBattlefield().countAll(filterPermanent, source.getControllerId(), game); Cards revealed = new CardsImpl(); Set chosenSubtypeCreatureCards = new LinkedHashSet<>(); Cards otherCards = new CardsImpl(); FilterCreatureCard filterCard = new FilterCreatureCard("creature card of the chosen type"); - filterCard.add(new SubtypePredicate(SubType.byDescription(creatureType))); + filterCard.add(new SubtypePredicate(subType)); while (chosenSubtypeCreatureCards.size() < numberOfCards && controller.getLibrary().hasCards()) { Card card = controller.getLibrary().removeFromTop(game); revealed.add(card); diff --git a/Mage.Sets/src/mage/cards/m/MetallicMimic.java b/Mage.Sets/src/mage/cards/m/MetallicMimic.java index 8295c1adaf..e118aaf4fd 100644 --- a/Mage.Sets/src/mage/cards/m/MetallicMimic.java +++ b/Mage.Sets/src/mage/cards/m/MetallicMimic.java @@ -27,6 +27,7 @@ */ package mage.cards.m; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -43,8 +44,6 @@ import mage.game.events.EntersTheBattlefieldEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * * @author Styxo @@ -105,8 +104,8 @@ class MetallicMimicReplacementEffect extends ReplacementEffectImpl { && enteringCreature.getControllerId().equals(source.getControllerId()) && enteringCreature.isCreature() && !event.getTargetId().equals(source.getSourceId())) { - SubType subtype = (SubType) game.getState().getValue(sourcePermanent.getId() + "_type"); - return subtype != null && enteringCreature.hasSubtype(subtype, game); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + return subType != null && enteringCreature.hasSubtype(subType, game); } return false; } diff --git a/Mage.Sets/src/mage/cards/o/ObeliskOfUrd.java b/Mage.Sets/src/mage/cards/o/ObeliskOfUrd.java index 24bf4fe769..8c6e986363 100644 --- a/Mage.Sets/src/mage/cards/o/ObeliskOfUrd.java +++ b/Mage.Sets/src/mage/cards/o/ObeliskOfUrd.java @@ -27,6 +27,7 @@ */ package mage.cards.o; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; @@ -40,8 +41,6 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * * @author emerald000 @@ -49,7 +48,7 @@ import java.util.UUID; public class ObeliskOfUrd extends CardImpl { public ObeliskOfUrd(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{6}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{6}"); // Convoke this.addAbility(new ConvokeAbility()); @@ -93,14 +92,16 @@ class ObeliskOfUrdBoostEffect extends ContinuousEffectImpl { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type"); - if (subtype != null) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { - if (perm.hasSubtype(subtype, game)) { + if (perm.hasSubtype(subType, game)) { perm.addPower(2); perm.addToughness(2); } } + } else { + discard(); } } return true; diff --git a/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java b/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java index 6aed375d7f..c67c33c87b 100644 --- a/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java +++ b/Mage.Sets/src/mage/cards/p/PillarOfOrigins.java @@ -79,10 +79,7 @@ class PillarOfOriginsManaBuilder extends ConditionalManaBuilder { @Override public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) { - SubType value = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - if (value != null) { - creatureType = value; - } + creatureType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); if (controller != null && sourceObject != null) { diff --git a/Mage.Sets/src/mage/cards/r/RidersOfGavony.java b/Mage.Sets/src/mage/cards/r/RidersOfGavony.java index 263429b2f0..57e86a791c 100644 --- a/Mage.Sets/src/mage/cards/r/RidersOfGavony.java +++ b/Mage.Sets/src/mage/cards/r/RidersOfGavony.java @@ -27,6 +27,7 @@ */ package mage.cards.r; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -44,15 +45,13 @@ import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * @author noxx */ public class RidersOfGavony extends CardImpl { public RidersOfGavony(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.KNIGHT); @@ -108,10 +107,12 @@ class RidersOfGavonyGainAbilityControlledEffect extends ContinuousEffectImpl { if (protectionFilter == null) { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { - SubType subtype = (SubType) game.getState().getValue(permanent.getId() + "_type"); - if (subtype != null) { - protectionFilter = new FilterPermanent(subtype.getDescription() + 's'); - protectionFilter.add(new SubtypePredicate(subtype)); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(permanent.getId(), game); + if (subType != null) { + protectionFilter = new FilterPermanent(subType.getDescription() + 's'); + protectionFilter.add(new SubtypePredicate(subType)); + } else { + discard(); } } } diff --git a/Mage.Sets/src/mage/cards/r/RiptideReplicator.java b/Mage.Sets/src/mage/cards/r/RiptideReplicator.java index c328418205..d536c3a500 100644 --- a/Mage.Sets/src/mage/cards/r/RiptideReplicator.java +++ b/Mage.Sets/src/mage/cards/r/RiptideReplicator.java @@ -27,6 +27,7 @@ */ package mage.cards.r; +import java.util.UUID; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; @@ -50,8 +51,6 @@ import mage.game.Game; import mage.game.permanent.token.RiptideReplicatorToken; import mage.game.permanent.token.Token; -import java.util.UUID; - /** * * @author HanClinto @@ -106,9 +105,12 @@ class RiptideReplicatorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); - SubType type = (SubType) game.getState().getValue(source.getSourceId() + "_type"); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType == null) { + return false; + } int x = (new CountersSourceCount(CounterType.CHARGE)).calculate(game, source, this); - Token token = new RiptideReplicatorToken(color, type, x); + Token token = new RiptideReplicatorToken(color, subType, x); return token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); } } diff --git a/Mage.Sets/src/mage/cards/s/SteelyResolve.java b/Mage.Sets/src/mage/cards/s/SteelyResolve.java index a2896c579f..f1ea5b734d 100644 --- a/Mage.Sets/src/mage/cards/s/SteelyResolve.java +++ b/Mage.Sets/src/mage/cards/s/SteelyResolve.java @@ -27,6 +27,7 @@ */ package mage.cards.s; +import java.util.UUID; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.common.ChooseCreatureTypeEffect; @@ -39,8 +40,6 @@ import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.UUID; - /** * * @author markedagain @@ -48,7 +47,7 @@ import java.util.UUID; public class SteelyResolve extends CardImpl { public SteelyResolve(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); // As Steely Resolve enters the battlefield, choose a creature type. this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.AddAbility))); @@ -65,30 +64,31 @@ public class SteelyResolve extends CardImpl { return new SteelyResolve(this); } } + class FilterSteelyResolve extends FilterCreaturePermanent { - + public FilterSteelyResolve() { super("All creatures of the chosen type"); } - + public FilterSteelyResolve(final FilterSteelyResolve filter) { super(filter); } - + @Override public FilterSteelyResolve copy() { return new FilterSteelyResolve(this); } - + @Override public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { if (super.match(permanent, sourceId, playerId, game)) { - SubType subtype = (SubType) game.getState().getValue(sourceId + "_type"); - if (subtype != null && permanent.hasSubtype(subtype, game)) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(sourceId, game); + if (subType != null && permanent.hasSubtype(subType, game)) { return true; } } return false; } - -} \ No newline at end of file + +} diff --git a/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java b/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java index d2dc2ab2d2..5a75d76a25 100644 --- a/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java +++ b/Mage.Sets/src/mage/cards/u/UnclaimedTerritory.java @@ -83,9 +83,9 @@ class UnclaimedTerritoryManaBuilder extends ConditionalManaBuilder { @Override public ConditionalManaBuilder setMana(Mana mana, Ability source, Game game) { - SubType value = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - if (value != null) { - creatureType = value; + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { + creatureType = subType; } Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/v/VanquishersBanner.java b/Mage.Sets/src/mage/cards/v/VanquishersBanner.java index 58af23ab79..18d9a70697 100644 --- a/Mage.Sets/src/mage/cards/v/VanquishersBanner.java +++ b/Mage.Sets/src/mage/cards/v/VanquishersBanner.java @@ -42,14 +42,11 @@ import mage.constants.Outcome; import mage.constants.SubType; import mage.constants.TargetController; import mage.constants.Zone; -import mage.filter.FilterSpell; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; -import mage.game.permanent.Permanent; import mage.game.stack.Spell; /** @@ -110,17 +107,14 @@ class DrawCardIfCreatureTypeAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - Permanent vanquishersBanner = game.getPermanent(getSourceId()); - if (vanquishersBanner != null) { - SubType subtype = (SubType) game.getState().getValue(vanquishersBanner.getId() + "_type"); - if (subtype != null) { - FilterSpell filter = new FilterSpell(); - filter.add(new ControllerPredicate(TargetController.YOU)); - filter.add(new SubtypePredicate(subtype)); - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filter.match(spell, getSourceId(), getControllerId(), game)) { - return true; - } + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(getSourceId(), game); + if (subType != null) { + Spell spell = game.getStack().getSpell(event.getTargetId()); + if (spell != null + && spell.isCreature() + && spell.hasSubtype(subType, game) + && spell.getControllerId().equals(getControllerId())) { + return true; } } return false; diff --git a/Mage.Sets/src/mage/cards/v/VolrathsLaboratory.java b/Mage.Sets/src/mage/cards/v/VolrathsLaboratory.java index 8d689b089e..098118bce0 100644 --- a/Mage.Sets/src/mage/cards/v/VolrathsLaboratory.java +++ b/Mage.Sets/src/mage/cards/v/VolrathsLaboratory.java @@ -27,6 +27,7 @@ */ package mage.cards.v; +import java.util.UUID; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; @@ -47,8 +48,6 @@ import mage.game.Game; import mage.game.permanent.token.Token; import mage.game.permanent.token.VolrathsLaboratoryToken; -import java.util.UUID; - /** * * @author emerald000 @@ -100,8 +99,8 @@ class VolrathsLaboratoryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { ObjectColor color = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color"); - SubType type = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - Token token = new VolrathsLaboratoryToken(color, type); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + Token token = new VolrathsLaboratoryToken(color, subType); return token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId()); } } diff --git a/Mage.Sets/src/mage/cards/x/Xenograft.java b/Mage.Sets/src/mage/cards/x/Xenograft.java index 49ca70239b..a78b5caef3 100644 --- a/Mage.Sets/src/mage/cards/x/Xenograft.java +++ b/Mage.Sets/src/mage/cards/x/Xenograft.java @@ -27,6 +27,8 @@ */ package mage.cards.x; +import java.util.List; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; @@ -39,9 +41,6 @@ import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.List; -import java.util.UUID; - /** * * @author North @@ -80,12 +79,12 @@ class XenograftAddSubtypeEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { - SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - if (subtype != null) { + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { List permanents = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game); for (Permanent permanent : permanents) { - if (permanent != null && !permanent.hasSubtype(subtype, game)) { - permanent.getSubtype(game).add(subtype); + if (permanent != null && !permanent.hasSubtype(subType, game)) { + permanent.getSubtype(game).add(subType); } } return true; diff --git a/Mage/src/main/java/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java index 7ecbabb190..78cd183347 100644 --- a/Mage/src/main/java/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AllyEntersBattlefieldTriggeredAbility.java @@ -57,12 +57,9 @@ public class AllyEntersBattlefieldTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkTrigger(GameEvent event, Game game) { EntersTheBattlefieldEvent ebe = (EntersTheBattlefieldEvent) event; - if (ebe.getTarget().getControllerId().equals(this.controllerId) + return ebe.getTarget().getControllerId().equals(this.controllerId) && (event.getTargetId().equals(this.getSourceId()) - || (ebe.getTarget().hasSubtype(SubType.ALLY, game) && !event.getTargetId().equals(this.getSourceId())))) { - return true; - } - return false; + || (ebe.getTarget().hasSubtype(SubType.ALLY, game) && !event.getTargetId().equals(this.getSourceId()))); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/AttacksOrBlocksEnchantedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksOrBlocksEnchantedTriggeredAbility.java index b8f0ad7735..dcebe6ea30 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksOrBlocksEnchantedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksOrBlocksEnchantedTriggeredAbility.java @@ -32,10 +32,7 @@ public class AttacksOrBlocksEnchantedTriggeredAbility extends TriggeredAbilityIm @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent enchantment = game.getPermanent(this.getSourceId()); - if (enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo())) { - return true; - } - return false; + return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo()); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/BecomesExertSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/BecomesExertSourceTriggeredAbility.java index d3efb7dc1a..7fbca6bfd5 100644 --- a/Mage/src/main/java/mage/abilities/common/BecomesExertSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/BecomesExertSourceTriggeredAbility.java @@ -1,72 +1,69 @@ -/* - * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. - */ -package mage.abilities.common; - -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; - -/** - * - * @author LevelX2 - */ -public class BecomesExertSourceTriggeredAbility extends TriggeredAbilityImpl { - - public BecomesExertSourceTriggeredAbility(Effect effect) { - super(Zone.BATTLEFIELD, effect, false); - } - - public BecomesExertSourceTriggeredAbility(final BecomesExertSourceTriggeredAbility ability) { - super(ability); - } - - @Override - public BecomesExertSourceTriggeredAbility copy() { - return new BecomesExertSourceTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.BECOMES_EXERTED; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(this.getSourceId())) { - return true; - } - return false; - } - - @Override - public String getRule() { - return "When {this} becomes exerted, " + super.getRule(); - } -} +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author LevelX2 + */ +public class BecomesExertSourceTriggeredAbility extends TriggeredAbilityImpl { + + public BecomesExertSourceTriggeredAbility(Effect effect) { + super(Zone.BATTLEFIELD, effect, false); + } + + public BecomesExertSourceTriggeredAbility(final BecomesExertSourceTriggeredAbility ability) { + super(ability); + } + + @Override + public BecomesExertSourceTriggeredAbility copy() { + return new BecomesExertSourceTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.BECOMES_EXERTED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return event.getSourceId().equals(this.getSourceId()); + } + + @Override + public String getRule() { + return "When {this} becomes exerted, " + super.getRule(); + } +} diff --git a/Mage/src/main/java/mage/abilities/common/CycleAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/CycleAllTriggeredAbility.java index f9bc057064..83e95b2f56 100644 --- a/Mage/src/main/java/mage/abilities/common/CycleAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/CycleAllTriggeredAbility.java @@ -61,11 +61,8 @@ public class CycleAllTriggeredAbility extends TriggeredAbilityImpl { return false; } StackObject item = game.getState().getStack().getFirst(); - if (item instanceof StackAbility - && item.getStackAbility() instanceof CyclingAbility) { - return true; - } - return false; + return item instanceof StackAbility + && item.getStackAbility() instanceof CyclingAbility; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksSourceTriggeredAbility.java index 44733c7ca9..810fd5f91b 100644 --- a/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/EntersBattlefieldOrAttacksSourceTriggeredAbility.java @@ -1,80 +1,77 @@ -/* - * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of BetaSteward_at_googlemail.com. - */ -package mage.abilities.common; - -import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; -import mage.constants.Zone; -import mage.game.Game; -import mage.game.events.GameEvent; - -/** - * - * @author Styxo - */ -public class EntersBattlefieldOrAttacksSourceTriggeredAbility extends TriggeredAbilityImpl { - - public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect) { - this(effect, false); - } - - public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect, boolean optional) { - super(Zone.BATTLEFIELD, effect, optional); - } - - public EntersBattlefieldOrAttacksSourceTriggeredAbility(final EntersBattlefieldOrAttacksSourceTriggeredAbility ability) { - super(ability); - } - - @Override - public EntersBattlefieldOrAttacksSourceTriggeredAbility copy() { - return new EntersBattlefieldOrAttacksSourceTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { - return true; - } - if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId())) { - return true; - } - return false; - } - - @Override - public String getRule() { - return "Whenever {this} enters the battlefield or attacks, " + super.getRule(); - } - -} +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.common; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.Effect; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; + +/** + * + * @author Styxo + */ +public class EntersBattlefieldOrAttacksSourceTriggeredAbility extends TriggeredAbilityImpl { + + public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect) { + this(effect, false); + } + + public EntersBattlefieldOrAttacksSourceTriggeredAbility(Effect effect, boolean optional) { + super(Zone.BATTLEFIELD, effect, optional); + } + + public EntersBattlefieldOrAttacksSourceTriggeredAbility(final EntersBattlefieldOrAttacksSourceTriggeredAbility ability) { + super(ability); + } + + @Override + public EntersBattlefieldOrAttacksSourceTriggeredAbility copy() { + return new EntersBattlefieldOrAttacksSourceTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ATTACKER_DECLARED || event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED && event.getSourceId().equals(this.getSourceId())) { + return true; + } + return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()); + } + + @Override + public String getRule() { + return "Whenever {this} enters the battlefield or attacks, " + super.getRule(); + } + +} diff --git a/Mage/src/main/java/mage/abilities/common/OnEventTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/OnEventTriggeredAbility.java index fbe6c32a91..46de144429 100644 --- a/Mage/src/main/java/mage/abilities/common/OnEventTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/OnEventTriggeredAbility.java @@ -77,10 +77,7 @@ public class OnEventTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (allPlayers || event.getPlayerId().equals(this.controllerId)) { - return true; - } - return false; + return allPlayers || event.getPlayerId().equals(this.controllerId); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/SimpleTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SimpleTriggeredAbility.java index aaf991993f..5dbea0c7d4 100644 --- a/Mage/src/main/java/mage/abilities/common/SimpleTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/SimpleTriggeredAbility.java @@ -74,10 +74,7 @@ public class SimpleTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (!onlyController || event.getPlayerId().equals(this.controllerId)) { - return true; - } - return false; + return !onlyController || event.getPlayerId().equals(this.controllerId); } @Override diff --git a/Mage/src/main/java/mage/abilities/common/delayed/AtTheBeginOfNextEndStepDelayedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/delayed/AtTheBeginOfNextEndStepDelayedTriggeredAbility.java index 7357c3bd41..72dde52c7d 100644 --- a/Mage/src/main/java/mage/abilities/common/delayed/AtTheBeginOfNextEndStepDelayedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/delayed/AtTheBeginOfNextEndStepDelayedTriggeredAbility.java @@ -101,10 +101,7 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg } } if (correctEndPhase) { - if (condition != null && !condition.apply(game, this)) { - return false; - } - return true; + return !(condition != null && !condition.apply(game, this)); } return false; } diff --git a/Mage/src/main/java/mage/abilities/costs/common/ExileSourceFromGraveCost.java b/Mage/src/main/java/mage/abilities/costs/common/ExileSourceFromGraveCost.java index 1a136f0f4b..c22e1094f5 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/ExileSourceFromGraveCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/ExileSourceFromGraveCost.java @@ -70,10 +70,7 @@ public class ExileSourceFromGraveCost extends CostImpl { @Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Card card = game.getCard(sourceId); - if (card != null && game.getState().getZone(sourceId) == Zone.GRAVEYARD) { - return true; - } - return false; + return card != null && game.getState().getZone(sourceId) == Zone.GRAVEYARD; } @Override diff --git a/Mage/src/main/java/mage/abilities/costs/common/RemoveCountersSourceCost.java b/Mage/src/main/java/mage/abilities/costs/common/RemoveCountersSourceCost.java index 44677e4c90..5ad0b3e239 100644 --- a/Mage/src/main/java/mage/abilities/costs/common/RemoveCountersSourceCost.java +++ b/Mage/src/main/java/mage/abilities/costs/common/RemoveCountersSourceCost.java @@ -64,10 +64,7 @@ public class RemoveCountersSourceCost extends CostImpl { @Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Permanent permanent = game.getPermanent(sourceId); - if (permanent != null && permanent.getCounters(game).getCount(name) >= amount) { - return true; - } - return false; + return permanent != null && permanent.getCounters(game).getCount(name) >= amount; } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java index 5058a298c6..48f2973a40 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AffinityEffect.java @@ -44,10 +44,7 @@ public class AffinityEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - if (abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId())) { - return true; - } - return false; + return abilityToModify instanceof SpellAbility && abilityToModify.getSourceId().equals(source.getSourceId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/AttacksIfAbleTargetPlayerSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AttacksIfAbleTargetPlayerSourceEffect.java index 1b49a2efa7..aea698d141 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AttacksIfAbleTargetPlayerSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AttacksIfAbleTargetPlayerSourceEffect.java @@ -26,10 +26,7 @@ public class AttacksIfAbleTargetPlayerSourceEffect extends RequirementEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getId().equals(source.getSourceId())) { - return true; - } - return false; + return permanent.getId().equals(source.getSourceId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java index 7af38326fb..28bcb457c5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ChooseCreatureTypeEffect.java @@ -27,6 +27,7 @@ */ package mage.abilities.effects.common; +import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; @@ -86,4 +87,18 @@ public class ChooseCreatureTypeEffect extends OneShotEffect { return new ChooseCreatureTypeEffect(this); } + /** + * + * @param objectId sourceId the effect was exeuted under + * @param game + * @return + */ + public static SubType getChoosenCreatureType(UUID objectId, Game game) { + SubType creatureType = null; + Object savedCreatureType = game.getState().getValue(objectId + "_type"); + if (savedCreatureType != null) { + creatureType = SubType.byDescription(savedCreatureType.toString()); + } + return creatureType; + } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DetainTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DetainTargetEffect.java index 94b03839e8..2b19b96892 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DetainTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DetainTargetEffect.java @@ -159,10 +159,7 @@ class DetainRestrictionEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (this.targetPointer.getTargets(game, source).contains(permanent.getId())) { - return true; - } - return false; + return this.targetPointer.getTargets(game, source).contains(permanent.getId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java index a1b1fb9d3b..4d0bfedc50 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PreventDamageToTargetMultiAmountEffect.java @@ -123,10 +123,7 @@ public class PreventDamageToTargetMultiAmountEffect extends PreventionEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (!used && super.applies(event, source, game) && targetAmountMap.containsKey(event.getTargetId())) { - return true; - } - return false; + return !used && super.applies(event, source, game) && targetAmountMap.containsKey(event.getTargetId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/RegenerateTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/RegenerateTargetEffect.java index 436fd1d802..c5a7b20e6b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/RegenerateTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/RegenerateTargetEffect.java @@ -82,10 +82,8 @@ public class RegenerateTargetEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { //20110204 - 701.11c - event.getAmount() is used to signal if regeneration is allowed - if (event.getAmount() == 0 && event.getTargetId().equals(targetPointer.getFirst(game, source)) && !this.used) { - return true; - } - return false; + + return event.getAmount() == 0 && event.getTargetId().equals(targetPointer.getFirst(game, source)) && !this.used; } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java index ec593c1f16..dbd3766b02 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackAloneAttachedEffect.java @@ -40,10 +40,7 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attachment = game.getPermanent(source.getSourceId()); - if (attachment != null && attachment.getAttachedTo() != null - && permanent.getId().equals(attachment.getAttachedTo())) { - return true; - } - return false; + return attachment != null && attachment.getAttachedTo() != null + && permanent.getId().equals(attachment.getAttachedTo()); } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java index ce15c24140..190b10f374 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackBlockAttachedEffect.java @@ -51,11 +51,8 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { Permanent attachment = game.getPermanent(source.getSourceId()); - if (attachment != null && attachment.getAttachedTo() != null - && permanent.getId().equals(attachment.getAttachedTo())) { - return true; - } - return false; + return attachment != null && attachment.getAttachedTo() != null + && permanent.getId().equals(attachment.getAttachedTo()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackIfDefenderControlsPermanent.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackIfDefenderControlsPermanent.java index 844ad8f484..5db6ce53f5 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackIfDefenderControlsPermanent.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackIfDefenderControlsPermanent.java @@ -76,10 +76,7 @@ public class CantAttackIfDefenderControlsPermanent extends RestrictionEffect { } else { defendingPlayerId = defenderId; } - if (defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) > 0) { - return false; - } - return true; + return !(defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) > 0); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackSourceEffect.java index c84508d18a..097c6e83ba 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantAttackSourceEffect.java @@ -51,10 +51,7 @@ public class CantAttackSourceEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getId().equals(source.getSourceId())) { - return true; - } - return false; + return permanent.getId().equals(source.getSourceId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java index 2e5c8a279a..551035b595 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByCreaturesAttachedEffect.java @@ -63,10 +63,7 @@ public class CantBeBlockedByCreaturesAttachedEffect extends RestrictionEffect { @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - if (filter.match(blocker, source.getSourceId(), source.getControllerId(), game)) { - return false; - } - return true; + return !filter.match(blocker, source.getSourceId(), source.getControllerId(), game); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java index 20317444d8..0f7659f55c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBeBlockedByTargetSourceEffect.java @@ -58,18 +58,12 @@ public class CantBeBlockedByTargetSourceEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (source.getSourceId().equals(permanent.getId())) { - return true; - } - return false; + return source.getSourceId().equals(permanent.getId()); } @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - if (this.getTargetPointer().getTargets(game, source).contains(blocker.getId())) { - return false; - } - return true; + return !this.getTargetPointer().getTargets(game, source).contains(blocker.getId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java index ca99b4bcd8..65cd76db50 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/CantBlockSourceEffect.java @@ -54,10 +54,7 @@ public class CantBlockSourceEffect extends RestrictionEffect { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getId().equals(source.getSourceId())) { - return true; - } - return false; + return permanent.getId().equals(source.getSourceId()); } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/ActivateAbilitiesAnyTimeYouCouldCastInstantEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/ActivateAbilitiesAnyTimeYouCouldCastInstantEffect.java index 2123247071..3d4470dd57 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/ActivateAbilitiesAnyTimeYouCouldCastInstantEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/ActivateAbilitiesAnyTimeYouCouldCastInstantEffect.java @@ -1,59 +1,56 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package mage.abilities.effects.common.continuous; - -import java.util.UUID; -import mage.abilities.Ability; -import mage.abilities.effects.AsThoughEffectImpl; -import mage.constants.AsThoughEffectType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.game.Game; - -/** - * - * @author Styxo - */ -public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl { - - private Class activatedAbility; - - public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) { - super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit); - this.activatedAbility = activatedAbility; - staticText = "You may activate " + activatedAbilityName + " any time you could cast an instant"; - } - - public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(final ActivateAbilitiesAnyTimeYouCouldCastInstantEffect effect) { - super(effect); - this.activatedAbility = effect.activatedAbility; - } - - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect copy() { - return new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(this); - } - - @Override - public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) { - if (affectedAbility.getControllerId().equals(source.getControllerId()) - && activatedAbility.isInstance(affectedAbility)) { - return true; - } - return false; - } - - @Override - public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { - return false; // Not used - } - -} +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package mage.abilities.effects.common.continuous; + +import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.AsThoughEffectImpl; +import mage.constants.AsThoughEffectType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; + +/** + * + * @author Styxo + */ +public class ActivateAbilitiesAnyTimeYouCouldCastInstantEffect extends AsThoughEffectImpl { + + private Class activatedAbility; + + public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(Class activatedAbility, String activatedAbilityName) { + super(AsThoughEffectType.ACTIVATE_AS_INSTANT, Duration.EndOfGame, Outcome.Benefit); + this.activatedAbility = activatedAbility; + staticText = "You may activate " + activatedAbilityName + " any time you could cast an instant"; + } + + public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(final ActivateAbilitiesAnyTimeYouCouldCastInstantEffect effect) { + super(effect); + this.activatedAbility = effect.activatedAbility; + } + + @Override + public boolean apply(Game game, Ability source) { + return true; + } + + @Override + public ActivateAbilitiesAnyTimeYouCouldCastInstantEffect copy() { + return new ActivateAbilitiesAnyTimeYouCouldCastInstantEffect(this); + } + + @Override + public boolean applies(UUID objectId, Ability affectedAbility, Ability source, Game game) { + return affectedAbility.getControllerId().equals(source.getControllerId()) + && activatedAbility.isInstance(affectedAbility); + } + + @Override + public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { + return false; // Not used + } + +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java index 1a9490f971..7ee579c1fb 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/BoostAllOfChosenSubtypeEffect.java @@ -6,6 +6,7 @@ package mage.abilities.effects.common.continuous; import mage.abilities.Ability; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.constants.Duration; import mage.constants.SubType; import mage.filter.common.FilterCreaturePermanent; @@ -48,9 +49,9 @@ public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect { @Override protected void setRuntimeData(Ability source, Game game) { - SubType s = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - if (s != null) { - subtype = s; + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { + subtype = subType; } else { discard(); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java index 3dbf157b81..3c66e69e28 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/CantCastMoreThanOneSpellEffect.java @@ -96,10 +96,7 @@ public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifyingEffec } } CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); - if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0) { - return true; - } - return false; + return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0; } @Override diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java index e6e0f4073b..71185730ca 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java @@ -6,6 +6,7 @@ package mage.abilities.effects.common.cost; import mage.abilities.Ability; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.cards.Card; import mage.constants.SubType; import mage.filter.FilterCard; @@ -32,9 +33,9 @@ public class SpellsCostReductionAllOfChosenSubtypeEffect extends SpellsCostReduc @Override protected boolean selectedByRuntimeData(Card card, Ability source, Game game) { - SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type"); - if (subtype != null) { - return card.hasSubtype(subtype, game); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(source.getSourceId(), game); + if (subType != null) { + return card.hasSubtype(subType, game); } return false; } diff --git a/Mage/src/main/java/mage/abilities/keyword/FearAbility.java b/Mage/src/main/java/mage/abilities/keyword/FearAbility.java index 939b05cfab..7a85ad8d2b 100644 --- a/Mage/src/main/java/mage/abilities/keyword/FearAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/FearAbility.java @@ -81,18 +81,12 @@ class FearEffect extends RestrictionEffect implements MageSingleton { @Override public boolean applies(Permanent permanent, Ability source, Game game) { - if (permanent.getAbilities().containsKey(FearAbility.getInstance().getId())) { - return true; - } - return false; + return permanent.getAbilities().containsKey(FearAbility.getInstance().getId()); } @Override public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - if (blocker.isArtifact() || blocker.getColor(game).isBlack()) { - return true; - } - return false; + return blocker.isArtifact() || blocker.getColor(game).isBlack(); } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java b/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java index cf70a57336..80bab29d56 100644 --- a/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/RippleAbility.java @@ -44,10 +44,7 @@ public class RippleAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && spell.getSourceId().equals(this.getSourceId())) { - return true; - } - return false; + return spell != null && spell.getSourceId().equals(this.getSourceId()); } diff --git a/Mage/src/main/java/mage/abilities/keyword/TotemArmorAbility.java b/Mage/src/main/java/mage/abilities/keyword/TotemArmorAbility.java index 9a389cef5e..604f164504 100644 --- a/Mage/src/main/java/mage/abilities/keyword/TotemArmorAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/TotemArmorAbility.java @@ -99,10 +99,7 @@ class TotemArmorEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (sourcePermanent != null && event.getTargetId().equals(sourcePermanent.getAttachedTo())) { - return true; - } - return false; + return sourcePermanent != null && event.getTargetId().equals(sourcePermanent.getAttachedTo()); } @Override diff --git a/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java b/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java index f5edbfd5d4..ea6d719907 100644 --- a/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/mageobject/ChosenSubtypePredicate.java @@ -27,13 +27,13 @@ */ package mage.filter.predicate.mageobject; +import java.util.UUID; import mage.MageObject; +import mage.abilities.effects.common.ChooseCreatureTypeEffect; import mage.constants.SubType; import mage.filter.predicate.Predicate; import mage.game.Game; -import java.util.UUID; - /** * * @author LoneFox @@ -48,8 +48,8 @@ public class ChosenSubtypePredicate implements Predicate { @Override public boolean apply(MageObject input, Game game) { - SubType subtype = (SubType) game.getState().getValue(cardID + "_type"); - return input.hasSubtype(subtype, game); + SubType subType = ChooseCreatureTypeEffect.getChoosenCreatureType(cardID, game); + return input.hasSubtype(subType, game); } @Override diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 37111ccd77..6df5305398 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -976,10 +976,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return true; } } - if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false)) { - return true; - } - return false; + return game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false); } protected boolean canDamage(MageObject source, Game game) { diff --git a/Mage/src/main/java/mage/game/permanent/token/TetraviteToken.java b/Mage/src/main/java/mage/game/permanent/token/TetraviteToken.java index 2345916ce2..5903c62b5f 100644 --- a/Mage/src/main/java/mage/game/permanent/token/TetraviteToken.java +++ b/Mage/src/main/java/mage/game/permanent/token/TetraviteToken.java @@ -71,11 +71,8 @@ class CantBeEnchantedAbility extends StaticAbility { } public boolean canTarget(MageObject source, Game game) { - if (source.isEnchantment() - && source.hasSubtype(SubType.AURA, game)) { - return false; - } - return true; + return !(source.isEnchantment() + && source.hasSubtype(SubType.AURA, game)); } }