diff --git a/Mage.Sets/src/mage/cards/c/CrystallineGiant.java b/Mage.Sets/src/mage/cards/c/CrystallineGiant.java new file mode 100644 index 0000000000..888bdfc897 --- /dev/null +++ b/Mage.Sets/src/mage/cards/c/CrystallineGiant.java @@ -0,0 +1,103 @@ +package mage.cards.c; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.TargetController; +import mage.counters.CounterType; +import mage.counters.Counters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.util.RandomUtil; + +import java.util.EnumSet; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class CrystallineGiant extends CardImpl { + + public CrystallineGiant(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}"); + + this.subtype.add(SubType.GIANT); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // At the beginning of combat on your turn, choose a kind of counter at random that Crystalline Giant doesn't have on it from among flying, first strike, deathtouch, hexproof, lifelink, menace, reach, trample, vigilance, or +1/+1. Put a counter of that kind on Crystalline Giant. + this.addAbility(new BeginningOfCombatTriggeredAbility( + new CrystallineGiantEffect(), TargetController.YOU, false + )); + } + + private CrystallineGiant(final CrystallineGiant card) { + super(card); + } + + @Override + public CrystallineGiant copy() { + return new CrystallineGiant(this); + } +} + +class CrystallineGiantEffect extends OneShotEffect { + + private static final EnumSet counterTypeSet = EnumSet.noneOf(CounterType.class); + + static { + counterTypeSet.add(CounterType.FLYING); + counterTypeSet.add(CounterType.FIRST_STRIKE); + counterTypeSet.add(CounterType.DEATHTOUCH); + counterTypeSet.add(CounterType.HEXPROOF); + counterTypeSet.add(CounterType.LIFELINK); + counterTypeSet.add(CounterType.MENACE); + counterTypeSet.add(CounterType.REACH); + counterTypeSet.add(CounterType.TRAMPLE); + counterTypeSet.add(CounterType.VIGILANCE); + counterTypeSet.add(CounterType.P1P1); + } + + CrystallineGiantEffect() { + super(Outcome.Benefit); + staticText = "choose a kind of counter at random that {this} doesn't have on it from among " + + "flying, first strike, deathtouch, hexproof, lifelink, menace, reach, trample, vigilance, or +1/+1. " + + "Put a counter of that kind on {this}"; + } + + private CrystallineGiantEffect(final CrystallineGiantEffect effect) { + super(effect); + } + + @Override + public CrystallineGiantEffect copy() { + return new CrystallineGiantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null) { + return false; + } + Counters counters = permanent.getCounters(game); + List counterTypes = counterTypeSet + .stream() + .filter(counterType -> !counters.containsKey(counterType)) + .collect(Collectors.toList()); + if (counterTypes.size() == 0) { + return false; + } + return permanent.addCounters(counterTypes.get( + RandomUtil.nextInt(counterTypes.size()) + ).createInstance(), source, game); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java index 690f6b8de2..79f4642852 100644 --- a/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java +++ b/Mage.Sets/src/mage/sets/IkoriaLairOfBehemoths.java @@ -35,6 +35,7 @@ public final class IkoriaLairOfBehemoths extends ExpansionSet { cards.add(new SetCardInfo("Chittering Harvester", 80, Rarity.UNCOMMON, mage.cards.c.ChitteringHarvester.class)); cards.add(new SetCardInfo("Cloudpiercer", 112, Rarity.COMMON, mage.cards.c.Cloudpiercer.class)); cards.add(new SetCardInfo("Colossification", 148, Rarity.RARE, mage.cards.c.Colossification.class)); + cards.add(new SetCardInfo("Crystalline Giant", 234, Rarity.RARE, mage.cards.c.CrystallineGiant.class)); cards.add(new SetCardInfo("Dire Tactics", 183, Rarity.UNCOMMON, mage.cards.d.DireTactics.class)); cards.add(new SetCardInfo("Dirge Bat", 84, Rarity.RARE, mage.cards.d.DirgeBat.class)); cards.add(new SetCardInfo("Drannith Stinger", 113, Rarity.COMMON, mage.cards.d.DrannithStinger.class));