- Added Musician and Illusionary Terrain.

This commit is contained in:
Jeff 2019-01-07 14:37:44 -06:00
parent 704972b6b1
commit 2b4c7eba13
5 changed files with 367 additions and 0 deletions

View file

@ -0,0 +1,229 @@
package mage.cards.i;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.abilities.mana.BlackManaAbility;
import mage.abilities.mana.BlueManaAbility;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.abilities.mana.WhiteManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.ChoiceBasicLandType;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import static mage.constants.Layer.AbilityAddingRemovingEffects_6;
import static mage.constants.Layer.TypeChangingEffects_4;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
* @author jeffwadsworth
*/
public final class IllusionaryTerrain extends CardImpl {
public IllusionaryTerrain(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}{U}");
// Cumulative upkeep {2}
this.addAbility(new CumulativeUpkeepAbility(new ManaCostsImpl("{2}")));
// As Illusionary Terrain enters the battlefield, choose two basic land types.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseTwoBasicLandTypesEffect(Outcome.Neutral)));
// Basic lands of the first chosen type are the second chosen type.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new IllusionaryTerrainEffect()));
}
private IllusionaryTerrain(final IllusionaryTerrain card) {
super(card);
}
@Override
public IllusionaryTerrain copy() {
return new IllusionaryTerrain(this);
}
}
class IllusionaryTerrainEffect extends ContinuousEffectImpl {
public IllusionaryTerrainEffect() {
super(Duration.WhileOnBattlefield, Outcome.Neutral);
staticText = "Basic lands of the first chosen type are the second chosen type";
}
public IllusionaryTerrainEffect(final IllusionaryTerrainEffect effect) {
super(effect);
}
@Override
public IllusionaryTerrainEffect copy() {
return new IllusionaryTerrainEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
SubType firstChoice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "firstChoice"));
SubType secondChoice = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "secondChoice"));
List<Permanent> lands = game.getBattlefield().getAllActivePermanents(CardType.LAND);
if (controller != null
&& firstChoice != null
&& secondChoice != null) {
for (Permanent land : lands) {
if (land != null
&& land.isBasic()) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
land.getSubtype(game).clear();
land.getSubtype(game).add(secondChoice);
}
break;
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
boolean addAbility = true;
land.getAbilities().clear();
if (secondChoice.equals(SubType.FOREST)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof GreenManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new GreenManaAbility(), source.getSourceId(), game);
}
}
if (secondChoice.equals(SubType.PLAINS)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof WhiteManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new WhiteManaAbility(), source.getSourceId(), game);
}
}
if (secondChoice.equals(SubType.MOUNTAIN)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof RedManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new RedManaAbility(), source.getSourceId(), game);
}
}
if (secondChoice.equals(SubType.ISLAND)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof BlueManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new BlueManaAbility(), source.getSourceId(), game);
}
}
if (secondChoice.equals(SubType.SWAMP)) {
for (Ability existingAbility : land.getAbilities()) {
if (existingAbility instanceof BlackManaAbility) {
addAbility = false;
break;
}
}
if (addAbility) {
land.addAbility(new BlackManaAbility(), source.getSourceId(), game);
}
}
}
break;
}
}
}
return true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.AbilityAddingRemovingEffects_6
|| layer == Layer.TypeChangingEffects_4;
}
}
class ChooseTwoBasicLandTypesEffect extends OneShotEffect {
String choiceOne;
String choiceTwo;
public ChooseTwoBasicLandTypesEffect(Outcome outcome) {
super(outcome);
this.staticText = "choose two basic land types";
}
public ChooseTwoBasicLandTypesEffect(final ChooseTwoBasicLandTypesEffect effect) {
super(effect);
}
@Override
public ChooseTwoBasicLandTypesEffect copy() {
return new ChooseTwoBasicLandTypesEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (mageObject == null) {
mageObject = game.getObject(source.getSourceId());
}
if (controller != null
&& mageObject != null) {
ChoiceImpl choices = new ChoiceBasicLandType();
if (controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(mageObject.getName() + ": First chosen basic land type is " + choices.getChoice());
game.getState().setValue(mageObject.getId().toString() + "firstChoice", choices.getChoice());
choiceOne = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "firstChoice")).getDescription();
}
if (controller.choose(Outcome.Neutral, choices, game)) {
game.informPlayers(mageObject.getName() + ": Second chosen basic land type is " + choices.getChoice());
game.getState().setValue(mageObject.getId().toString() + "secondChoice", choices.getChoice());
choiceTwo = SubType.byDescription((String) game.getState().getValue(source.getSourceId().toString() + "secondChoice")).getDescription();
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("Chosen Types", CardUtil.addToolTipMarkTags("First chosen basic land type: " + choiceOne
+ "\n Second chosen basic land type: " + choiceTwo), game);
}
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,134 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.constants.SubType;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.CountersSourceCount;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.DestroySourceEffect;
import mage.abilities.effects.common.DoUnlessControllerPaysEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author jeffwadsworth
*/
public final class Musician extends CardImpl {
public Musician(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
this.power = new MageInt(1);
this.toughness = new MageInt(3);
// Cumulative upkeep {1}
this.addAbility(new CumulativeUpkeepAbility(new ManaCostsImpl("{1}")));
// {tap}: Put a music counter on target creature. If it doesn't have "At the beginning of your upkeep, destroy this creature unless you pay {1} for each music counter on it," it gains that ability.
Effect effect = new DoUnlessControllerPaysEffect(
new DestroySourceEffect(),
new DynamicValueGenericManaCost(
new CountersSourceCount(
CounterType.MUSIC)));
effect.setText("destroy this creature unless you pay {1} for each music counter on it");
Ability ability = new BeginningOfUpkeepTriggeredAbility(
Zone.BATTLEFIELD,
effect,
TargetController.YOU,
false,
false,
"At the beginning of your upkeep, ");
Effect effect2 = new AddCountersTargetEffect(CounterType.MUSIC.createInstance());
effect2.setText("Put a music counter on target creature");
Effect effect3 = new GainAbilityTargetEffect(
ability,
Duration.WhileOnBattlefield);
effect3.setText("If it doesn't have \"At the beginning of your upkeep, destroy this creature unless you pay {1} for each music counter on it,\" it gains that ability");
Ability ability2 = new SimpleActivatedAbility(
Zone.BATTLEFIELD,
effect2,
new TapSourceCost());
ability2.addTarget(new TargetCreaturePermanent());
ability2.addEffect(effect3);
this.addAbility(ability2);
}
private Musician(final Musician card) {
super(card);
}
@Override
public Musician copy() {
return new Musician(this);
}
}
class DynamicValueGenericManaCost extends CostImpl {
DynamicValue amount;
public DynamicValueGenericManaCost(DynamicValue amount) {
this.amount = amount;
setText();
}
public DynamicValueGenericManaCost(DynamicValueGenericManaCost cost) {
super(cost);
this.amount = cost.amount;
}
@Override
public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) {
Player controller = game.getPlayer(controllerId);
if (controller == null) {
return false;
}
int convertedCost = amount.calculate(game, ability, null);
Cost cost = new GenericManaCost(convertedCost);
return cost.canPay(ability, sourceId, controllerId, game);
}
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
int convertedCost = amount.calculate(game, ability, null);
Cost cost = new GenericManaCost(convertedCost);
if (controller != null) {
paid = cost.pay(ability, game, sourceId, controllerId, noMana);
}
return paid;
}
@Override
public DynamicValueGenericManaCost copy() {
return new DynamicValueGenericManaCost(this);
}
private void setText() {
text = ("{1} for each music counter on {this}");
}
}

View file

@ -162,6 +162,7 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Icy Manipulator", 322, Rarity.UNCOMMON, mage.cards.i.IcyManipulator.class));
cards.add(new SetCardInfo("Icy Prison", 74, Rarity.RARE, mage.cards.i.IcyPrison.class));
cards.add(new SetCardInfo("Illusionary Forces", 75, Rarity.COMMON, mage.cards.i.IllusionaryForces.class));
cards.add(new SetCardInfo("Illusionary Terrain", 77, Rarity.UNCOMMON, mage.cards.i.IllusionaryTerrain.class));
cards.add(new SetCardInfo("Illusionary Wall", 78, Rarity.COMMON, mage.cards.i.IllusionaryWall.class));
cards.add(new SetCardInfo("Illusions of Grandeur", 79, Rarity.RARE, mage.cards.i.IllusionsOfGrandeur.class));
cards.add(new SetCardInfo("Imposing Visage", 193, Rarity.COMMON, mage.cards.i.ImposingVisage.class));
@ -231,6 +232,7 @@ public final class IceAge extends ExpansionSet {
cards.add(new SetCardInfo("Mountain", 377, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mountain", 378, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Mudslide", 204, Rarity.RARE, mage.cards.m.Mudslide.class));
cards.add(new SetCardInfo("Musician", 85, Rarity.RARE, mage.cards.m.Musician.class));
cards.add(new SetCardInfo("Mystic Might", 86, Rarity.RARE, mage.cards.m.MysticMight.class));
cards.add(new SetCardInfo("Mystic Remora", 87, Rarity.COMMON, mage.cards.m.MysticRemora.class));
cards.add(new SetCardInfo("Nacre Talisman", 329, Rarity.UNCOMMON, mage.cards.n.NacreTalisman.class));

View file

@ -161,6 +161,7 @@ public final class MastersEditionII extends ExpansionSet {
cards.add(new SetCardInfo("Mishra's Groundbreaker", 215, Rarity.UNCOMMON, mage.cards.m.MishrasGroundbreaker.class));
cards.add(new SetCardInfo("Misinformation", 105, Rarity.UNCOMMON, mage.cards.m.Misinformation.class));
cards.add(new SetCardInfo("Mudslide", 136, Rarity.RARE, mage.cards.m.Mudslide.class));
cards.add(new SetCardInfo("Musician", 56, Rarity.RARE, mage.cards.m.Musician.class));
cards.add(new SetCardInfo("Narwhal", 57, Rarity.UNCOMMON, mage.cards.n.Narwhal.class));
cards.add(new SetCardInfo("Nature's Blessing", 196, Rarity.UNCOMMON, mage.cards.n.NaturesBlessing.class));
cards.add(new SetCardInfo("Nature's Wrath", 172, Rarity.RARE, mage.cards.n.NaturesWrath.class));

View file

@ -80,6 +80,7 @@ public enum CounterType {
MINE("mine"),
MINING("mining"),
MIRE("mire"),
MUSIC("music"),
MUSTER("muster"),
NET("net"),
OMEN("omen"),