mirror of
https://github.com/correl/mage.git
synced 2025-03-12 17:00:08 -09:00
[CLB] Implemented Wild Magic Surge
This commit is contained in:
parent
c36bb52523
commit
5a674872e6
2 changed files with 94 additions and 0 deletions
93
Mage.Sets/src/mage/cards/w/WildMagicSurge.java
Normal file
93
Mage.Sets/src/mage/cards/w/WildMagicSurge.java
Normal file
|
@ -0,0 +1,93 @@
|
|||
package mage.cards.w;
|
||||
|
||||
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.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class WildMagicSurge extends CardImpl {
|
||||
|
||||
public WildMagicSurge(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{R}{R}");
|
||||
|
||||
// Destroy target permanent an opponent controls. Its controller reveals cards from the top of their library until they reveal a permanent card that shares a card type with that permanent. They put that card onto the battlefield and the rest on the bottom of their library in a random order.
|
||||
this.getSpellAbility().addEffect(new WildMagicSurgeEffect());
|
||||
this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_OPPONENTS_PERMANENT));
|
||||
}
|
||||
|
||||
private WildMagicSurge(final WildMagicSurge card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WildMagicSurge copy() {
|
||||
return new WildMagicSurge(this);
|
||||
}
|
||||
}
|
||||
|
||||
class WildMagicSurgeEffect extends OneShotEffect {
|
||||
|
||||
WildMagicSurgeEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "destroy target permanent an opponent controls. Its controller reveals cards " +
|
||||
"from the top of their library until they reveal a permanent card that shares a " +
|
||||
"card type with that permanent. They put that card onto the battlefield " +
|
||||
"and the rest on the bottom of their library in a random order";
|
||||
}
|
||||
|
||||
private WildMagicSurgeEffect(final WildMagicSurgeEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WildMagicSurgeEffect copy() {
|
||||
return new WildMagicSurgeEffect(this);
|
||||
}
|
||||
|
||||
private static final Card loopCards(List<CardType> cardTypes, Player player, Cards cards, Ability source, Game game) {
|
||||
for (Card card : player.getLibrary().getCards(game)) {
|
||||
cards.add(card);
|
||||
if (card.isPermanent(game)
|
||||
&& card
|
||||
.getCardType(game)
|
||||
.stream()
|
||||
.anyMatch(cardTypes::contains)) {
|
||||
return card;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (permanent == null) {
|
||||
return false;
|
||||
}
|
||||
permanent.destroy(source, game);
|
||||
Player player = game.getPlayer(permanent.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl();
|
||||
Card card = loopCards(permanent.getCardType(game), player, cards, source, game);
|
||||
player.revealCards(source, cards, game);
|
||||
player.moveCards(card, Zone.BATTLEFIELD, source, game);
|
||||
cards.retainZone(Zone.LIBRARY, game);
|
||||
player.putCardsOnBottomOfLibrary(cards, game, source, false);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -327,6 +327,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Warehouse Thief", 205, Rarity.COMMON, mage.cards.w.WarehouseThief.class));
|
||||
cards.add(new SetCardInfo("Wayfarer's Bauble", 344, Rarity.COMMON, mage.cards.w.WayfarersBauble.class));
|
||||
cards.add(new SetCardInfo("White Plume Adventurer", 49, Rarity.RARE, mage.cards.w.WhitePlumeAdventurer.class));
|
||||
cards.add(new SetCardInfo("Wild Magic Surge", 206, Rarity.UNCOMMON, mage.cards.w.WildMagicSurge.class));
|
||||
cards.add(new SetCardInfo("Wilson, Refined Grizzly", 261, Rarity.UNCOMMON, mage.cards.w.WilsonRefinedGrizzly.class));
|
||||
cards.add(new SetCardInfo("Winter Eladrin", 104, Rarity.COMMON, mage.cards.w.WinterEladrin.class));
|
||||
cards.add(new SetCardInfo("Wyll, Blade of Frontiers", 208, Rarity.RARE, mage.cards.w.WyllBladeOfFrontiers.class));
|
||||
|
|
Loading…
Add table
Reference in a new issue