mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
refactored some zone change handling
This commit is contained in:
parent
53cadd8ce9
commit
ae3ff96e11
8 changed files with 248 additions and 240 deletions
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
|
@ -18,9 +16,11 @@ import mage.constants.SubType;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author fireshoes
|
||||
*/
|
||||
public final class AethergeodeMiner extends CardImpl {
|
||||
|
@ -37,7 +37,7 @@ public final class AethergeodeMiner extends CardImpl {
|
|||
this.addAbility(new AttacksTriggeredAbility(new GetEnergyCountersControllerEffect(2), false));
|
||||
|
||||
// Pay {E}{E}: Exile Aethergeode Miner, then return it to the battlefield under its owner's control.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AethergeodeMinerEffect(), new PayEnergyCost(2)));
|
||||
this.addAbility(new SimpleActivatedAbility(new AethergeodeMinerEffect(), new PayEnergyCost(2)));
|
||||
}
|
||||
|
||||
private AethergeodeMiner(final AethergeodeMiner card) {
|
||||
|
@ -52,12 +52,12 @@ public final class AethergeodeMiner extends CardImpl {
|
|||
|
||||
class AethergeodeMinerEffect extends OneShotEffect {
|
||||
|
||||
public AethergeodeMinerEffect() {
|
||||
AethergeodeMinerEffect() {
|
||||
super(Outcome.Neutral);
|
||||
this.staticText = "Exile {this}, then return it to the battlefield under its owner's control";
|
||||
this.staticText = "exile {this}, then return it to the battlefield under its owner's control";
|
||||
}
|
||||
|
||||
public AethergeodeMinerEffect(final AethergeodeMinerEffect effect) {
|
||||
private AethergeodeMinerEffect(final AethergeodeMinerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -68,15 +68,14 @@ class AethergeodeMinerEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (permanent.moveToExile(source.getSourceId(), "Aethergeode Miner", source, game)) {
|
||||
Card card = game.getExile().getCard(source.getSourceId(), game);
|
||||
if (card != null) {
|
||||
return card.moveToZone(Zone.BATTLEFIELD, source, game, false);
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = permanent.getMainCard();
|
||||
player.moveCards(permanent, Zone.EXILED, source, game);
|
||||
player.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,25 @@
|
|||
package mage.cards.a;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileSpellEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -31,13 +32,12 @@ public final class AllHallowsEve extends CardImpl {
|
|||
|
||||
// Exile All Hallow's Eve with two scream counters on it.
|
||||
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
|
||||
Effect effect = new AddCountersSourceEffect(CounterType.SCREAM.createInstance(), StaticValue.get(2), true, true);
|
||||
effect.setText("with 2 scream counters on it");
|
||||
this.getSpellAbility().addEffect(effect);
|
||||
this.getSpellAbility().addEffect(new AddCountersSourceEffect(
|
||||
CounterType.SCREAM.createInstance(), StaticValue.get(2), true, true
|
||||
).setText("with 2 scream counters on it"));
|
||||
|
||||
// At the beginning of your upkeep, if All Hallow's Eve is exiled with a scream counter on it, remove a scream counter from it. If there are no more scream counters on it, put it into your graveyard and each player returns all creature cards from their graveyard to the battlefield.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.EXILED, new AllHallowsEveEffect(), TargetController.YOU, false));
|
||||
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(new BeginningOfUpkeepTriggeredAbility(Zone.EXILED, new AllHallowsEveEffect(), TargetController.YOU, false), AllHallowsEveCondition.instance, "At the beginning of your upkeep, if {this} is exiled with a scream counter on it, remove a scream counter from it. If there are no more scream counters on it, put it into your graveyard and each player returns all creature cards from their graveyard to the battlefield."));
|
||||
}
|
||||
|
||||
private AllHallowsEve(final AllHallowsEve card) {
|
||||
|
@ -50,14 +50,26 @@ public final class AllHallowsEve extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
enum AllHallowsEveCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
|
||||
return sourceObject != null
|
||||
&& game.getState().getZone(source.getSourceId()) == Zone.EXILED
|
||||
&& sourceObject instanceof Card
|
||||
&& ((Card) sourceObject).getMainCard().getCounters(game).getCount(CounterType.SCREAM) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
class AllHallowsEveEffect extends OneShotEffect {
|
||||
|
||||
public AllHallowsEveEffect() {
|
||||
AllHallowsEveEffect() {
|
||||
super(Outcome.PutCreatureInPlay);
|
||||
this.staticText = "if {this} is exiled with a scream counter on it, remove a scream counter from it. If there are no more scream counters on it, put it into your graveyard and each player returns all creature cards from their graveyard to the battlefield";
|
||||
}
|
||||
|
||||
public AllHallowsEveEffect(final AllHallowsEveEffect effect) {
|
||||
private AllHallowsEveEffect(final AllHallowsEveEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -68,23 +80,24 @@ class AllHallowsEveEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Card allHallowsEve = game.getCard(source.getSourceId());
|
||||
Card card = (Card) source.getSourceObject(game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (allHallowsEve != null
|
||||
&& controller != null
|
||||
&& game.getExile().getCard(allHallowsEve.getId(), game) != null) {
|
||||
allHallowsEve.removeCounters(CounterType.SCREAM.getName(), 1, source, game);
|
||||
if (allHallowsEve.getCounters(game).getCount(CounterType.SCREAM) == 0) {
|
||||
allHallowsEve.moveToZone(Zone.GRAVEYARD, source, game, false);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
player.moveCards(player.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game), Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (card == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
controller.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
Cards cards = new CardsImpl();
|
||||
game.getState()
|
||||
.getPlayersInRange(source.getControllerId(), game)
|
||||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Player::getGraveyard)
|
||||
.map(g -> g.getCards(game))
|
||||
.flatMap(Collection::stream)
|
||||
.filter(MageObject::isCreature)
|
||||
.forEach(cards::add);
|
||||
controller.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
|
||||
package mage.cards.a;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.constants.*;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
@ -32,12 +30,17 @@ public final class ArchmageAscension extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}");
|
||||
|
||||
// At the beginning of each end step, if you drew two or more cards this turn, you may put a quest counter on Archmage Ascension.
|
||||
this.addAbility(new ArchmageAscensionTriggeredAbility(), new CardsAmountDrawnThisTurnWatcher());
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
|
||||
new BeginningOfEndStepTriggeredAbility(
|
||||
new AddCountersSourceEffect(CounterType.QUEST.createInstance(1)),
|
||||
TargetController.EACH_PLAYER, true
|
||||
), ArchmageAscensionCondition.instance, "At the beginning of each end step, " +
|
||||
"if you drew two or more cards this turn, you may put a quest counter on {this}"
|
||||
), new CardsAmountDrawnThisTurnWatcher());
|
||||
|
||||
// As long as Archmage Ascension has six or more quest counters on it, if you would draw a card,
|
||||
// you may instead search your library for a card, put that card into your hand, then shuffle your library.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ArchmageAscensionReplacementEffect()));
|
||||
|
||||
this.addAbility(new SimpleStaticAbility(new ArchmageAscensionReplacementEffect()));
|
||||
}
|
||||
|
||||
private ArchmageAscension(final ArchmageAscension card) {
|
||||
|
@ -50,49 +53,25 @@ public final class ArchmageAscension extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class ArchmageAscensionTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public ArchmageAscensionTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.QUEST.createInstance(1)), true);
|
||||
}
|
||||
|
||||
public ArchmageAscensionTriggeredAbility(final ArchmageAscensionTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
enum ArchmageAscensionCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public ArchmageAscensionTriggeredAbility copy() {
|
||||
return new ArchmageAscensionTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.END_TURN_STEP_PRE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
Permanent archmage = game.getPermanent(super.getSourceId());
|
||||
CardsAmountDrawnThisTurnWatcher watcher
|
||||
= game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
|
||||
return archmage != null && watcher != null && watcher.getAmountCardsDrawn(this.getControllerId()) >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "At the beginning of each end step, if you drew two or more cards this turn, you may put a quest counter on {this}";
|
||||
public boolean apply(Game game, Ability source) {
|
||||
CardsAmountDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsAmountDrawnThisTurnWatcher.class);
|
||||
return watcher != null && watcher.getAmountCardsDrawn(source.getControllerId()) >= 2;
|
||||
}
|
||||
}
|
||||
|
||||
class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl {
|
||||
|
||||
public ArchmageAscensionReplacementEffect() {
|
||||
ArchmageAscensionReplacementEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
staticText = "As long as {this} has six or more quest counters on it, if you would draw a card, "
|
||||
+ "you may instead search your library for a card, put that card into your hand, then shuffle your library";
|
||||
}
|
||||
|
||||
public ArchmageAscensionReplacementEffect(final ArchmageAscensionReplacementEffect effect) {
|
||||
private ArchmageAscensionReplacementEffect(final ArchmageAscensionReplacementEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -109,16 +88,16 @@ class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl {
|
|||
@Override
|
||||
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||
Player player = game.getPlayer(event.getPlayerId());
|
||||
if (player != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
if (player.searchLibrary(target, source, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source, game, false);
|
||||
player.shuffleLibrary(source, game);
|
||||
}
|
||||
}
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary();
|
||||
player.searchLibrary(target, source, game);
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
player.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -135,6 +114,6 @@ class ArchmageAscensionReplacementEffect extends ReplacementEffectImpl {
|
|||
&& archmage != null
|
||||
&& archmage.getCounters(game).getCount(CounterType.QUEST) >= 6
|
||||
&& you != null
|
||||
&& you.chooseUse(Outcome.Benefit, "Would you like to search your library instead of drawing a card?", source, game);
|
||||
&& you.chooseUse(Outcome.Benefit, "Search your library instead of drawing a card?", source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
|
||||
package mage.cards.a;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
|
@ -14,8 +15,9 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class AuguryAdept extends CardImpl {
|
||||
|
@ -44,12 +46,13 @@ public final class AuguryAdept extends CardImpl {
|
|||
|
||||
class AuguryAdeptEffect extends OneShotEffect {
|
||||
|
||||
public AuguryAdeptEffect() {
|
||||
AuguryAdeptEffect() {
|
||||
super(Outcome.GainLife);
|
||||
this.staticText = "reveal the top card of your library and put that card into your hand. You gain life equal to its converted mana cost";
|
||||
this.staticText = "reveal the top card of your library and put that card into your hand. " +
|
||||
"You gain life equal to its converted mana cost";
|
||||
}
|
||||
|
||||
public AuguryAdeptEffect(final AuguryAdeptEffect effect) {
|
||||
private AuguryAdeptEffect(final AuguryAdeptEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -65,13 +68,14 @@ class AuguryAdeptEffect extends OneShotEffect {
|
|||
return false;
|
||||
}
|
||||
Card card = controller.getLibrary().getFromTop(game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source, game, true);
|
||||
int cmc = card.getConvertedManaCost();
|
||||
if (cmc > 0) {
|
||||
controller.gainLife(cmc, game, source);
|
||||
}
|
||||
controller.revealCards(source, new CardsImpl(card), game);
|
||||
if (card == null) {
|
||||
return false;
|
||||
}
|
||||
controller.revealCards(source, new CardsImpl(card), game);
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
int cmc = card.getConvertedManaCost();
|
||||
if (cmc > 0) {
|
||||
controller.gainLife(cmc, game, source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
|
@ -14,26 +12,29 @@ import mage.constants.CardType;
|
|||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
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 java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cbt33, noxx (DiscardCardYouChooseTargetOpponentEffect)
|
||||
*/
|
||||
public final class BalshanBeguiler extends CardImpl {
|
||||
|
||||
public BalshanBeguiler(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
|
||||
this.subtype.add(SubType.HUMAN, SubType.WIZARD);
|
||||
|
||||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
// Whenever Balshan Beguiler deals combat damage to a player, that player reveals the top two cards of their library. You choose one of those cards and put it into their graveyard.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new BalshanBeguilerEffect(), false, true));
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
|
||||
new BalshanBeguilerEffect(), false, true
|
||||
));
|
||||
}
|
||||
|
||||
private BalshanBeguiler(final BalshanBeguiler card) {
|
||||
|
@ -47,36 +48,40 @@ public final class BalshanBeguiler extends CardImpl {
|
|||
}
|
||||
|
||||
class BalshanBeguilerEffect extends OneShotEffect {
|
||||
|
||||
public BalshanBeguilerEffect() {
|
||||
|
||||
BalshanBeguilerEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = " that player reveals the top two cards of their library. You choose one of those cards and put it into their graveyard.";
|
||||
this.staticText = "that player reveals the top two cards of their library. " +
|
||||
"You choose one of those cards and put it into their graveyard.";
|
||||
}
|
||||
|
||||
public BalshanBeguilerEffect(final BalshanBeguilerEffect effect) {
|
||||
|
||||
private BalshanBeguilerEffect(final BalshanBeguilerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BalshanBeguilerEffect copy() {
|
||||
return new BalshanBeguilerEffect(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (player != null) {
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(player.getLibrary().getTopCards(game, 2));
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (you != null) {
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard());
|
||||
if (you.choose(Outcome.Benefit, cards, target, game)) {
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
card.moveToZone(Zone.BATTLEFIELD, source, game, true);
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
Player you = game.getPlayer(source.getControllerId());
|
||||
if (player == null || you == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
CardsImpl cards = new CardsImpl();
|
||||
cards.addAll(player.getLibrary().getTopCards(game, 2));
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
player.revealCards(source, cards, game);
|
||||
TargetCard target = new TargetCardInLibrary();
|
||||
if (you.choose(Outcome.Benefit, cards, target, game)) {
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
you.moveCards(card, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -14,10 +11,16 @@ import mage.filter.StaticFilters;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetCreaturePermanentSameController;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class BarrinsSpite extends CardImpl {
|
||||
|
@ -27,8 +30,9 @@ public final class BarrinsSpite extends CardImpl {
|
|||
|
||||
// Choose two target creatures controlled by the same player. Their controller chooses and sacrifices one of them. Return the other to its owner's hand.
|
||||
this.getSpellAbility().addEffect(new BarrinsSpiteEffect());
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController(2, 2, StaticFilters.FILTER_PERMANENT_CREATURE, false));
|
||||
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanentSameController(
|
||||
2, 2, StaticFilters.FILTER_PERMANENT_CREATURE, false
|
||||
));
|
||||
}
|
||||
|
||||
private BarrinsSpite(final BarrinsSpite card) {
|
||||
|
@ -43,12 +47,13 @@ public final class BarrinsSpite extends CardImpl {
|
|||
|
||||
class BarrinsSpiteEffect extends OneShotEffect {
|
||||
|
||||
public BarrinsSpiteEffect() {
|
||||
BarrinsSpiteEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = "Choose two target creatures controlled by the same player. Their controller chooses and sacrifices one of them. Return the other to its owner's hand";
|
||||
this.staticText = "Choose two target creatures controlled by the same player. " +
|
||||
"Their controller chooses and sacrifices one of them. Return the other to its owner's hand";
|
||||
}
|
||||
|
||||
public BarrinsSpiteEffect(final BarrinsSpiteEffect effect) {
|
||||
private BarrinsSpiteEffect(final BarrinsSpiteEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -59,30 +64,42 @@ class BarrinsSpiteEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (sourceObject != null) {
|
||||
boolean sacrificeDone = false;
|
||||
int count = 0;
|
||||
for (UUID targetId : getTargetPointer().getTargets(game, source)) {
|
||||
Permanent creature = game.getPermanent(targetId);
|
||||
if (creature != null) {
|
||||
Player controllerOfCreature = game.getPlayer(creature.getControllerId());
|
||||
if(controllerOfCreature != null) {
|
||||
if ((count == 0
|
||||
&& controllerOfCreature.chooseUse(Outcome.Sacrifice, "Sacrifice " + creature.getLogName() + '?', source, game))
|
||||
|| (count == 1
|
||||
&& !sacrificeDone)) {
|
||||
creature.sacrifice(source, game);
|
||||
sacrificeDone = true;
|
||||
} else {
|
||||
creature.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<Permanent> permanents = source
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getPermanent)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
if (permanents.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (permanents.size() == 1) {
|
||||
permanents.get(0).sacrifice(source, game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (permanents.size() > 2) {
|
||||
throw new IllegalStateException("Too many permanents in list, shouldn't be possible");
|
||||
}
|
||||
Player player = game.getPlayer(permanents.get(0).getControllerId());
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (player == null || controller == null) {
|
||||
return false;
|
||||
}
|
||||
Permanent perm1 = permanents.get(0);
|
||||
Permanent perm2 = permanents.get(1);
|
||||
if (player.chooseUse(
|
||||
outcome, "Choose which permanent to sacrifice",
|
||||
"The other will be returned to your hand",
|
||||
perm1.getIdName(), perm2.getIdName(), source, game
|
||||
)) {
|
||||
perm1.sacrifice(source, game);
|
||||
controller.moveCards(perm2, Zone.HAND, source, game);
|
||||
return true;
|
||||
}
|
||||
perm2.sacrifice(source, game);
|
||||
controller.moveCards(perm1, Zone.HAND, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.costs.common.PayLifeCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
@ -17,18 +16,20 @@ import mage.players.Player;
|
|||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class BloodClock extends CardImpl {
|
||||
|
||||
public BloodClock(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// At the beginning of each player's upkeep, that player returns a permanent they control to its owner's hand unless they pay 2 life.
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new BloodClockEffect(), TargetController.ANY, false, true);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
Zone.BATTLEFIELD, new BloodClockEffect(), TargetController.ANY, false, true
|
||||
));
|
||||
}
|
||||
|
||||
private BloodClock(final BloodClock card) {
|
||||
|
@ -43,12 +44,12 @@ public final class BloodClock extends CardImpl {
|
|||
|
||||
class BloodClockEffect extends OneShotEffect {
|
||||
|
||||
public BloodClockEffect() {
|
||||
BloodClockEffect() {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.staticText = "that player returns a permanent they control to its owner's hand unless they pay 2 life";
|
||||
}
|
||||
|
||||
public BloodClockEffect(final BloodClockEffect effect) {
|
||||
private BloodClockEffect(final BloodClockEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -63,20 +64,23 @@ class BloodClockEffect extends OneShotEffect {
|
|||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
if (player.getLife() > 2 && player.chooseUse(Outcome.Neutral, "Pay 2 life? If you don't, return a permanent you control to its owner's hand.", source, game)) {
|
||||
player.loseLife(2, game, source, false);
|
||||
game.informPlayers(player.getLogName() + " pays 2 life. They will not return a permanent they control.");
|
||||
PayLifeCost cost = new PayLifeCost(2);
|
||||
if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(
|
||||
Outcome.Neutral, "Pay 2 life? If you don't, " +
|
||||
"return a permanent you control to its owner's hand.", source, game
|
||||
) && cost.pay(source, game, source, player.getId(), true)) {
|
||||
return true;
|
||||
} else {
|
||||
Target target = new TargetControlledPermanent();
|
||||
if (target.canChoose(source.getSourceId(), player.getId(), game) && player.chooseTarget(outcome, target, source, game)) {
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
game.informPlayers(player.getLogName() + " returns " + permanent.getName() + " to hand.");
|
||||
return permanent.moveToZone(Zone.HAND, source, game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
Target target = new TargetControlledPermanent();
|
||||
target.setNotTarget(true);
|
||||
if (!target.canChoose(source.getSourceId(), player.getId(), game)
|
||||
|| !player.chooseTarget(outcome, target, source, game)) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
return player.moveCards(permanent, Zone.HAND, source, game);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,41 @@
|
|||
|
||||
package mage.cards.b;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public final class BottledCloister extends CardImpl {
|
||||
|
||||
public BottledCloister(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// At the beginning of each opponent's upkeep, exile all cards from your hand face down.
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(new BottledCloisterExileEffect(), TargetController.OPPONENT, false));
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new BottledCloisterExileEffect(), TargetController.OPPONENT, false
|
||||
));
|
||||
|
||||
// At the beginning of your upkeep, return all cards you own exiled with Bottled Cloister to your hand, then draw a card.
|
||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new BottledCloisterReturnEffect(), TargetController.YOU, false);
|
||||
Effect effect = new DrawCardSourceControllerEffect(1);
|
||||
effect.setText(", then draw a card");
|
||||
ability.addEffect(effect);
|
||||
this.addAbility(ability);
|
||||
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
|
||||
new BottledCloisterReturnEffect(), TargetController.YOU, false
|
||||
));
|
||||
}
|
||||
|
||||
private BottledCloister(final BottledCloister card) {
|
||||
|
@ -51,12 +50,12 @@ public final class BottledCloister extends CardImpl {
|
|||
|
||||
class BottledCloisterExileEffect extends OneShotEffect {
|
||||
|
||||
public BottledCloisterExileEffect() {
|
||||
BottledCloisterExileEffect() {
|
||||
super(Outcome.Detriment);
|
||||
this.staticText = "exile all cards from your hand face down";
|
||||
}
|
||||
|
||||
public BottledCloisterExileEffect(final BottledCloisterExileEffect effect) {
|
||||
private BottledCloisterExileEffect(final BottledCloisterExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -68,31 +67,31 @@ class BottledCloisterExileEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller != null && sourcePermanent != null) {
|
||||
int numberOfCards = controller.getHand().size();
|
||||
if (numberOfCards > 0) {
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
for (Card card: controller.getHand().getCards(game)) {
|
||||
card.moveToExile(exileId, sourcePermanent.getName(), source, game);
|
||||
card.setFaceDown(true, game);
|
||||
}
|
||||
game.informPlayers(sourcePermanent.getName() + ": " + controller.getLogName() + " exiles their hand face down (" + numberOfCards + "card" + (numberOfCards > 1 ?"s":"") + ')');
|
||||
}
|
||||
return true;
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller == null || sourceObject == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Cards cards = new CardsImpl(controller.getHand());
|
||||
if (cards.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
controller.moveCardsToExile(cards.getCards(game), source, game, false, CardUtil.getExileZoneId(game, source), sourceObject.getIdName());
|
||||
cards.getCards(game)
|
||||
.stream()
|
||||
.filter(c -> game.getState().getZone(c.getId()) == Zone.EXILED)
|
||||
.forEach(card -> card.setFaceDown(true, game));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class BottledCloisterReturnEffect extends OneShotEffect {
|
||||
|
||||
public BottledCloisterReturnEffect() {
|
||||
BottledCloisterReturnEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "return all cards you own exiled with {this} to your hand";
|
||||
this.staticText = "return all cards you own exiled with {this} to your hand, then draw a card";
|
||||
}
|
||||
|
||||
public BottledCloisterReturnEffect(final BottledCloisterReturnEffect effect) {
|
||||
private BottledCloisterReturnEffect(final BottledCloisterReturnEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
@ -103,26 +102,14 @@ class BottledCloisterReturnEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (controller != null && sourcePermanent != null) {
|
||||
UUID exileId = CardUtil.getCardExileZoneId(game, source);
|
||||
int numberOfCards = 0;
|
||||
ExileZone exileZone = game.getExile().getExileZone(exileId);
|
||||
if (exileZone != null) {
|
||||
for (Card card: exileZone.getCards(game)) {
|
||||
if (card.isOwnedBy(controller.getId())) {
|
||||
numberOfCards++;
|
||||
card.moveToZone(Zone.HAND, source, game, true);
|
||||
card.setFaceDown(false, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (numberOfCards > 0) {
|
||||
game.informPlayers(sourcePermanent.getLogName() + ": " + controller.getLogName() + " returns "+ numberOfCards + " card" + (numberOfCards > 1 ?"s":"") + " from exile to hand");
|
||||
}
|
||||
return true;
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
|
||||
Cards cards = new CardsImpl(exileZone);
|
||||
cards.removeIf(uuid -> !player.getId().equals(game.getOwnerId(uuid)));
|
||||
if (!cards.isEmpty()) {
|
||||
player.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
return false;
|
||||
player.drawCards(1, source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue