Merge origin/master

This commit is contained in:
fireshoes 2015-03-13 11:03:34 -05:00
commit 2849c87faa
5 changed files with 184 additions and 65 deletions

View file

@ -0,0 +1,145 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.dragonsoftarkir;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class MythRealized extends CardImpl {
private static final FilterSpell filterNonCreature = new FilterSpell("a noncreature spell");
static {
filterNonCreature.add(Predicates.not(new CardTypePredicate(CardType.CREATURE)));
}
public MythRealized(UUID ownerId) {
super(ownerId, 26, "Myth Realized", Rarity.RARE, new CardType[]{CardType.ENCHANTMENT}, "{W}");
this.expansionSetCode = "DTK";
// Whenever you cast a noncreature spell, put a lore counter on Myth Realized.
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersSourceEffect(CounterType.LORE.createInstance()), filterNonCreature, false));
// 2W: Put a lore counter on Myth Realized.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersSourceEffect(CounterType.LORE.createInstance()), new ManaCostsImpl("{2}{W}")));
// W: Until end of turn, Myth Realized becomes a Monk Avatar creature in addition to its other types and gains "This creature's power and toughness are each equal to the number of lore counters on it."
Effect effect = new BecomesCreatureSourceEffect(new MythRealizedToken(), null, Duration.EndOfTurn);
effect.setText("Until end of turn, {this} becomes a Monk Avatar creature in addition to its other types");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{W}"));
ability.addEffect(new MythRealizedSetPTEffect(Duration.EndOfTurn));
this.addAbility(ability);
}
public MythRealized(final MythRealized card) {
super(card);
}
@Override
public MythRealized copy() {
return new MythRealized(this);
}
}
class MythRealizedToken extends Token {
public MythRealizedToken() {
super("", "Monk Avatar creature in addition to its other types and gains \"This creature's power and toughness are each equal to the number of lore counters on it.\"");
cardType.add(CardType.CREATURE);
subtype.add("Monk");
subtype.add("Avatar");
power = new MageInt(0);
toughness = new MageInt(0);
}
}
class MythRealizedSetPTEffect extends ContinuousEffectImpl {
public MythRealizedSetPTEffect(Duration duration) {
super(duration, Layer.PTChangingEffects_7, SubLayer.SetPT_7b, Outcome.BoostCreature);
staticText = "and gains \"This creature's power and toughness are each equal to the number of lore counters on it.\"";
}
public MythRealizedSetPTEffect(final MythRealizedSetPTEffect effect) {
super(effect);
}
@Override
public MythRealizedSetPTEffect copy() {
return new MythRealizedSetPTEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && new MageObjectReference(source.getSourceObject(game)).refersTo(permanent)) {
int amount = permanent.getCounters().getCount(CounterType.LORE);
permanent.getPower().setValue(amount);
permanent.getToughness().setValue(amount);
return true;
} else {
discard();
}
}
return false;
}
}

View file

@ -27,14 +27,10 @@
*/ */
package mage.sets.innistrad; package mage.sets.innistrad;
import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.SubLayer;
import mage.constants.Zone; import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Abilities; import mage.abilities.Abilities;
@ -44,8 +40,9 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition; import mage.abilities.condition.Condition;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect;
import mage.abilities.effects.common.continuous.LoseAbilitySourceEffect;
import mage.abilities.keyword.DefenderAbility; import mage.abilities.keyword.DefenderAbility;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.IndestructibleAbility; import mage.abilities.keyword.IndestructibleAbility;
@ -70,11 +67,38 @@ public class ManorGargoyle extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
this.addAbility(DefenderAbility.getInstance()); this.addAbility(DefenderAbility.getInstance());
// Manor Gargoyle is indestructible as long as it has defender.
/*
TODO: Implement the dependency rule
613.7. Within a layer or sublayer, determining which order effects are applied in is sometimes done using a dependency system.
If a dependency exists, it will override the timestamp system.
613.7a An effect is said to depend on another if
(a) its applied in the same layer (and, if applicable, sublayer) as the other effect (see rules 613.1 and 613.3);
(b) applying the other would change the text or the existence of the first effect, what it applies to, or what
it does to any of the things it applies to; and
(c) neither effect is from a characteristic-defining ability or both effects are from characteristic-defining
abilities. Otherwise, the effect is considered to be independent of the other effect.
613.7b An effect dependent on one or more other effects waits to apply until just after all of those effects have been applied.
If multiple dependent effects would apply simultaneously in this way, theyre applied in timestamp order relative to each
other. If several dependent effects form a dependency loop, then this rule is ignored and the effects in the dependency
loop are applied in timestamp order.
613.7c After each effect is applied, the order of remaining effects is reevaluated and may change if an effect that has not yet
been applied becomes dependent on or independent of one or more other effects that have not yet been applied.
*/
// Manor Gargoyle has indestructible as long as it has defender.
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance()), HasDefenderCondition.getInstance(), rule); ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance()), HasDefenderCondition.getInstance(), rule);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
// {1}: Until end of turn, Manor Gargoyle loses defender and gains flying. // {1}: Until end of turn, Manor Gargoyle loses defender and gains flying.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new GargoyleSentinelEffect(), new ManaCostsImpl("{1}"))); Effect effect2 = new LoseAbilitySourceEffect(DefenderAbility.getInstance(), Duration.EndOfTurn);
effect2.setText("Until end of turn, {this} loses defender");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect2, new ManaCostsImpl("{1}"));
effect2 = new GainAbilitySourceEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
effect2.setText("and gains flying");
ability.addEffect(effect2);
this.addAbility(ability);
} }
public ManorGargoyle(final ManorGargoyle card) { public ManorGargoyle(final ManorGargoyle card) {
@ -87,55 +111,6 @@ public class ManorGargoyle extends CardImpl {
} }
} }
class GargoyleSentinelEffect extends ContinuousEffectImpl {
public GargoyleSentinelEffect() {
super(Duration.EndOfTurn, Outcome.AddAbility);
staticText = "Until end of turn, {this} loses defender and gains flying";
}
public GargoyleSentinelEffect(final GargoyleSentinelEffect effect) {
super(effect);
}
@Override
public GargoyleSentinelEffect copy() {
return new GargoyleSentinelEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
switch (layer) {
case AbilityAddingRemovingEffects_6:
if (sublayer == SubLayer.NA) {
for (Iterator<Ability> ability = permanent.getAbilities().iterator(); ability.hasNext();) {
Ability entry = ability.next();
if (entry.getId().equals(DefenderAbility.getInstance().getId())) {
ability.remove();
}
}
permanent.getAbilities().add(FlyingAbility.getInstance());
}
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;
}
}
class HasDefenderCondition implements Condition { class HasDefenderCondition implements Condition {
private static HasDefenderCondition INSTANCE; private static HasDefenderCondition INSTANCE;

View file

@ -70,13 +70,16 @@ public class AjaniGoldmane extends CardImpl {
this.color.setWhite(true); this.color.setWhite(true);
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), false)); this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(CounterType.LOYALTY.createInstance(4)), false));
// +1: You gain 2 life.
this.addAbility(new LoyaltyAbility(new GainLifeEffect(2), 1)); this.addAbility(new LoyaltyAbility(new GainLifeEffect(2), 1));
// -1: Put a +1/+1 counter on each creature you control. Those creatures gain vigilance until end of turn.
Effects effects1 = new Effects(); Effects effects1 = new Effects();
effects1.add(new AddCountersAllEffect(CounterType.P1P1.createInstance(), new FilterControlledCreaturePermanent())); effects1.add(new AddCountersAllEffect(CounterType.P1P1.createInstance(), new FilterControlledCreaturePermanent()));
effects1.add(new GainAbilityControlledEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent())); effects1.add(new GainAbilityControlledEffect(VigilanceAbility.getInstance(), Duration.EndOfTurn, new FilterCreaturePermanent()));
this.addAbility(new LoyaltyAbility(effects1, -1)); this.addAbility(new LoyaltyAbility(effects1, -1));
// -6: Put a white Avatar creature token onto the battlefield. It has "This creature's power and toughness are each equal to your life total."
this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new AvatarToken()), -6)); this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new AvatarToken()), -6));
} }

View file

@ -145,7 +145,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
} }
private void setText() { private void setText() {
if (type.length() > 0) { if (type != null && type.length() > 0) {
staticText = duration.toString() + " {this} becomes a " + token.getDescription() + " that's still a " + this.type; staticText = duration.toString() + " {this} becomes a " + token.getDescription() + " that's still a " + this.type;
} }
else { else {

View file

@ -12,14 +12,12 @@ import mage.constants.Outcome;
import mage.constants.SubLayer; import mage.constants.SubLayer;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import org.apache.log4j.Logger;
/** /**
* *
* @author Noahsark * @author Noahsark
*/ */
public class LoseAbilitySourceEffect extends ContinuousEffectImpl{ public class LoseAbilitySourceEffect extends ContinuousEffectImpl{
private static final Logger logger = Logger.getLogger(LoseAbilitySourceEffect.class);
protected Ability ability; protected Ability ability;
public LoseAbilitySourceEffect(Ability ability){ public LoseAbilitySourceEffect(Ability ability){
@ -46,12 +44,10 @@ public class LoseAbilitySourceEffect extends ContinuousEffectImpl{
public boolean apply(Game game, Ability source){ public boolean apply(Game game, Ability source){
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null){ if (permanent != null){
permanent.getAbilities().remove(ability); // 112.10
// while(permanent.getAbilities().contains(ability)){ while (permanent.getAbilities().remove(ability)) {
// if (!permanent.getAbilities().remove(ability)) {
// logger.warn("ability " + ability.getRule() + " couldn't be removed."); }
// }
// }
} }
return true; return true;
} }