mirror of
https://github.com/magefree/mage.git
synced 2025-12-19 18:20:13 -08:00
"D"on't stop refactoring
* Refactor "D" continuous effects
This commit is contained in:
parent
e64a10bf10
commit
64401be172
25 changed files with 495 additions and 317 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -17,6 +18,8 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -68,15 +71,9 @@ class DanLewisEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
if (layer == Layer.TypeChangingEffects_4) {
|
||||
affectedObjectList.clear();
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
}
|
||||
}
|
||||
for (MageObjectReference mor : affectedObjectList) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.addSubType(game, SubType.EQUIPMENT);
|
||||
|
|
@ -88,11 +85,34 @@ class DanLewisEffect extends ContinuousEffectImpl {
|
|||
permanent.addAbility(new EquipAbility(1, false), source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
if (layer == Layer.TypeChangingEffects_4) {
|
||||
affectedObjectList.clear();
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)) {
|
||||
affectedObjectList.add(new MageObjectReference(permanent, game));
|
||||
affectedObjects.add(permanent);
|
||||
}
|
||||
} else {
|
||||
for (MageObjectReference mor : affectedObjectList) {
|
||||
Permanent permanent = mor.getPermanent(game);
|
||||
if (permanent != null) {
|
||||
affectedObjects.add(permanent);
|
||||
}
|
||||
}
|
||||
}
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
List<MageItem> affectedObjects = new ArrayList<>();
|
||||
if (queryAffectedObjects(layer, source, game, affectedObjects)) {
|
||||
applyToObjects(layer, sublayer, source, game, affectedObjects);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -21,6 +22,7 @@ import mage.players.Player;
|
|||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -100,19 +102,31 @@ class DarkImpostorContinuousEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
|
||||
if (permanent == null || exileZone == null || exileZone.isEmpty()) {
|
||||
return false;
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source, permanent.getZoneChangeCounter(game)));
|
||||
if (exileZone == null || exileZone.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (Card card : exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game)) {
|
||||
for (Ability ability : card.getAbilities(game)) {
|
||||
if (ability.isActivatedAbility()) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game, true);
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -13,6 +13,9 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
|
|
@ -48,11 +51,17 @@ class DarkestHourEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game)) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
permanent.getColor(game).setColor(ObjectColor.BLACK);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
affectedObjects.addAll(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source, game));
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -19,6 +20,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.game.stack.Spell;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -112,7 +114,7 @@ class DarksteelMonolithAlternativeCost extends AlternativeCostSourceAbility {
|
|||
class DarksteelMonolithAddAltCostEffect extends ContinuousEffectImpl {
|
||||
|
||||
DarksteelMonolithAddAltCostEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
super(Duration.WhileOnBattlefield, Layer.RulesEffects, SubLayer.NA, Outcome.Benefit);
|
||||
staticText = "Once each turn, you may pay {0} rather than pay the mana cost for a colorless spell you cast from your hand.";
|
||||
}
|
||||
|
||||
|
|
@ -126,11 +128,10 @@ class DarksteelMonolithAddAltCostEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent sourcePermanent = (Permanent) object;
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
Boolean wasItUsed = (Boolean) game.getState().getValue(
|
||||
sourcePermanent.getId().toString()
|
||||
+ sourcePermanent.getZoneChangeCounter(game)
|
||||
|
|
@ -141,20 +142,17 @@ class DarksteelMonolithAddAltCostEffect extends ContinuousEffectImpl {
|
|||
alternateCostAbility.setSourceId(source.getSourceId());
|
||||
controller.getAlternativeSourceCosts().add(alternateCostAbility);
|
||||
}
|
||||
// Return true even if we didn't add the alt cost. We still applied the effect
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (controller == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.RulesEffects;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,27 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.abilities.keyword.DoubleStrikeAbility;
|
||||
import mage.abilities.keyword.FearAbility;
|
||||
import mage.abilities.keyword.FirstStrikeAbility;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.abilities.keyword.HasteAbility;
|
||||
import mage.abilities.keyword.LandwalkAbility;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.abilities.keyword.*;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.SubType;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.AbilityWord;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.DependencyType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
|
|
@ -71,6 +56,17 @@ public final class DeathMaskDuplicant extends CardImpl {
|
|||
|
||||
static class DeathMaskDuplicantEffect extends ContinuousEffectImpl {
|
||||
|
||||
private static final Set<Class<? extends Ability>> KEYWORD_ABILITIES = new HashSet<>(Arrays.asList(
|
||||
FlyingAbility.class,
|
||||
FearAbility.class,
|
||||
FirstStrikeAbility.class,
|
||||
DoubleStrikeAbility.class,
|
||||
HasteAbility.class,
|
||||
LandwalkAbility.class,
|
||||
ProtectionAbility.class,
|
||||
TrampleAbility.class
|
||||
));
|
||||
|
||||
public DeathMaskDuplicantEffect() {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.addDependedToType(DependencyType.AddingAbility);
|
||||
|
|
@ -82,45 +78,48 @@ public final class DeathMaskDuplicant extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Set<Ability> exileAbilities = new HashSet<>();
|
||||
|
||||
if (sourceObject == null) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
getAbilitiesInExile(game, source, permanent, exileAbilities);
|
||||
for (Ability ability : exileAbilities) {
|
||||
if (isValidKeywordAbility(ability.getClass())) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
|
||||
if (sourcePermanent == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)));
|
||||
if (exileZone != null && !exileZone.isEmpty()) {
|
||||
for (UUID cardId : exileZone) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card != null && card.isCreature(game)) {
|
||||
for (Ability ability : card.getAbilities(game)) {
|
||||
if (ability instanceof MageSingleton) {
|
||||
if (ability instanceof FlyingAbility
|
||||
|| ability instanceof FearAbility
|
||||
|| ability instanceof FirstStrikeAbility
|
||||
|| ability instanceof DoubleStrikeAbility
|
||||
|| ability instanceof HasteAbility
|
||||
|| ability instanceof TrampleAbility) {
|
||||
sourceObject.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
} else if (ability instanceof ProtectionAbility
|
||||
|| ability instanceof LandwalkAbility) {
|
||||
sourceObject.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
affectedObjects.add(sourcePermanent);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void getAbilitiesInExile(Game game, Ability source, Permanent sourcePermanent, Set<Ability> exileAbilities) {
|
||||
ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), sourcePermanent.getZoneChangeCounter(game)));
|
||||
if (exileZone == null || exileZone.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (Card card : exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game)) {
|
||||
exileAbilities.addAll(card.getAbilities(game));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidKeywordAbility(Class<? extends Ability> abilityClass) {
|
||||
return KEYWORD_ABILITIES.stream()
|
||||
.anyMatch(keywordClass ->
|
||||
keywordClass.isAssignableFrom(abilityClass)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeathMaskDuplicantEffect copy() {
|
||||
return new DeathMaskDuplicantEffect(this);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
|
@ -34,6 +35,7 @@ import mage.players.Player;
|
|||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -191,19 +193,26 @@ class DemonOfFatesDesignCastEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Player controller = (Player) object;
|
||||
controller.getAlternativeSourceCosts().add(alternativeCastingCostAbility);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
DemonOfFatesDesignWatcher watcher = game.getState().getWatcher(DemonOfFatesDesignWatcher.class);
|
||||
if (controller == null || watcher == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
alternativeCastingCostAbility.setSourceId(source.getSourceId());
|
||||
if (!watcher.canAbilityBeUsed(game, source, alternativeCastingCostAbility.getMor(game))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
controller.getAlternativeSourceCosts().add(alternativeCastingCostAbility);
|
||||
affectedObjects.add(controller);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,25 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.keyword.EscapeAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.*;
|
||||
import mage.abilities.keyword.VigilanceAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.ManaValuePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Cguy7777
|
||||
*/
|
||||
|
|
@ -77,15 +79,23 @@ class DesdemonaFreedomsEdgeEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card == null || card.getManaCost().getText().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Card card = (Card) object;
|
||||
Ability ability = new EscapeAbility(card, card.getManaCost().getText(), 2);
|
||||
ability.setSourceId(card.getId());
|
||||
ability.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card == null || card.getManaCost().getText().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
affectedObjects.add(card);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -24,6 +25,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -86,13 +88,23 @@ class DireBlunderbussGainAbilityEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
Ability ability = makeAbility(game, source);
|
||||
ability.getEffects().setValue("attachedPermanent", game.getPermanent(source.getSourceId()));
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent permanent = null;
|
||||
if (getAffectedObjectsSet()) {
|
||||
permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent == null) {
|
||||
discard();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Permanent equipment = game.getPermanent(source.getSourceId());
|
||||
|
|
@ -101,11 +113,9 @@ class DireBlunderbussGainAbilityEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
}
|
||||
if (permanent == null) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
Ability ability = makeAbility(game, source);
|
||||
ability.getEffects().setValue("attachedPermanent", game.getPermanent(source.getSourceId()));
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.LoyaltyAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.GetEmblemEffect;
|
||||
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
|
||||
import mage.abilities.effects.mana.ManaEffect;
|
||||
import mage.abilities.effects.mana.BasicManaEffect;
|
||||
import mage.abilities.effects.mana.ManaEffect;
|
||||
import mage.abilities.keyword.RiotAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
|
|
@ -18,11 +21,11 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.command.emblems.DomriChaosBringerEmblem;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -167,11 +170,19 @@ class DomriChaosBringAddRiotToSpellEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (cardId != null) {
|
||||
game.getState().addOtherAbility(game.getCard(cardId), riotAbility);
|
||||
return true;
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
game.getState().addOtherAbility((Card) object, riotAbility);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
affectedObjects.add(card);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
|
|
@ -18,6 +19,7 @@ import mage.constants.*;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -59,10 +61,11 @@ public final class DragonsoulKnight extends CardImpl {
|
|||
public DragonsoulKnight copy() {
|
||||
return new DragonsoulKnight(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static class DragonsoulKnightEffect extends ContinuousEffectImpl {
|
||||
class DragonsoulKnightEffect extends ContinuousEffectImpl {
|
||||
|
||||
private DragonsoulKnightEffect() {
|
||||
public DragonsoulKnightEffect() {
|
||||
super(Duration.EndOfTurn, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.BecomeCreature);
|
||||
staticText = "Until end of turn, {this} becomes a Dragon";
|
||||
}
|
||||
|
|
@ -77,14 +80,21 @@ public final class DragonsoulKnight extends CardImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
permanent.removeAllCreatureTypes(game);
|
||||
permanent.addSubType(game, SubType.DRAGON);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.removeAllCreatureTypes(game);
|
||||
permanent.addSubType(game, SubType.DRAGON);
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -21,6 +22,7 @@ import mage.game.events.DamageEvent;
|
|||
import mage.game.events.GameEvent;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -115,13 +117,21 @@ class DralnuLichLordFlashbackEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Card card = (Card) object;
|
||||
FlashbackAbility ability = new FlashbackAbility(card, card.getManaCost());
|
||||
ability.setSourceId(card.getId());
|
||||
ability.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Card card = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (card != null) {
|
||||
affectedObjects.add(card);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
package mage.cards.d;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -13,6 +14,8 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -48,8 +51,9 @@ class DralnusCrusadeEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source, game)) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.addSubType(game, SubType.ZOMBIE);
|
||||
|
|
@ -59,8 +63,23 @@ class DralnusCrusadeEffect extends ContinuousEffectImpl {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
affectedObjects.addAll(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE_GOBLINS, source.getControllerId(), source, game));
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
List<MageItem> affectedObjects = new ArrayList<>();
|
||||
if (queryAffectedObjects(layer, source, game, affectedObjects)) {
|
||||
applyToObjects(layer, sublayer, source, game, affectedObjects);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private DralnusCrusadeEffect(final DralnusCrusadeEffect effect) {
|
||||
super(effect);
|
||||
|
|
@ -71,11 +90,6 @@ class DralnusCrusadeEffect extends ContinuousEffectImpl {
|
|||
return new DralnusCrusadeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.TypeChangingEffects_4 || layer == Layer.ColorChangingEffects_5;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
|
|
@ -19,6 +20,7 @@ import mage.players.ManaPoolItem;
|
|||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -105,12 +107,31 @@ class DranaAndLinvalaGainAbilitiesEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
List<Ability> abilities = getOpponentActivatedAbilities(game, source);
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
for (Ability ability : abilities) {
|
||||
Ability addedAbility = permanent.addAbility(ability, source.getSourceId(), game, true);
|
||||
if (addedAbility != null) {
|
||||
addedAbility.getEffects().setValue("dranaLinvalaFlag", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent perm = source.getSourcePermanentIfItStillExists(game);
|
||||
if (perm == null) {
|
||||
return false;
|
||||
}
|
||||
for (Ability ability : game
|
||||
affectedObjects.add(perm);
|
||||
return true;
|
||||
}
|
||||
|
||||
private List<Ability> getOpponentActivatedAbilities(Game game, Ability source) {
|
||||
return game
|
||||
.getBattlefield()
|
||||
.getActivePermanents(
|
||||
StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE,
|
||||
|
|
@ -121,13 +142,7 @@ class DranaAndLinvalaGainAbilitiesEffect extends ContinuousEffectImpl {
|
|||
.flatMap(Collection::stream)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(Ability::isActivatedAbility)
|
||||
.collect(Collectors.toList())) {
|
||||
Ability addedAbility = perm.addAbility(ability, source.getSourceId(), game, true);
|
||||
if (addedAbility != null) {
|
||||
addedAbility.getEffects().setValue("dranaLinvalaFlag", true);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
|
|
@ -24,6 +25,7 @@ import mage.players.Player;
|
|||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -120,19 +122,21 @@ class DranaTheLastBloodchiefSubtypeEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent creature = mor.getPermanent(game);
|
||||
if (creature != null) {
|
||||
creature.addSubType(game, SubType.VAMPIRE);
|
||||
return true;
|
||||
} else {
|
||||
this.used = true;
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
permanent.addSubType(game, SubType.VAMPIRE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent creature = mor.getPermanent(game);
|
||||
if (creature != null) {
|
||||
affectedObjects.add(creature);
|
||||
return true;
|
||||
}
|
||||
this.used = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.ForetellSourceControllerTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -9,13 +9,7 @@ import mage.abilities.effects.ContinuousEffectImpl;
|
|||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.abilities.keyword.ForetellAbility;
|
||||
import mage.cards.*;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.filter.common.FilterNonlandCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.AbilityPredicate;
|
||||
|
|
@ -23,6 +17,9 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
|
|
@ -78,12 +75,9 @@ class DreamDevourerAddAbilityEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
for (Card card : controller.getHand().getCards(filter, game)) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Card card = (Card) object;
|
||||
ForetellAbility foretellAbility = null;
|
||||
if (card instanceof SplitCard) {
|
||||
String leftHalfCost = CardUtil.reduceCost(((SplitCard) card).getLeftHalfCard().getManaCost(), 2).getText();
|
||||
|
|
@ -117,6 +111,15 @@ class DreamDevourerAddAbilityEffect extends ContinuousEffectImpl {
|
|||
game.getState().addOtherAbility(card, foretellAbility);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
affectedObjects.addAll(controller.getHand().getCards(filter, game));
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.common.SourceIsSpellCondition;
|
||||
|
|
@ -17,6 +17,9 @@ import mage.filter.predicate.mageobject.SharesColorWithSourcePredicate;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
|
|
@ -52,7 +55,7 @@ class DreamHallsEffect extends ContinuousEffectImpl {
|
|||
private final AlternativeCostSourceAbility alternativeCastingCostAbility = new AlternativeCostSourceAbility(new DiscardCardCost(filter), SourceIsSpellCondition.instance);
|
||||
|
||||
public DreamHallsEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||
super(Duration.WhileOnBattlefield, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment);
|
||||
staticText = "Rather than pay the mana cost for a spell, its controller may discard a card that shares a color with that spell";
|
||||
}
|
||||
|
||||
|
|
@ -72,28 +75,25 @@ class DreamHallsEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Player player = (Player) object;
|
||||
player.getAlternativeSourceCosts().add(alternativeCastingCostAbility);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
affectedObjects.add(player);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.RulesEffects;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
|
|
@ -13,6 +14,7 @@ import mage.constants.*;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -55,7 +57,18 @@ class DregscapeSliverEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Card card = (Card) object;
|
||||
UnearthAbility ability = new UnearthAbility(new ManaCostsImpl<>("{2}"));
|
||||
ability.setSourceId(card.getId());
|
||||
ability.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
|
|
@ -65,12 +78,9 @@ class DregscapeSliverEffect extends ContinuousEffectImpl {
|
|||
if (card == null || !card.isCreature(game) || !card.hasSubtype(SubType.SLIVER, game)) {
|
||||
continue;
|
||||
}
|
||||
UnearthAbility ability = new UnearthAbility(new ManaCostsImpl<>("{2}"));
|
||||
ability.setSourceId(cardId);
|
||||
ability.setControllerId(card.getOwnerId());
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
affectedObjects.add(card);
|
||||
}
|
||||
return true;
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -19,7 +21,6 @@ import mage.filter.FilterPermanent;
|
|||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterOwnedCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -88,50 +89,52 @@ class DuneChanterContinuousEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
((MageObject) object).addSubType(game, subType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
UUID controllerId = source.getControllerId();
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// lands cards you own that aren't on the battlefield
|
||||
// in graveyard
|
||||
for (UUID cardId : controller.getGraveyard()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
|
||||
affectedObjects.add(card);
|
||||
}
|
||||
}
|
||||
// on hand
|
||||
for (UUID cardId : controller.getHand()) {
|
||||
Card card = game.getCard(cardId);
|
||||
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
|
||||
affectedObjects.add(card);
|
||||
}
|
||||
}
|
||||
// in exile
|
||||
for (Card card : game.getState().getExile().getAllCards(game, controllerId)) {
|
||||
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
|
||||
affectedObjects.add(card);
|
||||
}
|
||||
}
|
||||
// in library
|
||||
for (Card card : controller.getLibrary().getCards(game)) {
|
||||
if (filterCard.match(card, controllerId, source, game) && !card.hasSubtype(subType, game)) {
|
||||
game.getState().getCreateMageObjectAttribute(card, game).getSubtype().add(subType);
|
||||
affectedObjects.add(card);
|
||||
}
|
||||
}
|
||||
|
||||
// lands you control
|
||||
List<Permanent> lands = game.getBattlefield().getAllActivePermanents(
|
||||
filterPermanent, controllerId, game);
|
||||
for (Permanent land : lands) {
|
||||
if (land != null) {
|
||||
land.addSubType(game, subType);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
affectedObjects.addAll(game.getBattlefield().getAllActivePermanents(
|
||||
filterPermanent, controllerId, game
|
||||
));
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
|
|
@ -19,6 +20,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -108,7 +110,27 @@ class DuplicantContinuousEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
List<UUID> imprinted = permanent.getImprinted();
|
||||
Card card = game.getCard(imprinted.get(imprinted.size() - 1));
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.copySubTypesFrom(game, card, SubTypeSet.CreatureType);
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setModifiedBaseValue(card.getPower().getValue());
|
||||
permanent.getToughness().setModifiedBaseValue(card.getToughness().getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
|
|
@ -124,22 +146,17 @@ class DuplicantContinuousEffect extends ContinuousEffectImpl {
|
|||
if (card == null || !card.isCreature(game)) {
|
||||
return false;
|
||||
}
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.copySubTypesFrom(game, card, SubTypeSet.CreatureType);
|
||||
break;
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanent.getPower().setModifiedBaseValue(card.getPower().getValue());
|
||||
permanent.getToughness().setModifiedBaseValue(card.getToughness().getValue());
|
||||
}
|
||||
}
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
List<MageItem> affectedObjects = new ArrayList<>();
|
||||
if (queryAffectedObjects(layer, source, game, affectedObjects)) {
|
||||
applyToObjects(layer, sublayer, source, game, affectedObjects);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
|
@ -15,6 +16,7 @@ import mage.game.permanent.Permanent;
|
|||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -70,11 +72,19 @@ class DuskmournsDominationEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Permanent permanent = (Permanent) object;
|
||||
permanent.removeAllAbilities(source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Optional.ofNullable(source.getSourcePermanentIfItStillExists(game))
|
||||
.map(Permanent::getAttachedTo)
|
||||
.map(game::getPermanent)
|
||||
.ifPresent(permanent -> permanent.removeAllAbilities(source.getSourceId(), game));
|
||||
return true;
|
||||
.ifPresent(affectedObjects::add);
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
|
||||
package mage.cards.n;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.common.continuous.BoostAllEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostTargetEffect;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -23,6 +20,12 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class NightDay extends SplitCard {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures target player controls");
|
||||
|
||||
static {
|
||||
filter.add(TargetController.SOURCE_TARGETS.getControllerPredicate());
|
||||
}
|
||||
|
||||
public NightDay(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}", "{2}{W}", SpellAbilityType.SPLIT);
|
||||
|
||||
|
|
@ -34,7 +37,7 @@ public final class NightDay extends SplitCard {
|
|||
// Day
|
||||
// Creatures target player controls get +1/+1 until end of turn.
|
||||
getRightHalfCard().getSpellAbility().addTarget(new TargetPlayer());
|
||||
getRightHalfCard().getSpellAbility().addEffect(new DayEffect());
|
||||
getRightHalfCard().getSpellAbility().addEffect(new BoostAllEffect(1, 1, Duration.EndOfTurn, filter, false));
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -47,45 +50,3 @@ public final class NightDay extends SplitCard {
|
|||
return new NightDay(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DayEffect extends ContinuousEffectImpl {
|
||||
|
||||
DayEffect() {
|
||||
super(Duration.EndOfTurn, Layer.PTChangingEffects_7, SubLayer.ModifyPT_7c, Outcome.BoostCreature);
|
||||
staticText = "Creatures target player controls get +1/+1 until end of turn";
|
||||
}
|
||||
|
||||
private DayEffect(final DayEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DayEffect copy() {
|
||||
return new DayEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
if (getAffectedObjectsSet()) {
|
||||
List<Permanent> creatures = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getFirstTarget(), game);
|
||||
for (Permanent creature : creatures) {
|
||||
affectedObjectList.add(new MageObjectReference(creature, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext(); ) {
|
||||
Permanent permanent = it.next().getPermanent(game);
|
||||
if (permanent != null) {
|
||||
permanent.addPower(1);
|
||||
permanent.addToughness(1);
|
||||
} else {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
|
|
@ -11,6 +12,8 @@ import mage.constants.SubLayer;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
|
@ -32,13 +35,19 @@ public class DontLoseByZeroOrLessLifeEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
((Player) object).setLoseByZeroOrLessLife(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
controller.setLoseByZeroOrLessLife(false);
|
||||
affectedObjects.add(controller);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,11 +1,15 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.StaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.hint.common.DayNightHint;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
|
@ -49,12 +53,21 @@ class DayboundEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
if (!game.hasDayNight()) {
|
||||
// 702.145d
|
||||
// Any time a player controls a permanent with daybound, if it’s neither day nor night, it becomes day.
|
||||
game.setDaytime(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package mage.game.command.emblems;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.SpellAbility;
|
||||
|
|
@ -137,14 +138,21 @@ class DackFaydenEmblemEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
((Permanent) object).changeControllerId(source.getControllerId(), game, source);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (UUID permanentId : fixedTargets.getTargets(game, source)) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
permanent.changeControllerId(source.getControllerId(), game, source);
|
||||
affectedObjects.add(permanent);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return !affectedObjects.isEmpty();
|
||||
}
|
||||
|
||||
public void setTargets(List<Permanent> targetedPermanents, Game game) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.game.permanent.token;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageItem;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
|
|
@ -11,6 +12,8 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author spjspj
|
||||
*/
|
||||
|
|
@ -54,7 +57,18 @@ class DaxosSpiritSetPTEffect extends ContinuousEffectImpl {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
public void applyToObjects(Layer layer, SubLayer sublayer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
for (MageItem object : affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = (Permanent) object;
|
||||
int amount = controller.getCountersCount(CounterType.EXPERIENCE);
|
||||
permanent.getPower().setModifiedBaseValue(amount);
|
||||
permanent.getToughness().setModifiedBaseValue(amount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAffectedObjects(Layer layer, Ability source, Game game, List<MageItem> affectedObjects) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null) {
|
||||
return false;
|
||||
|
|
@ -64,10 +78,7 @@ class DaxosSpiritSetPTEffect extends ContinuousEffectImpl {
|
|||
discard();
|
||||
return false;
|
||||
}
|
||||
|
||||
int amount = controller.getCountersCount(CounterType.EXPERIENCE);
|
||||
permanent.getPower().setModifiedBaseValue(amount);
|
||||
permanent.getToughness().setModifiedBaseValue(amount);
|
||||
affectedObjects.add(permanent);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue