mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
make Morph cost reduction a separate class (and fix to work with new system)
This commit is contained in:
parent
3f82c36813
commit
e7927cb50f
8 changed files with 49 additions and 67 deletions
|
|
@ -1,13 +1,11 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect;
|
||||
import mage.abilities.effects.common.cost.MorphSpellsCostReductionControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.card.FaceDownCastablePredicate;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -15,18 +13,11 @@ import java.util.UUID;
|
|||
* @author North
|
||||
*/
|
||||
public final class DreamChisel extends CardImpl {
|
||||
|
||||
private static final FilterCreatureCard filter = new FilterCreatureCard("Face-down creature spells");
|
||||
|
||||
static {
|
||||
filter.add(FaceDownCastablePredicate.instance);
|
||||
}
|
||||
|
||||
public DreamChisel(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}");
|
||||
|
||||
// Face-down creature spells you cast cost {1} less to cast.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SpellsCostReductionControllerEffect(filter, 1)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MorphSpellsCostReductionControllerEffect(1)));
|
||||
}
|
||||
|
||||
private DreamChisel(final DreamChisel card) {
|
||||
|
|
@ -37,4 +28,4 @@ public final class DreamChisel extends CardImpl {
|
|||
public DreamChisel copy() {
|
||||
return new DreamChisel(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,6 @@ public final class GiftOfDoom extends CardImpl {
|
|||
TargetPermanent auraTarget = new TargetCreaturePermanent();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility));
|
||||
this.getSpellAbility().setTargetAdjuster(GiftOfDoomAdjuster.instance); // to remove the target set if Morph casting cost is paid
|
||||
Ability ability = new EnchantAbility(auraTarget);
|
||||
this.addAbility(ability);
|
||||
|
||||
|
|
@ -77,18 +76,6 @@ public final class GiftOfDoom extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
enum GiftOfDoomAdjuster implements TargetAdjuster {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public void adjustTargets(Ability ability, Game game) {
|
||||
// if the Morph casting cost is paid, clear the target of Enchant Creature
|
||||
if (game.getState().getValue("MorphAbility" + ability.getSourceId()) == "activated") {
|
||||
ability.getTargets().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GiftOfDoomEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import mage.MageInt;
|
|||
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||
import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect;
|
||||
import mage.abilities.effects.common.cost.MorphSpellsCostReductionControllerEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
|
|
@ -16,7 +16,6 @@ import mage.filter.FilterCard;
|
|||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.card.FaceDownCastablePredicate;
|
||||
import mage.filter.predicate.card.FaceDownPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -51,7 +50,7 @@ public final class KadenaSlinkingSorcerer extends CardImpl {
|
|||
|
||||
// The first face-down creature spell you cast each turn costs {3} less to cast.
|
||||
this.addAbility(new SimpleStaticAbility(
|
||||
new SpellsCostReductionControllerEffect(filterFirstFaceDownSpell, 3)
|
||||
new MorphSpellsCostReductionControllerEffect(filterFirstFaceDownSpell, 3)
|
||||
.setText("The first face-down creature spell you cast each turn costs {3} less to cast.")
|
||||
), new KadenaSlinkingSorcererWatcher());
|
||||
|
||||
|
|
@ -78,8 +77,7 @@ enum KadenaSlinkingSorcererPredicate implements Predicate<Card> {
|
|||
public boolean apply(Card input, Game game) {
|
||||
KadenaSlinkingSorcererWatcher watcher = game.getState().getWatcher(KadenaSlinkingSorcererWatcher.class);
|
||||
if (watcher != null) {
|
||||
return FaceDownCastablePredicate.instance.apply(input, game)
|
||||
&& !watcher.castFaceDownThisTurn(input.getOwnerId());
|
||||
return !watcher.castFaceDownThisTurn(input.getOwnerId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,13 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BecomesFaceDownCreatureEffect;
|
||||
import mage.abilities.effects.common.cost.SpellsCostReductionControllerEffect;
|
||||
import mage.abilities.effects.common.cost.MorphSpellsCostReductionControllerEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.filter.predicate.card.FaceDownCastablePredicate;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -21,17 +20,11 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class ObscuringAether extends CardImpl {
|
||||
|
||||
private static final FilterCreatureCard filter = new FilterCreatureCard("Face-down creature spells");
|
||||
|
||||
static {
|
||||
filter.add(FaceDownCastablePredicate.instance);
|
||||
}
|
||||
|
||||
public ObscuringAether(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}");
|
||||
|
||||
// Face-down creature spells you cast cost {1} less to cast.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SpellsCostReductionControllerEffect(filter, 1)));
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MorphSpellsCostReductionControllerEffect(1)));
|
||||
|
||||
// {1}{G}: Turn Obscuring Aether face down.
|
||||
Effect effect = new BecomesFaceDownCreatureEffect(Duration.Custom, BecomesFaceDownCreatureEffect.FaceDownType.MANUAL);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package mage.abilities.effects.common.cost;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.keyword.MorphAbility;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
|
||||
public class MorphSpellsCostReductionControllerEffect extends SpellsCostReductionControllerEffect{
|
||||
private static final FilterCreatureCard standardFilter = new FilterCreatureCard("Face-down creature spells");
|
||||
|
||||
public MorphSpellsCostReductionControllerEffect(int amount) {
|
||||
super(standardFilter, amount);
|
||||
}
|
||||
public MorphSpellsCostReductionControllerEffect(FilterCard filter, int amount) {
|
||||
super(filter, amount);
|
||||
}
|
||||
protected MorphSpellsCostReductionControllerEffect(final MorphSpellsCostReductionControllerEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
@Override
|
||||
public MorphSpellsCostReductionControllerEffect copy() {
|
||||
return new MorphSpellsCostReductionControllerEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||
if (abilityToModify instanceof MorphAbility) {
|
||||
return super.applies(abilityToModify, source, game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -46,11 +46,12 @@ public enum SpellAbilityCastMode {
|
|||
if (this.equals(BESTOW)) {
|
||||
BestowAbility.becomeAura(cardCopy);
|
||||
}
|
||||
if (this.isTransformed){
|
||||
if (this.isTransformed) {
|
||||
Card tmp = card.getSecondCardFace();
|
||||
if (tmp != null) {
|
||||
cardCopy = tmp.copy();
|
||||
}
|
||||
}
|
||||
if (this.equals(MORPH)) {
|
||||
MorphAbility.setObjectToFaceDownCreature(cardCopy, game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
package mage.filter.predicate.card;
|
||||
|
||||
import mage.abilities.keyword.MorphAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
public enum FaceDownCastablePredicate implements Predicate<Card> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Card input, Game game) {
|
||||
// is card able to cast as face down
|
||||
return input.getAbilities(game).containsClass(MorphAbility.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Face-down";
|
||||
}
|
||||
}
|
||||
|
|
@ -79,9 +79,6 @@ public class Spell extends StackObjectImpl implements Card {
|
|||
// simulate another side as new card (another code part in continues effect from disturb ability)
|
||||
affectedCard = TransformAbility.transformCardSpellStatic(card, card.getSecondCardFace(), game);
|
||||
}
|
||||
if (ability.getSpellAbilityCastMode() == SpellAbilityCastMode.MORPH){
|
||||
this.faceDown = true;
|
||||
}
|
||||
|
||||
this.card = affectedCard;
|
||||
this.color = affectedCard.getColor(null).copy();
|
||||
|
|
@ -93,6 +90,12 @@ public class Spell extends StackObjectImpl implements Card {
|
|||
this.zoneChangeCounter = affectedCard.getZoneChangeCounter(game); // sync card's ZCC with spell (copy spell settings)
|
||||
this.ability = ability;
|
||||
this.ability.setControllerId(controllerId);
|
||||
|
||||
if (ability.getSpellAbilityCastMode() == SpellAbilityCastMode.MORPH){
|
||||
this.faceDown = true;
|
||||
this.getColor(game).setColor(null);
|
||||
game.getState().getCreateMageObjectAttribute(this.getCard(), game).getSubtype().clear();
|
||||
}
|
||||
if (ability.getSpellAbilityType() == SpellAbilityType.SPLIT_FUSED) {
|
||||
// if this spell is going to be a copy, these abilities will be copied in copySpell
|
||||
if (!isCopy) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue