* Enslave - Fixed that the set source of the damge was wrong.

This commit is contained in:
LevelX2 2015-09-27 09:23:40 +02:00
parent f22fb380b7
commit 9e1111748d
4 changed files with 76 additions and 14 deletions

View file

@ -25,12 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.mirrodinbesieged;
import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
@ -39,6 +36,11 @@ import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.abilities.keyword.InfectAbility;
import mage.cards.CardImpl;
import mage.constants.AttachmentType;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -48,21 +50,26 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class CorruptedConscience extends CardImpl {
public CorruptedConscience (UUID ownerId) {
public CorruptedConscience(UUID ownerId) {
super(ownerId, 22, "Corrupted Conscience", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}");
this.expansionSetCode = "MBS";
this.subtype.add("Aura");
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// You control enchanted creature.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ControlEnchantedEffect()));
// Enchanted creature has infect. (It deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.)
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(InfectAbility.getInstance(), AttachmentType.AURA)));
}
public CorruptedConscience (final CorruptedConscience card) {
public CorruptedConscience(final CorruptedConscience card) {
super(card);
}

View file

@ -25,12 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.newphyrexia;
import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
@ -39,6 +36,11 @@ import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.ControlEnchantedEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -51,21 +53,26 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class Enslave extends CardImpl {
public Enslave (UUID ownerId) {
public Enslave(UUID ownerId) {
super(ownerId, 58, "Enslave", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{4}{B}{B}");
this.expansionSetCode = "NPH";
this.subtype.add("Aura");
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
this.getSpellAbility().addTarget(auraTarget);
this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature));
Ability ability = new EnchantAbility(auraTarget.getTargetName());
this.addAbility(ability);
// You control enchanted creature.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ControlEnchantedEffect()));
// At the beginning of your upkeep, enchanted creature deals 1 damage to its owner.
this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new EnslaveEffect(), TargetController.YOU, false, false));
}
public Enslave (final Enslave card) {
public Enslave(final Enslave card) {
super(card);
}
@ -77,6 +84,7 @@ public class Enslave extends CardImpl {
}
class EnslaveEffect extends OneShotEffect {
EnslaveEffect() {
super(Outcome.Damage);
staticText = "enchanted creature deals 1 damage to its owner";
@ -88,13 +96,13 @@ class EnslaveEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (sourcePermanent != null) {
Permanent attached = game.getPermanent(sourcePermanent.getAttachedTo());
Permanent attached = game.getPermanentOrLKIBattlefield(sourcePermanent.getAttachedTo());
if (attached != null) {
Player owner = game.getPlayer(attached.getOwnerId());
if (owner != null) {
owner.damage(1, source.getSourceId(), game, false, true);
owner.damage(1, attached.getId(), game, false, true);
return true;
}
}

View file

@ -58,7 +58,10 @@ public class PhyrexianObliterator extends CardImpl {
this.power = new MageInt(5);
this.toughness = new MageInt(5);
// Trample
this.addAbility(TrampleAbility.getInstance());
// Whenever a source deals damage to Phyrexian Obliterator, that source's controller sacrifices that many permanents.
this.addAbility(new PhyrexianObliteratorTriggeredAbility());
}
@ -73,6 +76,7 @@ public class PhyrexianObliterator extends CardImpl {
}
class PhyrexianObliteratorTriggeredAbility extends TriggeredAbilityImpl {
PhyrexianObliteratorTriggeredAbility() {
super(Zone.BATTLEFIELD, new SacrificeEffect(new FilterPermanent(), 0, ""));
}

View file

@ -27,6 +27,7 @@
*/
package org.mage.test.cards.abilities.keywords;
import mage.abilities.keyword.InfectAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
@ -126,4 +127,46 @@ public class InfectTest extends CardTestPlayerBase {
}
/**
* Phyrexian Obliterator is enchanted with Corrupted Conscience and Enslave
*
* on upkeep Phyrexian Obliterator does 1 damage to its owner but this
* damage was NOT infect damage and it should have been
*/
@Test
public void GainedInfectByEnchantment() {
// Trample
// Whenever a source deals damage to Phyrexian Obliterator, that source's controller sacrifices that many permanents.
addCard(Zone.BATTLEFIELD, playerB, "Phyrexian Obliterator");
// Enchant creature
// You control enchanted creature.
// Enchanted creature has infect. (It deals damage to creatures in the form of -1/-1 counters and to players in the form of poison counters.)
addCard(Zone.HAND, playerA, "Corrupted Conscience"); // Enchantment {3}{U}{U}
// Enchant creature
// You control enchanted creature.
// At the beginning of your upkeep, enchanted creature deals 1 damage to its owner.
addCard(Zone.HAND, playerA, "Enslave"); // Enchantment {4}{B}{B}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 9);
addCard(Zone.BATTLEFIELD, playerA, "Island", 2);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Corrupted Conscience", "Phyrexian Obliterator");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Enslave", "Phyrexian Obliterator");
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertPermanentCount(playerA, "Phyrexian Obliterator", 1);
assertPermanentCount(playerA, "Corrupted Conscience", 1);
assertPermanentCount(playerA, "Enslave", 1);
assertAbility(playerA, "Phyrexian Obliterator", InfectAbility.getInstance(), true);
assertLife(playerA, 20);
assertLife(playerB, 20);
assertCounterCount(playerB, CounterType.POISON, 1);
}
}