Some fixes to M15 cards or by M15 used classes.

This commit is contained in:
LevelX2 2014-07-06 16:00:32 +02:00
parent 9ad45a6ab9
commit 18e78b8294
23 changed files with 105 additions and 50 deletions

View file

@ -28,13 +28,12 @@
package mage.server.game;
import java.util.UUID;
import java.util.concurrent.Callable;
import mage.MageException;
import mage.game.Game;
import org.apache.log4j.Logger;
import java.util.UUID;
import java.util.concurrent.Callable;
/**
*
* @author BetaSteward_at_googlemail.com

View file

@ -27,8 +27,7 @@
*/
package mage.sets.avacynrestored;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
@ -36,7 +35,9 @@ import mage.abilities.costs.common.TapTargetCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.Predicates;
@ -50,8 +51,6 @@ import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
* @author noxx
*/
@ -112,7 +111,7 @@ class GallowsAtWillowHillEffect extends OneShotEffect {
Player controller = game.getPlayer(permanent.getControllerId());
permanent.destroy(source.getId(), game, false);
if (controller != null) {
Token spirit = new SpiritWhiteToken();
Token spirit = new SpiritWhiteToken("AVR", 1);
spirit.putOntoBattlefield(1, game, source.getSourceId(), controller.getId());
}
affectedTargets++;

View file

@ -28,13 +28,12 @@
package mage.sets.darkascension;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.TimingRule;
import mage.game.permanent.token.SpiritWhiteToken;
@ -51,7 +50,7 @@ public class LingeringSouls extends CardImpl {
this.color.setWhite(true);
// Put two 1/1 white Spirit creature tokens with flying onto the battlefield.
this.getSpellAbility().addEffect(new CreateTokenEffect(new SpiritWhiteToken(), 2));
this.getSpellAbility().addEffect(new CreateTokenEffect(new SpiritWhiteToken("ISD"), 2));
// Flashback {1}{B}
this.addAbility(new FlashbackAbility(new ManaCostsImpl("{1}{B}"), TimingRule.SORCERY));
}

View file

@ -130,7 +130,7 @@ class EvershrikeEffect extends OneShotEffect {
Card aura = game.getCard(targetAura.getFirstTarget());
if (aura != null) {
game.getState().setValue("attachTo:" + aura.getId(), evershrikePermanent);
aura.putOntoBattlefield(game, Zone.HAND, source.getId(), you.getId());
aura.putOntoBattlefield(game, Zone.HAND, source.getSourceId(), you.getId());
evershrikePermanent.addAttachment(aura.getId(), game);
exiled = false;
count = you.getHand().count(filterAuraCard, game);

View file

@ -27,8 +27,7 @@
*/
package mage.sets.innistrad;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -37,13 +36,13 @@ import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.continious.SetPowerToughnessSourceEffect;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.permanent.token.SpiritWhiteToken;
import java.util.UUID;
/**
* @author nantuko
*/
@ -65,7 +64,7 @@ public class GeistHonoredMonk extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent()), Duration.EndOfGame)));
// When Geist-Honored Monk enters the battlefield, put two 1/1 white Spirit creature tokens with flying onto the battlefield.
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new SpiritWhiteToken(), 2)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new CreateTokenEffect(new SpiritWhiteToken("ISD"), 2)));
}
public GeistHonoredMonk(final GeistHonoredMonk card) {

View file

@ -27,16 +27,15 @@
*/
package mage.sets.innistrad;
import mage.constants.CardType;
import mage.constants.Rarity;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.game.permanent.token.SpiritWhiteToken;
import java.util.UUID;
/**
* @author nantuko
*/
@ -53,7 +52,7 @@ public class MausoleumGuard extends CardImpl {
this.toughness = new MageInt(2);
// When Mausoleum Guard dies, put two 1/1 white Spirit creature tokens with flying onto the battlefield.
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SpiritWhiteToken(), 2)));
this.addAbility(new DiesTriggeredAbility(new CreateTokenEffect(new SpiritWhiteToken("ISD"), 2)));
}
public MausoleumGuard(final MausoleumGuard card) {

View file

@ -28,10 +28,10 @@
package mage.sets.innistrad;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.game.permanent.token.SpiritWhiteToken;
/**
@ -47,7 +47,7 @@ public class MidnightHaunting extends CardImpl {
this.color.setWhite(true);
// Put two 1/1 white Spirit creature tokens with flying onto the battlefield.
this.getSpellAbility().addEffect(new CreateTokenEffect(new SpiritWhiteToken(), 2));
this.getSpellAbility().addEffect(new CreateTokenEffect(new SpiritWhiteToken("ISD"), 2));
}
public MidnightHaunting(final MidnightHaunting card) {

View file

@ -118,6 +118,7 @@ public class AjaniSteadfast extends CardImpl {
class AjaniSteadfastEmblem extends Emblem {
public AjaniSteadfastEmblem() {
setName("Emblem Ajani Steadfast");
this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new AjaniSteadfastPreventEffect()));
this.setExpansionSetCodeForImage("M15");
}

View file

@ -118,7 +118,7 @@ class BoonweaverGiantEffect extends OneShotEffect {
}
}
}
if (player.chooseUse(Outcome.Neutral, "Search your Hand for an Aura card?", game)) {
if (card == null && player.chooseUse(Outcome.Neutral, "Search your Hand for an Aura card?", game)) {
TargetCardInHand target = new TargetCardInHand(filter);
if (player.choose(Outcome.PutCardInPlay, player.getHand(), target, game)) {
card = game.getCard(target.getFirstTarget());
@ -140,9 +140,9 @@ class BoonweaverGiantEffect extends OneShotEffect {
if (card != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
game.getState().setValue("attachTo:" + card.getId(), permanent.getId());
game.getState().setValue("attachTo:" + card.getId(), permanent);
}
card.putOntoBattlefield(game, zone, source.getSourceId(), source.getControllerId());
player.putOntoBattlefieldWithInfo(card, game, zone, source.getSourceId());
if (permanent != null) {
return permanent.addAttachment(card.getId(), game);
}

View file

@ -35,7 +35,6 @@ import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityAllEffect;
import mage.cards.Card;
@ -81,7 +80,7 @@ public class ConstrictingSliver extends CardImpl {
// Sliver creatures you control have "When this creature enters the battlefield, you may exile target creature an opponent controls
// until this creature leaves the battlefield."
Ability ability = new EntersBattlefieldTriggeredAbility(new DamageTargetEffect(1), true);
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileTargetEffect(), true);
ability.addTarget(new TargetCreaturePermanent(filterTarget));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new GainAbilityAllEffect(ability,

View file

@ -92,6 +92,11 @@ class ResoluteArchangelEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
controller.setLife(game.getLife(), game);
return true;
}
return false;
}
}

View file

@ -74,9 +74,9 @@ public class ReturnToTheRanks extends CardImpl {
public void adjustTargets(Ability ability, Game game) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof ReturnFromGraveyardToBattlefieldTargetEffect) {
int xValue = new GetXValue().calculate(game, ability);
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(xValue,xValue, new FilterCreatureCard("creature cards from your graveyard")));
ability.addTarget(new TargetCardInYourGraveyard(xValue,xValue, filter));
}
}
}

View file

@ -167,7 +167,19 @@ public abstract class AbilityImpl implements Ability {
for (Effect effect: getEffects()) {
if (effect instanceof OneShotEffect) {
if (!(effect instanceof PostResolveEffect)) {
result &= effect.apply(game, this);
boolean effectResult = effect.apply(game, this);
result &= effectResult;
if (logger.isDebugEnabled()) {
if (!effectResult) {
if (this.getSourceId() != null) {
MageObject mageObject = game.getObject(this.getSourceId());
if (mageObject != null) {
logger.debug("AbilityImpl.resolve: object: " + mageObject.getName());
}
}
logger.debug("AbilityImpl.resolve: effect returned false -" + effect.getText(this.getModes().getMode()));
}
}
}
}
else {

View file

@ -33,7 +33,8 @@ import mage.abilities.condition.Condition;
import mage.game.Game;
public class NotMyTurnCondition implements Condition {
private static NotMyTurnCondition fInstance = new NotMyTurnCondition();
private static final NotMyTurnCondition fInstance = new NotMyTurnCondition();
public static Condition getInstance() {
return fInstance;
@ -42,8 +43,9 @@ public class NotMyTurnCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
UUID activePlayerId = game.getActivePlayerId();
if (activePlayerId != null)
if (activePlayerId != null) {
return !activePlayerId.equals(source.getControllerId());
}
return false;
}
}

View file

@ -28,9 +28,10 @@
package mage.abilities.effects.common;
import mage.constants.Outcome;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.command.Emblem;
@ -40,7 +41,7 @@ import mage.game.command.Emblem;
*/
public class GetEmblemEffect extends OneShotEffect {
private Emblem emblem;
private final Emblem emblem;
public GetEmblemEffect(Emblem emblem) {
super(Outcome.Benefit);
@ -60,6 +61,10 @@ public class GetEmblemEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject == null) {
return false;
}
game.addEmblem(emblem, source);
return true;
}

View file

@ -48,15 +48,18 @@ import mage.game.stack.Spell;
public class ProtectionAbility extends StaticAbility {
protected Filter filter;
protected boolean removeAuras;
public ProtectionAbility(Filter filter) {
super(Zone.BATTLEFIELD, null);
this.filter = filter;
this.removeAuras = true;
}
public ProtectionAbility(final ProtectionAbility ability) {
super(ability);
this.filter = ability.filter.copy();
this.removeAuras = ability.removeAuras;
}
@Override
@ -66,7 +69,7 @@ public class ProtectionAbility extends StaticAbility {
@Override
public String getRule() {
return "Protection from " + filter.getMessage();
return "Protection from " + filter.getMessage() + (removeAuras ? "":". This effect doesn't remove auras.");
}
public boolean canTarget(MageObject source, Game game) {
@ -101,4 +104,12 @@ public class ProtectionAbility extends StaticAbility {
public void setFilter(FilterCard filter) {
this.filter = filter;
}
public void setRemovesAuras(boolean removeAuras) {
this.removeAuras = removeAuras;
}
public boolean removesAuras() {
return removeAuras;
}
}

View file

@ -507,6 +507,10 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
break;
case EXILED:
game.getExile().removeCard(this, game);
if (isFaceDown()) {
// 110.6b Permanents enter the battlefield untapped, unflipped, face up, and phased in unless a spell or ability says otherwise.
this.setFaceDown(false);
}
removed = true;
break;
case COMMAND:

View file

@ -1419,13 +1419,14 @@ public abstract class GameImpl implements Game, Serializable {
else {
Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter();
if (auraFilter instanceof FilterControlledCreaturePermanent) {
if (!((FilterControlledCreaturePermanent)auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this) || attachedTo.hasProtectionFrom(perm, this)) {
if (!((FilterControlledCreaturePermanent)auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this)
|| attachedTo.cantBeEnchantedBy(perm, this)) {
if (movePermanentToGraveyardWithInfo(perm)) {
somethingHappened = true;
}
}
} else {
if (!auraFilter.match(attachedTo, this) || attachedTo.hasProtectionFrom(perm, this)) {
if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeEnchantedBy(perm, this)) {
// handle bestow unattachment
Card card = this.getCard(perm.getId());
if (card != null && card.getCardType().contains(CardType.CREATURE)) {
@ -1442,15 +1443,15 @@ public abstract class GameImpl implements Game, Serializable {
}
}
else if (target instanceof TargetPlayer) {
Player attachedTo = getPlayer(perm.getAttachedTo());
if (attachedTo == null) {
Player attachedToPlayer = getPlayer(perm.getAttachedTo());
if (attachedToPlayer == null) {
if (movePermanentToGraveyardWithInfo(perm)) {
somethingHappened = true;
}
}
else {
Filter auraFilter = perm.getSpellAbility().getTargets().get(0).getFilter();
if (!auraFilter.match(attachedTo, this) || attachedTo.hasProtectionFrom(perm, this)) {
if (!auraFilter.match(attachedToPlayer, this) || attachedToPlayer.hasProtectionFrom(perm, this)) {
if (movePermanentToGraveyardWithInfo(perm)) {
somethingHappened = true;
}
@ -1988,9 +1989,9 @@ public abstract class GameImpl implements Game, Serializable {
targetName = targetPlayer.getName();
}
} else {
targetName = targetObject.getName();
targetName = targetObject.getLogName();
}
StringBuilder message = new StringBuilder(preventionSource.getName()).append(": Prevented ");
StringBuilder message = new StringBuilder(preventionSource.getLogName()).append(": Prevented ");
message.append(Integer.toString(result.getPreventedDamage())).append(" damage from ").append(damageSource.getName());
if (!targetName.isEmpty()) {
message.append(" to ").append(targetName);

View file

@ -63,6 +63,7 @@ public class Emblem implements CommandObject {
public Emblem(final Emblem emblem) {
this.id = emblem.id;
this.name = emblem.name;
this.controllerId = emblem.controllerId;
this.sourceId = emblem.sourceId;
this.abilites = emblem.abilites.copy();

View file

@ -78,6 +78,7 @@ public interface Permanent extends Card, Controllable {
boolean canBeTargetedBy(MageObject source, UUID controllerId, Game game);
boolean hasProtectionFrom(MageObject source, Game game);
boolean cantBeEnchantedBy(MageObject source, Game game);
boolean hasSummoningSickness();
int getDamage();
int damage(int damage, UUID sourceId, Game game, boolean preventable, boolean combat);

View file

@ -765,6 +765,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return false;
}
@Override
public boolean cantBeEnchantedBy(MageObject source, Game game) {
for (ProtectionAbility ability : abilities.getProtectionAbilities()) {
if (!(source.getSubtype().contains("Aura") && !ability.removesAuras()) && !ability.canTarget(source, game)) {
return true;
}
}
return false;
}
protected boolean canDamage(MageObject source, Game game) {
//noxx: having protection doesn't prevents from dealing damage
// instead it adds damage prevention

View file

@ -37,13 +37,24 @@ import mage.constants.CardType;
public class SpiritWhiteToken extends Token {
public SpiritWhiteToken() {
this("SHM", 0);
}
public SpiritWhiteToken(String setCode) {
this(setCode, 0);
}
public SpiritWhiteToken(String setCode, int tokenType) {
super("Spirit", "1/1 white Spirit creature token with flying");
setOriginalExpansionSetCode(setCode);
if (tokenType > 0) {
setTokenType(tokenType);
}
cardType.add(CardType.CREATURE);
subtype.add("Spirit");
color.setWhite(true);
power = new MageInt(1);
toughness = new MageInt(1);
addAbility(FlyingAbility.getInstance());
this.setOriginalExpansionSetCode("SHM");
}
}

View file

@ -63,9 +63,6 @@ public class PlayerLostLifeWatcher extends Watcher {
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.UNTAP_STEP_PRE) {
reset();
}
if (event.getType() == GameEvent.EventType.LOST_LIFE) {
UUID playerId = event.getPlayerId();
if (playerId != null) {