[LEG] Reimplement Stangg based on Mechtitan Core

This commit is contained in:
Alex W. Jackson 2022-10-19 18:19:35 -04:00
parent 6008e77d72
commit 191ba5f3e9
2 changed files with 84 additions and 68 deletions

View file

@ -30,7 +30,6 @@ import mage.target.targetpointer.FixedTargets;
import mage.util.CardUtil; import mage.util.CardUtil;
import java.util.HashSet; import java.util.HashSet;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;

View file

@ -1,54 +1,41 @@
package mage.cards.s; package mage.cards.s;
import java.util.ArrayList; import java.util.HashSet;
import java.util.List; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.LeavesBattlefieldTriggeredAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.InfoEffect; import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.CreateTokenEffect; import mage.abilities.effects.common.SacrificeSourceEffect;
import mage.abilities.effects.common.SacrificeTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.token.StanggTwinToken; import mage.game.permanent.token.StanggTwinToken;
import mage.players.Player; import mage.game.permanent.token.Token;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTargets;
/** /**
* *
* @author jeffwadsworth & L_J * @author awjackson
*/ */
public final class Stangg extends CardImpl { public final class Stangg extends CardImpl {
public Stangg(UUID ownerId, CardSetInfo setInfo) { public Stangg(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{G}");
addSuperType(SuperType.LEGENDARY); addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.HUMAN, SubType.WARRIOR);
this.subtype.add(SubType.WARRIOR);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// When Stangg enters the battlefield, create a legendary 3/4 red and green Human Warrior creature token named Stangg Twin. // When Stangg enters the battlefield, create Stangg Twin, a legendary 3/4 red and green Human Warrior creature token.
this.addAbility(new EntersBattlefieldTriggeredAbility(new StanggCreateTokenEffect(), false)); // Exile that token when Stangg leaves the battlefield. Sacrifice Stangg when that token leaves the battlefield.
this.addAbility(new EntersBattlefieldTriggeredAbility(new StanggCreateTokenEffect()));
// When Stangg leaves the battlefield, exile that token.
// When that token leaves the battlefield, sacrifice Stangg.
Ability ability = new LeavesBattlefieldTriggeredAbility(new StanggExileTokenEffect(), false);
ability.addEffect(new InfoEffect("When that token leaves the battlefield, sacrifice {this}"));
this.addAbility(ability);
} }
private Stangg(final Stangg card) { private Stangg(final Stangg card) {
@ -65,7 +52,9 @@ class StanggCreateTokenEffect extends OneShotEffect {
public StanggCreateTokenEffect() { public StanggCreateTokenEffect() {
super(Outcome.PutCreatureInPlay); super(Outcome.PutCreatureInPlay);
staticText = "create Stangg Twin, a legendary 3/4 red and green Human Warrior creature token"; staticText = "create Stangg Twin, a legendary 3/4 red and green Human Warrior creature token. "
+ "Exile that token when {this} leaves the battlefield. "
+ "Sacrifice {this} when that token leaves the battlefield";
} }
public StanggCreateTokenEffect(final StanggCreateTokenEffect effect) { public StanggCreateTokenEffect(final StanggCreateTokenEffect effect) {
@ -74,23 +63,12 @@ class StanggCreateTokenEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); Token token = new StanggTwinToken();
if (sourceObject != null) { token.putOntoBattlefield(1, game, source);
CreateTokenEffect effect = new CreateTokenEffect(new StanggTwinToken()); game.addDelayedTriggeredAbility(new StanggLeavesTriggeredAbility(token, game), source);
effect.apply(game, source); game.addDelayedTriggeredAbility(new StanggTwinLeavesTriggeredAbility(token), source);
game.getState().setValue(source.getSourceId() + "_token", effect.getLastAddedTokenIds());
for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
Effect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + sourceObject.getName());
sacrificeEffect.setTargetPointer(new FixedTarget(sourceObject, game));
LeavesBattlefieldTriggeredAbility triggerAbility = new LeavesBattlefieldTriggeredAbility(sacrificeEffect, false);
ContinuousEffect continuousEffect = new GainAbilityTargetEffect(triggerAbility, Duration.WhileOnBattlefield);
continuousEffect.setTargetPointer(new FixedTarget(addedTokenId, game));
game.addEffect(continuousEffect, source);
}
return true; return true;
} }
return false;
}
@Override @Override
public StanggCreateTokenEffect copy() { public StanggCreateTokenEffect copy() {
@ -98,39 +76,78 @@ class StanggCreateTokenEffect extends OneShotEffect {
} }
} }
class StanggExileTokenEffect extends OneShotEffect { class StanggLeavesTriggeredAbility extends DelayedTriggeredAbility {
public StanggExileTokenEffect() { StanggLeavesTriggeredAbility(Token token, Game game) {
super(Outcome.Removal); super(new ExileTargetEffect());
staticText = "exile that token"; this.getEffects().setTargetPointer(new FixedTargets(token, game));
} }
public StanggExileTokenEffect(final StanggExileTokenEffect effect) { private StanggLeavesTriggeredAbility(final StanggLeavesTriggeredAbility ability) {
super(effect); super(ability);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public StanggLeavesTriggeredAbility copy() {
Player controller = game.getPlayer(source.getControllerId()); return new StanggLeavesTriggeredAbility(this);
if (controller != null) {
List<UUID> tokenIds = (ArrayList<UUID>) game.getState().getValue(source.getSourceId() + "_token");
if (tokenIds != null) {
Cards cards = new CardsImpl();
for (UUID tokenId : tokenIds) {
Permanent tokenPermanent = game.getPermanent(tokenId);
if (tokenPermanent != null) {
cards.add(tokenPermanent);
} }
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
} }
controller.moveCards(cards, Zone.EXILED, source, game);
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getTargetId().equals(getSourceId()) && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD;
}
@Override
public String getRule() {
return "Exile that token when {this} leaves the battlefield.";
}
}
class StanggTwinLeavesTriggeredAbility extends DelayedTriggeredAbility {
private final Set<UUID> tokenIds = new HashSet<>();
StanggTwinLeavesTriggeredAbility(Token token) {
super(new SacrificeSourceEffect(), Duration.Custom, false);
tokenIds.addAll(token.getLastAddedTokenIds());
}
private StanggTwinLeavesTriggeredAbility(final StanggTwinLeavesTriggeredAbility ability) {
super(ability);
this.tokenIds.addAll(ability.tokenIds);
}
@Override
public StanggTwinLeavesTriggeredAbility copy() {
return new StanggTwinLeavesTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (tokenIds.contains(event.getTargetId()) && ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) {
tokenIds.remove(event.getTargetId());
return true; return true;
} }
}
return false; return false;
} }
@Override @Override
public StanggExileTokenEffect copy() { public boolean isInactive(Game game) {
return new StanggExileTokenEffect(this); return tokenIds.isEmpty();
}
@Override
public String getRule() {
return "Sacrifice {this} when that token leaves the battlefield.";
} }
} }