[40K] Implemented Ghost Ark

This commit is contained in:
Evan Kranzler 2022-10-03 22:58:25 -04:00
parent 68f655a284
commit 97d3a15ff1
2 changed files with 141 additions and 0 deletions

View file

@ -0,0 +1,140 @@
package mage.cards.g;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.CrewAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.UnearthAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterCard;
import mage.filter.common.FilterArtifactCard;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import java.util.UUID;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public final class GhostArk extends CardImpl {
public GhostArk(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
this.subtype.add(SubType.VEHICLE);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Repair Barge -- Whenever Ghost Ark becomes crewed, each artifact creature card in your graveyard gains unearth {3} until end of turn.
this.addAbility(new GhostArkTriggeredAbility());
// Crew 2
this.addAbility(new CrewAbility(2));
}
private GhostArk(final GhostArk card) {
super(card);
}
@Override
public GhostArk copy() {
return new GhostArk(this);
}
}
class GhostArkTriggeredAbility extends TriggeredAbilityImpl {
GhostArkTriggeredAbility() {
super(Zone.BATTLEFIELD, new GhostArkEffect());
setTriggerPhrase("Whenever {this} becomes crewed, ");
this.withFlavorWord("Repair Barge");
}
private GhostArkTriggeredAbility(final GhostArkTriggeredAbility ability) {
super(ability);
}
@Override
public GhostArkTriggeredAbility copy() {
return new GhostArkTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.VEHICLE_CREWED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
return event.getTargetId().equals(getSourceId());
}
}
class GhostArkEffect extends ContinuousEffectImpl {
private static final FilterCard filter = new FilterArtifactCard();
static {
filter.add(CardType.CREATURE.getPredicate());
}
GhostArkEffect() {
super(Duration.EndOfTurn, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
staticText = "each artifact creature card in your graveyard gains unearth {3} until end of turn";
}
private GhostArkEffect(final GhostArkEffect effect) {
super(effect);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return;
}
this.affectedObjectList.addAll(
player.getGraveyard()
.getCards(filter, game)
.stream().map(card -> new MageObjectReference(card, game))
.collect(Collectors.toSet())
);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
for (MageObjectReference mor : this.affectedObjectList) {
Card card = mor.getCard(game);
if (card == null) {
continue;
}
UnearthAbility ability = new UnearthAbility(new ManaCostsImpl<>("{3}"));
ability.setSourceId(card.getId());
ability.setControllerId(card.getOwnerId());
game.getState().addOtherAbility(card, ability);
}
return true;
}
@Override
public GhostArkEffect copy() {
return new GhostArkEffect(this);
}
}

View file

@ -108,6 +108,7 @@ public final class Warhammer40000 extends ExpansionSet {
cards.add(new SetCardInfo("Frontier Bivouac", 281, Rarity.UNCOMMON, mage.cards.f.FrontierBivouac.class)); cards.add(new SetCardInfo("Frontier Bivouac", 281, Rarity.UNCOMMON, mage.cards.f.FrontierBivouac.class));
cards.add(new SetCardInfo("Game Trail", 282, Rarity.RARE, mage.cards.g.GameTrail.class)); cards.add(new SetCardInfo("Game Trail", 282, Rarity.RARE, mage.cards.g.GameTrail.class));
cards.add(new SetCardInfo("Gargoyle Flock", 123, Rarity.RARE, mage.cards.g.GargoyleFlock.class)); cards.add(new SetCardInfo("Gargoyle Flock", 123, Rarity.RARE, mage.cards.g.GargoyleFlock.class));
cards.add(new SetCardInfo("Ghost Ark", 156, Rarity.RARE, mage.cards.g.GhostArk.class));
cards.add(new SetCardInfo("Gilded Lotus", 239, Rarity.RARE, mage.cards.g.GildedLotus.class)); cards.add(new SetCardInfo("Gilded Lotus", 239, Rarity.RARE, mage.cards.g.GildedLotus.class));
cards.add(new SetCardInfo("Go for the Throat", 201, Rarity.COMMON, mage.cards.g.GoForTheThroat.class)); cards.add(new SetCardInfo("Go for the Throat", 201, Rarity.COMMON, mage.cards.g.GoForTheThroat.class));
cards.add(new SetCardInfo("Goliath Truck", 158, Rarity.UNCOMMON, mage.cards.g.GoliathTruck.class)); cards.add(new SetCardInfo("Goliath Truck", 158, Rarity.UNCOMMON, mage.cards.g.GoliathTruck.class));