fix most issues from 9849a54081

Ali from Cairo and Sustaining Spirit still have issue with how damage is dealt
This commit is contained in:
kholdfuzion 2013-12-20 09:08:34 -06:00
parent 9a4c981ae2
commit db99909550
7 changed files with 101 additions and 27 deletions

View file

@ -78,7 +78,7 @@ class SustainingSpiritReplacementEffect extends ReplacementEffectImpl<Sustaining
public SustainingSpiritReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead";
staticText = "Damage that would reduce your life total to less than 1 reduces it to 1 instead";
}
public SustainingSpiritReplacementEffect(final SustainingSpiritReplacementEffect effect) {
@ -94,16 +94,17 @@ class SustainingSpiritReplacementEffect extends ReplacementEffectImpl<Sustaining
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType().equals(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS)) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& (controller.getLife() - event.getAmount()) < 1
&& (controller.getLife() > 0) &&(controller.getLife() - event.getAmount()) < 1
&& event.getPlayerId().equals(controller.getId())
) {
event.setAmount(controller.getLife() - 1);
//unsure how to make this comply with
// 10/1/2008: The ability doesn't change how much damage is dealt;
// it just changes how much life that damage makes you lose.
// An effect such as Spirit Link will see the full amount of damage being dealt.
}
}
}

View file

@ -72,7 +72,7 @@ class AliFromCairoReplacementEffect extends ReplacementEffectImpl<AliFromCairoRe
public AliFromCairoReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "If you control a creature, damage that would reduce your life total to less than 1 reduces it to 1 instead";
staticText = "Damage that would reduce your life total to less than 1 reduces it to 1 instead";
}
public AliFromCairoReplacementEffect(final AliFromCairoReplacementEffect effect) {
@ -88,16 +88,17 @@ class AliFromCairoReplacementEffect extends ReplacementEffectImpl<AliFromCairoRe
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType().equals(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS)) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
}
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null
&& (controller.getLife() - event.getAmount()) < 1
&& (controller.getLife() > 0) &&(controller.getLife() - event.getAmount()) < 1
&& event.getPlayerId().equals(controller.getId())
) {
event.setAmount(controller.getLife() - 1);
//unsure how to make this comply with
// 10/1/2008: The ability doesn't change how much damage is dealt;
// it just changes how much life that damage makes you lose.
// An effect such as Spirit Link will see the full amount of damage being dealt.
}
}
}

View file

@ -38,6 +38,7 @@ import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.target.TargetPermanent;
@ -47,11 +48,12 @@ import mage.target.TargetPermanent;
*/
public class KingSuleiman extends CardImpl<KingSuleiman> {
private static final FilterPermanent filter = new FilterPermanent("target Djinn or Efreet");
private static final FilterPermanent filter = new FilterPermanent("Djinn or Efreet");
static {
filter.add(new SubtypePredicate("Djinn"));
filter.add(new SubtypePredicate("Efreet"));
filter.add( Predicates.or(
new SubtypePredicate("Djinn"),
new SubtypePredicate("Efreet")));
}
public KingSuleiman(UUID ownerId) {

View file

@ -94,7 +94,7 @@ class BottleOfSuleimanEffect extends OneShotEffect<BottleOfSuleimanEffect> {
if (you != null) {
if (you.flipCoin(game)) {
DjinnToken token = new DjinnToken();
token.putOntoBattlefield(1, game, source.getId(), source.getControllerId());
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
return true;
} else {
you.damage(5, source.getSourceId(), game, true, false);

View file

@ -33,16 +33,13 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.PreventDamageFromTargetEffect;
import mage.abilities.effects.common.PreventDamageTargetEffect;
import mage.abilities.effects.common.UntapTargetEffect;
import mage.abilities.effects.common.*;
import mage.cards.CardImpl;
import mage.constants.*;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.AttackingPredicate;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.target.common.TargetAttackingCreature;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
/**
@ -64,9 +61,11 @@ public class EbonyHorse extends CardImpl<EbonyHorse> {
// {2}, {tap}: Untap target attacking creature you control. Prevent all combat damage that would be dealt to and dealt by that creature this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new UntapTargetEffect(), new GenericManaCost(2));
ability.addCost(new TapSourceCost());
ability.addEffect(new PreventDamageFromTargetEffect(Duration.EndOfTurn, true));
ability.addEffect(new PreventDamageTargetEffect(Duration.EndOfTurn, Integer.MAX_VALUE));
ability.addTarget(new TargetCreaturePermanent(filter));
ability.addEffect(new PreventCombatDamageSourceEffect(Duration.EndOfTurn));
ability.addEffect(new PreventCombatDamageFromSourceEffect(Duration.EndOfTurn));
Target target = new TargetCreaturePermanent(filter);
target.setRequired(true);
ability.addTarget(target);
this.addAbility(ability);
}

View file

@ -29,11 +29,21 @@ package mage.sets.invasion;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardControllerEffect;
import mage.abilities.effects.common.ScryEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
@ -48,8 +58,8 @@ public class Opt extends CardImpl<Opt> {
this.color.setBlue(true);
// Look at the top card of your library. You may put that card on the bottom of your library.
// This is functionally the same as scry, but is scry appropriate?
this.getSpellAbility().addEffect(new ScryEffect(1));
// This is functionally the same as scry, copy scry effect, removing "scry", unless theres a simpler way im overlooking?
this.getSpellAbility().addEffect(new OptEffect());
// Draw a card.
this.getSpellAbility().addEffect(new DrawCardControllerEffect(1));
}
@ -63,3 +73,62 @@ public class Opt extends CardImpl<Opt> {
return new Opt(this);
}
}
class OptEffect extends OneShotEffect<OptEffect> {
protected static FilterCard filter1 = new FilterCard("card to put on the bottom of your library");
public OptEffect() {
super(Outcome.DrawCard);
this.staticText = "Look at the top card of your library. You may put that card on the bottom of your library.";
}
public OptEffect(final OptEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Cards cards = new CardsImpl(Zone.PICK);
int count = Math.min( 1, player.getLibrary().size());
if (count == 0) {
return false;
}
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
cards.add(card);
game.setZone(card.getId(), Zone.PICK);
}
TargetCard target1 = new TargetCard(Zone.PICK, filter1);
// move cards to the bottom of the library
while (cards.size() > 0 && player.choose(Outcome.Detriment, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
card.moveToZone(Zone.LIBRARY, source.getId(), game, false);
}
target1.clearChosen();
}
// move cards to the top of the library
int onBottom = 1 - cards.size();
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
}
game.informPlayers(new StringBuilder(player.getName()).append(" puts ")
.append(onBottom).append(onBottom == 1 ?" card":" cards")
.append(" on the bottom of his or her library")
.append(1).append(")").toString());
return true;
}
return false;
}
@Override
public OptEffect copy() {
return new OptEffect(this);
}
}

View file

@ -36,6 +36,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.target.common.TargetCreaturePermanent;
/**
*
@ -51,6 +52,7 @@ public class Accelerate extends CardImpl<Accelerate> {
// Target creature gains haste until end of turn.
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// Draw a card.
this.getSpellAbility().addEffect(new DrawCardControllerEffect(1));
}