mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
added AttacksAloneControlledTriggeredAbility
This commit is contained in:
parent
63016b99d6
commit
62fa79cfd8
16 changed files with 138 additions and 310 deletions
|
|
@ -0,0 +1,74 @@
|
|||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class AttacksAloneControlledTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
private final FilterPermanent filter;
|
||||
private final boolean setTargetPointer;
|
||||
|
||||
public AttacksAloneControlledTriggeredAbility(Effect effect) {
|
||||
this(effect, false);
|
||||
}
|
||||
|
||||
public AttacksAloneControlledTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, false, optional);
|
||||
}
|
||||
|
||||
public AttacksAloneControlledTriggeredAbility(Effect effect, boolean setTargetPointer, boolean optional) {
|
||||
this(effect, StaticFilters.FILTER_CONTROLLED_A_CREATURE, setTargetPointer, optional);
|
||||
}
|
||||
|
||||
public AttacksAloneControlledTriggeredAbility(Effect effect, FilterPermanent filter, boolean setTargetPointer, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.filter = filter;
|
||||
this.setTargetPointer = setTargetPointer;
|
||||
}
|
||||
|
||||
private AttacksAloneControlledTriggeredAbility(final AttacksAloneControlledTriggeredAbility ability) {
|
||||
super(ability);
|
||||
this.filter = ability.filter;
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttacksAloneControlledTriggeredAbility copy() {
|
||||
return new AttacksAloneControlledTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (!game.getCombat().attacksAlone()) {
|
||||
return false;
|
||||
}
|
||||
Permanent permanent = game.getPermanent(game.getCombat().getAttackers().get(0));
|
||||
if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) {
|
||||
return false;
|
||||
}
|
||||
if (setTargetPointer) {
|
||||
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTriggerPhrase() {
|
||||
return "Whenever " + filter.getMessage() + " attacks alone, ";
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@ import mage.abilities.TriggeredAbilityImpl;
|
|||
import mage.abilities.effects.Effect;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
|
|
@ -15,19 +14,19 @@ import mage.target.targetpointer.FixedTarget;
|
|||
*
|
||||
* @author LoneFox
|
||||
*/
|
||||
public class AttacksAloneTriggeredAbility extends TriggeredAbilityImpl {
|
||||
public class AttacksAloneSourceTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public AttacksAloneTriggeredAbility(Effect effect) {
|
||||
public AttacksAloneSourceTriggeredAbility(Effect effect) {
|
||||
super(Zone.BATTLEFIELD, effect);
|
||||
}
|
||||
|
||||
public AttacksAloneTriggeredAbility(final AttacksAloneTriggeredAbility ability) {
|
||||
public AttacksAloneSourceTriggeredAbility(final AttacksAloneSourceTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttacksAloneTriggeredAbility copy() {
|
||||
return new AttacksAloneTriggeredAbility(this);
|
||||
public AttacksAloneSourceTriggeredAbility copy() {
|
||||
return new AttacksAloneSourceTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
Loading…
Add table
Add a link
Reference in a new issue