forked from External/mage
Fix Enduring Tenacity. Closes #12594
This commit is contained in:
parent
90176aca52
commit
4e5501f8b7
1 changed files with 15 additions and 10 deletions
|
|
@ -6,8 +6,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.common.DiesSourceTriggeredAbility;
|
||||
import mage.abilities.common.GainLifeControllerTriggeredAbility;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.condition.common.SourceMatchesFilterCondition;
|
||||
import mage.abilities.decorator.ConditionalTriggeredAbility;
|
||||
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.common.SavedGainedLifeValue;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -16,7 +15,6 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -30,8 +28,6 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class EnduringTenacity extends CardImpl {
|
||||
|
||||
private static final Condition condition = new SourceMatchesFilterCondition(StaticFilters.FILTER_PERMANENT_CREATURE);
|
||||
|
||||
public EnduringTenacity(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{2}{B}{B}");
|
||||
|
||||
|
|
@ -46,10 +42,10 @@ public final class EnduringTenacity extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// When Enduring Tenacity dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment.
|
||||
this.addAbility(new ConditionalTriggeredAbility(
|
||||
this.addAbility(new ConditionalInterveningIfTriggeredAbility(
|
||||
new DiesSourceTriggeredAbility(new EnduringTenacityReturnEffect()),
|
||||
condition, "When {this} dies, if it was a creature, " +
|
||||
"return it to the battlefield under its owner's control. It's an enchantment."
|
||||
EnduringTenacityCondition.instance,
|
||||
"When {this} dies, if it was a creature, return it to the battlefield under its owner's control. It's an enchantment"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +59,16 @@ public final class EnduringTenacity extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
enum EnduringTenacityCondition implements Condition {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = (Permanent) source.getEffects().get(0).getValue("permanentLeftBattlefield");
|
||||
return permanent != null && permanent.isCreature(game);
|
||||
}
|
||||
}
|
||||
|
||||
class EnduringTenacityReturnEffect extends OneShotEffect {
|
||||
|
||||
EnduringTenacityReturnEffect() {
|
||||
|
|
@ -82,8 +88,7 @@ class EnduringTenacityReturnEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card card = game.getCard(source.getSourceId());
|
||||
if (player == null || card == null
|
||||
|| card.getZoneChangeCounter(game) != source.getSourceObjectZoneChangeCounter() + 1) {
|
||||
if (player == null || card == null) {
|
||||
return false;
|
||||
}
|
||||
game.addEffect(new EnduringTenacityTypeEffect()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue