mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 12:49:39 -08:00
[AVR] Moonsilver Spear, extract common ability
This commit is contained in:
parent
0cbf65a072
commit
943555cebf
4 changed files with 120 additions and 65 deletions
|
|
@ -0,0 +1,39 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
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(Constants.Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue