mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Refactored AttacksAttachedTriggeredAbility, added SacrificeSourceTriggeredAbility.
This commit is contained in:
parent
6fbbb6f2ee
commit
811d4409ec
9 changed files with 174 additions and 55 deletions
|
@ -29,7 +29,7 @@ package mage.sets.alarareborn;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEquippedTriggeredAbility;
|
import mage.abilities.common.AttacksAttachedTriggeredAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.keyword.EquipAbility;
|
import mage.abilities.keyword.EquipAbility;
|
||||||
|
@ -56,7 +56,7 @@ public class MageSlayer extends CardImpl<MageSlayer> {
|
||||||
this.color.setGreen(true);
|
this.color.setGreen(true);
|
||||||
|
|
||||||
// Whenever equipped creature attacks, it deals damage equal to its power to defending player.
|
// Whenever equipped creature attacks, it deals damage equal to its power to defending player.
|
||||||
this.addAbility(new AttacksEquippedTriggeredAbility(new MageSlayerEffect(), false));
|
this.addAbility(new AttacksAttachedTriggeredAbility(new MageSlayerEffect(), false));
|
||||||
|
|
||||||
// Equip {3}
|
// Equip {3}
|
||||||
this.addAbility(new EquipAbility(Outcome.Benefit, new GenericManaCost(3), new TargetControlledCreaturePermanent()));
|
this.addAbility(new EquipAbility(Outcome.Benefit, new GenericManaCost(3), new TargetControlledCreaturePermanent()));
|
||||||
|
|
|
@ -30,7 +30,7 @@ package mage.sets.avacynrestored;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.abilities.common.AttacksEquippedTriggeredAbility;
|
import mage.abilities.common.AttacksAttachedTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.common.CreateTokenEffect;
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
|
@ -54,7 +54,7 @@ public class MoonsilverSpear extends CardImpl<MoonsilverSpear> {
|
||||||
// Equipped creature has first strike.
|
// Equipped creature has first strike.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.EQUIPMENT)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.EQUIPMENT)));
|
||||||
// Whenever equipped creature attacks, put a 4/4 white Angel creature token with flying onto the battlefield.
|
// Whenever equipped creature attacks, put a 4/4 white Angel creature token with flying onto the battlefield.
|
||||||
this.addAbility(new AttacksEquippedTriggeredAbility(new CreateTokenEffect(new AngelToken())));
|
this.addAbility(new AttacksAttachedTriggeredAbility(new CreateTokenEffect(new AngelToken())));
|
||||||
// Equip {4}
|
// Equip {4}
|
||||||
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(4)));
|
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(4)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ import mage.constants.SubLayer;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.Mode;
|
import mage.abilities.Mode;
|
||||||
import mage.abilities.common.AttacksEquippedTriggeredAbility;
|
import mage.abilities.common.AttacksAttachedTriggeredAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
@ -62,7 +62,7 @@ public class TrepanationBlade extends CardImpl<TrepanationBlade> {
|
||||||
|
|
||||||
// Whenever equipped creature attacks, defending player reveals cards from the top of his or her library until he or she reveals a land card.
|
// Whenever equipped creature attacks, defending player reveals cards from the top of his or her library until he or she reveals a land card.
|
||||||
// The creature gets +1/+0 until end of turn for each card revealed this way. That player puts the revealed cards into his or her graveyard.
|
// The creature gets +1/+0 until end of turn for each card revealed this way. That player puts the revealed cards into his or her graveyard.
|
||||||
Ability ability = new AttacksEquippedTriggeredAbility(new TrepanationBladeDiscardEffect());
|
Ability ability = new AttacksAttachedTriggeredAbility(new TrepanationBladeDiscardEffect());
|
||||||
ability.addEffect(new TrepanationBladeBoostEffect());
|
ability.addEffect(new TrepanationBladeBoostEffect());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
// Equip {2}
|
// Equip {2}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEquippedTriggeredAbility;
|
import mage.abilities.common.AttacksAttachedTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.common.continious.BoostEquippedEffect;
|
import mage.abilities.effects.common.continious.BoostEquippedEffect;
|
||||||
|
@ -55,7 +55,7 @@ public class ArgentumArmor extends CardImpl<ArgentumArmor> {
|
||||||
this.expansionSetCode = "SOM";
|
this.expansionSetCode = "SOM";
|
||||||
this.subtype.add("Equipment");
|
this.subtype.add("Equipment");
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(6, 6)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(6, 6)));
|
||||||
Ability ability = new AttacksEquippedTriggeredAbility(new DestroyTargetEffect());
|
Ability ability = new AttacksAttachedTriggeredAbility(new DestroyTargetEffect());
|
||||||
ability.addTarget(new TargetPermanent());
|
ability.addTarget(new TargetPermanent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(6)));
|
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(6)));
|
||||||
|
|
|
@ -33,7 +33,7 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEquippedTriggeredAbility;
|
import mage.abilities.common.AttacksAttachedTriggeredAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.keyword.EquipAbility;
|
import mage.abilities.keyword.EquipAbility;
|
||||||
|
@ -56,7 +56,7 @@ public class ExplorersScope extends CardImpl<ExplorersScope> {
|
||||||
this.expansionSetCode = "ZEN";
|
this.expansionSetCode = "ZEN";
|
||||||
this.subtype.add("Equipment");
|
this.subtype.add("Equipment");
|
||||||
|
|
||||||
this.addAbility(new AttacksEquippedTriggeredAbility(new ExplorersScopeEffect()));
|
this.addAbility(new AttacksAttachedTriggeredAbility(new ExplorersScopeEffect()));
|
||||||
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1)));
|
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import mage.constants.Outcome;
|
||||||
import mage.constants.Rarity;
|
import mage.constants.Rarity;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.AttacksEquippedTriggeredAbility;
|
import mage.abilities.common.AttacksAttachedTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.mana.GenericManaCost;
|
import mage.abilities.costs.mana.GenericManaCost;
|
||||||
import mage.abilities.effects.RequirementEffect;
|
import mage.abilities.effects.RequirementEffect;
|
||||||
|
@ -61,7 +61,7 @@ public class GrapplingHook extends CardImpl<GrapplingHook> {
|
||||||
// Equipped creature has double strike.
|
// Equipped creature has double strike.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(DoubleStrikeAbility.getInstance(), AttachmentType.EQUIPMENT)));
|
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(DoubleStrikeAbility.getInstance(), AttachmentType.EQUIPMENT)));
|
||||||
// Whenever equipped creature attacks, you may have target creature block it this turn if able.
|
// Whenever equipped creature attacks, you may have target creature block it this turn if able.
|
||||||
Ability ability = new AttacksEquippedTriggeredAbility(new GrapplingHookEffect(), true);
|
Ability ability = new AttacksAttachedTriggeredAbility(new GrapplingHookEffect(), true);
|
||||||
ability.addTarget(new TargetCreaturePermanent());
|
ability.addTarget(new TargetCreaturePermanent());
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
// Equip {4}
|
// Equip {4}
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
/*
|
||||||
|
* 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.AttachmentType;
|
||||||
|
import mage.constants.Zone;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "When enchanted/equipped creature attacks " triggered ability
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class AttacksAttachedTriggeredAbility extends TriggeredAbilityImpl<AttacksAttachedTriggeredAbility> {
|
||||||
|
|
||||||
|
private AttachmentType attachmentType;
|
||||||
|
|
||||||
|
public AttacksAttachedTriggeredAbility(Effect effect) {
|
||||||
|
this(effect, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttacksAttachedTriggeredAbility(Effect effect, boolean optional) {
|
||||||
|
this(effect, AttachmentType.EQUIPMENT, optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttacksAttachedTriggeredAbility(Effect effect, AttachmentType attachmentType, boolean optional) {
|
||||||
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
|
this.attachmentType = attachmentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AttacksAttachedTriggeredAbility(final AttacksAttachedTriggeredAbility abiltity) {
|
||||||
|
super(abiltity);
|
||||||
|
this.attachmentType = abiltity.attachmentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AttacksAttachedTriggeredAbility copy() {
|
||||||
|
return new AttacksAttachedTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
Permanent equipment = game.getPermanent(this.sourceId);
|
||||||
|
if (equipment != null && equipment.getAttachedTo() != null
|
||||||
|
&& event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|
||||||
|
&& event.getSourceId().equals(equipment.getAttachedTo())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
StringBuilder sb = new StringBuilder("Whenever ");
|
||||||
|
if (attachmentType.equals(AttachmentType.EQUIPMENT)) {
|
||||||
|
sb.append("equipped");
|
||||||
|
} else {
|
||||||
|
sb.append("enchanted");
|
||||||
|
}
|
||||||
|
return sb.append(" creature attacks, ").append(super.getRule()).toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,43 +0,0 @@
|
||||||
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;
|
|
||||||
|
|
||||||
public class AttacksEquippedTriggeredAbility extends TriggeredAbilityImpl<AttacksEquippedTriggeredAbility> {
|
|
||||||
public AttacksEquippedTriggeredAbility(Effect effect) {
|
|
||||||
super(Zone.BATTLEFIELD, effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttacksEquippedTriggeredAbility(Effect effect, boolean optional) {
|
|
||||||
super(Zone.BATTLEFIELD, effect, optional);
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttacksEquippedTriggeredAbility(final AttacksEquippedTriggeredAbility abiltity) {
|
|
||||||
super(abiltity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AttacksEquippedTriggeredAbility copy() {
|
|
||||||
return new AttacksEquippedTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
Permanent equipment = game.getPermanent(this.sourceId);
|
|
||||||
if (equipment != null && equipment.getAttachedTo() != null
|
|
||||||
&& event.getType() == GameEvent.EventType.ATTACKER_DECLARED
|
|
||||||
&& event.getSourceId().equals(equipment.getAttachedTo())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever equipped creature attacks, " + super.getRule();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SacrificeSourceTriggeredAbility extends TriggeredAbilityImpl<SacrificeSourceTriggeredAbility> {
|
||||||
|
|
||||||
|
public SacrificeSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||||
|
super(Zone.BATTLEFIELD, effect, optional);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SacrificeSourceTriggeredAbility(final SacrificeSourceTriggeredAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SacrificeSourceTriggeredAbility copy() {
|
||||||
|
return new SacrificeSourceTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
if (event.getType() == GameEvent.EventType.SACRIFICED_PERMANENT && event.getTargetId().equals(sourceId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "When you sacrifice {this}, " + super.getRule();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue