mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
[DMC] refactor Torsten, Founder of Benalia to use common class
This commit is contained in:
parent
c843dd23e1
commit
36ea6ae2b2
1 changed files with 21 additions and 48 deletions
|
@ -1,22 +1,19 @@
|
|||
package mage.cards.t;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DiesSourceTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateTokenEffect;
|
||||
import mage.abilities.effects.common.LookLibraryControllerEffect;
|
||||
import mage.abilities.effects.common.RevealLibraryPickControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.game.permanent.token.SoldierToken;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -25,6 +22,15 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class TorstenFounderOfBenalia extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("creature and/or land cards");
|
||||
|
||||
static {
|
||||
filter.add(Predicates.or(
|
||||
CardType.CREATURE.getPredicate(),
|
||||
CardType.LAND.getPredicate()
|
||||
));
|
||||
}
|
||||
|
||||
public TorstenFounderOfBenalia(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{W}");
|
||||
|
||||
|
@ -35,7 +41,11 @@ public final class TorstenFounderOfBenalia extends CardImpl {
|
|||
this.toughness = new MageInt(7);
|
||||
|
||||
// When Torsten, Founder of Benalia enters the battlefield, reveal the top seven cards of your library. Put any number of creature and/or land cards from among them into your hand and the rest on the bottom of your library in a random order.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new TorstenFounderOfBenaliaEffect()));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPickControllerEffect(
|
||||
7, Integer.MAX_VALUE, filter,
|
||||
LookLibraryControllerEffect.PutCards.HAND,
|
||||
LookLibraryControllerEffect.PutCards.BOTTOM_RANDOM, false
|
||||
)));
|
||||
|
||||
// When Torsten dies, create seven 1/1 white Soldier creature tokens.
|
||||
this.addAbility(new DiesSourceTriggeredAbility(new CreateTokenEffect(new SoldierToken(), 7)));
|
||||
|
@ -50,40 +60,3 @@ public final class TorstenFounderOfBenalia extends CardImpl {
|
|||
return new TorstenFounderOfBenalia(this);
|
||||
}
|
||||
}
|
||||
|
||||
class TorstenFounderOfBenaliaEffect extends OneShotEffect {
|
||||
|
||||
TorstenFounderOfBenaliaEffect() {
|
||||
super(Outcome.Benefit);
|
||||
staticText = "reveal the top seven cards of your library. Put any number of creature and/or land cards " +
|
||||
"from among them into your hand and the rest on the bottom of your library in a random order";
|
||||
}
|
||||
|
||||
private TorstenFounderOfBenaliaEffect(final TorstenFounderOfBenaliaEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TorstenFounderOfBenaliaEffect copy() {
|
||||
return new TorstenFounderOfBenaliaEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, 7));
|
||||
player.revealCards(source, cards, game);
|
||||
TargetCard target = new TargetCardInLibrary(
|
||||
0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_CREATURE_OR_LAND
|
||||
);
|
||||
player.choose(outcome, cards, target, game);
|
||||
Cards toHand = new CardsImpl(target.getTargets());
|
||||
player.moveCards(toHand, Zone.HAND, source, game);
|
||||
cards.retainZone(Zone.LIBRARY, game);
|
||||
player.putCardsOnBottomOfLibrary(cards, game, source, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue