mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
refactor a transformer
This commit is contained in:
parent
8158751813
commit
739a0cd846
2 changed files with 84 additions and 65 deletions
|
|
@ -1,55 +1,77 @@
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
import mage.abilities.common.CastSecondSpellTriggeredAbility;
|
import mage.abilities.common.CastSecondSpellTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.effects.common.CantBeCounteredControlledEffect;
|
||||||
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
import mage.abilities.effects.common.PreventAllDamageToAllEffect;
|
import mage.abilities.effects.common.PreventAllDamageToAllEffect;
|
||||||
import mage.abilities.effects.common.TransformSourceEffect;
|
import mage.abilities.effects.common.TransformSourceEffect;
|
||||||
|
import mage.abilities.keyword.LivingMetalAbility;
|
||||||
import mage.abilities.keyword.MoreThanMeetsTheEyeAbility;
|
import mage.abilities.keyword.MoreThanMeetsTheEyeAbility;
|
||||||
import mage.cards.CardImpl;
|
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.cards.TransformingDoubleFacedCard;
|
||||||
import mage.constants.Duration;
|
import mage.constants.*;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.SuperType;
|
|
||||||
import mage.filter.FilterPermanent;
|
import mage.filter.FilterPermanent;
|
||||||
|
import mage.filter.FilterSpell;
|
||||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.predicate.permanent.AttackingPredicate;
|
import mage.filter.predicate.permanent.AttackingPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author TheElk801
|
* @author TheElk801
|
||||||
*/
|
*/
|
||||||
public final class GoldbugHumanitysAlly extends CardImpl {
|
public final class GoldbugHumanitysAlly extends TransformingDoubleFacedCard {
|
||||||
|
|
||||||
private static final FilterPermanent filter
|
private static final FilterPermanent filter
|
||||||
= new FilterControlledCreaturePermanent(SubType.HUMAN, "attacking Humans you control");
|
= new FilterControlledCreaturePermanent(SubType.HUMAN, "attacking Humans you control");
|
||||||
|
private static final FilterSpell filter2 = new FilterSpell("Human spells");
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(AttackingPredicate.instance);
|
filter.add(AttackingPredicate.instance);
|
||||||
|
filter2.add(SubType.HUMAN.getPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoldbugHumanitysAlly(UUID ownerId, CardSetInfo setInfo) {
|
public GoldbugHumanitysAlly(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}{W}{U}");
|
super(
|
||||||
|
ownerId, setInfo,
|
||||||
this.supertype.add(SuperType.LEGENDARY);
|
new SuperType[]{SuperType.LEGENDARY}, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, new SubType[]{SubType.ROBOT}, "{1}{W}{U}",
|
||||||
this.subtype.add(SubType.ROBOT);
|
"Goldbug, Scrappy Scout",
|
||||||
this.power = new MageInt(3);
|
new SuperType[]{SuperType.LEGENDARY}, new CardType[]{CardType.ARTIFACT}, new SubType[]{SubType.VEHICLE}, "UW"
|
||||||
this.toughness = new MageInt(3);
|
);
|
||||||
|
this.getLeftHalfCard().setPT(3, 3);
|
||||||
|
this.getRightHalfCard().setPT(1, 3);
|
||||||
|
|
||||||
this.secondSideCardClazz = mage.cards.g.GoldbugScrappyScout.class;
|
this.secondSideCardClazz = mage.cards.g.GoldbugScrappyScout.class;
|
||||||
|
|
||||||
// More Than Meets the Eye {W}{U}
|
// More Than Meets the Eye {W}{U}
|
||||||
this.addAbility(new MoreThanMeetsTheEyeAbility(this, "{W}{U}"));
|
this.getLeftHalfCard().addAbility(new MoreThanMeetsTheEyeAbility(this, "{W}{U}"));
|
||||||
|
|
||||||
// Prevent all combat damage that would be dealt to attacking Humans you control.
|
// Prevent all combat damage that would be dealt to attacking Humans you control.
|
||||||
this.addAbility(new SimpleStaticAbility(new PreventAllDamageToAllEffect(
|
this.getLeftHalfCard().addAbility(new SimpleStaticAbility(new PreventAllDamageToAllEffect(
|
||||||
Duration.WhileOnBattlefield, filter, true
|
Duration.WhileOnBattlefield, filter, true
|
||||||
)));
|
)));
|
||||||
|
|
||||||
// Whenever you cast your second spell each turn, convert Goldbug.
|
// Whenever you cast your second spell each turn, convert Goldbug.
|
||||||
this.addAbility(new CastSecondSpellTriggeredAbility(new TransformSourceEffect().setText("convert {this}")));
|
this.getLeftHalfCard().addAbility(new CastSecondSpellTriggeredAbility(new TransformSourceEffect().setText("convert {this}")));
|
||||||
|
|
||||||
|
// Goldbug, Scrappy Scout
|
||||||
|
// Living metal
|
||||||
|
this.getRightHalfCard().addAbility(new LivingMetalAbility());
|
||||||
|
|
||||||
|
// Human spells you control can't be countered.
|
||||||
|
this.getRightHalfCard().addAbility(new SimpleStaticAbility(
|
||||||
|
new CantBeCounteredControlledEffect(filter2, Duration.WhileOnBattlefield)
|
||||||
|
));
|
||||||
|
|
||||||
|
// Whenever Goldbug and at least one Human attack, draw a card and convert Goldbug.
|
||||||
|
this.getRightHalfCard().addAbility(new GoldbugScrappyScoutTriggeredAbility());
|
||||||
|
|
||||||
|
this.finalizeDFC();
|
||||||
}
|
}
|
||||||
|
|
||||||
private GoldbugHumanitysAlly(final GoldbugHumanitysAlly card) {
|
private GoldbugHumanitysAlly(final GoldbugHumanitysAlly card) {
|
||||||
|
|
@ -61,3 +83,45 @@ public final class GoldbugHumanitysAlly extends CardImpl {
|
||||||
return new GoldbugHumanitysAlly(this);
|
return new GoldbugHumanitysAlly(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GoldbugScrappyScoutTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
|
GoldbugScrappyScoutTriggeredAbility() {
|
||||||
|
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
|
||||||
|
this.addEffect(new TransformSourceEffect());
|
||||||
|
}
|
||||||
|
|
||||||
|
private GoldbugScrappyScoutTriggeredAbility(final GoldbugScrappyScoutTriggeredAbility ability) {
|
||||||
|
super(ability);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GoldbugScrappyScoutTriggeredAbility copy() {
|
||||||
|
return new GoldbugScrappyScoutTriggeredAbility(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
|
return game
|
||||||
|
.getCombat()
|
||||||
|
.getAttackers()
|
||||||
|
.contains(getSourceId())
|
||||||
|
&& game
|
||||||
|
.getCombat()
|
||||||
|
.getAttackers()
|
||||||
|
.stream()
|
||||||
|
.map(game::getPermanent)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.anyMatch(permanent -> permanent.hasSubtype(SubType.HUMAN, game));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRule() {
|
||||||
|
return "Whenever {this} and at least one Human attack, draw a card and convert {this}.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,17 @@
|
||||||
package mage.cards.g;
|
package mage.cards.g;
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.effects.common.CantBeCounteredControlledEffect;
|
import mage.abilities.effects.common.CantBeCounteredControlledEffect;
|
||||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
|
||||||
import mage.abilities.effects.common.TransformSourceEffect;
|
|
||||||
import mage.abilities.keyword.LivingMetalAbility;
|
import mage.abilities.keyword.LivingMetalAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.constants.SuperType;
|
||||||
import mage.filter.FilterSpell;
|
import mage.filter.FilterSpell;
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.events.GameEvent;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -60,45 +57,3 @@ public final class GoldbugScrappyScout extends CardImpl {
|
||||||
return new GoldbugScrappyScout(this);
|
return new GoldbugScrappyScout(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class GoldbugScrappyScoutTriggeredAbility extends TriggeredAbilityImpl {
|
|
||||||
|
|
||||||
GoldbugScrappyScoutTriggeredAbility() {
|
|
||||||
super(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1));
|
|
||||||
this.addEffect(new TransformSourceEffect());
|
|
||||||
}
|
|
||||||
|
|
||||||
private GoldbugScrappyScoutTriggeredAbility(final GoldbugScrappyScoutTriggeredAbility ability) {
|
|
||||||
super(ability);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GoldbugScrappyScoutTriggeredAbility copy() {
|
|
||||||
return new GoldbugScrappyScoutTriggeredAbility(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkEventType(GameEvent event, Game game) {
|
|
||||||
return event.getType() == GameEvent.EventType.DECLARED_ATTACKERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
|
||||||
return game
|
|
||||||
.getCombat()
|
|
||||||
.getAttackers()
|
|
||||||
.contains(getSourceId())
|
|
||||||
&& game
|
|
||||||
.getCombat()
|
|
||||||
.getAttackers()
|
|
||||||
.stream()
|
|
||||||
.map(game::getPermanent)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.anyMatch(permanent -> permanent.hasSubtype(SubType.HUMAN, game));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRule() {
|
|
||||||
return "Whenever {this} and at least one Human attack, draw a card and convert {this}.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue