mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[refactoring] used duplicate abilities of AtEndOfTurnDelayedTriggeredAbility
This commit is contained in:
parent
93018628df
commit
b12c3530af
3 changed files with 20 additions and 94 deletions
|
@ -29,21 +29,19 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.SpellCastTriggeredAbility;
|
||||
import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnFromExileEffect;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterSpiritOrArcaneCard;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
|
@ -96,7 +94,8 @@ class HikariTwilightGuardianEffect extends OneShotEffect<HikariTwilightGuardianE
|
|||
if (permanent != null) {
|
||||
if (permanent.moveToExile(source.getSourceId(), "Hikari, Twilight Guardian", source.getId(), game)) {
|
||||
//create delayed triggered ability
|
||||
HikariTwilightGuardianDelayedTriggeredAbility delayedAbility = new HikariTwilightGuardianDelayedTriggeredAbility(source.getSourceId());
|
||||
AtEndOfTurnDelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(
|
||||
new ReturnFromExileEffect(source.getSourceId(), Constants.Zone.BATTLEFIELD));
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
|
@ -112,26 +111,3 @@ class HikariTwilightGuardianEffect extends OneShotEffect<HikariTwilightGuardianE
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class HikariTwilightGuardianDelayedTriggeredAbility extends DelayedTriggeredAbility<HikariTwilightGuardianDelayedTriggeredAbility> {
|
||||
|
||||
HikariTwilightGuardianDelayedTriggeredAbility ( UUID exileId ) {
|
||||
super(new ReturnFromExileEffect(exileId, Constants.Zone.BATTLEFIELD));
|
||||
}
|
||||
|
||||
HikariTwilightGuardianDelayedTriggeredAbility(HikariTwilightGuardianDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public HikariTwilightGuardianDelayedTriggeredAbility copy() {
|
||||
return new HikariTwilightGuardianDelayedTriggeredAbility(this);
|
||||
}
|
||||
}
|
|
@ -29,12 +29,11 @@
|
|||
package mage.sets.championsofkamigawa;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnFromExileEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
|
||||
|
@ -42,7 +41,6 @@ import mage.cards.CardImpl;
|
|||
import mage.counters.CounterType;
|
||||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
@ -90,18 +88,19 @@ class OtherworldlyJourneyEffect extends OneShotEffect<OtherworldlyJourneyEffect>
|
|||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (permanent != null) {
|
||||
if (permanent.moveToExile(source.getSourceId(), "Otherworldly Journey", source.getId(), game)) {
|
||||
ExileZone exile = game.getExile().getExileZone(source.getSourceId());
|
||||
// only if permanent is in exile (tokens would be stop to exist)
|
||||
if (exile != null && !exile.isEmpty()) {
|
||||
//create delayed triggered ability
|
||||
OtherworldlyJourneyDelayedTriggeredAbility delayedAbility = new OtherworldlyJourneyDelayedTriggeredAbility(source.getSourceId());
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
|
||||
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
|
||||
delayedAbility.addEffect(effect);
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
}
|
||||
ExileZone exile = game.getExile().getExileZone(source.getSourceId());
|
||||
// only if permanent is in exile (tokens would be stop to exist)
|
||||
if (exile != null && !exile.isEmpty()) {
|
||||
//create delayed triggered ability
|
||||
AtEndOfTurnDelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(
|
||||
new ReturnFromExileEffect(source.getSourceId(), Constants.Zone.BATTLEFIELD, "return that card to the battlefield under its owner's control with a +1/+1 counter on it"));
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
|
||||
effect.setTargetPointer(new FixedTarget(source.getFirstTarget()));
|
||||
delayedAbility.addEffect(effect);
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -114,28 +113,3 @@ class OtherworldlyJourneyEffect extends OneShotEffect<OtherworldlyJourneyEffect>
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class OtherworldlyJourneyDelayedTriggeredAbility extends DelayedTriggeredAbility<OtherworldlyJourneyDelayedTriggeredAbility> {
|
||||
|
||||
OtherworldlyJourneyDelayedTriggeredAbility ( UUID exileId ) {
|
||||
super(new ReturnFromExileEffect(exileId, Constants.Zone.BATTLEFIELD, "return that card to the battlefield under its owner's control with a +1/+1 counter on it"));
|
||||
}
|
||||
|
||||
OtherworldlyJourneyDelayedTriggeredAbility(OtherworldlyJourneyDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public OtherworldlyJourneyDelayedTriggeredAbility copy() {
|
||||
return new OtherworldlyJourneyDelayedTriggeredAbility(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -29,23 +29,21 @@
|
|||
package mage.sets.guildpact;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility;
|
||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ReturnFromExileEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
@ -132,7 +130,8 @@ class GhostCouncilOfOrzhovaRemovingEffect extends OneShotEffect<GhostCouncilOfOr
|
|||
if (permanent != null) {
|
||||
if (permanent.moveToExile(source.getSourceId(), " Ghost Council of Orzhova Exile", source.getId(), game)) {
|
||||
//create delayed triggered ability
|
||||
GhostCouncilOfOrzhovaDelayedTriggeredAbility delayedAbility = new GhostCouncilOfOrzhovaDelayedTriggeredAbility(source.getSourceId());
|
||||
AtEndOfTurnDelayedTriggeredAbility delayedAbility = new AtEndOfTurnDelayedTriggeredAbility(
|
||||
new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
|
@ -148,26 +147,3 @@ class GhostCouncilOfOrzhovaRemovingEffect extends OneShotEffect<GhostCouncilOfOr
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class GhostCouncilOfOrzhovaDelayedTriggeredAbility extends DelayedTriggeredAbility<GhostCouncilOfOrzhovaDelayedTriggeredAbility> {
|
||||
|
||||
GhostCouncilOfOrzhovaDelayedTriggeredAbility ( UUID exileId ) {
|
||||
super(new ReturnFromExileEffect(exileId, Zone.BATTLEFIELD));
|
||||
}
|
||||
|
||||
GhostCouncilOfOrzhovaDelayedTriggeredAbility(GhostCouncilOfOrzhovaDelayedTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == GameEvent.EventType.END_TURN_STEP_PRE) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public GhostCouncilOfOrzhovaDelayedTriggeredAbility copy() {
|
||||
return new GhostCouncilOfOrzhovaDelayedTriggeredAbility(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue