fixed bug #3857, recoded the C17 curses

This commit is contained in:
Evan Kranzler 2017-08-20 09:49:23 -04:00
parent eac2d31c88
commit f4cdb77513
6 changed files with 250 additions and 192 deletions

View file

@ -27,8 +27,9 @@
*/
package mage.cards.c;
import java.util.HashSet;
import java.util.Set;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
@ -37,19 +38,14 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
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.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.UntapAllControllerEffect;
import mage.filter.StaticFilters;
import mage.filter.common.FilterNonlandPermanent;
import mage.game.combat.CombatGroup;
import mage.players.Player;
/**
@ -70,7 +66,7 @@ public class CurseOfBounty extends CardImpl {
// Whenever enchanted player is attacked, untap all nonland permanents you control.
// Each opponent attacking that player untaps all nonland permanents he or she controls.
this.addAbility(new CurseOfBountyTriggeredAbility());
this.addAbility(new EnchantedPlayerAttackedTriggeredAbility(new CurseOfBountyEffect()));
}
public CurseOfBounty(final CurseOfBounty card) {
@ -83,52 +79,49 @@ public class CurseOfBounty extends CardImpl {
}
}
class CurseOfBountyTriggeredAbility extends TriggeredAbilityImpl {
class CurseOfBountyEffect extends OneShotEffect {
public CurseOfBountyTriggeredAbility() {
super(Zone.BATTLEFIELD, new UntapAllControllerEffect(new FilterNonlandPermanent()), false);
CurseOfBountyEffect() {
super(Outcome.Benefit);
this.staticText = "untap all nonland permanents you control. Each opponent attacking that player does the same.";
}
public CurseOfBountyTriggeredAbility(final CurseOfBountyTriggeredAbility ability) {
super(ability);
CurseOfBountyEffect(final CurseOfBountyEffect effect) {
super(effect);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
public CurseOfBountyEffect copy() {
return new CurseOfBountyEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
Effect effect = new UntapAllNonlandsTargetEffect();
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId())
&& game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
return true;
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new UntapAllNonlandsTargetEffect();
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted player is attacked, untap all nonland permanents you control. "
+ "Each opponent attacking that player untaps all nonland permanents he or she controls.";
}
@Override
public CurseOfBountyTriggeredAbility copy() {
return new CurseOfBountyTriggeredAbility(this);
}
}
class UntapAllNonlandsTargetEffect extends OneShotEffect {

View file

@ -27,11 +27,14 @@
*/
package mage.cards.c;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.Ability;
import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -39,11 +42,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
@ -67,7 +66,7 @@ public class CurseOfDisturbance extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, create a 2/2 black Zombie creature token. Each opponent attacking that player does the same.
this.addAbility(new CurseOfDisturbanceTriggeredAbility());
this.addAbility(new EnchantedPlayerAttackedTriggeredAbility(new CurseOfDisturbanceEffect()));
}
public CurseOfDisturbance(final CurseOfDisturbance card) {
@ -80,50 +79,48 @@ public class CurseOfDisturbance extends CardImpl {
}
}
class CurseOfDisturbanceTriggeredAbility extends TriggeredAbilityImpl {
class CurseOfDisturbanceEffect extends OneShotEffect {
public CurseOfDisturbanceTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenEffect(new ZombieToken()), false);
CurseOfDisturbanceEffect() {
super(Outcome.Benefit);
this.staticText = "create a 2/2 black Zombie creature token. "
+ "Each opponent attacking that player does the same.";
}
public CurseOfDisturbanceTriggeredAbility(final CurseOfDisturbanceTriggeredAbility ability) {
super(ability);
CurseOfDisturbanceEffect(final CurseOfDisturbanceEffect effect) {
super(effect);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
public CurseOfDisturbanceEffect copy() {
return new CurseOfDisturbanceEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
Effect effect = new CreateTokenTargetEffect(new ZombieToken());
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId())
&& game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
return true;
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new CreateTokenTargetEffect(new ZombieToken());
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted player is attacked, create a 2/2 black Zombie creature token. Each opponent attacking that player does the same.";
}
@Override
public CurseOfDisturbanceTriggeredAbility copy() {
return new CurseOfDisturbanceTriggeredAbility(this);
}
}

View file

@ -27,11 +27,14 @@
*/
package mage.cards.c;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.Ability;
import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -39,11 +42,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.GoldToken;
import mage.players.Player;
@ -68,7 +67,7 @@ public class CurseOfOpulence extends CardImpl {
// Whenever enchanted player is attacked, create a colorless artifact token named Gold.
// It has "sacrifice this artifact: Add one mana of any color to your mana pool." Each opponent attacking that player does the same.
this.addAbility(new CurseOfOpulenceTriggeredAbility());
this.addAbility(new EnchantedPlayerAttackedTriggeredAbility(new CurseOfOpulenceEffect()));
}
public CurseOfOpulence(final CurseOfOpulence card) {
@ -81,51 +80,49 @@ public class CurseOfOpulence extends CardImpl {
}
}
class CurseOfOpulenceTriggeredAbility extends TriggeredAbilityImpl {
class CurseOfOpulenceEffect extends OneShotEffect {
public CurseOfOpulenceTriggeredAbility() {
super(Zone.BATTLEFIELD, new CreateTokenEffect(new GoldToken()), false);
CurseOfOpulenceEffect() {
super(Outcome.Benefit);
this.staticText = "create a colorless artifact token named Gold. It has "
+ "\"sacrifice this artifact: Add one mana of any color to your mana pool.\" "
+ "Each opponent attacking that player does the same.";
}
public CurseOfOpulenceTriggeredAbility(final CurseOfOpulenceTriggeredAbility ability) {
super(ability);
CurseOfOpulenceEffect(final CurseOfOpulenceEffect effect) {
super(effect);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
public CurseOfOpulenceEffect copy() {
return new CurseOfOpulenceEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
Effect effect = new CreateTokenTargetEffect(new GoldToken());
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId())
&& game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
return true;
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new CreateTokenTargetEffect(new GoldToken());
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted player is attacked, create a colorless artifact token named Gold. "
+ "It has \"sacrifice this artifact: Add one mana of any color to your mana pool.\" Each opponent attacking that player does the same.";
}
@Override
public CurseOfOpulenceTriggeredAbility copy() {
return new CurseOfOpulenceTriggeredAbility(this);
}
}

View file

@ -27,11 +27,14 @@
*/
package mage.cards.c;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.Ability;
import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.DrawCardTargetEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -39,11 +42,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
@ -66,7 +65,7 @@ public class CurseOfVerbosity extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, draw a card. Each opponent attacking that player does the same.
this.addAbility(new CurseOfVerbosityTriggeredAbility());
this.addAbility(new EnchantedPlayerAttackedTriggeredAbility(new CurseOfVerbosityEffect()));
}
public CurseOfVerbosity(final CurseOfVerbosity card) {
@ -79,50 +78,47 @@ public class CurseOfVerbosity extends CardImpl {
}
}
class CurseOfVerbosityTriggeredAbility extends TriggeredAbilityImpl {
class CurseOfVerbosityEffect extends OneShotEffect {
public CurseOfVerbosityTriggeredAbility() {
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), false);
CurseOfVerbosityEffect() {
super(Outcome.Benefit);
this.staticText = "draw a card. Each opponent attacking that player does the same.";
}
public CurseOfVerbosityTriggeredAbility(final CurseOfVerbosityTriggeredAbility ability) {
super(ability);
CurseOfVerbosityEffect(final CurseOfVerbosityEffect effect) {
super(effect);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
public CurseOfVerbosityEffect copy() {
return new CurseOfVerbosityEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
Effect effect = new DrawCardTargetEffect(1);
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId())
&& game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
return true;
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new DrawCardTargetEffect(1);
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted player is attacked, draw a card. Each opponent attacking that player does the same.";
}
@Override
public CurseOfVerbosityTriggeredAbility copy() {
return new CurseOfVerbosityTriggeredAbility(this);
}
}

View file

@ -27,7 +27,8 @@
*/
package mage.cards.c;
import mage.abilities.TriggeredAbilityImpl;
import java.util.HashSet;
import java.util.Set;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
@ -36,17 +37,15 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
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.TargetPlayer;
import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.Ability;
import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.GainLifeTargetEffect;
import mage.game.combat.CombatGroup;
import mage.players.Player;
/**
@ -66,7 +65,7 @@ public class CurseOfVitality extends CardImpl {
this.addAbility(new EnchantAbility(auraTarget.getTargetName()));
// Whenever enchanted player is attacked, you gain 2 life. Each opponent attacking that player does the same.
this.addAbility(new CurseOfVitalityTriggeredAbility());
this.addAbility(new EnchantedPlayerAttackedTriggeredAbility(new CurseOfVitalityEffect()));
}
public CurseOfVitality(final CurseOfVitality card) {
@ -79,50 +78,47 @@ public class CurseOfVitality extends CardImpl {
}
}
class CurseOfVitalityTriggeredAbility extends TriggeredAbilityImpl {
class CurseOfVitalityEffect extends OneShotEffect {
public CurseOfVitalityTriggeredAbility() {
super(Zone.BATTLEFIELD, new GainLifeEffect(2), false);
CurseOfVitalityEffect() {
super(Outcome.Benefit);
this.staticText = "gain 2 life. Each opponent attacking that player does the same.";
}
public CurseOfVitalityTriggeredAbility(final CurseOfVitalityTriggeredAbility ability) {
super(ability);
CurseOfVitalityEffect(final CurseOfVitalityEffect effect) {
super(effect);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARED_ATTACKERS;
public CurseOfVitalityEffect copy() {
return new CurseOfVitalityEffect(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null
&& enchantment.getAttachedTo() != null
&& game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo())) {
for (CombatGroup group : game.getCombat().getBlockingGroups()) {
if (group.getDefenderId().equals(enchantment.getAttachedTo())) {
if (controller.hasOpponent(game.getCombat().getAttackingPlayerId(), game)) {
Effect effect = new GainLifeTargetEffect(2);
effect.setTargetPointer(new FixedTarget(game.getCombat().getAttackingPlayerId()));
this.addEffect(effect);
public boolean apply(Game game, Ability source) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (enchantment != null) {
Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo());
if (enchantedPlayer != null) {
Set<UUID> players = new HashSet();
for (UUID attacker : game.getCombat().getAttackers()) {
UUID defender = game.getCombat().getDefenderId(attacker);
if (defender.equals(enchantedPlayer.getId())
&& game.getPlayer(source.getControllerId()).hasOpponent(game.getPermanent(attacker).getControllerId(), game)) {
players.add(game.getPermanent(attacker).getControllerId());
}
return true;
}
players.add(source.getControllerId());
for (UUID player : players) {
game.getPlayer(player);
Effect effect = new GainLifeTargetEffect(2);
effect.setTargetPointer(new FixedTarget(player));
effect.apply(game, source);
}
}
return true;
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted player is attacked, you gain 2 life. Each opponent attacking that player does the same.";
}
@Override
public CurseOfVitalityTriggeredAbility copy() {
return new CurseOfVitalityTriggeredAbility(this);
}
}

View file

@ -0,0 +1,79 @@
/*
* 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.common;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
*
* @author LevelX2
*/
public class EnchantedPlayerAttackedTriggeredAbility extends TriggeredAbilityImpl {
protected Effect effect;
public EnchantedPlayerAttackedTriggeredAbility(Effect effect) {
super(Zone.BATTLEFIELD, effect, false);
}
public EnchantedPlayerAttackedTriggeredAbility(final EnchantedPlayerAttackedTriggeredAbility ability) {
super(ability);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(getSourceId());
Player controller = game.getPlayer(getControllerId());
if (controller != null && enchantment != null) {
return game.getCombat().getPlayerDefenders(game).contains(enchantment.getAttachedTo());
}
return false;
}
@Override
public String getRule() {
return "Whenever enchanted player is attacked, " + super.getRule();
}
@Override
public EnchantedPlayerAttackedTriggeredAbility copy() {
return new EnchantedPlayerAttackedTriggeredAbility(this);
}
}