mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
* Fixed handling of enlarged view for manifested and morphed cards.
This commit is contained in:
parent
ba8290a0c0
commit
001e17a73e
17 changed files with 196 additions and 102 deletions
|
|
@ -36,9 +36,6 @@ public class DevotionCount implements DynamicValue {
|
|||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
int devotion = 0;
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(sourceAbility.getControllerId())) {
|
||||
if (permanent.isFaceDown()) {
|
||||
continue; // workaround as long as Morph creatures are not cast as separate objects, face down creature does not have a mana cost
|
||||
}
|
||||
for(ManaCost manaCost :permanent.getManaCost()) {
|
||||
for(ColoredManaSymbol coloredManaSymbol: devotionColors) {
|
||||
if (manaCost.containsColor(coloredManaSymbol)) {
|
||||
|
|
|
|||
|
|
@ -59,33 +59,40 @@ import mage.game.permanent.Permanent;
|
|||
|
||||
public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implements SourceEffect {
|
||||
|
||||
public enum FaceDownType {
|
||||
MORPHED,
|
||||
MANIFESTED
|
||||
}
|
||||
|
||||
protected int zoneChangeCounter;
|
||||
protected Ability turnFaceUpAbility = null;
|
||||
protected boolean useTargetPointer;
|
||||
protected boolean foundPermanent;
|
||||
protected FaceDownType faceDownType;
|
||||
|
||||
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> morphCosts) {
|
||||
this(morphCosts, false);
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> turnFaceUpCosts, FaceDownType faceDownType){
|
||||
this(turnFaceUpCosts, false, faceDownType);
|
||||
}
|
||||
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> morphCosts, boolean useTargetPointer) {
|
||||
this(morphCosts, useTargetPointer, Duration.WhileOnBattlefield);
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> turnFaceUpCosts, boolean useTargetPointer, FaceDownType faceDownType) {
|
||||
this(turnFaceUpCosts, useTargetPointer, Duration.WhileOnBattlefield, faceDownType);
|
||||
}
|
||||
|
||||
public BecomesFaceDownCreatureEffect(Cost cost, boolean useTargetPointer, Duration duration) {
|
||||
this(createCosts(cost), useTargetPointer, duration);
|
||||
public BecomesFaceDownCreatureEffect(Cost cost, boolean useTargetPointer, Duration duration, FaceDownType faceDownType) {
|
||||
this(createCosts(cost), useTargetPointer, duration, faceDownType);
|
||||
}
|
||||
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> morphCosts, boolean useTargetPointer, Duration duration) {
|
||||
public BecomesFaceDownCreatureEffect(Costs<Cost> turnFaceUpCosts, boolean useTargetPointer, Duration duration, FaceDownType faceDownType) {
|
||||
super(duration, Outcome.BecomeCreature);
|
||||
this.useTargetPointer = useTargetPointer;
|
||||
this.zoneChangeCounter = Integer.MIN_VALUE;
|
||||
if (morphCosts != null) {
|
||||
this.turnFaceUpAbility = new TurnFaceUpAbility(morphCosts);
|
||||
if (turnFaceUpCosts != null) {
|
||||
this.turnFaceUpAbility = new TurnFaceUpAbility(turnFaceUpCosts);
|
||||
}
|
||||
staticText = "{this} becomes a 2/2 face-down creature, with no text, no name, no subtypes, and no mana cost";
|
||||
foundPermanent = false;
|
||||
this.faceDownType = faceDownType;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -97,6 +104,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
}
|
||||
this.useTargetPointer = effect.useTargetPointer;
|
||||
this.foundPermanent = effect.foundPermanent;
|
||||
this.faceDownType = effect.faceDownType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -123,7 +131,17 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
|
|||
}
|
||||
|
||||
if (permanent != null && permanent.isFaceDown()) {
|
||||
foundPermanent = true;
|
||||
if (!foundPermanent) {
|
||||
foundPermanent = true;
|
||||
switch(faceDownType) {
|
||||
case MANIFESTED:
|
||||
permanent.setManifested(true);
|
||||
break;
|
||||
case MORPHED:
|
||||
permanent.setMorphed(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (layer) {
|
||||
case TypeChangingEffects_4:
|
||||
permanent.setName("");
|
||||
|
|
|
|||
|
|
@ -34,12 +34,14 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect;
|
||||
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect.FaceDownType;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -76,18 +78,22 @@ public class ManifestEffect extends OneShotEffect {
|
|||
for (Card card: cards) {
|
||||
card.setFaceDown(true);
|
||||
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
if (manaCosts == null) {
|
||||
manaCosts = new ManaCostsImpl("{0}");
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setManifested(true);
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
if (manaCosts == null) {
|
||||
manaCosts = new ManaCostsImpl("{0}");
|
||||
}
|
||||
}
|
||||
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom, FaceDownType.MANIFESTED);
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom);
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
game.applyEffects(); // to apply nefore ETB triggered or replace Effects are executed
|
||||
}
|
||||
game.applyEffects(); // to apply before ETB triggered or replace Effects are executed
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -34,12 +34,14 @@ import mage.abilities.costs.mana.ManaCostsImpl;
|
|||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect;
|
||||
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect.FaceDownType;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
|
|
@ -80,17 +82,20 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
|
|||
for (Card card: cards) {
|
||||
card.setFaceDown(true);
|
||||
targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
if (manaCosts == null) {
|
||||
manaCosts = new ManaCostsImpl("{0}");
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null) {
|
||||
permanent.setManifested(true);
|
||||
ManaCosts manaCosts = null;
|
||||
if (card.getCardType().contains(CardType.CREATURE)) {
|
||||
manaCosts = card.getSpellAbility().getManaCosts();
|
||||
if (manaCosts == null) {
|
||||
manaCosts = new ManaCostsImpl("{0}");
|
||||
}
|
||||
}
|
||||
}
|
||||
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom);
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom, FaceDownType.MANIFESTED);
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
} }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import mage.abilities.costs.mana.GenericManaCost;
|
|||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect;
|
||||
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect.FaceDownType;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -124,7 +125,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
sb.append(REMINDER_TEXT);
|
||||
ruleText = sb.toString();
|
||||
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesFaceDownCreatureEffect(morphCosts));
|
||||
Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesFaceDownCreatureEffect(morphCosts, FaceDownType.MORPHED));
|
||||
ability.setRuleVisible(false);
|
||||
card.addAbility(ability);
|
||||
|
||||
|
|
@ -269,7 +270,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
|
|||
return alternateCosts;
|
||||
}
|
||||
|
||||
public static void setPermanentToMorph(Permanent permanent) {
|
||||
public static void setPermanentToFaceDownCreature(Permanent permanent) {
|
||||
permanent.getPower().initValue(2);
|
||||
permanent.getToughness().initValue(2);
|
||||
permanent.getAbilities().clear();
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
cardNumber = card.cardNumber;
|
||||
expansionSetCode = card.expansionSetCode;
|
||||
rarity = card.rarity;
|
||||
this.watchers.clear();
|
||||
for (Watcher watcher: (List<Watcher>)card.getWatchers()) {
|
||||
watchers.add(watcher.copy());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1283,8 +1283,8 @@ public abstract class GameImpl implements Game, Serializable {
|
|||
|
||||
//getState().addCard(permanent);
|
||||
permanent.reset(this);
|
||||
if (copyFromPermanent.isMorphCard() && copyFromPermanent.isFaceDown()) {
|
||||
MorphAbility.setPermanentToMorph(permanent);
|
||||
if (copyFromPermanent.isMorphed() || copyFromPermanent.isManifested()) {
|
||||
MorphAbility.setPermanentToFaceDownCreature(permanent);
|
||||
}
|
||||
permanent.assignNewId();
|
||||
if (copyFromPermanent.isTransformed()) {
|
||||
|
|
|
|||
|
|
@ -247,6 +247,12 @@ public interface Permanent extends Card, Controllable {
|
|||
*/
|
||||
void clearPairedCard();
|
||||
|
||||
void setMorphed(boolean value);
|
||||
boolean isMorphed();
|
||||
|
||||
void setManifested(boolean value);
|
||||
boolean isManifested();
|
||||
|
||||
@Override
|
||||
Permanent copy();
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,9 @@ package mage.game.permanent;
|
|||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.mana.GenericManaCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.ManaCosts;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.LevelerCard;
|
||||
import mage.constants.Zone;
|
||||
|
|
@ -108,7 +111,7 @@ public class PermanentCard extends PermanentImpl {
|
|||
this.cardNumber = card.getCardNumber();
|
||||
this.usesVariousArt = card.getUsesVariousArt();
|
||||
this.zoneChangeCounter = card.getZoneChangeCounter();
|
||||
|
||||
|
||||
canTransform = card.canTransform();
|
||||
if (canTransform) {
|
||||
secondSideCard = card.getSecondCardFace();
|
||||
|
|
@ -116,7 +119,6 @@ public class PermanentCard extends PermanentImpl {
|
|||
}
|
||||
this.flipCard = card.isFlipCard();
|
||||
this.flipCardName = card.getFlipCardName();
|
||||
this.morphCard = card.isMorphCard();
|
||||
this.faceDown = card.isFaceDown();
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +132,7 @@ public class PermanentCard extends PermanentImpl {
|
|||
|
||||
@Override
|
||||
public boolean moveToZone(Zone toZone, UUID sourceId, Game game, boolean flag, ArrayList<UUID> appliedEffects) {
|
||||
Zone fromZone = game.getState().getZone(objectId);
|
||||
Zone fromZone = game.getState().getZone(objectId);
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
if (controller != null && controller.removeFromBattlefield(this, game)) {
|
||||
if (isFaceDown()) {
|
||||
|
|
@ -218,6 +220,8 @@ public class PermanentCard extends PermanentImpl {
|
|||
@Override
|
||||
public boolean turnFaceUp(Game game, UUID playerId) {
|
||||
if (super.turnFaceUp(game, playerId)) {
|
||||
setManifested(false);
|
||||
setMorphed(false);
|
||||
card.setFaceDown(false);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -253,7 +257,17 @@ public class PermanentCard extends PermanentImpl {
|
|||
super.setFaceDown(value);
|
||||
if (card != null) {
|
||||
card.setFaceDown(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManaCosts<ManaCost> getManaCost() {
|
||||
if (isFaceDown()) { // face down permanent has always {0} mana costs
|
||||
manaCost.clear();
|
||||
manaCost.add(new GenericManaCost(0));
|
||||
}
|
||||
return super.getManaCost();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.Effect;
|
||||
|
|
@ -80,6 +79,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
protected boolean flipped;
|
||||
protected boolean transformed;
|
||||
protected boolean monstrous;
|
||||
protected boolean manifested = false;
|
||||
protected boolean morphed = false;
|
||||
protected UUID originalControllerId;
|
||||
protected UUID controllerId;
|
||||
protected UUID beforeResetControllerId;
|
||||
|
|
@ -152,6 +153,9 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
this.monstrous = permanent.monstrous;
|
||||
this.pairedCard = permanent.pairedCard;
|
||||
this.timesLoyaltyUsed = permanent.timesLoyaltyUsed;
|
||||
|
||||
this.morphed = permanent.morphed;
|
||||
this.manifested = permanent.manifested;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1146,4 +1150,24 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isManifested() {
|
||||
return manifested;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManifested(boolean value) {
|
||||
manifested = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMorphed() {
|
||||
return morphed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMorphed(boolean value) {
|
||||
morphed = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue