Merge remote-tracking branch 'upstream/master'

This commit is contained in:
drmDev 2016-07-04 04:16:33 -04:00
commit eb8519cd78
12 changed files with 282 additions and 53 deletions

View file

@ -29,12 +29,14 @@ package mage.sets.apocalypse;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
@ -42,8 +44,8 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
import mage.game.Game;
/**
*
@ -60,16 +62,12 @@ public class BrassHerald extends CardImpl {
// As Brass Herald enters the battlefield, choose a creature type.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature)));
// When Brass Herald enters the battlefield, reveal the top four cards of your library. Put all creature cards of the chosen type revealed this way into your hand and the rest on the bottom of your library in any order.
FilterCard filter = new FilterCard("creature cards of the chosen type");
filter.add(new ChosenSubtypePredicate(this.getId()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new EnvoyEffect(filter, 4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new BrassHeraldEntersEffect()));
// Creatures of the chosen type get +1/+1.
FilterCreaturePermanent filter2 = new FilterCreaturePermanent("creatures of the chosen type");
filter2.add(new ChosenSubtypePredicate(this.getId()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield,
filter2, false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllOfChosenSubtypeEffect(1, 1, Duration.WhileOnBattlefield, false)));
}
public BrassHerald(final BrassHerald card) {
@ -81,3 +79,27 @@ public class BrassHerald extends CardImpl {
return new BrassHerald(this);
}
}
class BrassHeraldEntersEffect extends OneShotEffect {
public BrassHeraldEntersEffect() {
super(Outcome.Benefit);
this.staticText = "reveal the top four cards of your library. Put all creature cards of the chosen type revealed this way into your hand and the rest on the bottom of your library in any order";
}
public BrassHeraldEntersEffect(final BrassHeraldEntersEffect effect) {
super(effect);
}
@Override
public BrassHeraldEntersEffect copy() {
return new BrassHeraldEntersEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
FilterCard filter = new FilterCard("creature cards of the chosen type");
filter.add(new ChosenSubtypePredicate(source.getSourceId()));
return new EnvoyEffect(filter, 4).apply(game, source);
}
}

View file

@ -34,7 +34,7 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
@ -45,8 +45,6 @@ import mage.constants.SubLayer;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -56,6 +54,12 @@ import mage.game.permanent.Permanent;
*/
public class AdaptiveAutomaton extends CardImpl {
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control of the chosen type");
static {
filter.add(new ControllerPredicate(TargetController.YOU));
}
public AdaptiveAutomaton(UUID ownerId) {
super(ownerId, 201, "Adaptive Automaton", Rarity.RARE, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{3}");
this.expansionSetCode = "M12";
@ -69,11 +73,7 @@ public class AdaptiveAutomaton extends CardImpl {
// Adaptive Automaton is the chosen type in addition to its other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AdaptiveAutomatonAddSubtypeEffect()));
// Other creatures you control of the chosen type get +1/+1.
FilterCreaturePermanent filter = new FilterCreaturePermanent("Other creatures you control of the chosen type");
filter.add(new ChosenSubtypePredicate(this.getId()));
filter.add(new AnotherPredicate());
filter.add(new ControllerPredicate(TargetController.YOU));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllOfChosenSubtypeEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
}
public AdaptiveAutomaton(final AdaptiveAutomaton card) {

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.ChooseLandTypeEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllOfChosenSubtypeEffect;
import mage.abilities.keyword.PhasingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -40,7 +40,6 @@ import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
/**
*
@ -54,11 +53,11 @@ public class Shimmer extends CardImpl {
// As Shimmer enters the battlefield, choose a land type.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseLandTypeEffect(Outcome.Detriment)));
// Each land of the chosen type has phasing.
FilterLandPermanent filter = new FilterLandPermanent("Each land of the chosen type");
filter.add(new ChosenSubtypePredicate(this.getId()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAllEffect(PhasingAbility.getInstance(), Duration.WhileOnBattlefield, filter, false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAllOfChosenSubtypeEffect(PhasingAbility.getInstance(), Duration.WhileOnBattlefield,
new FilterLandPermanent("Each land of the chosen type"))));
}
public Shimmer(final Shimmer card) {

View file

@ -31,15 +31,13 @@ import java.util.UUID;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
/**
*
@ -51,13 +49,10 @@ public class SharedTriumph extends CardImpl {
super(ownerId, 53, "Shared Triumph", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");
this.expansionSetCode = "ONS";
// As Shared Triumph enters the battlefield, choose a creature type.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature)));
// Creatures of the chosen type get +1/+1.
FilterCreaturePermanent filter = new FilterCreaturePermanent("Creatures of the chosen type");
filter.add(new ChosenSubtypePredicate(this.getId()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(1, 1, Duration.WhileOnBattlefield, filter, false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllOfChosenSubtypeEffect(1, 1, Duration.WhileOnBattlefield, false)));
}
public SharedTriumph(final SharedTriumph card) {

View file

@ -31,14 +31,13 @@ import java.util.UUID;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.cost.SpellsCostReductionAllEffect;
import mage.abilities.effects.common.cost.SpellsCostReductionAllOfChosenSubtypeEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
/**
*
@ -53,9 +52,8 @@ public class UrzasIncubator extends CardImpl {
// As Urza's Incubator enters the battlefield, choose a creature type.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature)));
// Creature spells of the chosen type cost {2} less to cast.
FilterCreatureCard filter = new FilterCreatureCard("creature spells of the chosen type");
filter.add(new ChosenSubtypePredicate(this.getId()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SpellsCostReductionAllEffect(filter, 2)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new SpellsCostReductionAllOfChosenSubtypeEffect(new FilterCreatureCard("creature spells of the chosen type"), 2)));
}
public UrzasIncubator(final UrzasIncubator card) {

View file

@ -31,15 +31,13 @@ import java.util.UUID;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ChosenSubtypePredicate;
/**
*
@ -51,13 +49,10 @@ public class EngineeredPlague extends CardImpl {
super(ownerId, 51, "Engineered Plague", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}");
this.expansionSetCode = "ULG";
// As Engineered Plague enters the battlefield, choose a creature type.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.UnboostCreature)));
// All creatures of the chosen type get -1/-1.
FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures of the chosen type");
filter.add(new ChosenSubtypePredicate(this.getId()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllEffect(-1, -1, Duration.WhileOnBattlefield, filter, false)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostAllOfChosenSubtypeEffect(-1, -1, Duration.WhileOnBattlefield, false)));
}
public EngineeredPlague(final EngineeredPlague card) {

View file

@ -109,9 +109,10 @@ public class BoostAllEffect extends ContinuousEffectImpl {
@Override
public void init(Ability source, Game game) {
super.init(source, game);
setRuntimeData(source, game);
if (this.affectedObjectsSet) {
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
@ -135,8 +136,9 @@ public class BoostAllEffect extends ContinuousEffectImpl {
}
}
} else {
setRuntimeData(source, game);
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
perm.addPower(power.calculate(game, source, this));
perm.addToughness(toughness.calculate(game, source, this));
}
@ -146,7 +148,29 @@ public class BoostAllEffect extends ContinuousEffectImpl {
return true;
}
private void setText() {
/**
* Overwrite this in effect that inherits from this
*
* @param source
* @param game
*/
protected void setRuntimeData(Ability source, Game game) {
}
/**
* Overwrite this in effect that inherits from this
*
* @param permanent
* @param source
* @param game
* @return
*/
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
return true;
}
protected void setText() {
StringBuilder sb = new StringBuilder();
if (excludeSource) {
sb.append("Other ");

View file

@ -0,0 +1,53 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class BoostAllOfChosenSubtypeEffect extends BoostAllEffect {
String subtype = null;
public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, boolean excludeSource) {
super(power, toughness, duration, new FilterCreaturePermanent("All creatures of the chosen type"), excludeSource);
}
public BoostAllOfChosenSubtypeEffect(int power, int toughness, Duration duration, FilterCreaturePermanent filter, boolean excludeSource) {
super(power, toughness, duration, filter, excludeSource);
}
public BoostAllOfChosenSubtypeEffect(final BoostAllOfChosenSubtypeEffect effect) {
super(effect);
this.subtype = effect.subtype;
}
@Override
public BoostAllOfChosenSubtypeEffect copy() {
return new BoostAllOfChosenSubtypeEffect(this);
}
@Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (subtype != null) {
return permanent.hasSubtype(subtype);
}
return false;
}
@Override
protected void setRuntimeData(Ability source, Game game) {
subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
}
}

View file

@ -92,9 +92,10 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
@Override
public void init(Ability source, Game game) {
super.init(source, game);
setRuntimeData(source, game);
if (this.affectedObjectsSet) {
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
@ -121,8 +122,9 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
}
}
} else {
setRuntimeData(source, game);
for (Permanent perm : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
perm.addAbility(ability, source.getSourceId(), game, false);
}
}
@ -131,7 +133,7 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
if (LKIBattlefield != null) {
for (MageObject mageObject : LKIBattlefield.values()) {
Permanent perm = (Permanent) mageObject;
if (!(excludeSource && perm.getId().equals(source.getSourceId()))) {
if (!(excludeSource && perm.getId().equals(source.getSourceId())) && selectedByRuntimeData(perm, source, game)) {
if (filter.match(perm, source.getSourceId(), source.getControllerId(), game)) {
perm.addAbility(ability, source.getSourceId(), game, false);
}
@ -142,6 +144,28 @@ public class GainAbilityAllEffect extends ContinuousEffectImpl {
return true;
}
/**
* Overwrite this in effect that inherits from this
*
* @param source
* @param game
*/
protected void setRuntimeData(Ability source, Game game) {
}
/**
* Overwrite this in effect that inherits from this
*
* @param permanent
* @param source
* @param game
* @return
*/
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
return true;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {

View file

@ -0,0 +1,49 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.continuous;
import mage.abilities.Ability;
import mage.constants.Duration;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class GainAbilityAllOfChosenSubtypeEffect extends GainAbilityAllEffect {
String subtype = null;
public GainAbilityAllOfChosenSubtypeEffect(Ability ability, Duration duration, FilterPermanent filter) {
super(ability, duration, filter);
}
public GainAbilityAllOfChosenSubtypeEffect(final GainAbilityAllOfChosenSubtypeEffect effect) {
super(effect);
this.subtype = effect.subtype;
}
@Override
public GainAbilityAllOfChosenSubtypeEffect copy() {
return new GainAbilityAllOfChosenSubtypeEffect(this);
}
@Override
protected boolean selectedByRuntimeData(Permanent permanent, Ability source, Game game) {
if (subtype != null) {
return permanent.hasSubtype(subtype);
}
return false;
}
@Override
protected void setRuntimeData(Ability source, Game game) {
subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
}
}

View file

@ -60,14 +60,14 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
public SpellsCostReductionAllEffect(FilterCard filter, int amount) {
this(filter, amount, false);
}
public SpellsCostReductionAllEffect(FilterCard filter, int amount, boolean upTo) {
super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST);
this.filter = filter;
this.amount = amount;
this.upTo = upTo;
this.staticText = filter.getMessage() + " cost " + (upTo ?"up to " :"") + "{" +amount + "} less to cast";
this.staticText = filter.getMessage() + " cost " + (upTo ? "up to " : "") + "{" + amount + "} less to cast";
}
protected SpellsCostReductionAllEffect(SpellsCostReductionAllEffect effect) {
@ -109,16 +109,38 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl {
return true;
}
/**
* Overwrite this in effect that inherits from this
*
* @param source
* @param game
*/
protected void setRuntimeData(Ability source, Game game) {
}
/**
* Overwrite this in effect that inherits from this
*
* @param card
* @param source
* @param game
* @return
*/
protected boolean selectedByRuntimeData(Card card, Ability source, Game game) {
return true;
}
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof SpellAbility) {
Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId());
if (spell != null) {
return this.filter.match(spell, game);
return this.filter.match(spell, game) && selectedByRuntimeData(spell, source, game);
} else {
// used at least for flashback ability because Flashback ability doesn't use stack
Card sourceCard = game.getCard(abilityToModify.getSourceId());
return sourceCard != null && this.filter.match(sourceCard, game);
return sourceCard != null && this.filter.match(sourceCard, game) && selectedByRuntimeData(sourceCard, source, game);
}
}
return false;

View file

@ -0,0 +1,48 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.effects.common.cost;
import mage.abilities.Ability;
import mage.cards.Card;
import mage.filter.FilterCard;
import mage.game.Game;
/**
*
* @author LevelX2
*/
public class SpellsCostReductionAllOfChosenSubtypeEffect extends SpellsCostReductionAllEffect {
String subtype = null;
public SpellsCostReductionAllOfChosenSubtypeEffect(FilterCard filter, int amount) {
super(filter, amount);
}
public SpellsCostReductionAllOfChosenSubtypeEffect(final SpellsCostReductionAllOfChosenSubtypeEffect effect) {
super(effect);
this.subtype = effect.subtype;
}
@Override
public SpellsCostReductionAllOfChosenSubtypeEffect copy() {
return new SpellsCostReductionAllOfChosenSubtypeEffect(this);
}
@Override
protected boolean selectedByRuntimeData(Card card, Ability source, Game game) {
if (subtype != null) {
return card.hasSubtype(subtype);
}
return false;
}
@Override
protected void setRuntimeData(Ability source, Game game) {
subtype = (String) game.getState().getValue(source.getSourceId() + "_type");
}
}