so, I've got the card partially implemented. You aren't able to cast him from the hand, and he is castable from the graveyard.
I've not been able to make it so Knight cards are castable from the graveyard.
I've also noticed a weird bug that seems to stem from Haakon, that I haven't been able to lock down. If the host of the lobby has more than one card with dredge in the graveyard, and the opponent has Haakon in play, the replacement effect selection dialog rapidly closes and opens.
I've attached the java file as txt and pasted the code below, if anyone wouldn't mind taking a look.
- Code: Select all
package mage.sets.coldsnap;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.common.DiesTriggeredAbility;
import mage.constants.Layer;
import mage.constants.SubLayer;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.AsThoughEffectType;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.players.Player;
/**
*
* @author Mainiack11
*/
public class HaakonStromgaldScourge extends CardImpl {
public HaakonStromgaldScourge(UUID ownerId) {
super(ownerId, 61, "Haakon, Stromgald Scourge", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{1}{B}{B}");
this.expansionSetCode = "CSP";
this.supertype.add("Legendary");
this.subtype.add("Zombie");
this.subtype.add("Knight");
this.color.setBlack(true);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
this.addAbility(new SimpleStaticAbility(Zone.GRAVEYARD, new HaakonStromgaldScourgePlayEffect()));
this.addAbility(new SimpleStaticAbility(Zone.ALL, new HaakonStromgaldScourgePlayEffect2()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect()));
this.addAbility(new DiesTriggeredAbility(new LoseLifeSourceControllerEffect(2)));
}
public HaakonStromgaldScourge(final HaakonStromgaldScourge card) {
super(card);
}
@Override
public HaakonStromgaldScourge copy() {
return new HaakonStromgaldScourge(this);
}
}
class HaakonStromgaldScourgePlayEffect extends AsThoughEffectImpl {
public HaakonStromgaldScourgePlayEffect() {
super(AsThoughEffectType.PLAY_FROM_NON_HAND_ZONE, Duration.EndOfGame, Outcome.Benefit);
staticText = "You may cast Haakon, Stromgald Scourge from your graveyard, but not from anywhere else.";
}
public HaakonStromgaldScourgePlayEffect(final HaakonStromgaldScourgePlayEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public HaakonStromgaldScourgePlayEffect copy() {
return new HaakonStromgaldScourgePlayEffect(this);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(source.getSourceId())) {
Card card = game.getCard(source.getSourceId());
if (card != null && card.getOwnerId().equals(source.getControllerId()) && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
return true;
}
}
return false;
}
}
class HaakonStromgaldScourgePlayEffect2 extends ContinuousRuleModifiyingEffectImpl {
public HaakonStromgaldScourgePlayEffect2() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "You may cast Haakon, Stromgald Scourge from your graveyard, but not from anywhere else.";
}
public HaakonStromgaldScourgePlayEffect2 (final HaakonStromgaldScourgePlayEffect2 effect) {
super(effect);
}
@Override
public HaakonStromgaldScourgePlayEffect2 copy() {
return new HaakonStromgaldScourgePlayEffect2(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if(event.getType() == GameEvent.EventType.CAST_SPELL) {
Card card = game.getCard(event.getSourceId());
if (card != null && card.getName().equals("Haakon, Stromgald Scourge")) {
Zone zone = game.getState().getZone(card.getId());
if (zone != null && (zone != Zone.GRAVEYARD)) {
return true;
}
}
}
return false;
}
}
class HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect extends ContinuousEffectImpl {
public HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect() {
super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility);
this.staticText = "As long as Haakon, Stromgald Scourge is on the battlefield, you may play Knight cards from your graveyard.";
}
public HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect(final HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect effect) {
super(effect);
}
@Override
public HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect copy() {
return new HaakonStromgaldScourgeCanPlayKnightsFromGraveyardEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
for (UUID cardId: player.getGraveyard()) {
Card card = game.getCard(cardId);
if(card != null && card.getSubtype().contains("Knight")) {
SimpleStaticAbility ability = new SimpleStaticAbility(Zone.GRAVEYARD, new PlayKnightsFromGraveyardAbility());
ability.setSourceId(cardId);
ability.setControllerId(card.getOwnerId());
game.getState().addOtherAbility(cardId, ability);
}
}
return true;
}
return false;
}
}
class PlayKnightsFromGraveyardAbility extends AsThoughEffectImpl {
public PlayKnightsFromGraveyardAbility () {
super(AsThoughEffectType.PLAY_FROM_NON_HAND_ZONE, Duration.WhileInGraveyard, Outcome.Benefit);
staticText = "As long as Haakon is on the battlefield, you may play Knight cards from your graveyard.";
}
public PlayKnightsFromGraveyardAbility(final PlayKnightsFromGraveyardAbility effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public PlayKnightsFromGraveyardAbility copy() {
return new PlayKnightsFromGraveyardAbility(this);
}
@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
if (sourceId.equals(source.getSourceId())) {
Card card = game.getCard(source.getSourceId());
if (card != null && card.getOwnerId().equals(source.getControllerId()) && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
return true;
}
}
return false;
}
}