mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 12:22:10 -08:00
[MIR] Implement Teferi's Imp (#11326)
This commit is contained in:
parent
69517f998f
commit
5996cfbce2
9 changed files with 186 additions and 4 deletions
|
|
@ -419,6 +419,22 @@ public interface Ability extends Controllable, Serializable {
|
|||
*/
|
||||
void setWorksFaceDown(boolean worksFaceDown);
|
||||
|
||||
/**
|
||||
* Returns true if this ability has to work also with phased out object.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean getWorksPhasedOut();
|
||||
|
||||
/**
|
||||
* Sets the value for the worksPhasedOut flag
|
||||
* <p>
|
||||
* true = the ability works also if the object is phased out
|
||||
*
|
||||
* @param worksPhasedOut
|
||||
*/
|
||||
void setWorksPhasedOut(boolean worksPhasedOut);
|
||||
|
||||
/**
|
||||
* Returns true if this ability's rule is visible on the card tooltip
|
||||
*
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
protected boolean ruleAdditionalCostsVisible = true;
|
||||
protected boolean activated = false;
|
||||
protected boolean worksFaceDown = false;
|
||||
protected boolean worksPhasedOut = false;
|
||||
protected int sourceObjectZoneChangeCounter;
|
||||
protected List<Watcher> watchers = new ArrayList<>(); // access to it by GetWatchers only (it can be overridden by some abilities)
|
||||
protected List<Ability> subAbilities = null;
|
||||
|
|
@ -121,6 +122,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
this.ruleVisible = ability.ruleVisible;
|
||||
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
|
||||
this.worksFaceDown = ability.worksFaceDown;
|
||||
this.worksPhasedOut = ability.worksPhasedOut;
|
||||
this.abilityWord = ability.abilityWord;
|
||||
this.flavorWord = ability.flavorWord;
|
||||
this.sourceObjectZoneChangeCounter = ability.sourceObjectZoneChangeCounter;
|
||||
|
|
@ -1050,7 +1052,9 @@ public abstract class AbilityImpl implements Ability {
|
|||
}
|
||||
if (object != null) {
|
||||
if (object instanceof Permanent) {
|
||||
return object.hasAbility(this, game) && ((Permanent) object).isPhasedIn();
|
||||
return object.hasAbility(this, game) && (
|
||||
((Permanent) object).isPhasedIn() || this.getWorksPhasedOut()
|
||||
);
|
||||
} else {
|
||||
// cards and other objects
|
||||
return object.hasAbility(this, game);
|
||||
|
|
@ -1270,6 +1274,16 @@ public abstract class AbilityImpl implements Ability {
|
|||
this.worksFaceDown = worksFaceDown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWorksPhasedOut() {
|
||||
return worksPhasedOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorksPhasedOut(boolean worksPhasedOut) {
|
||||
this.worksPhasedOut = worksPhasedOut;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MageObject getSourceObject(Game game) {
|
||||
return game.getObject(getSourceId());
|
||||
|
|
@ -1481,7 +1495,7 @@ public abstract class AbilityImpl implements Ability {
|
|||
// to change the zone of any existing singleton abilities
|
||||
return this;
|
||||
}
|
||||
AbilityImpl copy = ((AbilityImpl)this.copy());
|
||||
AbilityImpl copy = ((AbilityImpl) this.copy());
|
||||
copy.zone = zone;
|
||||
copy.newId();
|
||||
return copy;
|
||||
|
|
|
|||
|
|
@ -315,7 +315,6 @@ public abstract class TriggeredAbilityImpl extends AbilityImpl implements Trigge
|
|||
source = game.getLastKnownInformation(getSourceId(), Zone.BATTLEFIELD);
|
||||
}
|
||||
break;
|
||||
case PHASED_OUT:
|
||||
case PHASED_IN:
|
||||
if (isLeavesTheBattlefieldTrigger()) {
|
||||
source = game.getLastKnownInformation(getSourceId(), event.getZone());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
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 Susucr
|
||||
*/
|
||||
public class SourcePhaseOutTriggeredAbility extends TriggeredAbilityImpl {
|
||||
|
||||
public SourcePhaseOutTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
setTriggerPhrase("Whenever {this} phases out, ");
|
||||
setWorksPhasedOut(true);
|
||||
}
|
||||
|
||||
protected SourcePhaseOutTriggeredAbility(final SourcePhaseOutTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourcePhaseOutTriggeredAbility copy() {
|
||||
return new SourcePhaseOutTriggeredAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.PHASED_OUT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return getSourceId().equals(event.getTargetId());
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
package mage.constants;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public enum Zone {
|
||||
|
|
|
|||
|
|
@ -540,6 +540,16 @@ public class StackAbility extends StackObjectImpl implements Ability {
|
|||
this.ability.setWorksFaceDown(worksFaceDown);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWorksPhasedOut() {
|
||||
return this.ability.getWorksPhasedOut();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorksPhasedOut(boolean worksPhasedOut) {
|
||||
this.ability.setWorksPhasedOut(worksPhasedOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Watcher> getWatchers() {
|
||||
return this.ability.getWatchers();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue