* Fixed handling of enlarged view for manifested and morphed cards.

This commit is contained in:
LevelX2 2015-01-24 19:43:53 +01:00
parent ba8290a0c0
commit 001e17a73e
17 changed files with 196 additions and 102 deletions

View file

@ -310,11 +310,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}
BufferedImage srcImage;
if (gameCard.isFaceDown()) {
if (gameCard.isMorphCard()) {
srcImage = ImageCache.getMorphImage();
}else {
srcImage = ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
srcImage = getFaceDownImage();
} else {
srcImage = ImageCache.getImage(gameCard, getCardWidth(), getCardHeight());
}
@ -705,11 +701,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
BufferedImage srcImage;
if (gameCard.isFaceDown()) {
if (gameCard.isMorphCard()) {
srcImage = ImageCache.getMorphImage();
} else {
srcImage = ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
srcImage = getFaceDownImage();
} else {
srcImage = ImageCache.getThumbnail(gameCard);
}
@ -727,6 +719,22 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
});
}
private BufferedImage getFaceDownImage() {
if (isPermanent) {
if (((PermanentView) gameCard).isMorphed()) {
return ImageCache.getMorphImage();
} else {
return ImageCache.getManifestImage();
}
} else {
if (gameCard.isMorphCard()) {
return ImageCache.getMorphImage();
} else {
return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));
}
}
}
@Override
public List<MagePermanent> getLinks() {
return links;
@ -942,8 +950,8 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public Image getImage() {
if (this.hasImage) {
if (gameCard.isMorphCard() && gameCard.isFaceDown()) {
return ImageCache.getMorphImage();
if (gameCard.isFaceDown()) {
return getFaceDownImage();
} else {
return ImageCache.getImageOriginal(gameCard);
}

View file

@ -139,6 +139,14 @@ public class ImageCache {
return loadImage(file);
}
public static BufferedImage getManifestImage() {
CardDownloadData info = new CardDownloadData("Manifest", "FRF", 0, false, 0, "FRF");
info.setToken(true);
String path = CardImageUtils.generateTokenImagePath(info);
TFile file = new TFile(path);
return loadImage(file);
}
private static String buildThumbnailPath(String path) {
String thumbnailPath;
if (PreferencesDialog.isSaveImagesToZip()) {

View file

@ -136,13 +136,14 @@ public class CardView extends SimpleCardView {
// no information available for face down cards as long it's not a controlled face down morph card
// TODO: Better handle this in Framework (but currently I'm not sure how to do it there) LevelX2
if (card.isFaceDown()) {
if (card.isMorphCard()) {
// special handling for Morph cards
this.fillEmpty(card, controlled);
if (card.isMorphCard()) {
// special handling for casting of Morph cards
if (card instanceof Spell /*|| card instanceof Card*/) {
if (controlled) {
this.name = card.getName();
this.displayName = card.getName();
this.alternateName = card.getName();
}
this.power = "2";
this.toughness = "2";
@ -151,14 +152,11 @@ public class CardView extends SimpleCardView {
return;
}
} else {
if (card instanceof Permanent) {
this.fillEmpty(card, controlled);
this.power = Integer.toString(card.getPower().getValue());
this.toughness = Integer.toString(card.getToughness().getValue());
this.cardTypes = card.getCardType();
} else {
this.fillEmpty(card, false);
this.hideInfo = true;
return;
}

View file

@ -28,6 +28,9 @@
package mage.view;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.TurnFaceUpAbility;
import mage.cards.Card;
@ -36,10 +39,6 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentToken;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -58,6 +57,8 @@ public class PermanentView extends CardView {
private final String nameOwner; // only filled if != controller
private final boolean controlled;
private final UUID attachedTo;
private final boolean morphed;
private final boolean manifested;
public PermanentView(Permanent permanent, Card card, UUID createdForPlayerId, Game game) {
super(permanent, null, permanent.getControllerId().equals(createdForPlayerId));
@ -67,6 +68,8 @@ public class PermanentView extends CardView {
this.flipped = permanent.isFlipped();
this.phasedIn = permanent.isPhasedIn();
this.summoningSickness = permanent.hasSummoningSickness();
this.morphed = permanent.isMorphed();
this.manifested = permanent.isManifested();
this.damage = permanent.getDamage();
if (permanent.getAttachments().size() > 0) {
attachments = new ArrayList<>();
@ -79,7 +82,11 @@ public class PermanentView extends CardView {
tokenSetCode = original.getTokenSetCode();
} else {
if (card != null) {
// original may not be face down
boolean wasfaceDown = card.isFaceDown();
card.setFaceDown(false);
original = new CardView(card);
card.setFaceDown(wasfaceDown);
} else {
original = null;
}
@ -93,7 +100,8 @@ public class PermanentView extends CardView {
this.alternateName = permanent.getFlipCardName();
this.originalName = this.getName();
} else {
if (!this.isMorphCard() || controlled) {
if (controlled // controller may always know
|| (!morphed && !manifested)) { // others don't know for morph or transformed cards
this.alternateName = original.getName();
this.originalName = this.getName();
}
@ -110,30 +118,9 @@ public class PermanentView extends CardView {
this.nameOwner = "";
}
if (permanent.isFaceDown()) {
if (permanent.isMorphCard()){
// add morph rule text
if (card != null) {
if (controlled) {
for (Ability permanentAbility : permanent.getAbilities()) {
if (permanentAbility instanceof TurnFaceUpAbility && !permanentAbility.getRuleVisible()) {
this.rules.add(permanentAbility.getRule(true));
}
if (permanentAbility.getWorksFaceDown()) {
this.rules.add(permanentAbility.getRule());
}
}
this.name = card.getName();
this.expansionSetCode = card.getExpansionSetCode();
this.cardNumber = card.getCardNumber();
} else {
this.rules.add("If the controller has priority, he or she may turn this permanent face up." +
" This is a special action; it doesn’t use the stack. To do this he or she pays the morph costs," +
" then turns this permanent face up.");
}
}
} else{
if (controlled && card != null) {
if (permanent.isFaceDown() && card != null) {
if (controlled){
// must be a morphed or manifested card
for (Ability permanentAbility : permanent.getAbilities()) {
if (permanentAbility instanceof TurnFaceUpAbility && !permanentAbility.getRuleVisible()) {
this.rules.add(permanentAbility.getRule(true));
@ -144,10 +131,19 @@ public class PermanentView extends CardView {
}
this.name = card.getName();
this.displayName = card.getName();
this.expansionSetCode = card.getExpansionSetCode();
this.cardNumber = card.getCardNumber();
} else{
if (permanent.isMorphed()) {
this.rules.add("If the controller has priority, he or she may turn this permanent face up." +
" This is a special action; it doesn’t use the stack. To do this he or she pays the morph costs," +
" then turns this permanent face up.");
}else if (permanent.isManifested()) {
this.rules.add("A manifested creature card can be turned face up any time for it's mana cost." +
" A face-down card can also be turned face up for its morph cost.");
}
}
}
}
public boolean isTapped() {
@ -201,4 +197,11 @@ public class PermanentView extends CardView {
public boolean isAttachedTo() {
return attachedTo != null;
}
public boolean isMorphed() {
return morphed;
}
public boolean isManifested() {
return manifested;
}
}

View file

@ -37,6 +37,7 @@ 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.cards.CardImpl;
import mage.constants.CardType;
@ -127,7 +128,7 @@ class GhastlyConscriptionEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl<>("{0}");
}
}
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom);
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom, FaceDownType.MANIFESTED);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
game.informPlayers(controller.getName() + " puts facedown card from exile onto the battlefield");

View file

@ -45,6 +45,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.UnblockableSourceEffect;
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect;
import mage.abilities.effects.common.continious.BecomesFaceDownCreatureEffect.FaceDownType;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -148,7 +149,7 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl<>("{0}");
}
}
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom);
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom, FaceDownType.MANIFESTED);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
game.informPlayers(new StringBuilder(player.getName())

View file

@ -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)) {

View file

@ -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()) {
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("");

View file

@ -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,6 +78,9 @@ public class ManifestEffect extends OneShotEffect {
for (Card card: cards) {
card.setFaceDown(true);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
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();
@ -83,11 +88,12 @@ public class ManifestEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl("{0}");
}
}
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom);
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom, FaceDownType.MANIFESTED);
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;

View file

@ -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,6 +82,9 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
for (Card card: cards) {
card.setFaceDown(true);
targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, source.getSourceId());
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();
@ -87,10 +92,10 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
manaCosts = new ManaCostsImpl("{0}");
}
}
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom);
ContinuousEffect effect = new BecomesFaceDownCreatureEffect(manaCosts, true, Duration.Custom, FaceDownType.MANIFESTED);
effect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(effect, source);
}
} }
return true;
}
return false;

View file

@ -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();

View file

@ -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());
}

View file

@ -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()) {

View file

@ -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();

View file

@ -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;
@ -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();
}
@ -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;
}
@ -256,4 +260,14 @@ public class PermanentCard extends PermanentImpl {
}
}
@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();
}
}

View file

@ -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;
}
}

View file

@ -87,6 +87,9 @@ git log c370189787cff7fc129b1ccf1b223807143460de..HEAD --diff-filter=A --name-st
since 1.3.0-2014-11-29v8 (2015-01-17)
git log 79ceae999a72151e2fadd1e15ddd37ec76c3f205..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
since 1.3.0-2014-11-29v10 (2015-01-23)
git log 79ceae999a72151e2fadd1e15ddd37ec76c3f205..HEAD --diff-filter=A --name-status | sed -ne "s/^A[^u]Mage.Sets\/src\/mage\/sets\///p" | sort > added_cards.txt
3. Copy added_cards.txt to trunk\Utils folder
4. Run script:
> perl extract_in_wiki_format.perl