mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
[OTJ][BIG] Cleanup some card implementation
This commit is contained in:
parent
35a22527f1
commit
d591a89495
7 changed files with 50 additions and 68 deletions
|
|
@ -3,10 +3,10 @@ package mage.cards.a;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttachedToCreatureSourceTriggeredAbility;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
import mage.abilities.common.delayed.OnLeaveReturnExiledAbility;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CopyEffect;
|
||||
import mage.abilities.effects.common.ExileUntilSourceLeavesEffect;
|
||||
import mage.abilities.keyword.EquipAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
|
|
@ -37,7 +37,7 @@ public final class AssimilationAegis extends CardImpl {
|
|||
this.subtype.add(SubType.EQUIPMENT);
|
||||
|
||||
// When Assimilation Aegis enters the battlefield, exile up to one target creature until Assimilation Aegis leaves the battlefield.
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new AssimilationAegisETBEffect());
|
||||
Ability ability = new EntersBattlefieldTriggeredAbility(new ExileUntilSourceLeavesEffect());
|
||||
ability.addTarget(new TargetCreaturePermanent(0, 1));
|
||||
this.addAbility(ability);
|
||||
|
||||
|
|
@ -58,37 +58,6 @@ public final class AssimilationAegis extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class AssimilationAegisETBEffect extends OneShotEffect {
|
||||
|
||||
AssimilationAegisETBEffect() {
|
||||
super(Outcome.Exile);
|
||||
staticText = "exile up to one target creature until {this} leaves the battlefield.";
|
||||
}
|
||||
|
||||
private AssimilationAegisETBEffect(final AssimilationAegisETBEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AssimilationAegisETBEffect copy() {
|
||||
return new AssimilationAegisETBEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
|
||||
if (player == null || permanent == null || source.getSourcePermanentIfItStillExists(game) == null) {
|
||||
return false;
|
||||
}
|
||||
UUID exileId = CardUtil.getExileZoneId(game, source);
|
||||
String exileName = CardUtil.getSourceName(game, source);
|
||||
player.moveCardsToExile(permanent, source, game, true, exileId, exileName);
|
||||
game.addDelayedTriggeredAbility(new OnLeaveReturnExiledAbility(), source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Similar to Blade of Shared Souls.
|
||||
class AssimilationAegisEffect extends OneShotEffect {
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class LazavFamiliarStrangerEffect extends OneShotEffect {
|
|||
if (!flag) {
|
||||
return true;
|
||||
}
|
||||
Permanent lazav = game.getPermanent(source.getSourceId());
|
||||
Permanent lazav = source.getSourcePermanentIfItStillExists(game);
|
||||
if (lazav == null) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public final class LonghornSharpshooter extends CardImpl {
|
|||
this.addAbility(ReachAbility.getInstance());
|
||||
|
||||
// When Longhorn Sharpshooter becomes plotted, it deals 2 damage to any target.
|
||||
Ability ability = new BecomesPlottedSourceTriggeredAbility(new DamageTargetEffect(2, "it"));
|
||||
Ability ability = new BecomesPlottedSourceTriggeredAbility(new DamageTargetEffect(2));
|
||||
ability.addTarget(new TargetAnyTarget());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.condition.common.CastFromEverywhereSourceCondition;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.ExileTargetEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
|
@ -17,7 +17,6 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.game.ExileZone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
|
|
@ -39,7 +38,7 @@ public final class TerritoryForge extends CardImpl {
|
|||
|
||||
// When Territory Forge enters the battlefield, if you cast it, exile target artifact or land.
|
||||
Ability ability = new ConditionalInterveningIfTriggeredAbility(
|
||||
new EntersBattlefieldTriggeredAbility(new TerritoryForgeExileEffect()),
|
||||
new EntersBattlefieldTriggeredAbility(new ExileTargetEffect().setToSourceExileZone(true)),
|
||||
CastFromEverywhereSourceCondition.instance,
|
||||
"When {this} enters the battlefield, if you cast it, exile target artifact or land."
|
||||
);
|
||||
|
|
@ -60,34 +59,6 @@ public final class TerritoryForge extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
class TerritoryForgeExileEffect extends OneShotEffect {
|
||||
|
||||
TerritoryForgeExileEffect() {
|
||||
super(Outcome.Exile);
|
||||
}
|
||||
|
||||
private TerritoryForgeExileEffect(final TerritoryForgeExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerritoryForgeExileEffect copy() {
|
||||
return new TerritoryForgeExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
if (player == null || permanent == null) {
|
||||
return false;
|
||||
}
|
||||
UUID exileId = CardUtil.getExileZoneId(game, source);
|
||||
String exileName = CardUtil.getSourceName(game, source);
|
||||
return player.moveCardsToExile(permanent, source, game, true, exileId, exileName);
|
||||
}
|
||||
}
|
||||
|
||||
// Inspired by Dark Impostor
|
||||
class TerritoryForgeStaticEffect extends ContinuousEffectImpl {
|
||||
|
||||
|
|
@ -120,7 +91,7 @@ class TerritoryForgeStaticEffect extends ContinuousEffectImpl {
|
|||
for (Ability ability : card.getAbilities(game)) {
|
||||
if (ability.getAbilityType() == AbilityType.ACTIVATED || ability.getAbilityType() == AbilityType.MANA) {
|
||||
ActivatedAbility copyAbility = (ActivatedAbility) ability.copy();
|
||||
permanent.addAbility(copyAbility, source.getSourceId(), game);
|
||||
permanent.addAbility(copyAbility, source.getSourceId(), game, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package org.mage.test.cards.single.big;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* @author Susucr
|
||||
*/
|
||||
public class TerritoryForgeTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* {@link mage.cards.t.TerritoryForge Territory Forge} {4}{R}
|
||||
* Artifact
|
||||
* When Territory Forge enters the battlefield, if you cast it, exile target artifact or land.
|
||||
* Territory Forge has all activated abilities of the exiled card.
|
||||
*/
|
||||
private static final String forge = "Territory Forge";
|
||||
|
||||
@Test
|
||||
public void test_Simple() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Braidwood Cup"); // {T}: You gain 1 life.
|
||||
addCard(Zone.HAND, playerA, forge);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, forge);
|
||||
addTarget(playerA, "Braidwood Cup");
|
||||
|
||||
checkExileCount("After etb, Cup in exile", 1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Braidwood Cup", 1);
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "{T}");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20 + 1);
|
||||
assertTapped(forge, true);
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ public class AssimilationAegisTest extends CardTestPlayerBase {
|
|||
private static final String aegis = "Assimilation Aegis";
|
||||
|
||||
@Test
|
||||
public void TestEquipChainThenDisenchant() {
|
||||
public void test_Equip_Equip_Disenchant() {
|
||||
setStrictChooseMode(true);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Tundra", 9);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public class BecomesPlottedSourceTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public BecomesPlottedSourceTriggeredAbility(Effect effect, boolean optional) {
|
||||
super(Zone.EXILED, effect, optional);
|
||||
setTriggerPhrase("When {this} becomes plotted, ");
|
||||
replaceRuleText = true;
|
||||
}
|
||||
|
||||
public BecomesPlottedSourceTriggeredAbility(Effect effect) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue