mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Implemented Discovery // Dispersal
This commit is contained in:
parent
b19a799b83
commit
8792e0b5cf
3 changed files with 138 additions and 3 deletions
126
Mage.Sets/src/mage/cards/d/DiscoveryDispersal.java
Normal file
126
Mage.Sets/src/mage/cards/d/DiscoveryDispersal.java
Normal file
|
@ -0,0 +1,126 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.ReturnToHandFromBattlefieldAllEffect;
|
||||
import mage.abilities.effects.common.discard.DiscardEachPlayerEffect;
|
||||
import mage.abilities.effects.keyword.SurveilEffect;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterNonlandPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||
import mage.filter.predicate.permanent.PermanentIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class DiscoveryDispersal extends SplitCard {
|
||||
|
||||
public DiscoveryDispersal(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, new CardType[]{CardType.INSTANT}, "{1}{U/B}", "{3}{U}{B}", SpellAbilityType.SPLIT);
|
||||
|
||||
// Discovery
|
||||
// Surveil 2, then draw a card.
|
||||
this.getLeftHalfCard().getSpellAbility().addEffect(
|
||||
new SurveilEffect(2).setText("Surveil 2,")
|
||||
);
|
||||
this.getLeftHalfCard().getSpellAbility().addEffect(
|
||||
new DrawCardSourceControllerEffect(1
|
||||
).setText("then draw a card. <i>(To surveil 2, "
|
||||
+ "look at the top two cards of your library, "
|
||||
+ "then put any number of them into your graveyard "
|
||||
+ "and the rest on top of your library "
|
||||
+ "in any order.)</i>")
|
||||
);
|
||||
|
||||
// Dispersal
|
||||
// Each opponent returns a nonland permanent they control with the highest converted mana cost among permanents they control to its owner’s hand, then discards a card.
|
||||
this.getLeftHalfCard().getSpellAbility().addEffect(new DispersalEffect());
|
||||
}
|
||||
|
||||
public DiscoveryDispersal(final DiscoveryDispersal card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscoveryDispersal copy() {
|
||||
return new DiscoveryDispersal(this);
|
||||
}
|
||||
}
|
||||
|
||||
class DispersalEffect extends OneShotEffect {
|
||||
|
||||
public DispersalEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "Each opponent returns a nonland permanent "
|
||||
+ "they control with the highest converted mana cost "
|
||||
+ "among permanents they control to its owner’s hand, "
|
||||
+ "then discards a card.";
|
||||
}
|
||||
|
||||
public DispersalEffect(final DispersalEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispersalEffect copy() {
|
||||
return new DispersalEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
Set<PermanentIdPredicate> permsToReturn = new HashSet();
|
||||
for (UUID opponentId : game.getOpponents(player.getId())) {
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
if (opponent == null) {
|
||||
continue;
|
||||
}
|
||||
int highestCMC = 0;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(opponentId)) {
|
||||
if (permanent != null && !permanent.isLand()) {
|
||||
highestCMC = Math.max(highestCMC, permanent.getConvertedManaCost());
|
||||
}
|
||||
}
|
||||
FilterPermanent filter = new FilterNonlandPermanent("permanent you control with converted mana cost " + highestCMC);
|
||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, highestCMC));
|
||||
filter.add(new ControllerIdPredicate(opponentId));
|
||||
Target target = new TargetPermanent(1, 1, filter, true);
|
||||
if (opponent.choose(outcome, target, source.getSourceId(), game)) {
|
||||
if (target.getFirstTarget() == null) {
|
||||
continue;
|
||||
}
|
||||
permsToReturn.add(new PermanentIdPredicate(target.getFirstTarget()));
|
||||
}
|
||||
}
|
||||
FilterPermanent filter = new FilterPermanent();
|
||||
filter.add(Predicates.or(permsToReturn));
|
||||
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
|
||||
new DiscardEachPlayerEffect(
|
||||
new StaticValue(1), false, TargetController.OPPONENT
|
||||
).apply(game, source);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -18,8 +17,17 @@ public final class Preordain extends CardImpl {
|
|||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{U}");
|
||||
|
||||
// Scry 2, then draw a card. (To scry 2, look at the top two cards of your library, then put any number of them on the bottom of your library and the rest on top in any order.)
|
||||
this.getSpellAbility().addEffect(new ScryEffect(2));
|
||||
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
|
||||
this.getSpellAbility().addEffect(
|
||||
new ScryEffect(2).setText("Scry 2, ")
|
||||
);
|
||||
this.getSpellAbility().addEffect(
|
||||
new DrawCardSourceControllerEffect(1)
|
||||
.setText("then draw a card. <i>(To scry 2, "
|
||||
+ "look at the top two cards of your library, "
|
||||
+ "then put any number of them on the "
|
||||
+ "bottom of your library and the rest on "
|
||||
+ "top in any order.)</i>")
|
||||
);
|
||||
}
|
||||
|
||||
public Preordain(final Preordain card) {
|
||||
|
|
|
@ -63,6 +63,7 @@ public final class GuildsOfRavnica extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Dimir Locket", 234, Rarity.COMMON, mage.cards.d.DimirLocket.class));
|
||||
cards.add(new SetCardInfo("Dimir Spybug", 166, Rarity.UNCOMMON, mage.cards.d.DimirSpybug.class));
|
||||
cards.add(new SetCardInfo("Direct Current", 96, Rarity.COMMON, mage.cards.d.DirectCurrent.class));
|
||||
cards.add(new SetCardInfo("Discovery // Dispersal", 223, Rarity.UNCOMMON, mage.cards.d.DiscoveryDispersal.class));
|
||||
cards.add(new SetCardInfo("Disdainful Stroke", 37, Rarity.COMMON, mage.cards.d.DisdainfulStroke.class));
|
||||
cards.add(new SetCardInfo("Disinformation Campaign", 167, Rarity.UNCOMMON, mage.cards.d.DisinformationCampaign.class));
|
||||
cards.add(new SetCardInfo("District Guide", 128, Rarity.UNCOMMON, mage.cards.d.DistrictGuide.class));
|
||||
|
|
Loading…
Reference in a new issue