forked from External/mage
Update *.sh and *.java files to use Unix line endings
This commit is contained in:
parent
a6d03c925f
commit
9c7982e8f6
273 changed files with 26704 additions and 26704 deletions
|
|
@ -1,66 +1,66 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author antoni-g
|
||||
*/
|
||||
public class PreventDamageAndRemoveCountersEffect extends PreventionEffectImpl {
|
||||
private final boolean thatMany;
|
||||
|
||||
public PreventDamageAndRemoveCountersEffect(boolean thatMany) {
|
||||
super(Duration.WhileOnBattlefield, Integer.MAX_VALUE, false, false);
|
||||
this.thatMany = thatMany;
|
||||
staticText = "If damage would be dealt to {this} while it has a +1/+1 counter on it, " +
|
||||
"prevent that damage and remove " + (thatMany ? "that many +1/+1 counters" : "a +1/+1 counter") + " from it";
|
||||
}
|
||||
|
||||
private PreventDamageAndRemoveCountersEffect(final PreventDamageAndRemoveCountersEffect effect) {
|
||||
super(effect);
|
||||
this.thatMany = effect.thatMany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreventDamageAndRemoveCountersEffect copy() {
|
||||
return new PreventDamageAndRemoveCountersEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
int damage = event.getAmount();
|
||||
preventDamageAction(event, source, game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
if (!thatMany) {
|
||||
damage = 1;
|
||||
}
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(damage), game); //MTG ruling (this) loses counters even if the damage isn't prevented
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return super.applies(event, source, game)
|
||||
&& permanent != null
|
||||
&& event.getTargetId().equals(source.getSourceId())
|
||||
&& permanent.getCounters(game).containsKey(CounterType.P1P1);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author antoni-g
|
||||
*/
|
||||
public class PreventDamageAndRemoveCountersEffect extends PreventionEffectImpl {
|
||||
private final boolean thatMany;
|
||||
|
||||
public PreventDamageAndRemoveCountersEffect(boolean thatMany) {
|
||||
super(Duration.WhileOnBattlefield, Integer.MAX_VALUE, false, false);
|
||||
this.thatMany = thatMany;
|
||||
staticText = "If damage would be dealt to {this} while it has a +1/+1 counter on it, " +
|
||||
"prevent that damage and remove " + (thatMany ? "that many +1/+1 counters" : "a +1/+1 counter") + " from it";
|
||||
}
|
||||
|
||||
private PreventDamageAndRemoveCountersEffect(final PreventDamageAndRemoveCountersEffect effect) {
|
||||
super(effect);
|
||||
this.thatMany = effect.thatMany;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreventDamageAndRemoveCountersEffect copy() {
|
||||
return new PreventDamageAndRemoveCountersEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
int damage = event.getAmount();
|
||||
preventDamageAction(event, source, game);
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
if (!thatMany) {
|
||||
damage = 1;
|
||||
}
|
||||
permanent.removeCounters(CounterType.P1P1.createInstance(damage), game); //MTG ruling (this) loses counters even if the damage isn't prevented
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
||||
return super.applies(event, source, game)
|
||||
&& permanent != null
|
||||
&& event.getTargetId().equals(source.getSourceId())
|
||||
&& permanent.getCounters(game).containsKey(CounterType.P1P1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBeTargetedCardsGraveyardsEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
public CantBeTargetedCardsGraveyardsEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "Cards in graveyards can't be the targets of spells or abilities";
|
||||
}
|
||||
|
||||
public CantBeTargetedCardsGraveyardsEffect(final CantBeTargetedCardsGraveyardsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBeTargetedCardsGraveyardsEffect copy() {
|
||||
return new CantBeTargetedCardsGraveyardsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.TARGET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Card targetCard = game.getCard(event.getTargetId());
|
||||
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
|
||||
if (targetCard != null && stackObject != null) {
|
||||
Zone zone = game.getState().getZone(targetCard.getId());
|
||||
if (zone != null && zone == Zone.GRAVEYARD) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.stack.StackObject;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBeTargetedCardsGraveyardsEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
public CantBeTargetedCardsGraveyardsEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "Cards in graveyards can't be the targets of spells or abilities";
|
||||
}
|
||||
|
||||
public CantBeTargetedCardsGraveyardsEffect(final CantBeTargetedCardsGraveyardsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBeTargetedCardsGraveyardsEffect copy() {
|
||||
return new CantBeTargetedCardsGraveyardsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.TARGET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Card targetCard = game.getCard(event.getTargetId());
|
||||
StackObject stackObject = game.getStack().getStackObject(event.getSourceId());
|
||||
if (targetCard != null && stackObject != null) {
|
||||
Zone zone = game.getState().getZone(targetCard.getId());
|
||||
if (zone != null && zone == Zone.GRAVEYARD) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,53 +1,53 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
|
||||
public class DiscardCardControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public DiscardCardControllerTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
this(effect, isOptional, StaticFilters.FILTER_CARD_A);
|
||||
}
|
||||
|
||||
public DiscardCardControllerTriggeredAbility(Effect effect, boolean isOptional, FilterCard filter) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
private DiscardCardControllerTriggeredAbility(final DiscardCardControllerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscardCardControllerTriggeredAbility copy() {
|
||||
return new DiscardCardControllerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DISCARDED_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getPlayerId().equals(getControllerId())
|
||||
&& filter.match(game.getCard(event.getTargetId()), getId(), getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you discard " + filter.getMessage() + ", " + super.getRule();
|
||||
}
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
|
||||
public class DiscardCardControllerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public DiscardCardControllerTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
this(effect, isOptional, StaticFilters.FILTER_CARD_A);
|
||||
}
|
||||
|
||||
public DiscardCardControllerTriggeredAbility(Effect effect, boolean isOptional, FilterCard filter) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
private DiscardCardControllerTriggeredAbility(final DiscardCardControllerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscardCardControllerTriggeredAbility copy() {
|
||||
return new DiscardCardControllerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DISCARDED_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getPlayerId().equals(getControllerId())
|
||||
&& filter.match(game.getCard(event.getTargetId()), getId(), getControllerId(), game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever you discard " + filter.getMessage() + ", " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,51 +1,51 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class DiscardCardPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private SetTargetPointer setTargetPointer;
|
||||
|
||||
public DiscardCardPlayerTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
this(effect, isOptional, SetTargetPointer.NONE);
|
||||
}
|
||||
|
||||
public DiscardCardPlayerTriggeredAbility(Effect effect, boolean isOptional, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
private DiscardCardPlayerTriggeredAbility(final DiscardCardPlayerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscardCardPlayerTriggeredAbility copy() {
|
||||
return new DiscardCardPlayerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DISCARDED_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a player discards a card, " + super.getRule();
|
||||
}
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class DiscardCardPlayerTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private SetTargetPointer setTargetPointer;
|
||||
|
||||
public DiscardCardPlayerTriggeredAbility(Effect effect, boolean isOptional) {
|
||||
this(effect, isOptional, SetTargetPointer.NONE);
|
||||
}
|
||||
|
||||
public DiscardCardPlayerTriggeredAbility(Effect effect, boolean isOptional, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, isOptional);
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
private DiscardCardPlayerTriggeredAbility(final DiscardCardPlayerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscardCardPlayerTriggeredAbility copy() {
|
||||
return new DiscardCardPlayerTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DISCARDED_CARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever a player discards a card, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +1,65 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExchangeLifeTargetEffect extends OneShotEffect {
|
||||
|
||||
public ExchangeLifeTargetEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
public ExchangeLifeTargetEffect(final ExchangeLifeTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExchangeLifeTargetEffect copy() {
|
||||
return new ExchangeLifeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (controller != null && player != null) {
|
||||
int lifeController = controller.getLife();
|
||||
int lifePlayer = player.getLife();
|
||||
|
||||
if (lifeController == lifePlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!controller.isLifeTotalCanChange() || !player.isLifeTotalCanChange()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lifeController < lifePlayer && (!controller.isCanGainLife() || !player.isCanLoseLife())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lifeController > lifePlayer && (!controller.isCanLoseLife() || !player.isCanGainLife())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
controller.setLife(lifePlayer, game, source);
|
||||
player.setLife(lifeController, game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Exchange life totals with target " + mode.getTargets().get(0).getTargetName();
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExchangeLifeTargetEffect extends OneShotEffect {
|
||||
|
||||
public ExchangeLifeTargetEffect() {
|
||||
super(Outcome.Neutral);
|
||||
}
|
||||
|
||||
public ExchangeLifeTargetEffect(final ExchangeLifeTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExchangeLifeTargetEffect copy() {
|
||||
return new ExchangeLifeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (controller != null && player != null) {
|
||||
int lifeController = controller.getLife();
|
||||
int lifePlayer = player.getLife();
|
||||
|
||||
if (lifeController == lifePlayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!controller.isLifeTotalCanChange() || !player.isLifeTotalCanChange()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lifeController < lifePlayer && (!controller.isCanGainLife() || !player.isCanLoseLife())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lifeController > lifePlayer && (!controller.isCanLoseLife() || !player.isCanGainLife())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
controller.setLife(lifePlayer, game, source);
|
||||
player.setLife(lifeController, game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
return "Exchange life totals with target " + mode.getTargets().get(0).getTargetName();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExileAttachedEffect extends OneShotEffect {
|
||||
|
||||
public ExileAttachedEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "Exile enchanted creature";
|
||||
}
|
||||
|
||||
public ExileAttachedEffect(final ExileAttachedEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileAttachedEffect copy() {
|
||||
return new ExileAttachedEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller != null && enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
controller.moveCardsToExile(creature, source, game, true, null, "");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExileAttachedEffect extends OneShotEffect {
|
||||
|
||||
public ExileAttachedEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "Exile enchanted creature";
|
||||
}
|
||||
|
||||
public ExileAttachedEffect(final ExileAttachedEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileAttachedEffect copy() {
|
||||
return new ExileAttachedEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller != null && enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (creature != null) {
|
||||
controller.moveCardsToExile(creature, source, game, true, null, "");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,41 +1,41 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.replacement.DiesReplacementEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ExileTargetIfDiesEffect extends OneShotEffect {
|
||||
|
||||
public ExileTargetIfDiesEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "If that creature would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public ExileTargetIfDiesEffect(final ExileTargetIfDiesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileTargetIfDiesEffect copy() {
|
||||
return new ExileTargetIfDiesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (targetCreature != null) {
|
||||
game.addEffect(new DiesReplacementEffect(new MageObjectReference(targetCreature, game), Duration.EndOfTurn), source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.replacement.DiesReplacementEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ExileTargetIfDiesEffect extends OneShotEffect {
|
||||
|
||||
public ExileTargetIfDiesEffect() {
|
||||
super(Outcome.Damage);
|
||||
this.staticText = "If that creature would die this turn, exile it instead";
|
||||
}
|
||||
|
||||
public ExileTargetIfDiesEffect(final ExileTargetIfDiesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileTargetIfDiesEffect copy() {
|
||||
return new ExileTargetIfDiesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (targetCreature != null) {
|
||||
game.addEffect(new DiesReplacementEffect(new MageObjectReference(targetCreature, game), Duration.EndOfTurn), source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExileUntilSourceLeavesEffect extends OneShotEffect {
|
||||
|
||||
public ExileUntilSourceLeavesEffect(String targetName) {
|
||||
super(Outcome.Removal);
|
||||
this.staticText = "exile target " + targetName + " an opponent controls until {this} leaves the battlefield";
|
||||
}
|
||||
|
||||
public ExileUntilSourceLeavesEffect(final ExileUntilSourceLeavesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileUntilSourceLeavesEffect copy() {
|
||||
return new ExileUntilSourceLeavesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
ExileTargetEffect effect = new ExileTargetEffect(CardUtil.getCardExileZoneId(game, source), permanent.getIdName());
|
||||
if (targetPointer != null) { // Grasping Giant
|
||||
effect.setTargetPointer(targetPointer);
|
||||
}
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ExileUntilSourceLeavesEffect extends OneShotEffect {
|
||||
|
||||
public ExileUntilSourceLeavesEffect(String targetName) {
|
||||
super(Outcome.Removal);
|
||||
this.staticText = "exile target " + targetName + " an opponent controls until {this} leaves the battlefield";
|
||||
}
|
||||
|
||||
public ExileUntilSourceLeavesEffect(final ExileUntilSourceLeavesEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExileUntilSourceLeavesEffect copy() {
|
||||
return new ExileUntilSourceLeavesEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
ExileTargetEffect effect = new ExileTargetEffect(CardUtil.getCardExileZoneId(game, source), permanent.getIdName());
|
||||
if (targetPointer != null) { // Grasping Giant
|
||||
effect.setTargetPointer(targetPointer);
|
||||
}
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,92 +1,92 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class FlipCoinEffect extends OneShotEffect {
|
||||
|
||||
protected Effects executingEffectsWon = new Effects();
|
||||
protected Effects executingEffectsLost = new Effects();
|
||||
|
||||
public FlipCoinEffect(Effect effectWon) {
|
||||
this(effectWon, null);
|
||||
}
|
||||
|
||||
public FlipCoinEffect(Effect effectWon, Effect effectLost) {
|
||||
this(effectWon, effectLost, Outcome.Benefit);
|
||||
|
||||
}
|
||||
|
||||
public FlipCoinEffect(Effect effectWon, Effect effectLost, Outcome outcome) {
|
||||
super(outcome);
|
||||
addEffectWon(effectWon);
|
||||
addEffectLost(effectLost);
|
||||
}
|
||||
|
||||
public FlipCoinEffect(final FlipCoinEffect effect) {
|
||||
super(effect);
|
||||
this.executingEffectsWon = effect.executingEffectsWon.copy();
|
||||
this.executingEffectsLost = effect.executingEffectsLost.copy();
|
||||
}
|
||||
|
||||
public void addEffectWon(Effect effect) {
|
||||
if (effect != null) {
|
||||
executingEffectsWon.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public void addEffectLost(Effect effect) {
|
||||
if (effect != null) {
|
||||
executingEffectsLost.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && mageObject != null) {
|
||||
boolean result = true;
|
||||
for (Effect effect : controller.flipCoin(source, game, true) ? executingEffectsWon : executingEffectsLost) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
result &= effect.apply(game, source);
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("Flip a coin. If you win the flip, ").append(executingEffectsWon.getText(mode));
|
||||
if (!executingEffectsLost.isEmpty()) {
|
||||
sb.append(" If you lose the flip, ").append(executingEffectsLost.getText(mode));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlipCoinEffect copy() {
|
||||
return new FlipCoinEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.Effects;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class FlipCoinEffect extends OneShotEffect {
|
||||
|
||||
protected Effects executingEffectsWon = new Effects();
|
||||
protected Effects executingEffectsLost = new Effects();
|
||||
|
||||
public FlipCoinEffect(Effect effectWon) {
|
||||
this(effectWon, null);
|
||||
}
|
||||
|
||||
public FlipCoinEffect(Effect effectWon, Effect effectLost) {
|
||||
this(effectWon, effectLost, Outcome.Benefit);
|
||||
|
||||
}
|
||||
|
||||
public FlipCoinEffect(Effect effectWon, Effect effectLost, Outcome outcome) {
|
||||
super(outcome);
|
||||
addEffectWon(effectWon);
|
||||
addEffectLost(effectLost);
|
||||
}
|
||||
|
||||
public FlipCoinEffect(final FlipCoinEffect effect) {
|
||||
super(effect);
|
||||
this.executingEffectsWon = effect.executingEffectsWon.copy();
|
||||
this.executingEffectsLost = effect.executingEffectsLost.copy();
|
||||
}
|
||||
|
||||
public void addEffectWon(Effect effect) {
|
||||
if (effect != null) {
|
||||
executingEffectsWon.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
public void addEffectLost(Effect effect) {
|
||||
if (effect != null) {
|
||||
executingEffectsLost.add(effect);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject mageObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && mageObject != null) {
|
||||
boolean result = true;
|
||||
for (Effect effect : controller.flipCoin(source, game, true) ? executingEffectsWon : executingEffectsLost) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
if (effect instanceof OneShotEffect) {
|
||||
result &= effect.apply(game, source);
|
||||
} else {
|
||||
game.addEffect((ContinuousEffect) effect, source);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder("Flip a coin. If you win the flip, ").append(executingEffectsWon.getText(mode));
|
||||
if (!executingEffectsLost.isEmpty()) {
|
||||
sb.append(" If you lose the flip, ").append(executingEffectsLost.getText(mode));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlipCoinEffect copy() {
|
||||
return new FlipCoinEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class LoseHalfLifeTargetEffect extends OneShotEffect {
|
||||
|
||||
public LoseHalfLifeTargetEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "that player loses half their life, rounded up";
|
||||
}
|
||||
|
||||
public LoseHalfLifeTargetEffect(final LoseHalfLifeTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoseHalfLifeTargetEffect copy() {
|
||||
return new LoseHalfLifeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
Integer amount = (int) Math.ceil(player.getLife() / 2f);
|
||||
if (amount > 0) {
|
||||
player.loseLife(amount, game, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class LoseHalfLifeTargetEffect extends OneShotEffect {
|
||||
|
||||
public LoseHalfLifeTargetEffect() {
|
||||
super(Outcome.Damage);
|
||||
staticText = "that player loses half their life, rounded up";
|
||||
}
|
||||
|
||||
public LoseHalfLifeTargetEffect(final LoseHalfLifeTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoseHalfLifeTargetEffect copy() {
|
||||
return new LoseHalfLifeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
Integer amount = (int) Math.ceil(player.getLife() / 2f);
|
||||
if (amount > 0) {
|
||||
player.loseLife(amount, game, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
public class ReturnCreaturesFromExileEffect extends OneShotEffect {
|
||||
|
||||
private UUID exileId;
|
||||
private boolean byOwner;
|
||||
|
||||
public ReturnCreaturesFromExileEffect(UUID exileId, boolean byOwner, String description) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.exileId = exileId;
|
||||
this.setText(description);
|
||||
this.byOwner = byOwner;
|
||||
}
|
||||
|
||||
|
||||
public ReturnCreaturesFromExileEffect(final ReturnCreaturesFromExileEffect effect) {
|
||||
super(effect);
|
||||
this.exileId = effect.exileId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnCreaturesFromExileEffect copy() {
|
||||
return new ReturnCreaturesFromExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ExileZone exile = game.getExile().getExileZone(exileId);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && exile != null) {
|
||||
controller.moveCards(exile.getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game, false, false, this.byOwner, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
public class ReturnCreaturesFromExileEffect extends OneShotEffect {
|
||||
|
||||
private UUID exileId;
|
||||
private boolean byOwner;
|
||||
|
||||
public ReturnCreaturesFromExileEffect(UUID exileId, boolean byOwner, String description) {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.exileId = exileId;
|
||||
this.setText(description);
|
||||
this.byOwner = byOwner;
|
||||
}
|
||||
|
||||
|
||||
public ReturnCreaturesFromExileEffect(final ReturnCreaturesFromExileEffect effect) {
|
||||
super(effect);
|
||||
this.exileId = effect.exileId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReturnCreaturesFromExileEffect copy() {
|
||||
return new ReturnCreaturesFromExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ExileZone exile = game.getExile().getExileZone(exileId);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && exile != null) {
|
||||
controller.moveCards(exile.getCards(new FilterCreatureCard(), game), Zone.BATTLEFIELD, source, game, false, false, this.byOwner, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,149 +1,149 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Library;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
|
||||
|
||||
private FilterCard filter;
|
||||
private Zone zoneToPutRest;
|
||||
private Zone zoneToPutCard;
|
||||
private boolean shuffleRestInto;
|
||||
private boolean anyOrder;
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest) {
|
||||
this(filter, zoneToPutCard, zoneToPutRest, false, false);
|
||||
}
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest, boolean shuffleRestInto) {
|
||||
this(filter, zoneToPutCard, zoneToPutRest, shuffleRestInto, false);
|
||||
}
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest, boolean shuffleRestInto, boolean anyOrder) {
|
||||
super(Outcome.Benefit);
|
||||
this.filter = filter;
|
||||
this.zoneToPutCard = zoneToPutCard;
|
||||
this.zoneToPutRest = zoneToPutRest;
|
||||
this.shuffleRestInto = shuffleRestInto;
|
||||
this.anyOrder = anyOrder;
|
||||
setText();
|
||||
}
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(final RevealCardsFromLibraryUntilEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.zoneToPutCard = effect.zoneToPutCard;
|
||||
this.zoneToPutRest = effect.zoneToPutRest;
|
||||
this.shuffleRestInto = effect.shuffleRestInto;
|
||||
this.anyOrder = effect.anyOrder;
|
||||
setText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevealCardsFromLibraryUntilEffect copy() {
|
||||
return new RevealCardsFromLibraryUntilEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && controller.getLibrary().hasCards()) {
|
||||
Cards cards = new CardsImpl();
|
||||
Library library = controller.getLibrary();
|
||||
Card card = null;
|
||||
do {
|
||||
card = library.removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
} while (library.hasCards() && card != null && !filter.match(card, game));
|
||||
// reveal cards
|
||||
if (!cards.isEmpty()) {
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
if (filter.match(card, game)) {
|
||||
// put card in correct zone
|
||||
controller.moveCards(card, zoneToPutCard, source, game);
|
||||
// remove it from revealed card list
|
||||
cards.remove(card);
|
||||
}
|
||||
// Put the rest in correct zone
|
||||
switch (zoneToPutRest) {
|
||||
case LIBRARY: {
|
||||
if (!cards.isEmpty()) {
|
||||
if (shuffleRestInto) {
|
||||
library.addAll(cards.getCards(game), game);
|
||||
} else {
|
||||
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (!cards.isEmpty()) {
|
||||
controller.moveCards(cards, zoneToPutRest, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("reveal cards from the top of your library until you reveal a " + filter.getMessage() + ". Put that card ");
|
||||
|
||||
switch (zoneToPutCard) {
|
||||
case HAND: {
|
||||
sb.append("into your hand ");
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD: {
|
||||
sb.append("onto the battlefield");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (zoneToPutRest) {
|
||||
case GRAVEYARD: {
|
||||
sb.append(" and put all other cards revealed this way into your graveyard.");
|
||||
break;
|
||||
}
|
||||
case LIBRARY: {
|
||||
if (shuffleRestInto) {
|
||||
sb.append(", then shuffles the rest into their library.");
|
||||
} else {
|
||||
sb.append(" and the rest on the bottom of your library in ");
|
||||
if (anyOrder) {
|
||||
sb.append("any");
|
||||
} else {
|
||||
sb.append("a random");
|
||||
|
||||
}
|
||||
sb.append(" order");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EXILED: {
|
||||
sb.append(" and exile all other cards revealed this way.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Library;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
|
||||
|
||||
private FilterCard filter;
|
||||
private Zone zoneToPutRest;
|
||||
private Zone zoneToPutCard;
|
||||
private boolean shuffleRestInto;
|
||||
private boolean anyOrder;
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest) {
|
||||
this(filter, zoneToPutCard, zoneToPutRest, false, false);
|
||||
}
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest, boolean shuffleRestInto) {
|
||||
this(filter, zoneToPutCard, zoneToPutRest, shuffleRestInto, false);
|
||||
}
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest, boolean shuffleRestInto, boolean anyOrder) {
|
||||
super(Outcome.Benefit);
|
||||
this.filter = filter;
|
||||
this.zoneToPutCard = zoneToPutCard;
|
||||
this.zoneToPutRest = zoneToPutRest;
|
||||
this.shuffleRestInto = shuffleRestInto;
|
||||
this.anyOrder = anyOrder;
|
||||
setText();
|
||||
}
|
||||
|
||||
public RevealCardsFromLibraryUntilEffect(final RevealCardsFromLibraryUntilEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.zoneToPutCard = effect.zoneToPutCard;
|
||||
this.zoneToPutRest = effect.zoneToPutRest;
|
||||
this.shuffleRestInto = effect.shuffleRestInto;
|
||||
this.anyOrder = effect.anyOrder;
|
||||
setText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevealCardsFromLibraryUntilEffect copy() {
|
||||
return new RevealCardsFromLibraryUntilEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && controller.getLibrary().hasCards()) {
|
||||
Cards cards = new CardsImpl();
|
||||
Library library = controller.getLibrary();
|
||||
Card card = null;
|
||||
do {
|
||||
card = library.removeFromTop(game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
} while (library.hasCards() && card != null && !filter.match(card, game));
|
||||
// reveal cards
|
||||
if (!cards.isEmpty()) {
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
if (filter.match(card, game)) {
|
||||
// put card in correct zone
|
||||
controller.moveCards(card, zoneToPutCard, source, game);
|
||||
// remove it from revealed card list
|
||||
cards.remove(card);
|
||||
}
|
||||
// Put the rest in correct zone
|
||||
switch (zoneToPutRest) {
|
||||
case LIBRARY: {
|
||||
if (!cards.isEmpty()) {
|
||||
if (shuffleRestInto) {
|
||||
library.addAll(cards.getCards(game), game);
|
||||
} else {
|
||||
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (!cards.isEmpty()) {
|
||||
controller.moveCards(cards, zoneToPutRest, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
StringBuilder sb = new StringBuilder("reveal cards from the top of your library until you reveal a " + filter.getMessage() + ". Put that card ");
|
||||
|
||||
switch (zoneToPutCard) {
|
||||
case HAND: {
|
||||
sb.append("into your hand ");
|
||||
break;
|
||||
}
|
||||
case BATTLEFIELD: {
|
||||
sb.append("onto the battlefield");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (zoneToPutRest) {
|
||||
case GRAVEYARD: {
|
||||
sb.append(" and put all other cards revealed this way into your graveyard.");
|
||||
break;
|
||||
}
|
||||
case LIBRARY: {
|
||||
if (shuffleRestInto) {
|
||||
sb.append(", then shuffles the rest into their library.");
|
||||
} else {
|
||||
sb.append(" and the rest on the bottom of your library in ");
|
||||
if (anyOrder) {
|
||||
sb.append("any");
|
||||
} else {
|
||||
sb.append("a random");
|
||||
|
||||
}
|
||||
sb.append(" order");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EXILED: {
|
||||
sb.append(" and exile all other cards revealed this way.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
staticText = sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,55 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SetPlayerLifeTargetEffect extends OneShotEffect {
|
||||
|
||||
protected DynamicValue amount;
|
||||
|
||||
public SetPlayerLifeTargetEffect(int amount) {
|
||||
this(StaticValue.get(amount));
|
||||
}
|
||||
|
||||
public SetPlayerLifeTargetEffect(DynamicValue amount) {
|
||||
super(Outcome.Neutral);
|
||||
this.amount = amount;
|
||||
this.staticText = setText();
|
||||
}
|
||||
|
||||
public SetPlayerLifeTargetEffect(final SetPlayerLifeTargetEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPlayerLifeTargetEffect copy() {
|
||||
return new SetPlayerLifeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.setLife(amount.calculate(game, source, this), game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Target player's life total becomes ");
|
||||
sb.append(amount.toString());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SetPlayerLifeTargetEffect extends OneShotEffect {
|
||||
|
||||
protected DynamicValue amount;
|
||||
|
||||
public SetPlayerLifeTargetEffect(int amount) {
|
||||
this(StaticValue.get(amount));
|
||||
}
|
||||
|
||||
public SetPlayerLifeTargetEffect(DynamicValue amount) {
|
||||
super(Outcome.Neutral);
|
||||
this.amount = amount;
|
||||
this.staticText = setText();
|
||||
}
|
||||
|
||||
public SetPlayerLifeTargetEffect(final SetPlayerLifeTargetEffect effect) {
|
||||
super(effect);
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPlayerLifeTargetEffect copy() {
|
||||
return new SetPlayerLifeTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
if (player != null) {
|
||||
player.setLife(amount.calculate(game, source, this), game, source);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String setText() {
|
||||
StringBuilder sb = new StringBuilder("Target player's life total becomes ");
|
||||
sb.append(amount.toString());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +1,62 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ShuffleIntoLibraryTargetEffect extends OneShotEffect {
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect() {
|
||||
super(Outcome.Detriment);
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(String effectText) {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = effectText;
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(final ShuffleIntoLibraryTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShuffleIntoLibraryTargetEffect copy() {
|
||||
return new ShuffleIntoLibraryTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null && controller != null) {
|
||||
if (controller.moveCards(permanent, Zone.LIBRARY, source, game)) {
|
||||
game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
} else {
|
||||
return "choose target " + mode.getTargets().get(0).getTargetName() + ". Its owner shuffles it into their library";
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class ShuffleIntoLibraryTargetEffect extends OneShotEffect {
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect() {
|
||||
super(Outcome.Detriment);
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(String effectText) {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = effectText;
|
||||
}
|
||||
|
||||
public ShuffleIntoLibraryTargetEffect(final ShuffleIntoLibraryTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShuffleIntoLibraryTargetEffect copy() {
|
||||
return new ShuffleIntoLibraryTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (permanent != null && controller != null) {
|
||||
if (controller.moveCards(permanent, Zone.LIBRARY, source, game)) {
|
||||
game.getPlayer(permanent.getOwnerId()).shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
} else {
|
||||
return "choose target " + mode.getTargets().get(0).getTargetName() + ". Its owner shuffles it into their library";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,55 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class SkipCombatStepEffect extends ReplacementEffectImpl {
|
||||
|
||||
public SkipCombatStepEffect(Duration duration) {
|
||||
super(duration, Outcome.Detriment);
|
||||
staticText = "that player skips their next combat phase";
|
||||
}
|
||||
|
||||
public SkipCombatStepEffect(final SkipCombatStepEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipCombatStepEffect copy() {
|
||||
return new SkipCombatStepEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COMBAT_PHASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getPlayerId().equals(targetPointer.getFirst(game, source));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class SkipCombatStepEffect extends ReplacementEffectImpl {
|
||||
|
||||
public SkipCombatStepEffect(Duration duration) {
|
||||
super(duration, Outcome.Detriment);
|
||||
staticText = "that player skips their next combat phase";
|
||||
}
|
||||
|
||||
public SkipCombatStepEffect(final SkipCombatStepEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipCombatStepEffect copy() {
|
||||
return new SkipCombatStepEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.COMBAT_PHASE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getPlayerId().equals(targetPointer.getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,55 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class SkipNextDrawStepTargetEffect extends ReplacementEffectImpl {
|
||||
|
||||
public SkipNextDrawStepTargetEffect() {
|
||||
super(Duration.OneUse, Outcome.Detriment);
|
||||
staticText = "Target player skips their next draw step";
|
||||
}
|
||||
|
||||
public SkipNextDrawStepTargetEffect(final SkipNextDrawStepTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipNextDrawStepTargetEffect copy() {
|
||||
return new SkipNextDrawStepTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_STEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getPlayerId().equals(source.getFirstTarget());
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
|
||||
public class SkipNextDrawStepTargetEffect extends ReplacementEffectImpl {
|
||||
|
||||
public SkipNextDrawStepTargetEffect() {
|
||||
super(Duration.OneUse, Outcome.Detriment);
|
||||
staticText = "Target player skips their next draw step";
|
||||
}
|
||||
|
||||
public SkipNextDrawStepTargetEffect(final SkipNextDrawStepTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkipNextDrawStepTargetEffect copy() {
|
||||
return new SkipNextDrawStepTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DRAW_STEP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getPlayerId().equals(source.getFirstTarget());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,120 +1,120 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class WishEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
private final boolean reveal;
|
||||
private final boolean alsoFromExile;
|
||||
private final String choiceText;
|
||||
|
||||
public WishEffect() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public WishEffect(FilterCard filter) {
|
||||
this(filter, true);
|
||||
}
|
||||
|
||||
public WishEffect(FilterCard filter, boolean reveal) {
|
||||
this(filter, reveal, false);
|
||||
}
|
||||
|
||||
public WishEffect(FilterCard filter, boolean reveal, boolean alsoFromExile) {
|
||||
super(Outcome.DrawCard);
|
||||
this.filter = filter;
|
||||
this.alsoFromExile = alsoFromExile;
|
||||
this.reveal = reveal;
|
||||
choiceText = "Choose " + filter.getMessage() + " you own from outside the game"
|
||||
+ (alsoFromExile ? " or in exile" : "")
|
||||
+ (reveal ? ", reveal that card," : "")
|
||||
+ " and put it into your hand.";
|
||||
staticText = "You may c" + choiceText.substring(1, choiceText.length() - 1);
|
||||
|
||||
}
|
||||
|
||||
public WishEffect(final WishEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.alsoFromExile = effect.alsoFromExile;
|
||||
this.reveal = effect.reveal;
|
||||
this.choiceText = effect.choiceText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WishEffect copy() {
|
||||
return new WishEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
if (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) {
|
||||
Cards cards = controller.getSideboard();
|
||||
List<Card> exile = game.getExile().getAllCards(game);
|
||||
boolean noTargets = cards.isEmpty() && (!alsoFromExile || exile.isEmpty());
|
||||
if (noTargets) {
|
||||
game.informPlayer(controller, "You have no cards outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<Card> filtered = cards.getCards(filter, game);
|
||||
Cards filteredCards = new CardsImpl();
|
||||
for (Card card : filtered) {
|
||||
filteredCards.add(card.getId());
|
||||
}
|
||||
if (alsoFromExile) {
|
||||
for (Card exileCard : exile) {
|
||||
if (exileCard.isOwnedBy(source.getControllerId()) && filter.match(exileCard, game)) {
|
||||
filteredCards.add(exileCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filteredCards.isEmpty()) {
|
||||
game.informPlayer(controller, "You don't have " + filter.getMessage() + " outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
TargetCard target = new TargetCard(Zone.ALL, filter);
|
||||
target.setNotTarget(true);
|
||||
if (controller.choose(Outcome.Benefit, filteredCards, target, game)) {
|
||||
Card card = controller.getSideboard().get(target.getFirstTarget(), game);
|
||||
if (card == null && alsoFromExile) {
|
||||
card = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
if (reveal) {
|
||||
Cards revealCard = new CardsImpl();
|
||||
revealCard.add(card);
|
||||
controller.revealCards(sourceObject.getIdName(), revealCard, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class WishEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
private final boolean reveal;
|
||||
private final boolean alsoFromExile;
|
||||
private final String choiceText;
|
||||
|
||||
public WishEffect() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public WishEffect(FilterCard filter) {
|
||||
this(filter, true);
|
||||
}
|
||||
|
||||
public WishEffect(FilterCard filter, boolean reveal) {
|
||||
this(filter, reveal, false);
|
||||
}
|
||||
|
||||
public WishEffect(FilterCard filter, boolean reveal, boolean alsoFromExile) {
|
||||
super(Outcome.DrawCard);
|
||||
this.filter = filter;
|
||||
this.alsoFromExile = alsoFromExile;
|
||||
this.reveal = reveal;
|
||||
choiceText = "Choose " + filter.getMessage() + " you own from outside the game"
|
||||
+ (alsoFromExile ? " or in exile" : "")
|
||||
+ (reveal ? ", reveal that card," : "")
|
||||
+ " and put it into your hand.";
|
||||
staticText = "You may c" + choiceText.substring(1, choiceText.length() - 1);
|
||||
|
||||
}
|
||||
|
||||
public WishEffect(final WishEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.alsoFromExile = effect.alsoFromExile;
|
||||
this.reveal = effect.reveal;
|
||||
this.choiceText = effect.choiceText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WishEffect copy() {
|
||||
return new WishEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
if (controller.chooseUse(Outcome.Benefit, choiceText, source, game)) {
|
||||
Cards cards = controller.getSideboard();
|
||||
List<Card> exile = game.getExile().getAllCards(game);
|
||||
boolean noTargets = cards.isEmpty() && (!alsoFromExile || exile.isEmpty());
|
||||
if (noTargets) {
|
||||
game.informPlayer(controller, "You have no cards outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<Card> filtered = cards.getCards(filter, game);
|
||||
Cards filteredCards = new CardsImpl();
|
||||
for (Card card : filtered) {
|
||||
filteredCards.add(card.getId());
|
||||
}
|
||||
if (alsoFromExile) {
|
||||
for (Card exileCard : exile) {
|
||||
if (exileCard.isOwnedBy(source.getControllerId()) && filter.match(exileCard, game)) {
|
||||
filteredCards.add(exileCard);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filteredCards.isEmpty()) {
|
||||
game.informPlayer(controller, "You don't have " + filter.getMessage() + " outside the game" + (alsoFromExile ? " or in exile" : "") + '.');
|
||||
return true;
|
||||
}
|
||||
|
||||
TargetCard target = new TargetCard(Zone.ALL, filter);
|
||||
target.setNotTarget(true);
|
||||
if (controller.choose(Outcome.Benefit, filteredCards, target, game)) {
|
||||
Card card = controller.getSideboard().get(target.getFirstTarget(), game);
|
||||
if (card == null && alsoFromExile) {
|
||||
card = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
|
||||
if (reveal) {
|
||||
Cards revealCard = new CardsImpl();
|
||||
revealCard.add(card);
|
||||
controller.revealCards(sourceObject.getIdName(), revealCard, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,165 +1,165 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends ContinuousEffectImpl {
|
||||
|
||||
public enum LoseType {
|
||||
NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE_AND_PT
|
||||
}
|
||||
|
||||
protected Token token;
|
||||
protected String type;
|
||||
protected LoseType loseType; // what attributes are lost
|
||||
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration) {
|
||||
this(token, text, duration, LoseType.NONE);
|
||||
}
|
||||
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration, LoseType loseType) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.BecomeCreature);
|
||||
this.token = token;
|
||||
this.loseType = loseType;
|
||||
staticText = text;
|
||||
}
|
||||
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(final BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect effect) {
|
||||
super(effect);
|
||||
this.token = effect.token.copy();
|
||||
this.type = effect.type;
|
||||
this.loseType = effect.loseType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect copy() {
|
||||
return new BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
Permanent attachedPermanent = game.getPermanent(source.getSourceId());
|
||||
if (attachedPermanent != null) {
|
||||
Permanent permanentAttachedTo = game.getPermanent(attachedPermanent.getAttachedTo());
|
||||
if (permanentAttachedTo != null) {
|
||||
affectedObjectList.add(new MageObjectReference(permanentAttachedTo, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
boolean attachedExists = false;
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null) {
|
||||
for (MageObjectReference mageObjectReference : affectedObjectList) {
|
||||
Permanent permanentAttachedTo = mageObjectReference.getPermanent(game);
|
||||
if (permanentAttachedTo != null) {
|
||||
attachedExists = true;
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for (SuperType superType : token.getSuperType()) {
|
||||
permanentAttachedTo.addSuperType(superType);
|
||||
|
||||
}
|
||||
// card type
|
||||
switch (loseType) {
|
||||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
permanentAttachedTo.getCardType().clear();
|
||||
break;
|
||||
}
|
||||
for (CardType cardType : token.getCardType()) {
|
||||
permanentAttachedTo.addCardType(cardType);
|
||||
}
|
||||
|
||||
// sub type
|
||||
switch (loseType) {
|
||||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
case ABILITIES_SUBTYPE_AND_PT:
|
||||
permanentAttachedTo.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
break;
|
||||
}
|
||||
for (SubType subType : token.getSubtype(game)) {
|
||||
if (!permanentAttachedTo.hasSubtype(subType, game)) {
|
||||
permanentAttachedTo.getSubtype(game).add(subType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ColorChangingEffects_5:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
if (loseType == LoseType.ALL) {
|
||||
permanentAttachedTo.getColor(game).setBlack(false);
|
||||
permanentAttachedTo.getColor(game).setGreen(false);
|
||||
permanentAttachedTo.getColor(game).setBlue(false);
|
||||
permanentAttachedTo.getColor(game).setWhite(false);
|
||||
permanentAttachedTo.getColor(game).setRed(false);
|
||||
}
|
||||
if (token.getColor(game).hasColor()) {
|
||||
permanentAttachedTo.getColor(game).setColor(token.getColor(game));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
switch (loseType) {
|
||||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
case ABILITIES:
|
||||
case ABILITIES_SUBTYPE_AND_PT:
|
||||
permanentAttachedTo.removeAllAbilities(source.getSourceId(), game);
|
||||
break;
|
||||
}
|
||||
for (Ability ability : token.getAbilities()) {
|
||||
permanentAttachedTo.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanentAttachedTo.getPower().setValue(token.getPower().getValue());
|
||||
permanentAttachedTo.getToughness().setValue(token.getToughness().getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!attachedExists) {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.PTChangingEffects_7
|
||||
|| layer == Layer.AbilityAddingRemovingEffects_6
|
||||
|| layer == Layer.ColorChangingEffects_5
|
||||
|| layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
}
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.*;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.permanent.token.Token;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends ContinuousEffectImpl {
|
||||
|
||||
public enum LoseType {
|
||||
NONE, ALL, ALL_BUT_COLOR, ABILITIES, ABILITIES_SUBTYPE_AND_PT
|
||||
}
|
||||
|
||||
protected Token token;
|
||||
protected String type;
|
||||
protected LoseType loseType; // what attributes are lost
|
||||
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration) {
|
||||
this(token, text, duration, LoseType.NONE);
|
||||
}
|
||||
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(Token token, String text, Duration duration, LoseType loseType) {
|
||||
super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.BecomeCreature);
|
||||
this.token = token;
|
||||
this.loseType = loseType;
|
||||
staticText = text;
|
||||
}
|
||||
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(final BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect effect) {
|
||||
super(effect);
|
||||
this.token = effect.token.copy();
|
||||
this.type = effect.type;
|
||||
this.loseType = effect.loseType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect copy() {
|
||||
return new BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
Permanent attachedPermanent = game.getPermanent(source.getSourceId());
|
||||
if (attachedPermanent != null) {
|
||||
Permanent permanentAttachedTo = game.getPermanent(attachedPermanent.getAttachedTo());
|
||||
if (permanentAttachedTo != null) {
|
||||
affectedObjectList.add(new MageObjectReference(permanentAttachedTo, game));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
boolean attachedExists = false;
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null) {
|
||||
for (MageObjectReference mageObjectReference : affectedObjectList) {
|
||||
Permanent permanentAttachedTo = mageObjectReference.getPermanent(game);
|
||||
if (permanentAttachedTo != null) {
|
||||
attachedExists = true;
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for (SuperType superType : token.getSuperType()) {
|
||||
permanentAttachedTo.addSuperType(superType);
|
||||
|
||||
}
|
||||
// card type
|
||||
switch (loseType) {
|
||||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
permanentAttachedTo.getCardType().clear();
|
||||
break;
|
||||
}
|
||||
for (CardType cardType : token.getCardType()) {
|
||||
permanentAttachedTo.addCardType(cardType);
|
||||
}
|
||||
|
||||
// sub type
|
||||
switch (loseType) {
|
||||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
case ABILITIES_SUBTYPE_AND_PT:
|
||||
permanentAttachedTo.getSubtype(game).retainAll(SubType.getLandTypes());
|
||||
break;
|
||||
}
|
||||
for (SubType subType : token.getSubtype(game)) {
|
||||
if (!permanentAttachedTo.hasSubtype(subType, game)) {
|
||||
permanentAttachedTo.getSubtype(game).add(subType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ColorChangingEffects_5:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
if (loseType == LoseType.ALL) {
|
||||
permanentAttachedTo.getColor(game).setBlack(false);
|
||||
permanentAttachedTo.getColor(game).setGreen(false);
|
||||
permanentAttachedTo.getColor(game).setBlue(false);
|
||||
permanentAttachedTo.getColor(game).setWhite(false);
|
||||
permanentAttachedTo.getColor(game).setRed(false);
|
||||
}
|
||||
if (token.getColor(game).hasColor()) {
|
||||
permanentAttachedTo.getColor(game).setColor(token.getColor(game));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
switch (loseType) {
|
||||
case ALL:
|
||||
case ALL_BUT_COLOR:
|
||||
case ABILITIES:
|
||||
case ABILITIES_SUBTYPE_AND_PT:
|
||||
permanentAttachedTo.removeAllAbilities(source.getSourceId(), game);
|
||||
break;
|
||||
}
|
||||
for (Ability ability : token.getAbilities()) {
|
||||
permanentAttachedTo.addAbility(ability, source.getSourceId(), game);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case PTChangingEffects_7:
|
||||
if (sublayer == SubLayer.SetPT_7b) {
|
||||
permanentAttachedTo.getPower().setValue(token.getPower().getValue());
|
||||
permanentAttachedTo.getToughness().setValue(token.getToughness().getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!attachedExists) {
|
||||
discard();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return layer == Layer.PTChangingEffects_7
|
||||
|| layer == Layer.AbilityAddingRemovingEffects_6
|
||||
|| layer == Layer.ColorChangingEffects_5
|
||||
|| layer == Layer.TypeChangingEffects_4;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,79 +1,79 @@
|
|||
/*
|
||||
* 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 mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
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.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class BecomesEnchantmentSourceEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
public BecomesEnchantmentSourceEffect() {
|
||||
super(Duration.Custom, Outcome.AddAbility);
|
||||
staticText = "{this} becomes an Enchantment";
|
||||
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
|
||||
|
||||
}
|
||||
|
||||
public BecomesEnchantmentSourceEffect(final BecomesEnchantmentSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesEnchantmentSourceEffect copy() {
|
||||
return new BecomesEnchantmentSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getCardType().clear();
|
||||
permanent.getSubtype(game).clear();
|
||||
if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
permanent.getCardType().add(CardType.ENCHANTMENT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
this.discard();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return Layer.TypeChangingEffects_4 == layer;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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 mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
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.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class BecomesEnchantmentSourceEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
public BecomesEnchantmentSourceEffect() {
|
||||
super(Duration.Custom, Outcome.AddAbility);
|
||||
staticText = "{this} becomes an Enchantment";
|
||||
dependencyTypes.add(DependencyType.EnchantmentAddingRemoving);
|
||||
|
||||
}
|
||||
|
||||
public BecomesEnchantmentSourceEffect(final BecomesEnchantmentSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BecomesEnchantmentSourceEffect copy() {
|
||||
return new BecomesEnchantmentSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Ability source, Game game) {
|
||||
super.init(source, game);
|
||||
affectedObjectList.add(new MageObjectReference(source.getSourceId(), game));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||
Permanent permanent = affectedObjectList.get(0).getPermanent(game);
|
||||
if (permanent != null) {
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
permanent.getCardType().clear();
|
||||
permanent.getSubtype(game).clear();
|
||||
if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
|
||||
permanent.getCardType().add(CardType.ENCHANTMENT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
this.discard();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLayer(Layer layer) {
|
||||
return Layer.TypeChangingEffects_4 == layer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
/*
|
||||
* 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 mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
|
||||
|
||||
SubType subtype = null;
|
||||
|
||||
public GainAbilityAllOfChosenSubtypeEffect(Ability ability, Duration duration, FilterPermanent filter) {
|
||||
super(ability, duration, filter);
|
||||
}
|
||||
|
||||
public GainAbilityAllOfChosenSubtypeEffect(final GainAbilityAllOfChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
this.subtype = effect.subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainAbilityAllOfChosenSubtypeEffect copy() {
|
||||
return new GainAbilityAllOfChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
|
||||
if (subtype != null) {
|
||||
return permanent.hasSubtype(subtype, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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 mage.abilities.Ability;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.SubType;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
|
||||
|
||||
SubType subtype = null;
|
||||
|
||||
public GainAbilityAllOfChosenSubtypeEffect(Ability ability, Duration duration, FilterPermanent filter) {
|
||||
super(ability, duration, filter);
|
||||
}
|
||||
|
||||
public GainAbilityAllOfChosenSubtypeEffect(final GainAbilityAllOfChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
this.subtype = effect.subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainAbilityAllOfChosenSubtypeEffect copy() {
|
||||
return new GainAbilityAllOfChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
|
||||
if (subtype != null) {
|
||||
return permanent.hasSubtype(subtype, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setRuntimeData(Ability source, Game game) {
|
||||
subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,83 +1,83 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final Ability ability;
|
||||
private final FilterCard filter;
|
||||
|
||||
public GainAbilityControlledSpellsEffect(Ability ability, FilterCard filter) {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.ability = ability;
|
||||
this.filter = filter;
|
||||
staticText = filter.getMessage() + " you cast have " + ability.getRule() + '.';
|
||||
}
|
||||
|
||||
public GainAbilityControlledSpellsEffect(final GainAbilityControlledSpellsEffect effect) {
|
||||
super(effect);
|
||||
this.ability = effect.ability;
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainAbilityControlledSpellsEffect copy() {
|
||||
return new GainAbilityControlledSpellsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (card.isOwnedBy(source.getControllerId()) && filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (Card card : player.getLibrary().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (Card card : player.getHand().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (Card card : player.getGraveyard().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
// only spells cast, so no copies of spells
|
||||
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) {
|
||||
Card card = game.getCard(stackObject.getSourceId());
|
||||
if (card != null && filter.match(card, game)) {
|
||||
if (!card.hasAbility(ability, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.game.stack.Spell;
|
||||
import mage.game.stack.StackObject;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class GainAbilityControlledSpellsEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final Ability ability;
|
||||
private final FilterCard filter;
|
||||
|
||||
public GainAbilityControlledSpellsEffect(Ability ability, FilterCard filter) {
|
||||
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
|
||||
this.ability = ability;
|
||||
this.filter = filter;
|
||||
staticText = filter.getMessage() + " you cast have " + ability.getRule() + '.';
|
||||
}
|
||||
|
||||
public GainAbilityControlledSpellsEffect(final GainAbilityControlledSpellsEffect effect) {
|
||||
super(effect);
|
||||
this.ability = effect.ability;
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GainAbilityControlledSpellsEffect copy() {
|
||||
return new GainAbilityControlledSpellsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (player != null && permanent != null) {
|
||||
for (Card card : game.getExile().getAllCards(game)) {
|
||||
if (card.isOwnedBy(source.getControllerId()) && filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (Card card : player.getLibrary().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (Card card : player.getHand().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (Card card : player.getGraveyard().getCards(game)) {
|
||||
if (filter.match(card, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
for (StackObject stackObject : game.getStack()) {
|
||||
// only spells cast, so no copies of spells
|
||||
if ((stackObject instanceof Spell) && !stackObject.isCopy() && stackObject.isControlledBy(source.getControllerId())) {
|
||||
Card card = game.getCard(stackObject.getSourceId());
|
||||
if (card != null && filter.match(card, game)) {
|
||||
if (!card.hasAbility(ability, game)) {
|
||||
game.getState().addOtherAbility(card, ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +1,57 @@
|
|||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SetPowerToughnessEnchantedEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final int power;
|
||||
private final int toughness;
|
||||
|
||||
public SetPowerToughnessEnchantedEffect() {
|
||||
this(0, 2);
|
||||
}
|
||||
|
||||
public SetPowerToughnessEnchantedEffect(int power, int toughness) {
|
||||
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
|
||||
staticText = "Enchanted creature has base power and toughness " + power + "/" + toughness;
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
public SetPowerToughnessEnchantedEffect(final SetPowerToughnessEnchantedEffect effect) {
|
||||
super(effect);
|
||||
this.power = effect.power;
|
||||
this.toughness = effect.toughness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPowerToughnessEnchantedEffect copy() {
|
||||
return new SetPowerToughnessEnchantedEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (enchanted != null) {
|
||||
enchanted.getPower().setValue(power);
|
||||
enchanted.getToughness().setValue(toughness);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
package mage.abilities.effects.common.continuous;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubLayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class SetPowerToughnessEnchantedEffect extends ContinuousEffectImpl {
|
||||
|
||||
private final int power;
|
||||
private final int toughness;
|
||||
|
||||
public SetPowerToughnessEnchantedEffect() {
|
||||
this(0, 2);
|
||||
}
|
||||
|
||||
public SetPowerToughnessEnchantedEffect(int power, int toughness) {
|
||||
super(Duration.WhileOnBattlefield, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
|
||||
staticText = "Enchanted creature has base power and toughness " + power + "/" + toughness;
|
||||
this.power = power;
|
||||
this.toughness = toughness;
|
||||
}
|
||||
|
||||
public SetPowerToughnessEnchantedEffect(final SetPowerToughnessEnchantedEffect effect) {
|
||||
super(effect);
|
||||
this.power = effect.power;
|
||||
this.toughness = effect.toughness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetPowerToughnessEnchantedEffect copy() {
|
||||
return new SetPowerToughnessEnchantedEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
|
||||
if (enchanted != null) {
|
||||
enchanted.getPower().setValue(power);
|
||||
enchanted.getToughness().setValue(toughness);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
/*
|
||||
* 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.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class AbilitiesCostReductionControllerEffect extends CostModificationEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.activatedAbility = activatedAbility;
|
||||
staticText = activatedAbilityName + " costs you pay cost {1} less";
|
||||
}
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(AbilitiesCostReductionControllerEffect effect) {
|
||||
super(effect);
|
||||
this.activatedAbility = effect.activatedAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbilitiesCostReductionControllerEffect copy() {
|
||||
return new AbilitiesCostReductionControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
CardUtil.reduceCost(abilityToModify, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify.isControlledBy(source.getControllerId())
|
||||
&& activatedAbility.isInstance(abilityToModify);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class AbilitiesCostReductionControllerEffect extends CostModificationEffectImpl {
|
||||
|
||||
private Class activatedAbility;
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(Class activatedAbility, String activatedAbilityName) {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
|
||||
this.activatedAbility = activatedAbility;
|
||||
staticText = activatedAbilityName + " costs you pay cost {1} less";
|
||||
}
|
||||
|
||||
public AbilitiesCostReductionControllerEffect(AbilitiesCostReductionControllerEffect effect) {
|
||||
super(effect);
|
||||
this.activatedAbility = effect.activatedAbility;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbilitiesCostReductionControllerEffect copy() {
|
||||
return new AbilitiesCostReductionControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
CardUtil.reduceCost(abilityToModify, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
return abilityToModify.isControlledBy(source.getControllerId())
|
||||
&& activatedAbility.isInstance(abilityToModify);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,78 +1,78 @@
|
|||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class MoveCountersTargetsEffect extends OneShotEffect {
|
||||
|
||||
private final CounterType counterType;
|
||||
private final int amount;
|
||||
|
||||
public MoveCountersTargetsEffect(CounterType counterType, int amount) {
|
||||
super(Outcome.Detriment);
|
||||
this.counterType = counterType;
|
||||
this.amount = amount;
|
||||
|
||||
}
|
||||
|
||||
public MoveCountersTargetsEffect(final MoveCountersTargetsEffect effect) {
|
||||
super(effect);
|
||||
this.counterType = effect.counterType;
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoveCountersTargetsEffect copy() {
|
||||
return new MoveCountersTargetsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent removeTargetCreature = game.getPermanent(targetPointer.getTargets(game, source).get(0));
|
||||
Permanent addTargetCreature = game.getPermanent(targetPointer.getTargets(game, source).get(1));
|
||||
if (removeTargetCreature != null && addTargetCreature != null && removeTargetCreature.getCounters(game).getCount(counterType) >= amount) {
|
||||
removeTargetCreature.removeCounters(counterType.createInstance(amount), game);
|
||||
addTargetCreature.addCounters(counterType.createInstance(amount), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("Moved " + amount + ' ' + counterType.getName() + " counter" + (amount > 1 ? "s" : "") + " from " + removeTargetCreature.getLogName() + " to " + addTargetCreature.getLogName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("move ");
|
||||
if (amount > 1) {
|
||||
sb.append(amount);
|
||||
} else {
|
||||
sb.append('a');
|
||||
}
|
||||
sb.append(' ');
|
||||
sb.append(counterType.getName());
|
||||
sb.append(" counter");
|
||||
if (amount > 1) {
|
||||
sb.append("s ");
|
||||
} else {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append("from one target creature to another target creature");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common.counter;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class MoveCountersTargetsEffect extends OneShotEffect {
|
||||
|
||||
private final CounterType counterType;
|
||||
private final int amount;
|
||||
|
||||
public MoveCountersTargetsEffect(CounterType counterType, int amount) {
|
||||
super(Outcome.Detriment);
|
||||
this.counterType = counterType;
|
||||
this.amount = amount;
|
||||
|
||||
}
|
||||
|
||||
public MoveCountersTargetsEffect(final MoveCountersTargetsEffect effect) {
|
||||
super(effect);
|
||||
this.counterType = effect.counterType;
|
||||
this.amount = effect.amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MoveCountersTargetsEffect copy() {
|
||||
return new MoveCountersTargetsEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent removeTargetCreature = game.getPermanent(targetPointer.getTargets(game, source).get(0));
|
||||
Permanent addTargetCreature = game.getPermanent(targetPointer.getTargets(game, source).get(1));
|
||||
if (removeTargetCreature != null && addTargetCreature != null && removeTargetCreature.getCounters(game).getCount(counterType) >= amount) {
|
||||
removeTargetCreature.removeCounters(counterType.createInstance(amount), game);
|
||||
addTargetCreature.addCounters(counterType.createInstance(amount), source, game);
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers("Moved " + amount + ' ' + counterType.getName() + " counter" + (amount > 1 ? "s" : "") + " from " + removeTargetCreature.getLogName() + " to " + addTargetCreature.getLogName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Mode mode) {
|
||||
if (!staticText.isEmpty()) {
|
||||
return staticText;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder("move ");
|
||||
if (amount > 1) {
|
||||
sb.append(amount);
|
||||
} else {
|
||||
sb.append('a');
|
||||
}
|
||||
sb.append(' ');
|
||||
sb.append(counterType.getName());
|
||||
sb.append(" counter");
|
||||
if (amount > 1) {
|
||||
sb.append("s ");
|
||||
} else {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append("from one target creature to another target creature");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
|
||||
package mage.abilities.effects.common.enterAttribute;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* IMPORTANT: This only adds the chosen subtype while the source permanent is entering the battlefield.
|
||||
* You should also use @link{mage.abilities.effects.common.continuous.AddChosenSubtypeEffect} to make the subtype persist.
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class EnterAttributeAddChosenSubtypeEffect extends OneShotEffect {
|
||||
|
||||
public EnterAttributeAddChosenSubtypeEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "{this} is the chosen type in addition to its other types";
|
||||
}
|
||||
|
||||
public EnterAttributeAddChosenSubtypeEffect(final EnterAttributeAddChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterAttributeAddChosenSubtypeEffect copy() {
|
||||
return new EnterAttributeAddChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (permanent != null && subtype != null) {
|
||||
if (!permanent.getSubtype(game).contains(subtype)) {
|
||||
permanent.getSubtype(game).add(subtype);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common.enterAttribute;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* IMPORTANT: This only adds the chosen subtype while the source permanent is entering the battlefield.
|
||||
* You should also use @link{mage.abilities.effects.common.continuous.AddChosenSubtypeEffect} to make the subtype persist.
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class EnterAttributeAddChosenSubtypeEffect extends OneShotEffect {
|
||||
|
||||
public EnterAttributeAddChosenSubtypeEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "{this} is the chosen type in addition to its other types";
|
||||
}
|
||||
|
||||
public EnterAttributeAddChosenSubtypeEffect(final EnterAttributeAddChosenSubtypeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnterAttributeAddChosenSubtypeEffect copy() {
|
||||
return new EnterAttributeAddChosenSubtypeEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (permanent != null && subtype != null) {
|
||||
if (!permanent.getSubtype(game).contains(subtype)) {
|
||||
permanent.getSubtype(game).add(subtype);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
|
||||
package mage.abilities.effects.common.replacement;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CreateTwiceThatManyTokensEffect extends ReplacementEffectImpl {
|
||||
|
||||
public CreateTwiceThatManyTokensEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Copy);
|
||||
staticText = "If an effect would create one or more tokens under your control, it creates twice that many of those tokens instead";
|
||||
}
|
||||
|
||||
public CreateTwiceThatManyTokensEffect(final CreateTwiceThatManyTokensEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateTwiceThatManyTokensEffect copy() {
|
||||
return new CreateTwiceThatManyTokensEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CREATE_TOKEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getPlayerId().equals(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(event.getAmount() * 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common.replacement;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CreateTwiceThatManyTokensEffect extends ReplacementEffectImpl {
|
||||
|
||||
public CreateTwiceThatManyTokensEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Copy);
|
||||
staticText = "If an effect would create one or more tokens under your control, it creates twice that many of those tokens instead";
|
||||
}
|
||||
|
||||
public CreateTwiceThatManyTokensEffect(final CreateTwiceThatManyTokensEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateTwiceThatManyTokensEffect copy() {
|
||||
return new CreateTwiceThatManyTokensEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.CREATE_TOKEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
return event.getPlayerId().equals(source.getControllerId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
event.setAmount(event.getAmount() * 2);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,72 +1,72 @@
|
|||
/*
|
||||
* 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.replacement;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DiesReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private final MageObjectReference objectRef;
|
||||
|
||||
public DiesReplacementEffect(MageObjectReference objectRef, Duration duration) {
|
||||
super(duration, Outcome.Exile);
|
||||
this.objectRef = objectRef;
|
||||
staticText = "If that creature would die " + (duration == Duration.EndOfTurn ? "this turn" : "") + ", exile it instead";
|
||||
}
|
||||
|
||||
public DiesReplacementEffect(final DiesReplacementEffect effect) {
|
||||
super(effect);
|
||||
this.objectRef = effect.objectRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiesReplacementEffect copy() {
|
||||
return new DiesReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && permanent != null) {
|
||||
return controller.moveCards(permanent, Zone.EXILED, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
return zce.isDiesEvent()
|
||||
&& objectRef.equals(new MageObjectReference(zce.getTarget(), game));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* 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.replacement;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class DiesReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
private final MageObjectReference objectRef;
|
||||
|
||||
public DiesReplacementEffect(MageObjectReference objectRef, Duration duration) {
|
||||
super(duration, Outcome.Exile);
|
||||
this.objectRef = objectRef;
|
||||
staticText = "If that creature would die " + (duration == Duration.EndOfTurn ? "this turn" : "") + ", exile it instead";
|
||||
}
|
||||
|
||||
public DiesReplacementEffect(final DiesReplacementEffect effect) {
|
||||
super(effect);
|
||||
this.objectRef = effect.objectRef;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiesReplacementEffect copy() {
|
||||
return new DiesReplacementEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Permanent permanent = ((ZoneChangeEvent) event).getTarget();
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null && permanent != null) {
|
||||
return controller.moveCards(permanent, Zone.EXILED, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == EventType.ZONE_CHANGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
return zce.isDiesEvent()
|
||||
&& objectRef.equals(new MageObjectReference(zce.getTarget(), game));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,92 +1,92 @@
|
|||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SearchLibraryGraveyardPutOntoBattlefieldEffect extends OneShotEffect {
|
||||
|
||||
private FilterCard filter;
|
||||
private boolean forceToSearchBoth;
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(FilterCard filter) {
|
||||
this(filter, false);
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(FilterCard filter, boolean forceToSearchBoth) {
|
||||
this(filter, forceToSearchBoth, false);
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(FilterCard filter, boolean forceToSearchBoth, boolean youMay) {
|
||||
super(Outcome.Benefit);
|
||||
this.filter = filter;
|
||||
this.forceToSearchBoth = forceToSearchBoth;
|
||||
staticText = (youMay ? "You may " : "") + "search your library and" + (forceToSearchBoth ? "" : "/or") + " graveyard for a " + filter.getMessage()
|
||||
+ " and put it onto the battlefield. " + (forceToSearchBoth ? "Then shuffle your library" : "If you search your library this way, shuffle it");
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(final SearchLibraryGraveyardPutOntoBattlefieldEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.forceToSearchBoth = effect.forceToSearchBoth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect copy() {
|
||||
return new SearchLibraryGraveyardPutOntoBattlefieldEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Card cardFound = null;
|
||||
boolean needShuffle = false;
|
||||
if (controller != null && sourceObject != null) {
|
||||
if (forceToSearchBoth || controller.chooseUse(outcome, "Search your library for a " + filter.getMessage() + '?', source, game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
|
||||
target.clearChosen();
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
needShuffle = true;
|
||||
}
|
||||
|
||||
if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a " + filter.getMessage() + '?', source, game)) {
|
||||
TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true);
|
||||
target.clearChosen();
|
||||
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cardFound != null) {
|
||||
controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
|
||||
if (needShuffle) {
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
/**
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SearchLibraryGraveyardPutOntoBattlefieldEffect extends OneShotEffect {
|
||||
|
||||
private FilterCard filter;
|
||||
private boolean forceToSearchBoth;
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(FilterCard filter) {
|
||||
this(filter, false);
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(FilterCard filter, boolean forceToSearchBoth) {
|
||||
this(filter, forceToSearchBoth, false);
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(FilterCard filter, boolean forceToSearchBoth, boolean youMay) {
|
||||
super(Outcome.Benefit);
|
||||
this.filter = filter;
|
||||
this.forceToSearchBoth = forceToSearchBoth;
|
||||
staticText = (youMay ? "You may " : "") + "search your library and" + (forceToSearchBoth ? "" : "/or") + " graveyard for a " + filter.getMessage()
|
||||
+ " and put it onto the battlefield. " + (forceToSearchBoth ? "Then shuffle your library" : "If you search your library this way, shuffle it");
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect(final SearchLibraryGraveyardPutOntoBattlefieldEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
this.forceToSearchBoth = effect.forceToSearchBoth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchLibraryGraveyardPutOntoBattlefieldEffect copy() {
|
||||
return new SearchLibraryGraveyardPutOntoBattlefieldEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Card cardFound = null;
|
||||
boolean needShuffle = false;
|
||||
if (controller != null && sourceObject != null) {
|
||||
if (forceToSearchBoth || controller.chooseUse(outcome, "Search your library for a " + filter.getMessage() + '?', source, game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
|
||||
target.clearChosen();
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
needShuffle = true;
|
||||
}
|
||||
|
||||
if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a " + filter.getMessage() + '?', source, game)) {
|
||||
TargetCard target = new TargetCardInYourGraveyard(0, 1, filter, true);
|
||||
target.clearChosen();
|
||||
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cardFound != null) {
|
||||
controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
|
||||
if (needShuffle) {
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,87 +1,87 @@
|
|||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author antoni-g
|
||||
*/
|
||||
public class SearchLibraryGraveyardWithLessCMCPutIntoPlay extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay(FilterCard filter) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.filter = filter;
|
||||
staticText = "Search your library or graveyard for a " + filter.getMessage() + " with converted mana cost X or less, put it onto the battlefield, then shuffle your library";
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay(final SearchLibraryGraveyardWithLessCMCPutIntoPlay effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay copy() {
|
||||
return new SearchLibraryGraveyardWithLessCMCPutIntoPlay(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Card cardFound = null;
|
||||
if (controller != null && sourceObject != null) {
|
||||
// create x cost filter
|
||||
FilterCard advancedFilter = filter.copy(); // never change static objects so copy the object here before
|
||||
advancedFilter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||
|
||||
if (controller.chooseUse(outcome, "Search your library for a " + filter.getMessage() + " with CMC X or less" + '?', source, game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(advancedFilter);
|
||||
target.clearChosen();
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
|
||||
if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a " + filter.getMessage() + " with CMC X or less" + '?', source, game)) {
|
||||
TargetCard target = new TargetCard(0, 1, Zone.GRAVEYARD, advancedFilter);
|
||||
target.clearChosen();
|
||||
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cardFound != null) {
|
||||
controller.revealCards(sourceObject.getIdName(), new CardsImpl(cardFound), game);
|
||||
controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author antoni-g
|
||||
*/
|
||||
public class SearchLibraryGraveyardWithLessCMCPutIntoPlay extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay(FilterCard filter) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.filter = filter;
|
||||
staticText = "Search your library or graveyard for a " + filter.getMessage() + " with converted mana cost X or less, put it onto the battlefield, then shuffle your library";
|
||||
}
|
||||
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay(final SearchLibraryGraveyardWithLessCMCPutIntoPlay effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchLibraryGraveyardWithLessCMCPutIntoPlay copy() {
|
||||
return new SearchLibraryGraveyardWithLessCMCPutIntoPlay(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
Card cardFound = null;
|
||||
if (controller != null && sourceObject != null) {
|
||||
// create x cost filter
|
||||
FilterCard advancedFilter = filter.copy(); // never change static objects so copy the object here before
|
||||
advancedFilter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||
|
||||
if (controller.chooseUse(outcome, "Search your library for a " + filter.getMessage() + " with CMC X or less" + '?', source, game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(advancedFilter);
|
||||
target.clearChosen();
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
|
||||
if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a " + filter.getMessage() + " with CMC X or less" + '?', source, game)) {
|
||||
TargetCard target = new TargetCard(0, 1, Zone.GRAVEYARD, advancedFilter);
|
||||
target.clearChosen();
|
||||
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
cardFound = game.getCard(target.getFirstTarget());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cardFound != null) {
|
||||
controller.revealCards(sourceObject.getIdName(), new CardsImpl(cardFound), game);
|
||||
controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,65 +1,65 @@
|
|||
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SearchLibraryWithLessCMCPutInPlayEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect(FilterCard filter) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.filter = filter;
|
||||
staticText = "Search your library for a " + filter.getMessage() + " with converted mana cost X or less, put it onto the battlefield, then shuffle your library";
|
||||
}
|
||||
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect(final SearchLibraryWithLessCMCPutInPlayEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
FilterCard advancedFilter = filter.copy(); // never change static objects so copy the object here before
|
||||
advancedFilter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(advancedFilter);
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect copy() {
|
||||
return new SearchLibraryWithLessCMCPutInPlayEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package mage.abilities.effects.common.search;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Styxo
|
||||
*/
|
||||
public class SearchLibraryWithLessCMCPutInPlayEffect extends OneShotEffect {
|
||||
|
||||
private final FilterCard filter;
|
||||
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect() {
|
||||
this(new FilterCard());
|
||||
}
|
||||
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect(FilterCard filter) {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.filter = filter;
|
||||
staticText = "Search your library for a " + filter.getMessage() + " with converted mana cost X or less, put it onto the battlefield, then shuffle your library";
|
||||
}
|
||||
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect(final SearchLibraryWithLessCMCPutInPlayEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
FilterCard advancedFilter = filter.copy(); // never change static objects so copy the object here before
|
||||
advancedFilter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(advancedFilter);
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchLibraryWithLessCMCPutInPlayEffect copy() {
|
||||
return new SearchLibraryWithLessCMCPutInPlayEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +1,38 @@
|
|||
|
||||
package mage.abilities.effects.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ExploreTargetEffect extends OneShotEffect {
|
||||
|
||||
public ExploreTargetEffect() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public ExploreTargetEffect(boolean showAbilityHint) {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = ExploreSourceEffect.getRuleText(showAbilityHint);
|
||||
}
|
||||
|
||||
public ExploreTargetEffect(final ExploreTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExploreTargetEffect copy() {
|
||||
return new ExploreTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return ExploreSourceEffect.explorePermanent(game, getTargetPointer().getFirst(game, source), source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package mage.abilities.effects.keyword;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ExploreTargetEffect extends OneShotEffect {
|
||||
|
||||
public ExploreTargetEffect() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
public ExploreTargetEffect(boolean showAbilityHint) {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = ExploreSourceEffect.getRuleText(showAbilityHint);
|
||||
}
|
||||
|
||||
public ExploreTargetEffect(final ExploreTargetEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExploreTargetEffect copy() {
|
||||
return new ExploreTargetEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return ExploreSourceEffect.explorePermanent(game, getTargetPointer().getFirst(game, source), source);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,61 @@
|
|||
/*
|
||||
* 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.mana;
|
||||
|
||||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.mana.builder.ConditionalManaBuilder;
|
||||
import mage.choices.ManaChoice;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class AddConditionalManaOfTwoDifferentColorsEffect extends ManaEffect {
|
||||
|
||||
private final ConditionalManaBuilder manaBuilder;
|
||||
|
||||
public AddConditionalManaOfTwoDifferentColorsEffect(ConditionalManaBuilder manaBuilder) {
|
||||
super();
|
||||
this.manaBuilder = manaBuilder;
|
||||
staticText = "Add two mana of different colors. " + manaBuilder.getRule();
|
||||
}
|
||||
|
||||
private AddConditionalManaOfTwoDifferentColorsEffect(final AddConditionalManaOfTwoDifferentColorsEffect effect) {
|
||||
super(effect);
|
||||
this.manaBuilder = effect.manaBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.AnyMana(2));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
Mana mana = new ConditionalMana(manaBuilder.setMana(
|
||||
ManaChoice.chooseTwoDifferentColors(
|
||||
player, game), source, game).build());
|
||||
return mana;
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConditionalManaOfTwoDifferentColorsEffect copy() {
|
||||
return new AddConditionalManaOfTwoDifferentColorsEffect(this);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.mana;
|
||||
|
||||
import mage.ConditionalMana;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.abilities.mana.builder.ConditionalManaBuilder;
|
||||
import mage.choices.ManaChoice;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public class AddConditionalManaOfTwoDifferentColorsEffect extends ManaEffect {
|
||||
|
||||
private final ConditionalManaBuilder manaBuilder;
|
||||
|
||||
public AddConditionalManaOfTwoDifferentColorsEffect(ConditionalManaBuilder manaBuilder) {
|
||||
super();
|
||||
this.manaBuilder = manaBuilder;
|
||||
staticText = "Add two mana of different colors. " + manaBuilder.getRule();
|
||||
}
|
||||
|
||||
private AddConditionalManaOfTwoDifferentColorsEffect(final AddConditionalManaOfTwoDifferentColorsEffect effect) {
|
||||
super(effect);
|
||||
this.manaBuilder = effect.manaBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.AnyMana(2));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
Mana mana = new ConditionalMana(manaBuilder.setMana(
|
||||
ManaChoice.chooseTwoDifferentColors(
|
||||
player, game), source, game).build());
|
||||
return mana;
|
||||
}
|
||||
return new Mana();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConditionalManaOfTwoDifferentColorsEffect copy() {
|
||||
return new AddConditionalManaOfTwoDifferentColorsEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
package mage.abilities.effects.mana;
|
||||
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.choices.ManaChoice;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AddManaOfTwoDifferentColorsEffect extends ManaEffect {
|
||||
|
||||
public AddManaOfTwoDifferentColorsEffect() {
|
||||
super();
|
||||
staticText = "Add two mana of different colors.";
|
||||
}
|
||||
|
||||
private AddManaOfTwoDifferentColorsEffect(final AddManaOfTwoDifferentColorsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.AnyMana(2));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseTwoDifferentColors(player, game);
|
||||
} else {
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddManaOfTwoDifferentColorsEffect copy() {
|
||||
return new AddManaOfTwoDifferentColorsEffect(this);
|
||||
}
|
||||
}
|
||||
package mage.abilities.effects.mana;
|
||||
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.common.ManaEffect;
|
||||
import mage.choices.ManaChoice;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AddManaOfTwoDifferentColorsEffect extends ManaEffect {
|
||||
|
||||
public AddManaOfTwoDifferentColorsEffect() {
|
||||
super();
|
||||
staticText = "Add two mana of different colors.";
|
||||
}
|
||||
|
||||
private AddManaOfTwoDifferentColorsEffect(final AddManaOfTwoDifferentColorsEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Mana> getNetMana(Game game, Ability source) {
|
||||
List<Mana> netMana = new ArrayList<>();
|
||||
netMana.add(Mana.AnyMana(2));
|
||||
return netMana;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mana produceMana(Game game, Ability source) {
|
||||
if (game != null) {
|
||||
Player player = getPlayer(game, source);
|
||||
return ManaChoice.chooseTwoDifferentColors(player, game);
|
||||
} else {
|
||||
return new Mana();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddManaOfTwoDifferentColorsEffect copy() {
|
||||
return new AddManaOfTwoDifferentColorsEffect(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue