Implemented Alpine Moon

This commit is contained in:
Evan Kranzler 2018-06-19 13:32:15 -04:00
parent 880534c4df
commit 8116f1365e
4 changed files with 147 additions and 0 deletions

View file

@ -0,0 +1,114 @@
package mage.cards.a;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ChooseACardNameEffect;
import mage.abilities.mana.AnyColorManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author TheElk801
*/
public final class AlpineMoon extends CardImpl {
public AlpineMoon(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{R}");
// As Alpine Moon enters the battlefield, choose a nonbasic land card name.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseACardNameEffect(ChooseACardNameEffect.TypeOfName.NONBASIC_LAND_NAME)));
// Lands your opponents control with the chosen name lose all land types and abilities, and they gain "{T}: Add one mana of any color."
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AlpineMoonEffect()));
}
public AlpineMoon(final AlpineMoon card) {
super(card);
}
@Override
public AlpineMoon copy() {
return new AlpineMoon(this);
}
}
class AlpineMoonEffect extends ContinuousEffectImpl {
private static final FilterPermanent filter = new FilterLandPermanent();
static {
filter.add(new ControllerPredicate(TargetController.OPPONENT));
filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
}
public AlpineMoonEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
this.staticText = "lands your opponents control with the chosen name "
+ "lose all land types and abilities, "
+ "and they gain \"{T}: Add one mana of any color.\"";
}
public AlpineMoonEffect(final AlpineMoonEffect effect) {
super(effect);
}
@Override
public AlpineMoonEffect copy() {
return new AlpineMoonEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY);
if (cardName == null) {
return false;
}
FilterPermanent filter2 = filter.copy();
filter2.add(new NamePredicate(cardName));
for (Permanent land : game.getBattlefield().getActivePermanents(filter2, source.getControllerId(), game)) {
switch (layer) {
case TypeChangingEffects_4:
// 305.7 Note that this doesn't remove any abilities that were granted to the land by other effects
// So the ability removing has to be done before Layer 6
land.removeAllAbilities(source.getSourceId(), game);
land.getSubtype(game).removeAll(SubType.getLandTypes(false));
break;
case AbilityAddingRemovingEffects_6:
land.addAbility(new AnyColorManaAbility(), source.getSourceId(), game);
break;
}
}
return true;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.TypeChangingEffects_4;
}
}

View file

@ -37,6 +37,7 @@ public final class CoreSet2019 extends ExpansionSet {
cards.add(new SetCardInfo("Ajani's Pridemate", 5, Rarity.UNCOMMON, mage.cards.a.AjanisPridemate.class));
cards.add(new SetCardInfo("Ajani, Adversary of Tyrants", 3, Rarity.MYTHIC, mage.cards.a.AjaniAdversaryOfTyrants.class));
cards.add(new SetCardInfo("Ajani, Wise Counselor", 281, Rarity.MYTHIC, mage.cards.a.AjaniWiseCounselor.class));
cards.add(new SetCardInfo("Alpine Moon", 128, Rarity.RARE, mage.cards.a.AlpineMoon.class));
cards.add(new SetCardInfo("Anticipate", 44, Rarity.COMMON, mage.cards.a.Anticipate.class));
cards.add(new SetCardInfo("Apex of Power", 129, Rarity.MYTHIC, mage.cards.a.ApexOfPower.class));
cards.add(new SetCardInfo("Arisen Gorgon", 292, Rarity.UNCOMMON, mage.cards.a.ArisenGorgon.class));

View file

@ -24,6 +24,7 @@ public class ChooseACardNameEffect extends OneShotEffect {
ALL,
NOT_BASIC_LAND_NAME,
NONBASIC_LAND_NAME,
NON_ARTIFACT_AND_NON_LAND_NAME,
NON_LAND_NAME,
NON_LAND_AND_NON_CREATURE_NAME,
@ -62,6 +63,10 @@ public class ChooseACardNameEffect extends OneShotEffect {
cardChoice.setChoices(CardRepository.instance.getNotBasicLandNames());
cardChoice.setMessage("Choose a card name other than a basic land card name");
break;
case NONBASIC_LAND_NAME:
cardChoice.setChoices(CardRepository.instance.getNonbasicLandNames());
cardChoice.setMessage("Choose a nonbasic land card name");
break;
case NON_ARTIFACT_AND_NON_LAND_NAME:
cardChoice.setChoices(CardRepository.instance.getNonArtifactAndNonLandNames());
cardChoice.setMessage("Choose a nonartifact, nonland card name");
@ -113,6 +118,9 @@ public class ChooseACardNameEffect extends OneShotEffect {
case NOT_BASIC_LAND_NAME:
sb.append("card name other than a basic land card");
break;
case NONBASIC_LAND_NAME:
sb.append("nonbasic land card name");
break;
case NON_ARTIFACT_AND_NON_LAND_NAME:
sb.append("nonartifact, nonland card");
break;

View file

@ -153,6 +153,30 @@ public enum CardRepository {
return names;
}
public Set<String> getNonbasicLandNames() {
Set<String> names = new TreeSet<>();
try {
QueryBuilder<CardInfo, Object> qb = cardDao.queryBuilder();
qb.distinct().selectColumns("name");
Where where = qb.where();
where.and(where.not().not().like("supertypes", '%' + SuperType.BASIC.name() + '%'), where.like("types", '%' + CardType.LAND.name() + '%'));
List<CardInfo> results = cardDao.query(qb.prepare());
for (CardInfo card : results) {
int result = card.getName().indexOf(" // ");
if (result > 0) {
names.add(card.getName().substring(0, result));
names.add(card.getName().substring(result + 4));
} else {
names.add(card.getName());
}
}
} catch (SQLException ex) {
Logger.getLogger(CardRepository.class).error("Error getting non-land names from DB : " + ex);
}
return names;
}
public Set<String> getNotBasicLandNames() {
Set<String> names = new TreeSet<>();
try {