mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Implemented Hatchery Spider
This commit is contained in:
parent
024b7ccb59
commit
b19a799b83
3 changed files with 130 additions and 2 deletions
121
Mage.Sets/src/mage/cards/h/HatcherySpider.java
Normal file
121
Mage.Sets/src/mage/cards/h/HatcherySpider.java
Normal file
|
@ -0,0 +1,121 @@
|
|||
package mage.cards.h;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.common.CardsInControllerGraveyardCount;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CastSourceTriggeredAbility;
|
||||
import mage.constants.SubType;
|
||||
import mage.abilities.keyword.ReachAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.ComparisonType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterPermanentCard;
|
||||
import mage.filter.predicate.mageobject.ColorPredicate;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author TheElk801
|
||||
*/
|
||||
public final class HatcherySpider extends CardImpl {
|
||||
|
||||
public HatcherySpider(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{G}");
|
||||
|
||||
this.subtype.add(SubType.SPIDER);
|
||||
this.power = new MageInt(5);
|
||||
this.toughness = new MageInt(7);
|
||||
|
||||
// Reach
|
||||
this.addAbility(ReachAbility.getInstance());
|
||||
|
||||
// Undergrowth — When you cast this spell, reveal the top X cards of your library, where X is the number of creature cards in your graveyard. You may put a green permanent card with converted mana cost X or less from among them onto the battlefield. Put the rest on the bottom of your library in a random order.
|
||||
this.addAbility(new CastSourceTriggeredAbility(
|
||||
new HatcherySpiderEffect(), false,
|
||||
"<i>Undergrowth</i> — "
|
||||
));
|
||||
}
|
||||
|
||||
public HatcherySpider(final HatcherySpider card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HatcherySpider copy() {
|
||||
return new HatcherySpider(this);
|
||||
}
|
||||
}
|
||||
|
||||
class HatcherySpiderEffect extends OneShotEffect {
|
||||
|
||||
public HatcherySpiderEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "reveal the top X cards of your library, "
|
||||
+ "where X is the number of creature cards in your graveyard. "
|
||||
+ "You may put a green permanent card with converted mana cost "
|
||||
+ "X or less from among them onto the battlefield. "
|
||||
+ "Put the rest on the bottom of your library "
|
||||
+ "in a random order.";
|
||||
}
|
||||
|
||||
public HatcherySpiderEffect(final HatcherySpiderEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HatcherySpiderEffect copy() {
|
||||
return new HatcherySpiderEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getFirstTarget());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
int xValue = new CardsInControllerGraveyardCount(
|
||||
StaticFilters.FILTER_CARD_CREATURE
|
||||
).calculate(game, source, this);
|
||||
FilterCard filter = new FilterPermanentCard(
|
||||
"green permanent card with converted mana cost "
|
||||
+ xValue + " or less"
|
||||
);
|
||||
filter.add(new ColorPredicate(ObjectColor.GREEN));
|
||||
filter.add(new ConvertedManaCostPredicate(
|
||||
ComparisonType.FEWER_THAN, xValue + 1
|
||||
));
|
||||
TargetCard target = new TargetCardInLibrary(filter);
|
||||
Cards cards = new CardsImpl(
|
||||
player.getLibrary().getTopCards(game, xValue)
|
||||
);
|
||||
if (player.chooseUse(outcome, "Put a card onto the battlefield?", source, game)
|
||||
&& player.choose(outcome, cards, target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
if (card != null
|
||||
&& player.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
cards.remove(card);
|
||||
}
|
||||
}
|
||||
while (!cards.isEmpty()) {
|
||||
Card card = cards.getRandom(game);
|
||||
player.getLibrary().putOnBottom(card, game);
|
||||
cards.remove(card);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -92,6 +92,7 @@ public final class GuildsOfRavnica extends ExpansionSet {
|
|||
cards.add(new SetCardInfo("Guild Summit", 41, Rarity.UNCOMMON, mage.cards.g.GuildSummit.class));
|
||||
cards.add(new SetCardInfo("Haazda Marshal", 13, Rarity.UNCOMMON, mage.cards.h.HaazdaMarshal.class));
|
||||
cards.add(new SetCardInfo("Hammer Dropper", 176, Rarity.COMMON, mage.cards.h.HammerDropper.class));
|
||||
cards.add(new SetCardInfo("Hatchery Spider", 132, Rarity.RARE, mage.cards.h.HatcherySpider.class));
|
||||
cards.add(new SetCardInfo("Healer's Hawk", 14, Rarity.COMMON, mage.cards.h.HealersHawk.class));
|
||||
cards.add(new SetCardInfo("House Guildmage", 177, Rarity.UNCOMMON, mage.cards.h.HouseGuildmage.class));
|
||||
cards.add(new SetCardInfo("Hunted Witness", 15, Rarity.COMMON, mage.cards.h.HuntedWitness.class));
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.effects.common;
|
||||
|
||||
import mage.MageObject;
|
||||
|
@ -16,18 +15,25 @@ import mage.game.stack.Spell;
|
|||
public class CastSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public static final String SOURCE_CAST_SPELL_ABILITY = "sourceCastSpellAbility";
|
||||
private final String rulePrefix;
|
||||
|
||||
public CastSourceTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public CastSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, "");
|
||||
}
|
||||
|
||||
public CastSourceTriggeredAbility(Effect effect, boolean optional, String rulePrefix) {
|
||||
super(Zone.STACK, effect, optional);
|
||||
this.ruleAtTheTop = true;
|
||||
this.rulePrefix = rulePrefix;
|
||||
}
|
||||
|
||||
public CastSourceTriggeredAbility(final CastSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.rulePrefix = ability.rulePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,6 +65,6 @@ public class CastSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "When you cast {source}, " + super.getRule();
|
||||
return rulePrefix + "When you cast this spell, " + super.getRule();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue