[J22] Implement Skullslither Worm

This commit is contained in:
PurpleCrowbar 2023-02-09 16:38:00 +00:00
parent a926b638e0
commit f985e15459
2 changed files with 101 additions and 0 deletions

View file

@ -0,0 +1,100 @@
package mage.cards.s;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetDiscard;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author PurpleCrowbar
*/
public final class SkullslitherWorm extends CardImpl {
public SkullslitherWorm(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add(SubType.WORM);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// When Skullslither Worm enters the battlefield, each opponent discards a card.
// For each opponent who can't, put two +1/+1 counters on Skullslither Worm.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SkullslitherWormEffect()));
}
private SkullslitherWorm(final SkullslitherWorm card) {
super(card);
}
@Override
public SkullslitherWorm copy() {
return new SkullslitherWorm(this);
}
}
class SkullslitherWormEffect extends OneShotEffect {
SkullslitherWormEffect() {
super(Outcome.Benefit);
this.staticText = "each opponent discards a card. For each opponent who can't, put two +1/+1 counters on {this}";
}
private SkullslitherWormEffect(final SkullslitherWormEffect effect) {
super(effect);
}
@Override
public SkullslitherWormEffect copy() {
return new SkullslitherWormEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Map<UUID, Cards> cardsToDiscard = new HashMap<>();
// choose cards to discard
for (UUID playerId : game.getOpponents(source.getControllerId(), true)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int numberOfCardsToDiscard = Math.min(1, player.getHand().size());
Cards cards = new CardsImpl();
Target target = new TargetDiscard(numberOfCardsToDiscard, numberOfCardsToDiscard, StaticFilters.FILTER_CARD, playerId);
player.chooseTarget(outcome, target, source, game);
cards.addAll(target.getTargets());
cardsToDiscard.put(playerId, cards);
}
// discard all chosen cards
for (UUID playerId : game.getOpponents(source.getControllerId(), true)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
int amountDiscarded = player.discard(cardsToDiscard.get(playerId), false, source, game).size();
if (amountDiscarded == 0 && permanent != null) {
permanent.addCounters(CounterType.P1P1.createInstance(2), source, game);
}
}
return true;
}
}

View file

@ -654,6 +654,7 @@ public final class Jumpstart2022 extends ExpansionSet {
cards.add(new SetCardInfo("Skilled Animator", 348, Rarity.UNCOMMON, mage.cards.s.SkilledAnimator.class));
cards.add(new SetCardInfo("Skirsdag High Priest", 467, Rarity.RARE, mage.cards.s.SkirsdagHighPriest.class));
cards.add(new SetCardInfo("Skirsdag Supplicant", 468, Rarity.COMMON, mage.cards.s.SkirsdagSupplicant.class));
cards.add(new SetCardInfo("Skullslither Worm", 26, Rarity.UNCOMMON, mage.cards.s.SkullslitherWorm.class));
cards.add(new SetCardInfo("Skyhunter Patrol", 245, Rarity.COMMON, mage.cards.s.SkyhunterPatrol.class));
cards.add(new SetCardInfo("Skyhunter Prowler", 246, Rarity.COMMON, mage.cards.s.SkyhunterProwler.class));
cards.add(new SetCardInfo("Sling-Gang Lieutenant", 469, Rarity.UNCOMMON, mage.cards.s.SlingGangLieutenant.class));