mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Add LoseLifeControllerAttachedEffect. Kill some custom abilities and effects. Implement card: Pooling Venom
This commit is contained in:
parent
a6aa484ea0
commit
41ca5f198f
7 changed files with 193 additions and 272 deletions
|
|
@ -29,26 +29,18 @@ package mage.sets.conflux;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.filter.FilterPermanent;
|
||||||
import mage.filter.common.FilterLandPermanent;
|
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetLandPermanent;
|
|
||||||
import mage.target.targetpointer.FixedTarget;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -56,7 +48,7 @@ import mage.target.targetpointer.FixedTarget;
|
||||||
*/
|
*/
|
||||||
public class CorruptedRoots extends CardImpl {
|
public class CorruptedRoots extends CardImpl {
|
||||||
|
|
||||||
private static final FilterLandPermanent filter = new FilterLandPermanent("Forest or Plains");
|
private static final FilterPermanent filter = new FilterPermanent("Forest or Plains");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(Predicates.or(
|
filter.add(Predicates.or(
|
||||||
|
|
@ -69,17 +61,15 @@ public class CorruptedRoots extends CardImpl {
|
||||||
this.expansionSetCode = "CON";
|
this.expansionSetCode = "CON";
|
||||||
this.subtype.add("Aura");
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
|
||||||
// Enchant Forest or Plains
|
// Enchant Forest or Plains
|
||||||
TargetPermanent auraTarget = new TargetLandPermanent(filter);
|
TargetPermanent auraTarget = new TargetPermanent(filter);
|
||||||
this.getSpellAbility().addTarget(auraTarget);
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Whenever enchanted land becomes tapped, its controller loses 2 life.
|
// Whenever enchanted land becomes tapped, its controller loses 2 life.
|
||||||
this.addAbility(new CorruptedRootsTriggeredAbility());
|
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new LoseLifeControllerAttachedEffect(2), "enchanted land"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CorruptedRoots(final CorruptedRoots card) {
|
public CorruptedRoots(final CorruptedRoots card) {
|
||||||
|
|
@ -91,44 +81,3 @@ public class CorruptedRoots extends CardImpl {
|
||||||
return new CorruptedRoots(this);
|
return new CorruptedRoots(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CorruptedRootsTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
|
|
||||||
CorruptedRootsTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
CorruptedRootsTriggeredAbility(final CorruptedRootsTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == EventType.TAPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
Permanent enchantment = game.getPermanent(this.sourceId);
|
|
||||||
if (enchantment != null && enchantment.getAttachedTo().equals(event.getTargetId())) {
|
|
||||||
Permanent attached = game.getPermanent(enchantment.getAttachedTo());
|
|
||||||
if (attached != null) {
|
|
||||||
for (Effect effect : getEffects()) {
|
|
||||||
effect.setTargetPointer(new FixedTarget(attached.getControllerId()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CorruptedRootsTriggeredAbility copy() {
|
|
||||||
return new CorruptedRootsTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever enchanted land becomes tapped, its controller loses 2 life.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -29,19 +29,15 @@ package mage.sets.dragonsmaze;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
|
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
|
||||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
|
@ -81,61 +77,3 @@ public class SinisterPossession extends CardImpl {
|
||||||
return new SinisterPossession(this);
|
return new SinisterPossession(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoseLifeControllerAttachedEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
protected DynamicValue amount;
|
|
||||||
|
|
||||||
public LoseLifeControllerAttachedEffect(int amount) {
|
|
||||||
this(new StaticValue(amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoseLifeControllerAttachedEffect(DynamicValue amount) {
|
|
||||||
super(Outcome.Damage);
|
|
||||||
this.amount = amount;
|
|
||||||
setText();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoseLifeControllerAttachedEffect(final LoseLifeControllerAttachedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
this.amount = effect.amount.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoseLifeControllerAttachedEffect copy() {
|
|
||||||
return new LoseLifeControllerAttachedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
|
||||||
if (enchantment == null) {
|
|
||||||
enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
|
||||||
}
|
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
|
||||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
|
||||||
if (creature == null) {
|
|
||||||
creature = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
|
||||||
}
|
|
||||||
if (creature != null) {
|
|
||||||
Player player = game.getPlayer(creature.getControllerId());
|
|
||||||
if (player != null) {
|
|
||||||
player.loseLife(amount.calculate(game, source, this), game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setText() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("it's controller loses ").append(amount.toString()).append(" life");
|
|
||||||
String message = amount.getMessage();
|
|
||||||
if (message.length() > 0) {
|
|
||||||
sb.append(" for each ");
|
|
||||||
sb.append(message);
|
|
||||||
}
|
|
||||||
staticText = sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
78
Mage.Sets/src/mage/sets/futuresight/PoolingVenom.java
Normal file
78
Mage.Sets/src/mage/sets/futuresight/PoolingVenom.java
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* 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.futuresight;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||||
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.DestroyAttachedEffect;
|
||||||
|
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
|
||||||
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Rarity;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.target.TargetPermanent;
|
||||||
|
import mage.target.common.TargetLandPermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LoneFox
|
||||||
|
*/
|
||||||
|
public class PoolingVenom extends CardImpl {
|
||||||
|
|
||||||
|
public PoolingVenom(UUID ownerId) {
|
||||||
|
super(ownerId, 74, "Pooling Venom", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}");
|
||||||
|
this.expansionSetCode = "FUT";
|
||||||
|
this.subtype.add("Aura");
|
||||||
|
|
||||||
|
// Enchant land
|
||||||
|
TargetPermanent auraTarget = new TargetLandPermanent();
|
||||||
|
this.getSpellAbility().addTarget(auraTarget);
|
||||||
|
this.getSpellAbility().addEffect(new AttachEffect(Outcome.Detriment));
|
||||||
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
|
this.addAbility(ability);
|
||||||
|
// Whenever enchanted land becomes tapped, its controller loses 2 life.
|
||||||
|
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new LoseLifeControllerAttachedEffect(2), "enchanted land"));
|
||||||
|
// {3}{B}: Destroy enchanted land.
|
||||||
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyAttachedEffect("enchanted land"), new ManaCostsImpl("{3}{B}")));
|
||||||
|
}
|
||||||
|
|
||||||
|
public PoolingVenom(final PoolingVenom card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PoolingVenom copy() {
|
||||||
|
return new PoolingVenom(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,22 +30,17 @@ package mage.sets.limitedalpha;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.DamageTargetEffect;
|
import mage.abilities.effects.common.DamageAttachedControllerEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetLandPermanent;
|
import mage.target.common.TargetLandPermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -67,7 +62,9 @@ public class PsychicVenom extends CardImpl {
|
||||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
// Whenever enchanted land becomes tapped, Psychic Venom deals 2 damage to that land's controller.
|
// Whenever enchanted land becomes tapped, Psychic Venom deals 2 damage to that land's controller.
|
||||||
this.addAbility(new PsychicVenomAbility());
|
Effect effect = new DamageAttachedControllerEffect(2);
|
||||||
|
effect.setText("{this} deals 2 damage to that land's controller");
|
||||||
|
this.addAbility(new BecomesTappedAttachedTriggeredAbility(effect, "enchanted land"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PsychicVenom(final PsychicVenom card) {
|
public PsychicVenom(final PsychicVenom card) {
|
||||||
|
|
@ -79,43 +76,3 @@ public class PsychicVenom extends CardImpl {
|
||||||
return new PsychicVenom(this);
|
return new PsychicVenom(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PsychicVenomAbility extends TriggeredAbilityImpl {
|
|
||||||
PsychicVenomAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new DamageTargetEffect(2, true, "that land's controller"));
|
|
||||||
}
|
|
||||||
|
|
||||||
PsychicVenomAbility(final PsychicVenomAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == EventType.TAPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
Permanent source = game.getPermanent(this.sourceId);
|
|
||||||
if (source != null && source.getAttachedTo().equals(event.getTargetId())) {
|
|
||||||
Permanent attached = game.getPermanent(source.getAttachedTo());
|
|
||||||
if (attached != null) {
|
|
||||||
for (Effect e : getEffects()) {
|
|
||||||
e.setTargetPointer(new FixedTarget(attached.getControllerId()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PsychicVenomAbility copy() {
|
|
||||||
return new PsychicVenomAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever enchanted land becomes tapped, " + super.getRule();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -30,19 +30,14 @@ package mage.sets.ninthedition;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
|
import mage.abilities.common.AttacksOrBlocksEnchantedTriggeredAbility;
|
||||||
import mage.abilities.dynamicvalue.DynamicValue;
|
|
||||||
import mage.abilities.dynamicvalue.common.StaticValue;
|
|
||||||
import mage.abilities.effects.OneShotEffect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
|
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.players.Player;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
|
||||||
|
|
@ -77,50 +72,3 @@ public class ContaminatedBond extends CardImpl {
|
||||||
return new ContaminatedBond(this);
|
return new ContaminatedBond(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LoseLifeControllerAttachedEffect extends OneShotEffect {
|
|
||||||
|
|
||||||
protected DynamicValue amount;
|
|
||||||
|
|
||||||
public LoseLifeControllerAttachedEffect(int amount) {
|
|
||||||
this(new StaticValue(amount));
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoseLifeControllerAttachedEffect(DynamicValue amount) {
|
|
||||||
super(Outcome.Damage);
|
|
||||||
this.amount = amount;
|
|
||||||
staticText = "its controller loses " + amount.toString() +" life";
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoseLifeControllerAttachedEffect(final LoseLifeControllerAttachedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
this.amount = effect.amount.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoseLifeControllerAttachedEffect copy() {
|
|
||||||
return new LoseLifeControllerAttachedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Game game, Ability source) {
|
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
|
||||||
if (enchantment == null) {
|
|
||||||
enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
|
||||||
}
|
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
|
||||||
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
|
||||||
if (creature == null) {
|
|
||||||
creature = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
|
||||||
}
|
|
||||||
if (creature != null) {
|
|
||||||
Player player = game.getPlayer(creature.getControllerId());
|
|
||||||
if (player != null) {
|
|
||||||
player.loseLife(amount.calculate(game, source, this), game);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,10 @@ package mage.sets.riseoftheeldrazi;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.Effect;
|
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.LoseLifeTargetEffect;
|
import mage.abilities.effects.common.LoseLifeControllerAttachedEffect;
|
||||||
import mage.abilities.effects.common.continuous.BecomesBasicLandEnchantedEffect;
|
import mage.abilities.effects.common.continuous.BecomesBasicLandEnchantedEffect;
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
|
|
@ -41,13 +40,8 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
import mage.game.events.GameEvent.EventType;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetLandPermanent;
|
import mage.target.common.TargetLandPermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Loki
|
* @author Loki
|
||||||
|
|
@ -69,9 +63,9 @@ public class ContaminatedGround extends CardImpl {
|
||||||
|
|
||||||
// Enchanted land is a Swamp.
|
// Enchanted land is a Swamp.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesBasicLandEnchantedEffect("Swamp")));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesBasicLandEnchantedEffect("Swamp")));
|
||||||
|
|
||||||
// Whenever enchanted land becomes tapped, its controller loses 2 life.
|
// Whenever enchanted land becomes tapped, its controller loses 2 life.
|
||||||
this.addAbility(new ContaminatedGroundAbility());
|
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new LoseLifeControllerAttachedEffect(2), "enchanted land"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContaminatedGround(final ContaminatedGround card) {
|
public ContaminatedGround(final ContaminatedGround card) {
|
||||||
|
|
@ -83,44 +77,3 @@ public class ContaminatedGround extends CardImpl {
|
||||||
return new ContaminatedGround(this);
|
return new ContaminatedGround(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContaminatedGroundAbility extends TriggeredAbilityImpl {
|
|
||||||
ContaminatedGroundAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new LoseLifeTargetEffect(2));
|
|
||||||
}
|
|
||||||
|
|
||||||
ContaminatedGroundAbility(final ContaminatedGroundAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == EventType.TAPPED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
Permanent source = game.getPermanent(this.sourceId);
|
|
||||||
if (source != null && source.getAttachedTo().equals(event.getTargetId())) {
|
|
||||||
Permanent attached = game.getPermanent(source.getAttachedTo());
|
|
||||||
if (attached != null) {
|
|
||||||
|
|
||||||
for (Effect e : getEffects()) {
|
|
||||||
e.setTargetPointer(new FixedTarget(attached.getControllerId()));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContaminatedGroundAbility copy() {
|
|
||||||
return new ContaminatedGroundAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever enchanted land becomes tapped, its controller loses 2 life.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* 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.abilities.effects.common;
|
||||||
|
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.dynamicvalue.DynamicValue;
|
||||||
|
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||||
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.constants.Outcome;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
|
||||||
|
public class LoseLifeControllerAttachedEffect extends OneShotEffect {
|
||||||
|
|
||||||
|
protected DynamicValue amount;
|
||||||
|
|
||||||
|
public LoseLifeControllerAttachedEffect(int amount) {
|
||||||
|
this(new StaticValue(amount));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoseLifeControllerAttachedEffect(DynamicValue amount) {
|
||||||
|
super(Outcome.LoseLife);
|
||||||
|
this.amount = amount;
|
||||||
|
setText();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LoseLifeControllerAttachedEffect(final LoseLifeControllerAttachedEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.amount = effect.amount.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LoseLifeControllerAttachedEffect copy() {
|
||||||
|
return new LoseLifeControllerAttachedEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
Permanent enchantment = game.getPermanent(source.getSourceId());
|
||||||
|
if (enchantment == null) {
|
||||||
|
enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||||
|
}
|
||||||
|
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
||||||
|
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
|
||||||
|
if (creature == null) {
|
||||||
|
creature = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||||
|
}
|
||||||
|
if (creature != null) {
|
||||||
|
Player player = game.getPlayer(creature.getControllerId());
|
||||||
|
if (player != null) {
|
||||||
|
player.loseLife(amount.calculate(game, source, this), game);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setText() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("it's controller loses ").append(amount.toString()).append(" life");
|
||||||
|
String message = amount.getMessage();
|
||||||
|
if (message.length() > 0) {
|
||||||
|
sb.append(" for each ");
|
||||||
|
sb.append(message);
|
||||||
|
}
|
||||||
|
staticText = sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue