mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
Fixing Icon of Ancestry ability
This commit is contained in:
parent
a91b210456
commit
138fcf6c92
1 changed files with 12 additions and 53 deletions
|
@ -1,12 +1,12 @@
|
|||
package mage.cards.i;
|
||||
|
||||
import java.util.Set;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AsEntersBattlefieldAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
|
||||
import mage.abilities.effects.common.LookLibraryAndPickControllerEffect;
|
||||
import mage.abilities.effects.common.continuous.BoostAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
@ -17,13 +17,8 @@ import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
@ -51,7 +46,8 @@ public final class IconOfAncestry extends CardImpl {
|
|||
|
||||
// {3}, {T}: Look at the top three cards of your library. You may reveal a creature card of the
|
||||
// chosen type from among them and put it into your hand. Put the rest on the bottom of your library in a random order.
|
||||
Ability ability = new SimpleActivatedAbility(new IconOfAncestryEffect(), new ManaCostsImpl("{3}"));
|
||||
FilterCreatureCard filter2 = new FilterCreatureCard("creature card that matches the chosen subtype");
|
||||
Ability ability = new SimpleActivatedAbility(new IconOfAncestryEffect(filter2), new ManaCostsImpl("{3}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
}
|
||||
|
@ -66,57 +62,20 @@ public final class IconOfAncestry extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class IconOfAncestryEffect extends OneShotEffect {
|
||||
|
||||
public IconOfAncestryEffect() {
|
||||
super(Outcome.AIDontUseIt);
|
||||
this.staticText = "Look at the top three cards of your library. "
|
||||
+ "You may reveal a creature card of the "
|
||||
+ "chosen type from among them and put it into your hand. "
|
||||
+ "Put the rest on the bottom of your library in a random order";
|
||||
}
|
||||
|
||||
public IconOfAncestryEffect(final IconOfAncestryEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IconOfAncestryEffect copy() {
|
||||
return new IconOfAncestryEffect(this);
|
||||
class IconOfAncestryEffect extends LookLibraryAndPickControllerEffect {
|
||||
public IconOfAncestryEffect(FilterCreatureCard filter) {
|
||||
super(StaticValue.get(3), false, StaticValue.get(1), filter, Zone.LIBRARY, false,
|
||||
true, false, Zone.HAND, true, false, false);
|
||||
this.setOutcome(Outcome.AIDontUseIt);
|
||||
this.setBackInRandomOrder(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller == null
|
||||
|| !controller.getLibrary().hasCards()) {
|
||||
return false;
|
||||
}
|
||||
Set<Card> cardsFromTopOfLibrary = controller.getLibrary().getTopCards(game, 3);
|
||||
Cards cardsFromLibrary = new CardsImpl();
|
||||
Cards revealedCard = new CardsImpl();
|
||||
cardsFromLibrary.addAll(cardsFromTopOfLibrary);
|
||||
if (cardsFromTopOfLibrary.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
FilterCreatureCard filter = new FilterCreatureCard("creature card that matches the chosen subtype");
|
||||
SubType subtype = (SubType) game.getState().getValue(source.getSourceId() + "_type");
|
||||
if (subtype != null) {
|
||||
filter.add(subtype.getPredicate());
|
||||
}
|
||||
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
|
||||
if (target.canChoose(controller.getId(), game)
|
||||
&& controller.chooseUse(outcome, "Do you wish to use Icon of Ancestry's effect?", source, game)
|
||||
&& controller.choose(Outcome.Benefit, cardsFromLibrary, target, game)) {
|
||||
Card chosenCard = game.getCard(target.getFirstTarget());
|
||||
if (chosenCard != null) {
|
||||
revealedCard.add(chosenCard);
|
||||
controller.revealCards(source, revealedCard, game);
|
||||
controller.putInHand(chosenCard, game);
|
||||
cardsFromLibrary.remove(chosenCard);
|
||||
}
|
||||
}
|
||||
controller.putCardsOnBottomOfLibrary(cardsFromLibrary, game, source, true);
|
||||
return true;
|
||||
return super.apply(game, source);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue