[MH2] Implemented Yavimaya, Cradle of Growth

This commit is contained in:
Evan Kranzler 2021-06-05 09:02:04 -04:00
parent f41ff7177e
commit ac04c27133
4 changed files with 130 additions and 83 deletions

View file

@ -1,32 +1,14 @@
package mage.cards.u;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.effects.common.continuous.AddBasicLandTypeAllLandsEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.DependencyType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.TypeChangingEffects_4;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.constants.*;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class UrborgTombOfYawgmoth extends CardImpl {
@ -36,9 +18,7 @@ public final class UrborgTombOfYawgmoth extends CardImpl {
addSuperType(SuperType.LEGENDARY);
// Each land is a Swamp in addition to its other land types.
Ability ability = new SimpleStaticAbility(new UrborgTombOfYawgmothEffect());
this.addAbility(ability);
this.addAbility(new SimpleStaticAbility(new AddBasicLandTypeAllLandsEffect(SubType.SWAMP)));
}
private UrborgTombOfYawgmoth(final UrborgTombOfYawgmoth card) {
@ -49,62 +29,4 @@ public final class UrborgTombOfYawgmoth extends CardImpl {
public UrborgTombOfYawgmoth copy() {
return new UrborgTombOfYawgmoth(this);
}
class UrborgTombOfYawgmothEffect extends ContinuousEffectImpl {
UrborgTombOfYawgmothEffect() {
super(Duration.WhileOnBattlefield, Outcome.AIDontUseIt);
this.staticText = "Each land is a Swamp in addition to its other land types";
this.dependencyTypes.add(DependencyType.BecomeSwamp);
}
UrborgTombOfYawgmothEffect(final UrborgTombOfYawgmothEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public UrborgTombOfYawgmothEffect copy() {
return new UrborgTombOfYawgmothEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
for (Permanent land : game.getBattlefield().getActivePermanents(new FilterLandPermanent(), 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
// Lands have their mana ability intrinsically, so that is added in layer 4
if (!land.hasSubtype(SubType.SWAMP, game)) {
land.addSubType(game, SubType.SWAMP);
}
if (!land.getAbilities().containsRule(new BlackManaAbility())) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
break;
}
}
return true;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.TypeChangingEffects_4;
}
@Override
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
// the dependent classes needs to be an enclosed class for dependent check of continuous effects
return allEffectsInLayer.stream()
.filter(effect -> mage.cards.b.BloodMoon.class.equals(effect.getClass().getEnclosingClass()))
.map(Effect::getId)
.collect(Collectors.toSet()); // Blood Moon affects non-basic land like Urborg
}
}
}

View file

@ -0,0 +1,35 @@
package mage.cards.y;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.continuous.AddBasicLandTypeAllLandsEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class YavimayaCradleOfGrowth extends CardImpl {
public YavimayaCradleOfGrowth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
this.addSuperType(SuperType.LEGENDARY);
// Each land is a Forest in addition to its other land types.
this.addAbility(new SimpleStaticAbility(new AddBasicLandTypeAllLandsEffect(SubType.FOREST)));
}
private YavimayaCradleOfGrowth(final YavimayaCradleOfGrowth card) {
super(card);
}
@Override
public YavimayaCradleOfGrowth copy() {
return new YavimayaCradleOfGrowth(this);
}
}

View file

@ -311,6 +311,7 @@ public final class ModernHorizons2 extends ExpansionSet {
cards.add(new SetCardInfo("World-Weary", 109, Rarity.COMMON, mage.cards.w.WorldWeary.class));
cards.add(new SetCardInfo("Wren's Run Hydra", 183, Rarity.UNCOMMON, mage.cards.w.WrensRunHydra.class));
cards.add(new SetCardInfo("Yavimaya Elder", 288, Rarity.UNCOMMON, mage.cards.y.YavimayaElder.class));
cards.add(new SetCardInfo("Yavimaya, Cradle of Growth", 261, Rarity.RARE, mage.cards.y.YavimayaCradleOfGrowth.class));
cards.add(new SetCardInfo("Young Necromancer", 110, Rarity.UNCOMMON, mage.cards.y.YoungNecromancer.class));
cards.add(new SetCardInfo("Yusri, Fortune's Flame", 218, Rarity.RARE, mage.cards.y.YusriFortunesFlame.class));
cards.add(new SetCardInfo("Zuran Orb", 300, Rarity.UNCOMMON, mage.cards.z.ZuranOrb.class));

View file

@ -0,0 +1,89 @@
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.mana.*;
import mage.constants.*;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import org.junit.Assert;
/**
* @author Plopman, TheElk801
*/
public class AddBasicLandTypeAllLandsEffect extends ContinuousEffectImpl {
private final SubType subType;
public AddBasicLandTypeAllLandsEffect(SubType subType) {
super(Duration.WhileOnBattlefield, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.AIDontUseIt);
this.subType = subType;
this.staticText = "Each land is " + subType.getIndefiniteArticle() + " "
+ subType.getDescription() + " in addition to its other land types";
Assert.assertSame("Subtype should be a basic land type", subType.getSubTypeSet(), SubTypeSet.BasicLandType);
switch (subType) {
case PLAINS:
this.dependencyTypes.add(DependencyType.BecomePlains);
break;
case ISLAND:
this.dependencyTypes.add(DependencyType.BecomeIsland);
break;
case SWAMP:
this.dependencyTypes.add(DependencyType.BecomeSwamp);
break;
case MOUNTAIN:
this.dependencyTypes.add(DependencyType.BecomeMountain);
break;
case FOREST:
this.dependencyTypes.add(DependencyType.BecomeForest);
break;
}
}
private AddBasicLandTypeAllLandsEffect(final AddBasicLandTypeAllLandsEffect effect) {
super(effect);
this.subType = effect.subType;
}
@Override
public AddBasicLandTypeAllLandsEffect copy() {
return new AddBasicLandTypeAllLandsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Ability ability;
switch (subType) {
case PLAINS:
ability = new WhiteManaAbility();
break;
case ISLAND:
ability = new BlueManaAbility();
break;
case SWAMP:
ability = new BlackManaAbility();
break;
case MOUNTAIN:
ability = new RedManaAbility();
break;
case FOREST:
ability = new GreenManaAbility();
break;
default:
ability = null;
}
for (Permanent land : game.getBattlefield().getActivePermanents(
StaticFilters.FILTER_LAND, source.getControllerId(), game
)) {
// 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
// Lands have their mana ability intrinsically, so that is added in layer 4
land.addSubType(game, subType);
if (ability != null && !land.getAbilities().containsRule(ability)) {
land.addAbility(ability, source.getSourceId(), game);
}
}
return true;
}
}