mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
[DMU] Implemented Chaotic Transformation
This commit is contained in:
parent
c26c2f3785
commit
05a0c8818b
2 changed files with 109 additions and 0 deletions
108
Mage.Sets/src/mage/cards/c/ChaoticTransformation.java
Normal file
108
Mage.Sets/src/mage/cards/c/ChaoticTransformation.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package mage.cards.c;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author weirddan455
|
||||
*/
|
||||
public final class ChaoticTransformation extends CardImpl {
|
||||
|
||||
public ChaoticTransformation(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{5}{R}");
|
||||
|
||||
// Exile up to one target artifact, up to one target creature, up to one target enchantment, up to one target planeswalker, and/or up to one target land.
|
||||
// For each permanent exiled this way, its controller reveals cards from the top of their library until they reveal a card that shares a card type with it, puts that card onto the battlefield, then shuffles.
|
||||
this.getSpellAbility().addTarget(new TargetArtifactPermanent(0, 1));
|
||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, 1));
|
||||
this.getSpellAbility().addTarget(new TargetEnchantmentPermanent(0, 1));
|
||||
this.getSpellAbility().addTarget(new TargetPlaneswalkerPermanent(0, 1));
|
||||
this.getSpellAbility().addTarget(new TargetLandPermanent(0, 1));
|
||||
this.getSpellAbility().addEffect(new ChaoticTransformationEffect());
|
||||
}
|
||||
|
||||
private ChaoticTransformation(final ChaoticTransformation card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChaoticTransformation copy() {
|
||||
return new ChaoticTransformation(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ChaoticTransformationEffect extends OneShotEffect {
|
||||
|
||||
public ChaoticTransformationEffect() {
|
||||
super(Outcome.PutCardInPlay);
|
||||
this.staticText = "Exile up to one target artifact, up to one target creature, up to one target enchantment, up to one target planeswalker, and/or up to one target land. "
|
||||
+ "For each permanent exiled this way, its controller reveals cards from the top of their library until they reveal a card that shares a card type with it, puts that card onto the battlefield, then shuffles.";
|
||||
}
|
||||
|
||||
private ChaoticTransformationEffect(final ChaoticTransformationEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChaoticTransformationEffect copy() {
|
||||
return new ChaoticTransformationEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player sourceController = game.getPlayer(source.getControllerId());
|
||||
if (sourceController == null) {
|
||||
return false;
|
||||
}
|
||||
for (Target target : source.getTargets()) {
|
||||
Permanent permanent = game.getPermanent(target.getFirstTarget());
|
||||
if (permanent == null) {
|
||||
continue;
|
||||
}
|
||||
Player permanentController = game.getPlayer(permanent.getControllerId());
|
||||
HashSet<CardType> types = new HashSet<>(permanent.getCardType(game));
|
||||
if (!sourceController.moveCards(permanent, Zone.EXILED, source, game) || permanentController == null) {
|
||||
continue;
|
||||
}
|
||||
Cards revealedCards = new CardsImpl();
|
||||
Card toBattlefield = null;
|
||||
for (Card card : permanentController.getLibrary().getCards(game)) {
|
||||
revealedCards.add(card);
|
||||
if (sharesType(card, types, game)) {
|
||||
toBattlefield = card;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!revealedCards.isEmpty()) {
|
||||
permanentController.revealCards(source, revealedCards, game);
|
||||
}
|
||||
if (toBattlefield != null) {
|
||||
permanentController.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game);
|
||||
}
|
||||
permanentController.shuffleLibrary(source, game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean sharesType(Card card, HashSet<CardType> types, Game game) {
|
||||
for (CardType type : card.getCardType(game)) {
|
||||
if (types.contains(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -60,6 +60,7 @@ public final class DominariaUnited extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Broken Wings", 157, Rarity.COMMON, mage.cards.b.BrokenWings.class));
|
||||
cards.add(new SetCardInfo("Captain's Call", 9, Rarity.COMMON, mage.cards.c.CaptainsCall.class));
|
||||
cards.add(new SetCardInfo("Caves of Koilos", 244, Rarity.RARE, mage.cards.c.CavesOfKoilos.class));
|
||||
cards.add(new SetCardInfo("Chaotic Transformation", 117, Rarity.RARE, mage.cards.c.ChaoticTransformation.class));
|
||||
cards.add(new SetCardInfo("Charismatic Vanguard", 10, Rarity.COMMON, mage.cards.c.CharismaticVanguard.class));
|
||||
cards.add(new SetCardInfo("Choking Miasma", 86, Rarity.UNCOMMON, mage.cards.c.ChokingMiasma.class));
|
||||
cards.add(new SetCardInfo("Citizen's Arrest", 11, Rarity.COMMON, mage.cards.c.CitizensArrest.class));
|
||||
|
|
Loading…
Reference in a new issue