[MID] Implemented Sungold Sentinel

This commit is contained in:
Evan Kranzler 2021-09-17 08:43:49 -04:00
parent 6dd0cb69e7
commit 7c2db3c5fc
5 changed files with 231 additions and 0 deletions

View file

@ -0,0 +1,94 @@
package mage.cards.s;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldOrAttacksSourceTriggeredAbility;
import mage.abilities.condition.common.CovenCondition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalActivatedAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByAllSourceEffect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.hint.common.CovenHint;
import mage.abilities.keyword.HexproofBaseAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceColor;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInGraveyard;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class SungoldSentinel extends CardImpl {
public SungoldSentinel(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.SOLDIER);
this.power = new MageInt(3);
this.toughness = new MageInt(2);
// Whenever Sungold Sentinel enters the battlefield or attacks, exile up to one target card from a graveyard.
Ability ability = new EntersBattlefieldOrAttacksSourceTriggeredAbility(new ExileTargetEffect());
ability.addTarget(new TargetCardInGraveyard(0, 1));
this.addAbility(ability);
// Coven {1}{W}: Choose a color. Sungold Sentinel gains hexproof from that color until end of turn and can't be blocked by creatures of that color this turn. Activate only if you control three or more creatures with different powers.
this.addAbility(new ConditionalActivatedAbility(
Zone.BATTLEFIELD, new SungoldSentinelEffect(),
new ManaCostsImpl<>("{1}{W}"), CovenCondition.instance
).addHint(CovenHint.instance).setAbilityWord(AbilityWord.COVEN));
}
private SungoldSentinel(final SungoldSentinel card) {
super(card);
}
@Override
public SungoldSentinel copy() {
return new SungoldSentinel(this);
}
}
class SungoldSentinelEffect extends OneShotEffect {
SungoldSentinelEffect() {
super(Outcome.Benefit);
staticText = "choose a color. {this} gains hexproof from that color until end of turn " +
"and can't be blocked by creatures of that color this turn";
}
private SungoldSentinelEffect(final SungoldSentinelEffect effect) {
super(effect);
}
@Override
public SungoldSentinelEffect copy() {
return new SungoldSentinelEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ChoiceColor choice = new ChoiceColor(true);
player.choose(outcome, choice, game);
Ability ability = HexproofBaseAbility.getFirstFromColor(choice.getColor());
game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
game.addEffect(new CantBeBlockedByAllSourceEffect(filter, Duration.EndOfTurn), source);
return true;
}
}

View file

@ -292,6 +292,7 @@ public final class InnistradMidnightHunt extends ExpansionSet {
cards.add(new SetCardInfo("Stromkirk Bloodthief", 123, Rarity.UNCOMMON, mage.cards.s.StromkirkBloodthief.class));
cards.add(new SetCardInfo("Stuffed Bear", 259, Rarity.COMMON, mage.cards.s.StuffedBear.class));
cards.add(new SetCardInfo("Sungold Barrage", 36, Rarity.COMMON, mage.cards.s.SungoldBarrage.class));
cards.add(new SetCardInfo("Sungold Sentinel", 37, Rarity.RARE, mage.cards.s.SungoldSentinel.class));
cards.add(new SetCardInfo("Sunrise Cavalier", 244, Rarity.UNCOMMON, mage.cards.s.SunriseCavalier.class));
cards.add(new SetCardInfo("Sunset Revelry", 38, Rarity.UNCOMMON, mage.cards.s.SunsetRevelry.class));
cards.add(new SetCardInfo("Sunstreak Phoenix", 162, Rarity.MYTHIC, mage.cards.s.SunstreakPhoenix.class));

View file

@ -1,12 +1,16 @@
package mage.abilities.keyword;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.MageSingleton;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.icon.abilities.HexproofAbilityIcon;
import mage.constants.Zone;
import mage.game.Game;
import java.util.HashSet;
import java.util.Set;
/**
* an abstract base class for hexproof abilities
*
@ -20,4 +24,40 @@ public abstract class HexproofBaseAbility extends SimpleStaticAbility implements
}
public abstract boolean checkObject(MageObject source, Game game);
public static Set<HexproofBaseAbility> getFromColor(ObjectColor color) {
Set<HexproofBaseAbility> abilities = new HashSet<>();
if (color.isWhite()) {
abilities.add(HexproofFromWhiteAbility.getInstance());
}
if (color.isBlue()) {
abilities.add(HexproofFromBlueAbility.getInstance());
}
if (color.isBlack()) {
abilities.add(HexproofFromBlackAbility.getInstance());
}
if (color.isRed()) {
abilities.add(HexproofFromRedAbility.getInstance());
}
if (color.isGreen()) {
abilities.add(HexproofFromGreenAbility.getInstance());
}
return abilities;
}
public static HexproofBaseAbility getFirstFromColor(ObjectColor color) {
if (color.isWhite()) {
return HexproofFromWhiteAbility.getInstance();
} else if (color.isBlue()) {
return HexproofFromBlueAbility.getInstance();
} else if (color.isBlack()) {
return HexproofFromBlackAbility.getInstance();
} else if (color.isRed()) {
return HexproofFromRedAbility.getInstance();
} else if (color.isGreen()) {
return HexproofFromGreenAbility.getInstance();
} else {
return null;
}
}
}

View file

@ -0,0 +1,48 @@
package mage.abilities.keyword;
import mage.MageObject;
import mage.game.Game;
import java.io.ObjectStreamException;
/**
* Hexproof from green (This creature or player can't be the target of green
* spells or abilities your opponents control.)
*
* @author igoudt
*/
public class HexproofFromGreenAbility extends HexproofBaseAbility {
private static final HexproofFromGreenAbility instance;
static {
instance = new HexproofFromGreenAbility();
}
private Object readResolve() throws ObjectStreamException {
return instance;
}
public static HexproofFromGreenAbility getInstance() {
return instance;
}
private HexproofFromGreenAbility() {
super();
}
@Override
public boolean checkObject(MageObject source, Game game) {
return source.getColor(game).isGreen();
}
@Override
public HexproofFromGreenAbility copy() {
return instance;
}
@Override
public String getRule() {
return "hexproof from green <i>(This creature can't be the target of green spells or abilities your opponents control.)</i>";
}
}

View file

@ -0,0 +1,48 @@
package mage.abilities.keyword;
import mage.MageObject;
import mage.game.Game;
import java.io.ObjectStreamException;
/**
* Hexproof from red (This creature or player can't be the target of red
* spells or abilities your opponents control.)
*
* @author igoudt
*/
public class HexproofFromRedAbility extends HexproofBaseAbility {
private static final HexproofFromRedAbility instance;
static {
instance = new HexproofFromRedAbility();
}
private Object readResolve() throws ObjectStreamException {
return instance;
}
public static HexproofFromRedAbility getInstance() {
return instance;
}
private HexproofFromRedAbility() {
super();
}
@Override
public boolean checkObject(MageObject source, Game game) {
return source.getColor(game).isRed();
}
@Override
public HexproofFromRedAbility copy() {
return instance;
}
@Override
public String getRule() {
return "hexproof from red <i>(This creature can't be the target of red spells or abilities your opponents control.)</i>";
}
}