[EMN] Implemented basic Meld functionality.

This commit is contained in:
emerald000 2016-07-11 04:49:40 -04:00
parent cb91282f9e
commit e1b3428a39
14 changed files with 1053 additions and 136 deletions

View file

@ -40,12 +40,15 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.MeldCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
import mage.game.permanent.PermanentMeld;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTargets;
@ -105,7 +108,18 @@ class EerieInterludeEffect extends OneShotEffect {
Cards cardsToReturn = new CardsImpl();
for (Card exiled : toExile) {
if (((Permanent) exiled).getZoneChangeCounter(game) == game.getState().getZoneChangeCounter(exiled.getId()) - 1) {
if (exiled instanceof PermanentMeld) {
MeldCard meldCard = (MeldCard) ((PermanentCard) exiled).getCard();
Card topCard = meldCard.getTopHalfCard();
Card bottomCard = meldCard.getBottomHalfCard();
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter()) {
cardsToReturn.add(topCard);
}
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter()) {
cardsToReturn.add(bottomCard);
}
}
else if (exiled.getZoneChangeCounter(game) == game.getState().getZoneChangeCounter(exiled.getId()) - 1) {
cardsToReturn.add(exiled);
}
}

View file

@ -36,7 +36,7 @@ import mage.abilities.effects.common.continuous.BoostControlledEffect;
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.MenaceAbility;
import mage.cards.CardImpl;
import mage.cards.MeldCard;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
@ -46,7 +46,7 @@ import mage.filter.common.FilterControlledCreaturePermanent;
*
* @author LevelX2
*/
public class ChitteringHost extends CardImpl {
public class ChitteringHost extends MeldCard {
public ChitteringHost(UUID ownerId) {
super(ownerId, 96, "Chittering Host", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "");
@ -57,10 +57,13 @@ public class ChitteringHost extends CardImpl {
this.toughness = new MageInt(6);
this.nightCard = true; // Meld card
// Haste
this.addAbility(HasteAbility.getInstance());
// Menace <i>(This creature can't be blocked except by two or more creatures.
this.addAbility(new MenaceAbility());
// When Chittering Host enters the battlefield, other creatures you control get +1/+0 and gain menace until end of turn.
Effect effect = new BoostControlledEffect(1, 0, Duration.EndOfTurn, true);
effect.setText("other creatures you control get +1/+0");
@ -68,7 +71,6 @@ public class ChitteringHost extends CardImpl {
effect = new GainAbilityAllEffect(new MenaceAbility(), Duration.EndOfTurn, new FilterControlledCreaturePermanent("other creatures"), true);
effect.setText("and gain menace until end of turn");
this.addAbility(ability);
}
public ChitteringHost(final ChitteringHost card) {

View file

@ -29,16 +29,18 @@ package mage.sets.eldritchmoon;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
import mage.abilities.condition.common.MeldCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.common.MeldEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.constants.TargetController;
/**
*
* @author LevelX2
* @author emerald000
*/
public class GrafRats extends CardImpl {
@ -50,7 +52,10 @@ public class GrafRats extends CardImpl {
this.toughness = new MageInt(1);
// At the beginning of combat on your turn, if you both own and control Graf Rats and a creature named Midnight Scavengers, exile them, then meld them into Chittering Host.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new InfoEffect("Meld ability not implemeted yet.")));
this.addAbility(new ConditionalTriggeredAbility(
new BeginningOfCombatTriggeredAbility(new MeldEffect("Midnight Scavengers", new ChitteringHost(ownerId)), TargetController.YOU, false),
new MeldCondition("Midnight Scavengers"),
"At the beginning of combat on your turn, if you both own and control {this} and a creature named Midnight Scavengers, exile them, then meld them into Chittering Host."));
}
public GrafRats(final GrafRats card) {

View file

@ -36,6 +36,7 @@ import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.MeldCard;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -93,7 +94,7 @@ class LongRoadHomeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
if (permanent.moveToExile(source.getSourceId(), "Otherworldly Journey", source.getSourceId(), game)) {
if (permanent.moveToExile(source.getSourceId(), "Long Road Home", source.getSourceId(), game)) {
ExileZone exile = game.getExile().getExileZone(source.getSourceId());
// only if permanent is in exile (tokens would be stop to exist)
if (exile != null && !exile.isEmpty()) {
@ -147,7 +148,14 @@ class LongRoadHomeReturnFromExileEffect extends OneShotEffect {
if (card != null && objectToReturn.refersTo(card, game)) {
Player owner = game.getPlayer(card.getOwnerId());
if (owner != null) {
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source);
if (card instanceof MeldCard) {
MeldCard meldCard = (MeldCard) card;
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getTopHalfCard(), game)), source);
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(new MageObjectReference(meldCard.getBottomHalfCard(), game)), source);
}
else {
game.addEffect(new LongRoadHomeEntersBattlefieldEffect(objectToReturn), source);
}
owner.moveCards(card, Zone.BATTLEFIELD, source, game, false, false, true, null);
}
}

View file

@ -30,17 +30,23 @@ package mage.sets.shadowsoverinnistrad;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetForSourceEffect;
import mage.abilities.effects.common.ReturnToBattlefieldUnderOwnerControlTargetEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.MeldCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.game.ExileZone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
@ -60,7 +66,7 @@ public class EssenceFlux extends CardImpl {
Effect effect = new ExileTargetForSourceEffect();
effect.setApplyEffectsAfter();
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(new EssenceFluxEffect(false, true));
this.getSpellAbility().addEffect(new EssenceFluxEffect());
}
public EssenceFlux(final EssenceFlux card) {
@ -73,14 +79,14 @@ public class EssenceFlux extends CardImpl {
}
}
class EssenceFluxEffect extends ReturnToBattlefieldUnderOwnerControlTargetEffect {
class EssenceFluxEffect extends OneShotEffect {
public EssenceFluxEffect(boolean tapped, boolean fromExileZone) {
super(tapped, fromExileZone);
staticText = ", then return that card to the battlefield under its owner's control. If it's a Spirit, put a +1/+1 counter on it";
EssenceFluxEffect() {
super(Outcome.Benefit);
staticText = "return that card to the battlefield under its owner's control";
}
public EssenceFluxEffect(final EssenceFluxEffect effect) {
EssenceFluxEffect(final EssenceFluxEffect effect) {
super(effect);
}
@ -91,22 +97,43 @@ class EssenceFluxEffect extends ReturnToBattlefieldUnderOwnerControlTargetEffect
@Override
public boolean apply(Game game, Ability source) {
Card card = null;
UUID exilZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exilZoneId != null) {
ExileZone exileZone = game.getExile().getExileZone(exilZoneId);
if (exileZone != null && getTargetPointer().getFirst(game, source) != null) {
card = exileZone.get(getTargetPointer().getFirst(game, source), game);
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cardsToBattlefield = new CardsImpl();
UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
if (exileZoneId != null) {
ExileZone exileZone = game.getExile().getExileZone(exileZoneId);
if (exileZone != null) {
for (UUID targetId : this.getTargetPointer().getTargets(game, source)) {
if (exileZone.contains(targetId)) {
cardsToBattlefield.add(targetId);
}
else {
Card card = game.getCard(targetId);
if (card != null && card instanceof MeldCard) {
MeldCard meldCard = (MeldCard) card;
Card topCard = meldCard.getTopHalfCard();
Card bottomCard = meldCard.getBottomHalfCard();
if (topCard.getZoneChangeCounter(game) == meldCard.getTopLastZoneChangeCounter() && exileZone.contains(topCard.getId())) {
cardsToBattlefield.add(topCard);
}
if (bottomCard.getZoneChangeCounter(game) == meldCard.getBottomLastZoneChangeCounter() && exileZone.contains(bottomCard.getId())) {
cardsToBattlefield.add(bottomCard);
}
}
}
}
}
}
}
if (super.apply(game, source)) {
if (card != null) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null && permanent.getSubtype().contains("Spirit")) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
return effect.apply(game, source);
if (!cardsToBattlefield.isEmpty()) {
controller.moveCards(cardsToBattlefield.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
for (UUID cardId : cardsToBattlefield) {
Permanent permanent = game.getPermanent(cardId);
if (permanent != null && permanent.getSubtype().contains("Spirit")) {
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance());
effect.setTargetPointer(new FixedTarget(permanent, game));
return effect.apply(game, source);
}
}
}
return true;