moved faceDown property from Card to CardState

This commit is contained in:
betasteward 2015-03-12 22:09:12 -04:00
parent d7b9a4a979
commit 9ad8530dee
61 changed files with 378 additions and 224 deletions

View file

@ -721,13 +721,13 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private BufferedImage getFaceDownImage() { private BufferedImage getFaceDownImage() {
if (isPermanent) { if (isPermanent) {
if (gameCard.isMorphCard() && ((PermanentView) gameCard).isMorphed()) { if (((PermanentView) gameCard).isMorphed()) {
return ImageCache.getMorphImage(); return ImageCache.getMorphImage();
} else { } else {
return ImageCache.getManifestImage(); return ImageCache.getManifestImage();
} }
} else { } else {
if (gameCard.isMorphCard() && this.gameCard instanceof StackAbilityView) { if (this.gameCard instanceof StackAbilityView) {
return ImageCache.getMorphImage(); return ImageCache.getMorphImage();
} else { } else {
return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename)); return ImageCache.loadImage(new TFile(DirectLinksForDownload.outDir + File.separator + DirectLinksForDownload.cardbackFilename));

View file

@ -87,7 +87,7 @@ public class CardView extends SimpleCardView {
protected boolean transformed; protected boolean transformed;
protected boolean flipCard; protected boolean flipCard;
protected boolean morphCard; protected boolean faceDown;
protected String alternateName; protected String alternateName;
protected String originalName; protected String originalName;
@ -138,13 +138,12 @@ public class CardView extends SimpleCardView {
* @param controlled is the card view created for the card controller - used for morph / face down cards to know which player may see information for the card * @param controlled is the card view created for the card controller - used for morph / face down cards to know which player may see information for the card
*/ */
public CardView(Card card, Game game, UUID cardId, boolean controlled) { public CardView(Card card, Game game, UUID cardId, boolean controlled) {
super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown(), card.getUsesVariousArt(), card.getTokenSetCode()); super(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode());
this.morphCard = card.isMorphCard();
// no information available for face down cards as long it's not a controlled face down morph card // 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 // TODO: Better handle this in Framework (but currently I'm not sure how to do it there) LevelX2
if (card.isFaceDown()) { if (card.isFaceDown(game)) {
this.fillEmpty(card, controlled); this.fillEmpty(card, controlled);
if (card.isMorphCard() && card instanceof Spell) { if (card instanceof Spell) {
// special handling for casting of Morph cards // special handling for casting of Morph cards
if (controlled) { if (controlled) {
this.name = card.getName(); this.name = card.getName();
@ -242,7 +241,7 @@ public class CardView extends SimpleCardView {
this.color = card.getColor(); this.color = card.getColor();
this.canTransform = card.canTransform(); this.canTransform = card.canTransform();
this.flipCard = card.isFlipCard(); this.flipCard = card.isFlipCard();
this.faceDown = game != null ? card.isFaceDown(game) : false;
if (card instanceof PermanentToken) { if (card instanceof PermanentToken) {
this.isToken = true; this.isToken = true;
@ -299,7 +298,7 @@ public class CardView extends SimpleCardView {
} }
public CardView(MageObject object) { public CardView(MageObject object) {
super(object.getId(), "", 0, false, false, ""); super(object.getId(), "", 0, false, "");
this.name = object.getName(); this.name = object.getName();
this.displayName = object.getName(); this.displayName = object.getName();
if (object instanceof Permanent) { if (object instanceof Permanent) {
@ -343,7 +342,7 @@ public class CardView extends SimpleCardView {
} }
protected CardView() { protected CardView() {
super(null, "", 0, false, false, ""); super(null, "", 0, false, "");
} }
public CardView(EmblemView emblem) { public CardView(EmblemView emblem) {
@ -359,7 +358,7 @@ public class CardView extends SimpleCardView {
} }
public CardView(boolean empty) { public CardView(boolean empty) {
super(null, "", 0, false, false, ""); super(null, "", 0, false, "");
if (!empty) { if (!empty) {
throw new IllegalArgumentException("Not supported."); throw new IllegalArgumentException("Not supported.");
} }
@ -417,7 +416,7 @@ public class CardView extends SimpleCardView {
} }
CardView(Token token) { CardView(Token token) {
super(token.getId(), "", 0, false, false, ""); super(token.getId(), "", 0, false, "");
this.isToken = true; this.isToken = true;
this.id = token.getId(); this.id = token.getId();
this.name = token.getName(); this.name = token.getName();
@ -581,7 +580,6 @@ public class CardView extends SimpleCardView {
return getName() + " [" + getId() + "]"; return getName() + " [" + getId() + "]";
} }
@Override
public boolean isFaceDown() { public boolean isFaceDown() {
return faceDown; return faceDown;
} }
@ -696,10 +694,6 @@ public class CardView extends SimpleCardView {
return flipCard; return flipCard;
} }
public boolean isMorphCard() {
return morphCard;
}
public boolean isToRotate() { public boolean isToRotate() {
return rotate; return rotate;
} }

View file

@ -46,7 +46,7 @@ public class LookedAtView implements Serializable {
public LookedAtView(String name, Cards cards, Game game) { public LookedAtView(String name, Cards cards, Game game) {
this.name = name; this.name = name;
for (Card card: cards.getCards(game)) { for (Card card: cards.getCards(game)) {
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.isFaceDown(), card.getTokenSetCode())); this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode()));
} }
} }

View file

@ -84,10 +84,7 @@ public class PermanentView extends CardView {
} else { } else {
if (card != null) { if (card != null) {
// original may not be face down // original may not be face down
boolean wasfaceDown = card.isFaceDown();
card.setFaceDown(false);
original = new CardView(card); original = new CardView(card);
card.setFaceDown(wasfaceDown);
} else { } else {
original = null; original = null;
} }
@ -119,7 +116,7 @@ public class PermanentView extends CardView {
this.nameOwner = ""; this.nameOwner = "";
} }
if (permanent.isFaceDown() && card != null) { if (permanent.isFaceDown(game) && card != null) {
if (controlled){ if (controlled){
// must be a morphed or manifested card // must be a morphed or manifested card
for (Ability permanentAbility : permanent.getAbilities()) { for (Ability permanentAbility : permanent.getAbilities()) {

View file

@ -45,7 +45,7 @@ public class RevealedView implements Serializable {
public RevealedView(String name, Cards cards, Game game) { public RevealedView(String name, Cards cards, Game game) {
this.name = name; this.name = name;
for (Card card: cards.getCards(game)) { for (Card card: cards.getCards(game)) {
this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.isFaceDown(), card.getTokenSetCode())); this.cards.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode()));
} }
} }

View file

@ -40,14 +40,12 @@ public class SimpleCardView implements Serializable {
protected String expansionSetCode; protected String expansionSetCode;
protected String tokenSetCode; protected String tokenSetCode;
protected int cardNumber; protected int cardNumber;
protected boolean faceDown;
protected boolean usesVariousArt; protected boolean usesVariousArt;
public SimpleCardView(UUID id, String expansionSetCode, int cardNumber, boolean faceDown, boolean usesVariousArt, String tokenSetCode) { public SimpleCardView(UUID id, String expansionSetCode, int cardNumber, boolean usesVariousArt, String tokenSetCode) {
this.id = id; this.id = id;
this.expansionSetCode = expansionSetCode; this.expansionSetCode = expansionSetCode;
this.cardNumber = cardNumber; this.cardNumber = cardNumber;
this.faceDown = faceDown;
this.usesVariousArt = usesVariousArt; this.usesVariousArt = usesVariousArt;
this.tokenSetCode = tokenSetCode; this.tokenSetCode = tokenSetCode;
} }
@ -64,10 +62,6 @@ public class SimpleCardView implements Serializable {
return cardNumber; return cardNumber;
} }
public boolean isFaceDown() {
return faceDown;
}
public boolean getUsesVariousArt() { public boolean getUsesVariousArt() {
return usesVariousArt; return usesVariousArt;
} }

View file

@ -44,7 +44,7 @@ public class SimpleCardsView extends LinkedHashMap<UUID, SimpleCardView> {
public SimpleCardsView(Collection<Card> cards) { public SimpleCardsView(Collection<Card> cards) {
for (Card card: cards) { for (Card card: cards) {
this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.isFaceDown(), card.getUsesVariousArt(), card.getTokenSetCode())); this.put(card.getId(), new SimpleCardView(card.getId(), card.getExpansionSetCode(), card.getCardNumber(), card.getUsesVariousArt(), card.getTokenSetCode()));
} }
} }

View file

@ -74,7 +74,7 @@ public class StackAbilityView extends CardView {
this.power = ability.getPower().toString(); this.power = ability.getPower().toString();
this.toughness = ability.getToughness().toString(); this.toughness = ability.getToughness().toString();
String nameToShow; String nameToShow;
if (sourceCard.isMorphCard() && sourceCard.isFaceDown()) { if (sourceCard.isFaceDown()) {
CardView tmpSourceCard = this.getSourceCard(); CardView tmpSourceCard = this.getSourceCard();
tmpSourceCard.displayName = "Face Down"; tmpSourceCard.displayName = "Face Down";
tmpSourceCard.superTypes.clear(); tmpSourceCard.superTypes.clear();

View file

@ -575,7 +575,7 @@ public class HumanPlayer extends PlayerImpl {
if (object != null) { if (object != null) {
Zone zone = game.getState().getZone(object.getId()); Zone zone = game.getState().getZone(object.getId());
if (zone != null) { if (zone != null) {
if (object instanceof Card && ((Card) object).isFaceDown()) { if (object instanceof Card && ((Card) object).isFaceDown(game)) {
revealFaceDownCard((Card) object, game); revealFaceDownCard((Card) object, game);
result = true; result = true;
} }

View file

@ -94,7 +94,7 @@ class LifebloodHydraComesIntoPlayEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown()) { if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();

View file

@ -107,8 +107,7 @@ class ShorecrasherElementalEffect extends OneShotEffect {
if (shorecrasherElemental.moveToExile(source.getSourceId(), "Shorecrasher Elemental", source.getSourceId(), game)) { if (shorecrasherElemental.moveToExile(source.getSourceId(), "Shorecrasher Elemental", source.getSourceId(), game)) {
Card card = game.getExile().getCard(source.getSourceId(), game); Card card = game.getExile().getCard(source.getSourceId(), game);
if (card != null) { if (card != null) {
card.setFaceDown(true); return card.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), card.getOwnerId(), false, true);
return card.moveToZone(Zone.BATTLEFIELD, source.getSourceId(), game, false);
} }
} }
} }

View file

@ -99,14 +99,12 @@ class GhastlyConscriptionEffect extends OneShotEffect {
for(Card card: targetPlayer.getGraveyard().getCards(new FilterCreatureCard(), game)) { for(Card card: targetPlayer.getGraveyard().getCards(new FilterCreatureCard(), game)) {
cardsToManifest.add(card); cardsToManifest.add(card);
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD); controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD);
card.setFaceDown(true);
} }
Collections.shuffle(cardsToManifest); Collections.shuffle(cardsToManifest);
game.informPlayers(controller.getName() + " shuffles the face-down pile"); game.informPlayers(controller.getName() + " shuffles the face-down pile");
Ability newSource = source.copy(); Ability newSource = source.copy();
newSource.setWorksFaceDown(true); newSource.setWorksFaceDown(true);
for (Card card: cardsToManifest) { for (Card card: cardsToManifest) {
card.setFaceDown(true);
ManaCosts manaCosts = null; ManaCosts manaCosts = null;
if (card.getCardType().contains(CardType.CREATURE)) { if (card.getCardType().contains(CardType.CREATURE)) {
manaCosts = card.getSpellAbility().getManaCosts(); manaCosts = card.getSpellAbility().getManaCosts();
@ -116,7 +114,7 @@ class GhastlyConscriptionEffect extends OneShotEffect {
} }
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game); MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
if (controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId())) { if (controller.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) {
game.informPlayers(new StringBuilder(controller.getName()) game.informPlayers(new StringBuilder(controller.getName())
.append(" puts facedown card from exile onto the battlefield").toString()); .append(" puts facedown card from exile onto the battlefield").toString());
} }

View file

@ -114,12 +114,10 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
Card sourceCard = game.getCard(source.getSourceId()); Card sourceCard = game.getCard(source.getSourceId());
if (sourcePermanent != null && sourceCard != null) { if (sourcePermanent != null && sourceCard != null) {
player.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getName(), source.getSourceId(), game, Zone.BATTLEFIELD); player.moveCardToExileWithInfo(sourcePermanent, sourcePermanent.getId(), sourcePermanent.getName(), source.getSourceId(), game, Zone.BATTLEFIELD);
sourceCard.setFaceDown(true);
cardsToManifest.add(sourceCard); cardsToManifest.add(sourceCard);
} }
if (sourcePermanent!= null && player.getLibrary().size() > 0) { if (sourcePermanent!= null && player.getLibrary().size() > 0) {
Card cardFromLibrary = player.getLibrary().removeFromTop(game); Card cardFromLibrary = player.getLibrary().removeFromTop(game);
cardFromLibrary.setFaceDown(true);
player.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getName(), source.getSourceId(), game, Zone.LIBRARY); player.moveCardToExileWithInfo(cardFromLibrary, sourcePermanent.getId(), sourcePermanent.getName(), source.getSourceId(), game, Zone.LIBRARY);
cardsToManifest.add(cardFromLibrary); cardsToManifest.add(cardFromLibrary);
} }
@ -128,7 +126,6 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
Ability newSource = source.copy(); Ability newSource = source.copy();
newSource.setWorksFaceDown(true); newSource.setWorksFaceDown(true);
for (Card card : cardsToManifest) { for (Card card : cardsToManifest) {
card.setFaceDown(true);
ManaCosts manaCosts = null; ManaCosts manaCosts = null;
if (card.getCardType().contains(CardType.CREATURE)) { if (card.getCardType().contains(CardType.CREATURE)) {
manaCosts = card.getSpellAbility().getManaCosts(); manaCosts = card.getSpellAbility().getManaCosts();
@ -138,7 +135,7 @@ class JeskaiInfiltratorEffect extends OneShotEffect {
} }
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game); MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
if (card.moveToZone(Zone.BATTLEFIELD, newSource.getSourceId(), game, false)) { if (player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId(), false, true)) {
game.informPlayers(new StringBuilder(player.getName()) game.informPlayers(new StringBuilder(player.getName())
.append(" puts facedown card from exile onto the battlefield").toString()); .append(" puts facedown card from exile onto the battlefield").toString());
} }

View file

@ -97,8 +97,8 @@ class SummonersEggImprintEffect extends OneShotEffect {
&& controller.choose(Outcome.Benefit, controller.getHand(), target, game)) { && controller.choose(Outcome.Benefit, controller.getHand(), target, game)) {
Card card = controller.getHand().get(target.getFirstTarget(), game); Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) { if (card != null) {
card.setFaceDown(true);
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourcePermanent.getLogName() +" (Imprint)", source.getSourceId(), game, Zone.HAND); controller.moveCardToExileWithInfo(card, source.getSourceId(), sourcePermanent.getLogName() +" (Imprint)", source.getSourceId(), game, Zone.HAND);
card.setFaceDown(true, game);
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
permanent.imprint(card.getId(), game); permanent.imprint(card.getId(), game);

View file

@ -105,7 +105,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
} }

View file

@ -146,8 +146,10 @@ class BaneAlleyBrokerDrawExileEffect extends OneShotEffect {
Card card = game.getCard(target.getFirstTarget()); Card card = game.getCard(target.getFirstTarget());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (card != null && sourceObject != null) { if (card != null && sourceObject != null) {
card.setFaceDown(true); if (card.moveToExile(CardUtil.getCardExileZoneId(game, source), new StringBuilder(sourceObject.getLogName()).toString(), source.getSourceId(), game)) {
return card.moveToExile(CardUtil.getCardExileZoneId(game, source), new StringBuilder(sourceObject.getLogName()).toString(), source.getSourceId(), game); card.setFaceDown(true, game);
return true;
}
} }
} }
} }

View file

@ -136,8 +136,8 @@ class NecropotenceEffect extends OneShotEffect {
if (controller != null) { if (controller != null) {
if (controller.getLibrary().size() > 0) { if (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game); Card card = controller.getLibrary().removeFromTop(game);
card.setFaceDown(true);
if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY)) { if (controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY)) {
card.setFaceDown(true, game);
Effect returnToHandeffect = new ReturnToHandTargetEffect(); Effect returnToHandeffect = new ReturnToHandTargetEffect();
returnToHandeffect.setText("put that face down card into your hand"); returnToHandeffect.setText("put that face down card into your hand");
returnToHandeffect.setTargetPointer(new FixedTarget(card.getId())); returnToHandeffect.setTargetPointer(new FixedTarget(card.getId()));

View file

@ -112,8 +112,7 @@ class AshcloudPhoenixEffect extends OneShotEffect {
if (card != null) { if (card != null) {
Player owner = game.getPlayer(card.getOwnerId()); Player owner = game.getPlayer(card.getOwnerId());
if (owner != null && owner.getGraveyard().contains(card.getId())) { if (owner != null && owner.getGraveyard().contains(card.getId())) {
card.setFaceDown(true); player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId(), false, true);
player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
} }
} }
return true; return true;

View file

@ -120,7 +120,7 @@ class EfreetWeaponmasterAbility extends TriggeredAbilityImpl {
} }
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()) ) { if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()) ) {
Permanent sourcePermanent = game.getPermanent(getSourceId()); Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
} }

View file

@ -111,7 +111,7 @@ class HoodedHydraEffect1 extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && !permanent.isFaceDown()) { if (permanent != null && !permanent.isFaceDown(game)) {
Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); Object obj = getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY);
if (obj != null && obj instanceof SpellAbility) { if (obj != null && obj instanceof SpellAbility) {
int amount = ((SpellAbility) obj).getManaCostsToPay().getX(); int amount = ((SpellAbility) obj).getManaCostsToPay().getX();

View file

@ -184,7 +184,7 @@ class LensOfClarityLookFaceDownEffect extends OneShotEffect {
Permanent faceDownCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent faceDownCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.add(copyFaceDown); cards.add(copyFaceDown);
Player player = game.getPlayer(faceDownCreature.getControllerId()); Player player = game.getPlayer(faceDownCreature.getControllerId());

View file

@ -107,7 +107,7 @@ class PonybackBrigadeAbility extends TriggeredAbilityImpl {
} }
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()) ) { if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD && event.getTargetId().equals(this.getSourceId()) ) {
Permanent sourcePermanent = game.getPermanent(getSourceId()); Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
} }

View file

@ -112,7 +112,7 @@ class SmokeTellerLookFaceDownEffect extends OneShotEffect {
Permanent faceDownCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent faceDownCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (faceDownCreature != null) { if (faceDownCreature != null) {
Permanent copyFaceDown = faceDownCreature.copy(); Permanent copyFaceDown = faceDownCreature.copy();
copyFaceDown.setFaceDown(false); copyFaceDown.setFaceDown(false, game);
Cards cards = new CardsImpl(); Cards cards = new CardsImpl();
cards.add(copyFaceDown); cards.add(copyFaceDown);
player.lookAtCards("face down card - " + mageObject.getLogName(), cards, game); player.lookAtCards("face down card - " + mageObject.getLogName(), cards, game);

View file

@ -136,7 +136,7 @@ class FaceUpPredicate implements Predicate<Card> {
@Override @Override
public boolean apply(Card input, Game game) { public boolean apply(Card input, Game game) {
return !input.isFaceDown(); return !input.isFaceDown(game);
} }
@Override @Override

View file

@ -105,9 +105,9 @@ class PraetorsGraspEffect extends OneShotEffect {
Card card = opponent.getLibrary().getCard(targetId, game); Card card = opponent.getLibrary().getCard(targetId, game);
UUID exileId = CardUtil.getObjectExileZoneId(game, sourceObject); UUID exileId = CardUtil.getObjectExileZoneId(game, sourceObject);
if (card != null && exileId != null) { if (card != null && exileId != null) {
card.setFaceDown(true);
game.informPlayers(controller.getName() + " moves the searched card face down to exile"); game.informPlayers(controller.getName() + " moves the searched card face down to exile");
card.moveToExile(exileId, sourceObject.getName(), source.getSourceId(), game); card.moveToExile(exileId, sourceObject.getName(), source.getSourceId(), game);
card.setFaceDown(true, game);
game.addEffect(new PraetorsGraspPlayEffect(card.getId()), source); game.addEffect(new PraetorsGraspPlayEffect(card.getId()), source);
game.addEffect(new PraetorsGraspRevealEffect(card.getId()), source); game.addEffect(new PraetorsGraspRevealEffect(card.getId()), source);
} }

View file

@ -106,7 +106,7 @@ class PrimalPlasmaReplacementEffect extends ReplacementEffectImpl {
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
} }

View file

@ -101,8 +101,8 @@ class BottledCloisterExileEffect extends OneShotEffect {
if (numberOfCards > 0) { if (numberOfCards > 0) {
UUID exileId = CardUtil.getCardExileZoneId(game, source); UUID exileId = CardUtil.getCardExileZoneId(game, source);
for (Card card: controller.getHand().getCards(game)) { for (Card card: controller.getHand().getCards(game)) {
card.setFaceDown(true);
card.moveToExile(exileId, sourcePermanent.getName(), source.getSourceId(), game); card.moveToExile(exileId, sourcePermanent.getName(), source.getSourceId(), game);
card.setFaceDown(true, game);
} }
game.informPlayers(sourcePermanent.getName() + ": " + controller.getName() + " exiles his or her hand face down (" + numberOfCards + "card" + (numberOfCards > 1 ?"s":"") +")"); game.informPlayers(sourcePermanent.getName() + ": " + controller.getName() + " exiles his or her hand face down (" + numberOfCards + "card" + (numberOfCards > 1 ?"s":"") +")");
} }
@ -140,8 +140,8 @@ class BottledCloisterReturnEffect extends OneShotEffect {
for (Card card: exileZone.getCards(game)) { for (Card card: exileZone.getCards(game)) {
if (card.getOwnerId().equals(controller.getId())) { if (card.getOwnerId().equals(controller.getId())) {
numberOfCards++; numberOfCards++;
card.setFaceDown(false);
card.moveToZone(Zone.HAND, source.getSourceId(), game, true); card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
card.setFaceDown(false, game);
} }
} }
} }

View file

@ -113,8 +113,8 @@ class CloneShellEffect extends OneShotEffect {
Card card = cards.get(target1.getFirstTarget(), game); Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) { if (card != null) {
cards.remove(card); cards.remove(card);
card.setFaceDown(true);
card.moveToExile(getId(), "Clone Shell (Imprint)", source.getSourceId(), game); card.moveToExile(getId(), "Clone Shell (Imprint)", source.getSourceId(), game);
card.setFaceDown(true, game);
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) { if (permanent != null) {
permanent.imprint(card.getId(), game); permanent.imprint(card.getId(), game);
@ -166,7 +166,7 @@ class CloneShellDiesEffect extends OneShotEffect {
List<UUID> imprinted = permanent.getImprinted(); List<UUID> imprinted = permanent.getImprinted();
if (imprinted.size() > 0) { if (imprinted.size() > 0) {
Card imprintedCard = game.getCard(imprinted.get(0)); Card imprintedCard = game.getCard(imprinted.get(0));
imprintedCard.setFaceDown(false); imprintedCard.setFaceDown(false, game);
if (imprintedCard.getCardType().contains(CardType.CREATURE)) { if (imprintedCard.getCardType().contains(CardType.CREATURE)) {
imprintedCard.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId()); imprintedCard.putOntoBattlefield(game, Zone.EXILED, source.getSourceId(), source.getControllerId());
} }

View file

@ -115,7 +115,7 @@ class AquamorphEntityReplacementEffect extends ReplacementEffectImpl {
if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) { if (event.getType() == EventType.ENTERS_THE_BATTLEFIELD) {
if (event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && !sourcePermanent.isFaceDown()) { if (sourcePermanent != null && !sourcePermanent.isFaceDown(game)) {
return true; return true;
} }
} }

View file

@ -101,8 +101,8 @@ class ScrollRackEffect extends OneShotEffect {
for (UUID targetId : targets) { for (UUID targetId : targets) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null) { if (card != null) {
card.setFaceDown(true);
if (card.moveToExile(source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game)) { if (card.moveToExile(source.getSourceId(), sourceObject.getLogName(), source.getSourceId(), game)) {
card.setFaceDown(true, game);
amountExiled++; amountExiled++;
} }
} }

View file

@ -122,10 +122,10 @@ class PyxisOfPandemoniumExileEffect extends OneShotEffect {
exileId = UUID.randomUUID(); exileId = UUID.randomUUID();
exileIds.put(exileKey, exileId); exileIds.put(exileKey, exileId);
} }
card.setFaceDown(true);
player.moveCardToExileWithInfo(card, exileId, player.moveCardToExileWithInfo(card, exileId,
new StringBuilder(sourceObject.getLogName() +" (").append(player.getName()).append(")").toString(), new StringBuilder(sourceObject.getLogName() +" (").append(player.getName()).append(")").toString(),
source.getSourceId(), game, Zone.LIBRARY); source.getSourceId(), game, Zone.LIBRARY);
card.setFaceDown(true, game);
} }
} }
} }
@ -173,7 +173,7 @@ class PyxisOfPandemoniumPutOntoBattlefieldEffect extends OneShotEffect {
ExileZone exileZone = game.getState().getExile().getExileZone(exileId); ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
if (exileZone != null) { if (exileZone != null) {
for(Card card: exileZone.getCards(game)) { for(Card card: exileZone.getCards(game)) {
card.setFaceDown(false); // card.setFaceDown(false, game);
if (CardUtil.isPermanentCard(card)) { if (CardUtil.isPermanentCard(card)) {
player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId()); player.putOntoBattlefieldWithInfo(card, game, Zone.EXILED, source.getSourceId());
} }

View file

@ -248,7 +248,7 @@ class RescueFromTheUnderworldReturnEffect extends OneShotEffect {
if (source.getTargets().get(1) != null) { if (source.getTargets().get(1) != null) {
for (UUID targetId: ((Target) source.getTargets().get(1)).getTargets()) { for (UUID targetId: ((Target) source.getTargets().get(1)).getTargets()) {
Card card = game.getCard(targetId); Card card = game.getCard(targetId);
if (card != null && !card.isFaceDown()) { if (card != null && !card.isFaceDown(game)) {
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player != null) { if (player != null) {
Zone currentZone = game.getState().getZone(card.getId()); Zone currentZone = game.getState().getZone(card.getId());

View file

@ -107,8 +107,8 @@ class MemoryJarEffect extends OneShotEffect {
Card card = hand.get(hand.iterator().next(), game); Card card = hand.get(hand.iterator().next(), game);
if(card != null) if(card != null)
{ {
card.setFaceDown(true);
card.moveToExile(getId(), "Memory Jar", source.getSourceId(), game); card.moveToExile(getId(), "Memory Jar", source.getSourceId(), game);
card.setFaceDown(true, game);
cards.add(card); cards.add(card);
} }
} }

View file

@ -247,7 +247,7 @@ public class ManifestTest extends CardTestPlayerBase {
for (Card card :currentGame.getExile().getAllCards(currentGame)){ for (Card card :currentGame.getExile().getAllCards(currentGame)){
if (card.getName().equals("Gore Swine")) { if (card.getName().equals("Gore Swine")) {
Assert.assertTrue("Gore Swine may not be face down in exile", !card.isFaceDown()); Assert.assertTrue("Gore Swine may not be face down in exile", !card.isFaceDown(currentGame));
} }
} }

View file

@ -0,0 +1,55 @@
package org.mage.test.cards.facedown;
import mage.cards.Card;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.ExileZone;
import org.junit.Assert;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author BetaSteward
*/
public class BaneAlleyBrokerTest extends CardTestPlayerBase {
/**
* Bane Alley Broker
* Creature Human Rogue 0/3, 1UB (3)
* {T}: Draw a card, then exile a card from your hand face down.
* You may look at cards exiled with Bane Alley Broker.
* {U}{B}, {T}: Return a card exiled with Bane Alley Broker to its owner's hand.
*
*/
// test that cards exiled using Bane Alley Broker are face down
@Test
public void testBaneAlleyBroker() {
addCard(Zone.BATTLEFIELD, playerA, "Bane Alley Broker");
addCard(Zone.HAND, playerA, "Goblin Roughrider");
addCard(Zone.HAND, playerA, "Sejiri Merfolk");
addCard(Zone.BATTLEFIELD, playerA, "Island");
addCard(Zone.BATTLEFIELD, playerA, "Swamp");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Draw a card, then exile a card from your hand face down.");
addTarget(playerA, "Goblin Roughrider");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 2);
assertHandCount(playerA, "Sejiri Merfolk", 1);
assertHandCount(playerA, "Goblin Roughrider", 0);
assertExileCount("Goblin Roughrider", 1);
for (Card card :currentGame.getExile().getAllCards(currentGame)){
if (card.getName().equals("Goblin Roughrider")) {
Assert.assertTrue("Exiled card is not face down", card.isFaceDown(currentGame));
}
}
}
}

View file

@ -0,0 +1,45 @@
package org.mage.test.cards.facedown;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author BetaSteward
*/
public class GhastlyConscriptionTest extends CardTestPlayerBase {
/**
* Ghastly Conscription
* Sorcery, 5BB (7)
* Exile all creature cards from target player's graveyard in a face-down pile,
* shuffle that pile, then manifest those cards. (To manifest a card, put it
* onto the battlefield face down as a 2/2 creature. Turn it face up any time
* for its mana cost if it's a creature card.)
*
*/
// test that cards exiled using Ghastly Conscription return face down
@Test
public void testGhastlyConscription() {
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 7);
addCard(Zone.HAND, playerA, "Ghastly Conscription");
addCard(Zone.GRAVEYARD, playerA, "Ashcloud Phoenix");
addCard(Zone.GRAVEYARD, playerA, "Goblin Roughrider");
addCard(Zone.GRAVEYARD, playerA, "Island");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Ghastly Conscription", playerA);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertLife(playerA, 20);
assertLife(playerB, 20);
assertGraveyardCount(playerA, 2);
assertPermanentCount(playerA, "face down creature", 2);
}
}

View file

@ -0,0 +1,117 @@
package org.mage.test.cards.facedown;
import mage.cards.Card;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
* @author BetaSteward
*/
public class SummonersEggTest extends CardTestPlayerBase {
/**
* Summoner's Egg
* Artifact Creature Construct 0/4, 4 (4)
* Imprint When Summoner's Egg enters the battlefield, you may exile a
* card from your hand face down.
* When Summoner's Egg dies, turn the exiled card face up. If it's a creature
* card, put it onto the battlefield under your control.
*
*/
// test that cards imprinted using Summoner's Egg are face down
@Test
public void testSummonersEggImprint() {
addCard(Zone.HAND, playerA, "Summoner's Egg");
addCard(Zone.HAND, playerA, "Sejiri Merfolk");
addCard(Zone.HAND, playerA, "Goblin Roughrider");
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Summoner's Egg");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertHandCount(playerA, 1);
assertHandCount(playerA, "Sejiri Merfolk", 1);
assertHandCount(playerA, "Goblin Roughrider", 0);
assertExileCount("Goblin Roughrider", 1);
for (Card card :currentGame.getExile().getAllCards(currentGame)){
if (card.getName().equals("Goblin Roughrider")) {
Assert.assertTrue("Exiled card is not face down", card.isFaceDown(currentGame));
}
}
}
// test that creature cards imprinted using Summoner's Egg are put in play face up
@Test
public void testSummonersEggDies() {
addCard(Zone.HAND, playerA, "Summoner's Egg");
addCard(Zone.HAND, playerA, "Sejiri Merfolk");
addCard(Zone.HAND, playerA, "Goblin Roughrider");
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.HAND, playerB, "Char");
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Summoner's Egg");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Char", "Summoner's Egg");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertHandCount(playerA, 1);
assertHandCount(playerA, "Sejiri Merfolk", 1);
assertHandCount(playerA, "Goblin Roughrider", 0);
assertGraveyardCount(playerA, "Summoner's Egg", 1);
assertExileCount("Goblin Roughrider", 0);
assertPermanentCount(playerA, "Goblin Roughrider", 1);
for (Permanent p :currentGame.getBattlefield().getAllActivePermanents()){
if (p.getName().equals("Goblin Roughrider")) {
Assert.assertTrue("Permanent is not face up", !p.isFaceDown(currentGame));
}
}
}
// test that non-creature cards imprinted using Summoner's Egg are left in exile face up
@Test
public void testSummonersEggDies2() {
addCard(Zone.HAND, playerA, "Summoner's Egg");
addCard(Zone.HAND, playerA, "Forest", 2);
addCard(Zone.BATTLEFIELD, playerA, "Island", 4);
addCard(Zone.HAND, playerB, "Char");
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 3);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Summoner's Egg");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Char", "Summoner's Egg");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertHandCount(playerA, 1);
assertHandCount(playerA, "Forest", 1);
assertGraveyardCount(playerA, "Summoner's Egg", 1);
assertExileCount("Forest", 1);
for (Card card :currentGame.getExile().getAllCards(currentGame)){
if (card.getName().equals("Forest")) {
Assert.assertTrue("Exiled card is not face up", !card.isFaceDown(currentGame));
}
}
}
}

View file

@ -860,7 +860,7 @@ public abstract class AbilityImpl implements Ability {
return false; return false;
} }
} else if (object instanceof PermanentCard) { } else if (object instanceof PermanentCard) {
if (((PermanentCard)object).isFaceDown()&& !this.getWorksFaceDown()) { if (((PermanentCard)object).isFaceDown(game)&& !this.getWorksFaceDown()) {
return false; return false;
} }
} }

View file

@ -95,28 +95,6 @@ public class TriggeredAbilities extends ConcurrentHashMap<String, TriggeredAbili
} }
} }
} }
private boolean checkAbilityStillExists(TriggeredAbility ability, GameEvent event, MageObject object) {
boolean exists = true;
if (!object.getAbilities().contains(ability)) {
exists = false;
if (object instanceof PermanentCard) {
PermanentCard permanent = (PermanentCard)object;
if (permanent.canTransform() && event.getType() == GameEvent.EventType.TRANSFORMED) {
exists = permanent.getCard().getAbilities().contains(ability);
}
}
} else {
if (object instanceof PermanentCard) {
PermanentCard permanent = (PermanentCard)object;
if (permanent.isFaceDown()) {
exists = ability.getWorksFaceDown();
}
}
}
return exists;
}
private MageObject getMageObject(GameEvent event, Game game, TriggeredAbility ability) { private MageObject getMageObject(GameEvent event, Game game, TriggeredAbility ability) {
MageObject object = game.getPermanent(ability.getSourceId()); MageObject object = game.getPermanent(ability.getSourceId());

View file

@ -82,7 +82,7 @@ public class TurnedFaceUpAllTriggeredAbility extends TriggeredAbilityImpl {
if (!event.getTargetId().equals(getSourceId())) { if (!event.getTargetId().equals(getSourceId())) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(getSourceId());
if (sourcePermanent != null) { if (sourcePermanent != null) {
if (sourcePermanent.isFaceDown()) { if (sourcePermanent.isFaceDown(game)) {
// if face down and it's not itself that is turned face up, it does not trigger // if face down and it's not itself that is turned face up, it does not trigger
return false; return false;
} }

View file

@ -52,10 +52,10 @@ public class FaceDownSourceCondition implements Condition {
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) { if (mageObject != null) {
if (mageObject instanceof Permanent) { if (mageObject instanceof Permanent) {
return ((Permanent)mageObject).isFaceDown(); return ((Permanent)mageObject).isFaceDown(game);
} }
if (mageObject instanceof Card) { if (mageObject instanceof Card) {
return ((Card)mageObject).isFaceDown(); return ((Card)mageObject).isFaceDown(game);
} }
} }
return false; return false;

View file

@ -89,7 +89,7 @@ public class AuraReplacementEffect extends ReplacementEffectImpl {
UUID controllerId = event.getPlayerId(); UUID controllerId = event.getPlayerId();
// Aura cards that go to battlefield face down (Manifest) don't have to select targets // Aura cards that go to battlefield face down (Manifest) don't have to select targets
if (card.isFaceDown()) { if (card.isFaceDown(game)) {
return false; return false;
} }
// Aura enters the battlefield attached // Aura enters the battlefield attached

View file

@ -416,12 +416,12 @@ public class ContinuousEffects implements Serializable {
} else { } else {
if (object instanceof PermanentCard) { if (object instanceof PermanentCard) {
PermanentCard permanent = (PermanentCard)object; PermanentCard permanent = (PermanentCard)object;
if (permanent.isFaceDown() && !ability.getWorksFaceDown()) { if (permanent.isFaceDown(game) && !ability.getWorksFaceDown()) {
return false; return false;
} }
} else if (object instanceof Spell) { } else if (object instanceof Spell) {
Spell spell = (Spell)object; Spell spell = (Spell)object;
if (spell.isFaceDown() && !ability.getWorksFaceDown()) { if (spell.isFaceDown(game) && !ability.getWorksFaceDown()) {
return false; return false;
} }
} }

View file

@ -71,7 +71,7 @@ public class HideawayPlayEffect extends OneShotEffect {
// If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn. // If the revealed card is a land, you can play it only if it's your turn and you haven't yet played a land this turn.
if (game.getActivePlayerId().equals(source.getControllerId()) && controller.canPlayLand()) { if (game.getActivePlayerId().equals(source.getControllerId()) && controller.canPlayLand()) {
if (controller.chooseUse(Outcome.Benefit, new StringBuilder("Play ").append(card.getName()).append(" from Exile?").toString(), game)) { if (controller.chooseUse(Outcome.Benefit, new StringBuilder("Play ").append(card.getName()).append(" from Exile?").toString(), game)) {
card.setFaceDown(false); card.setFaceDown(false, game);
return controller.playLand(card, game); return controller.playLand(card, game);
} }
} else { } else {
@ -83,7 +83,7 @@ public class HideawayPlayEffect extends OneShotEffect {
// Timing restrictions based on the card's type are ignored (for instance, if it's a creature or sorcery). // Timing restrictions based on the card's type are ignored (for instance, if it's a creature or sorcery).
// Other play restrictions are not (such as "Play [this card] only during combat"). // Other play restrictions are not (such as "Play [this card] only during combat").
if (controller.chooseUse(Outcome.Benefit, new StringBuilder("Cast ").append(card.getName()).append(" without paying it's mana cost?").toString(), game)) { if (controller.chooseUse(Outcome.Benefit, new StringBuilder("Cast ").append(card.getName()).append(" without paying it's mana cost?").toString(), game)) {
card.setFaceDown(false); card.setFaceDown(false, game);
return controller.cast(card.getSpellAbility(), game, true); return controller.cast(card.getSpellAbility(), game, true);
} }
} else { } else {

View file

@ -85,9 +85,9 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
public void init(Ability source, Game game) { public void init(Ability source, Game game) {
super.init(source, game); super.init(source, game);
for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { for (Permanent perm: game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
if (!perm.isFaceDown() && !perm.canTransform()) { if (!perm.isFaceDown(game) && !perm.canTransform()) {
affectedObjectList.add(new MageObjectReference(perm)); affectedObjectList.add(new MageObjectReference(perm));
perm.setFaceDown(true); perm.setFaceDown(true, game);
// check for Morph // check for Morph
Card card = game.getCard(perm.getId()); Card card = game.getCard(perm.getId());
if (card != null) { if (card != null) {
@ -106,7 +106,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
boolean targetExists = false; boolean targetExists = false;
for (MageObjectReference mor: affectedObjectList) { for (MageObjectReference mor: affectedObjectList) {
Permanent permanent = mor.getPermanent(game); Permanent permanent = mor.getPermanent(game);
if (permanent != null && permanent.isFaceDown()) { if (permanent != null && permanent.isFaceDown(game)) {
targetExists = true; targetExists = true;
switch (layer) { switch (layer) {
case TypeChangingEffects_4: case TypeChangingEffects_4:

View file

@ -132,7 +132,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
permanent = game.getPermanent(source.getSourceId()); permanent = game.getPermanent(source.getSourceId());
} }
if (permanent != null && permanent.isFaceDown()) { if (permanent != null && permanent.isFaceDown(game)) {
if (!foundPermanent) { if (!foundPermanent) {
foundPermanent = true; foundPermanent = true;
switch(faceDownType) { switch(faceDownType) {

View file

@ -79,7 +79,6 @@ public class ManifestEffect extends OneShotEffect {
newSource.setWorksFaceDown(true); newSource.setWorksFaceDown(true);
List<Card> cards = controller.getLibrary().getTopCards(game, amount); List<Card> cards = controller.getLibrary().getTopCards(game, amount);
for (Card card: cards) { for (Card card: cards) {
card.setFaceDown(true);
ManaCosts manaCosts = null; ManaCosts manaCosts = null;
if (card.getCardType().contains(CardType.CREATURE)) { if (card.getCardType().contains(CardType.CREATURE)) {
manaCosts = card.getSpellAbility().getManaCosts(); manaCosts = card.getSpellAbility().getManaCosts();
@ -89,7 +88,7 @@ public class ManifestEffect extends OneShotEffect {
} }
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game); MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId()); controller.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true);
Permanent permanent = game.getPermanent(card.getId()); Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) { if (permanent != null) {
permanent.setManifested(true); permanent.setManifested(true);

View file

@ -83,7 +83,6 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
newSource.setWorksFaceDown(true); newSource.setWorksFaceDown(true);
List<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount); List<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount);
for (Card card: cards) { for (Card card: cards) {
card.setFaceDown(true);
ManaCosts manaCosts = null; ManaCosts manaCosts = null;
if (card.getCardType().contains(CardType.CREATURE)) { if (card.getCardType().contains(CardType.CREATURE)) {
manaCosts = card.getSpellAbility().getManaCosts(); manaCosts = card.getSpellAbility().getManaCosts();
@ -93,7 +92,7 @@ public class ManifestTargetPlayerEffect extends OneShotEffect {
} }
MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game); MageObjectReference objectReference= new MageObjectReference(card.getId(), card.getZoneChangeCounter() +1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource); game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId()); targetPlayer.putOntoBattlefieldWithInfo(card, game, Zone.LIBRARY, newSource.getSourceId(), false, true);
Permanent permanent = game.getPermanent(card.getId()); Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) { if (permanent != null) {
permanent.setManifested(true); permanent.setManifested(true);

View file

@ -130,10 +130,10 @@ class HideawayExileEffect extends OneShotEffect {
Card card = cards.get(target1.getFirstTarget(), game); Card card = cards.get(target1.getFirstTarget(), game);
if (card != null) { if (card != null) {
cards.remove(card); cards.remove(card);
card.setFaceDown(true);
card.moveToExile(CardUtil.getCardExileZoneId(game, source), card.moveToExile(CardUtil.getCardExileZoneId(game, source),
new StringBuilder("Hideaway (").append(hideawaySource.getName()).append(")").toString(), new StringBuilder("Hideaway (").append(hideawaySource.getName()).append(")").toString(),
source.getSourceId(), game); source.getSourceId(), game);
card.setFaceDown(true, game);
} }
target1.clearChosen(); target1.clearChosen();
} }

View file

@ -122,7 +122,6 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
super(Zone.HAND, null); super(Zone.HAND, null);
this.morphCosts = morphCosts; this.morphCosts = morphCosts;
this.megamorph = megamorph; this.megamorph = megamorph;
card.setMorphCard(true);
this.setWorksFaceDown(true); this.setWorksFaceDown(true);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (megamorph) { if (megamorph) {
@ -203,7 +202,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
Spell spell = game.getStack().getSpell(ability.getId()); Spell spell = game.getStack().getSpell(ability.getId());
if (player != null && spell != null) { if (player != null && spell != null) {
this.resetMorph(); this.resetMorph();
spell.setFaceDown(true); // so only the back is visible spell.setFaceDown(true, game); // so only the back is visible
if (alternateCosts.canPay(ability, sourceId, controllerId, game)) { if (alternateCosts.canPay(ability, sourceId, controllerId, game)) {
if (player.chooseUse(Outcome.Benefit, new StringBuilder("Cast this card as a 2/2 face-down creature for ").append(getCosts().getText()).append(" ?").toString(), game)) { if (player.chooseUse(Outcome.Benefit, new StringBuilder("Cast this card as a 2/2 face-down creature for ").append(getCosts().getText()).append(" ?").toString(), game)) {
activateMorph(game); activateMorph(game);
@ -226,7 +225,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
spellColor.setWhite(false); spellColor.setWhite(false);
spellColor.setBlue(false); spellColor.setBlue(false);
} else { } else {
spell.setFaceDown(false); spell.setFaceDown(false, game);
} }
} }
} }

View file

@ -54,8 +54,8 @@ public interface Card extends MageObject {
List<String> getRules(Game game); // gets card rules + in game modifications List<String> getRules(Game game); // gets card rules + in game modifications
String getExpansionSetCode(); String getExpansionSetCode();
String getTokenSetCode(); String getTokenSetCode();
void setFaceDown(boolean value); void setFaceDown(boolean value, Game game);
boolean isFaceDown(); boolean isFaceDown(Game game);
boolean turnFaceUp(Game game, UUID playerId); boolean turnFaceUp(Game game, UUID playerId);
boolean turnFaceDown(Game game, UUID playerId); boolean turnFaceDown(Game game, UUID playerId);
boolean isFlipCard(); boolean isFlipCard();
@ -106,12 +106,12 @@ public interface Card extends MageObject {
boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId); boolean cast(Game game, Zone fromZone, SpellAbility ability, UUID controllerId);
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId); boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId);
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped); boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped);
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects); boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown);
boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, ArrayList<UUID> appliedEffects);
List<Mana> getMana(); List<Mana> getMana();
void build(); void build();
void setUsesVariousArt(boolean usesVariousArt);
/** /**
* *
* @return true if there exists various art images for this card * @return true if there exists various art images for this card
@ -127,9 +127,6 @@ public interface Card extends MageObject {
void removeCounters(String name, int amount, Game game); void removeCounters(String name, int amount, Game game);
void removeCounters(Counter counter, Game game); void removeCounters(Counter counter, Game game);
void setMorphCard(boolean morphCard);
boolean isMorphCard();
@Override @Override
Card copy(); Card copy();

View file

@ -39,6 +39,7 @@ import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.PlayLandAbility; import mage.abilities.PlayLandAbility;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.keyword.MorphAbility;
import mage.abilities.mana.ManaAbility; import mage.abilities.mana.ManaAbility;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.ColoredManaSymbol; import mage.constants.ColoredManaSymbol;
@ -78,7 +79,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
protected String expansionSetCode; protected String expansionSetCode;
protected String tokenSetCode; protected String tokenSetCode;
protected Rarity rarity; protected Rarity rarity;
protected boolean faceDown;
protected boolean canTransform; protected boolean canTransform;
protected Card secondSideCard; protected Card secondSideCard;
protected boolean nightCard; protected boolean nightCard;
@ -143,7 +143,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
cardNumber = card.cardNumber; cardNumber = card.cardNumber;
expansionSetCode = card.expansionSetCode; expansionSetCode = card.expansionSetCode;
rarity = card.rarity; rarity = card.rarity;
faceDown = card.faceDown;
canTransform = card.canTransform; canTransform = card.canTransform;
if (canTransform) { if (canTransform) {
@ -155,7 +154,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
flipCardName = card.flipCardName; flipCardName = card.flipCardName;
splitCard = card.splitCard; splitCard = card.splitCard;
usesVariousArt = card.usesVariousArt; usesVariousArt = card.usesVariousArt;
morphCard = card.isMorphCard();
} }
@Override @Override
@ -341,10 +339,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
game.rememberLKI(objectId, event.getFromZone(), this); game.rememberLKI(objectId, event.getFromZone(), this);
} }
if (isFaceDown() && !event.getToZone().equals(Zone.BATTLEFIELD)) { // to battlefield is possible because of Morph setFaceDown(false, game);
setFaceDown(false);
game.getCard(this.getId()).setFaceDown(false);
}
updateZoneChangeCounter(); updateZoneChangeCounter();
switch (event.getToZone()) { switch (event.getToZone()) {
case GRAVEYARD: case GRAVEYARD:
@ -477,6 +472,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
} else { } else {
game.getExile().createZone(exileId, name).add(this); game.getExile().createZone(exileId, name).add(this);
} }
setFaceDown(false, game);
updateZoneChangeCounter(); updateZoneChangeCounter();
game.setZone(objectId, event.getToZone()); game.setZone(objectId, event.getToZone());
game.addSimultaneousEvent(event); game.addSimultaneousEvent(event);
@ -487,17 +483,21 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override @Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId) { public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId) {
return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, false); return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, false, false, null);
} }
@Override @Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped){ public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped){
return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, tapped, null); return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, tapped, false, null);
}
@Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown){
return this.putOntoBattlefield(game, fromZone, sourceId, controllerId, tapped, facedown, null);
} }
@Override @Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects){ public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, ArrayList<UUID> appliedEffects){
ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, controllerId, fromZone, Zone.BATTLEFIELD, appliedEffects, tapped); ZoneChangeEvent event = new ZoneChangeEvent(this.objectId, sourceId, controllerId, fromZone, Zone.BATTLEFIELD, appliedEffects, tapped);
if (!game.replaceEvent(event)) { if (!game.replaceEvent(event)) {
if (fromZone != null) { if (fromZone != null) {
@ -514,10 +514,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
break; break;
case EXILED: case EXILED:
game.getExile().removeCard(this, game); game.getExile().removeCard(this, game);
if (isFaceDown()) {
// 110.6b Permanents enter the battlefield untapped, unflipped, face up, and phased in unless a spell or ability says otherwise.
this.setFaceDown(false);
}
removed = true; removed = true;
break; break;
case COMMAND: case COMMAND:
@ -543,6 +539,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
setZone(Zone.BATTLEFIELD, game); setZone(Zone.BATTLEFIELD, game);
game.setScopeRelevant(true); game.setScopeRelevant(true);
permanent.setTapped(tapped); permanent.setTapped(tapped);
permanent.setFaceDown(facedown, game);
permanent.entersBattlefield(sourceId, game, event.getFromZone(), true); permanent.entersBattlefield(sourceId, game, event.getFromZone(), true);
game.setScopeRelevant(false); game.setScopeRelevant(false);
game.applyEffects(); game.applyEffects();
@ -553,21 +550,20 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
} }
@Override @Override
public void setFaceDown(boolean value) { public void setFaceDown(boolean value, Game game) {
faceDown = value; game.getState().getCardState(objectId).setFaceDown(value);
} }
@Override @Override
public boolean isFaceDown() { public boolean isFaceDown(Game game) {
return faceDown; return game.getState().getCardState(objectId).isFaceDown();
} }
@Override @Override
public boolean turnFaceUp(Game game, UUID playerId) { public boolean turnFaceUp(Game game, UUID playerId) {
GameEvent event = GameEvent.getEvent(GameEvent.EventType.TURNFACEUP, getId(), playerId); GameEvent event = GameEvent.getEvent(GameEvent.EventType.TURNFACEUP, getId(), playerId);
if (!game.replaceEvent(event)) { if (!game.replaceEvent(event)) {
setFaceDown(false); setFaceDown(false, game);
game.getCard(objectId).setFaceDown(false); // Another instance?
for (Ability ability :abilities) { // abilities that were set to not visible face down must be set to visible again for (Ability ability :abilities) { // abilities that were set to not visible face down must be set to visible again
if (ability.getWorksFaceDown() && !ability.getRuleVisible()) { if (ability.getWorksFaceDown() && !ability.getRuleVisible()) {
ability.setRuleVisible(true); ability.setRuleVisible(true);
@ -583,8 +579,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
public boolean turnFaceDown(Game game, UUID playerId) { public boolean turnFaceDown(Game game, UUID playerId) {
GameEvent event = GameEvent.getEvent(GameEvent.EventType.TURNFACEDOWN, getId(), playerId); GameEvent event = GameEvent.getEvent(GameEvent.EventType.TURNFACEDOWN, getId(), playerId);
if (!game.replaceEvent(event)) { if (!game.replaceEvent(event)) {
setFaceDown(true); setFaceDown(true, game);
game.getCard(objectId).setFaceDown(true); // Another instance?
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TURNEDFACEDOWN, getId(), playerId)); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.TURNEDFACEDOWN, getId(), playerId));
return true; return true;
} }
@ -638,11 +633,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
@Override @Override
public void build() {} public void build() {}
@Override
public void setUsesVariousArt(boolean usesVariousArt) {
this.usesVariousArt = usesVariousArt;
}
@Override @Override
public boolean getUsesVariousArt() { public boolean getUsesVariousArt() {
return usesVariousArt; return usesVariousArt;
@ -713,21 +703,11 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
removeCounters(counter.getName(), counter.getCount(), game); removeCounters(counter.getName(), counter.getCount(), game);
} }
@Override
public void setMorphCard(boolean morphCard) {
this.morphCard = morphCard;
}
@Override
public boolean isMorphCard() {
return morphCard;
}
@Override @Override
public String getLogName() { public String getLogName() {
if (this.isFaceDown()) { // if (this.isFaceDown()) {
return "facedown card"; // return "facedown card";
} // }
return name; return name;
} }

View file

@ -39,7 +39,7 @@ public class FaceDownPredicate implements Predicate<Card> {
@Override @Override
public boolean apply(Card input, Game game) { public boolean apply(Card input, Game game) {
return input.isFaceDown(); return input.isFaceDown(game);
} }
@Override @Override

View file

@ -9,6 +9,7 @@ import mage.counters.Counters;
*/ */
public class CardState { public class CardState {
protected boolean faceDown;
protected Map<String, String> info; protected Map<String, String> info;
protected Counters counters; protected Counters counters;
@ -19,6 +20,7 @@ public class CardState {
} }
public CardState(final CardState state) { public CardState(final CardState state) {
this.faceDown = state.faceDown;
if (state.info != null) { if (state.info != null) {
info = new HashMap<>(); info = new HashMap<>();
info.putAll(state.info); info.putAll(state.info);
@ -30,6 +32,14 @@ public class CardState {
return new CardState(this); return new CardState(this);
} }
public void setFaceDown(boolean value) {
faceDown = value;
}
public boolean isFaceDown() {
return faceDown;
}
public Counters getCounters() { public Counters getCounters() {
return counters; return counters;
} }

View file

@ -127,8 +127,8 @@ public abstract class GameCommanderImpl extends GameImpl {
if(!mulliganedCards.containsKey(playerId)){ if(!mulliganedCards.containsKey(playerId)){
mulliganedCards.put(playerId, new CardsImpl()); mulliganedCards.put(playerId, new CardsImpl());
} }
card.setFaceDown(true);
card.moveToExile(null, "", null, this); card.moveToExile(null, "", null, this);
card.setFaceDown(true, this);
mulliganedCards.get(playerId).add(card); mulliganedCards.get(playerId).add(card);
} }
} }
@ -165,8 +165,8 @@ public abstract class GameCommanderImpl extends GameImpl {
if(player != null && mulliganedCards.containsKey(playerId)){ if(player != null && mulliganedCards.containsKey(playerId)){
for(Card card : mulliganedCards.get(playerId).getCards(this)){ for(Card card : mulliganedCards.get(playerId).getCards(this)){
if(card != null){ if(card != null){
card.setFaceDown(false);
card.moveToZone(Zone.LIBRARY, null, this, false); card.moveToZone(Zone.LIBRARY, null, this, false);
card.setFaceDown(false, this);
} }
} }
if(mulliganedCards.get(playerId).size() > 0){ if(mulliganedCards.get(playerId).size() > 0){

View file

@ -277,7 +277,6 @@ public abstract class GameImpl implements Game, Serializable {
card = ((PermanentCard)card).getCard(); card = ((PermanentCard)card).getCard();
} }
card.setOwnerId(ownerId); card.setOwnerId(ownerId);
card.setFaceDown(false); // can be set face down from previous game
gameCards.put(card.getId(), card); gameCards.put(card.getId(), card);
state.addCard(card); state.addCard(card);
if (card.isSplitCard()) { if (card.isSplitCard()) {

View file

@ -88,7 +88,16 @@ public class PermanentCard extends PermanentImpl {
protected void copyFromCard(Card card) { protected void copyFromCard(Card card) {
this.name = card.getName(); this.name = card.getName();
this.abilities.clear(); this.abilities.clear();
this.abilities.addAll(card.getAbilities().copy()); if (this.faceDown) {
for (Ability ability: card.getAbilities()) {
if (ability.getWorksFaceDown()) {
this.abilities.add(ability.copy());
}
}
}
else {
this.abilities = card.getAbilities().copy();
}
this.abilities.setControllerId(this.controllerId); this.abilities.setControllerId(this.controllerId);
this.cardType.clear(); this.cardType.clear();
this.cardType.addAll(card.getCardType()); this.cardType.addAll(card.getCardType());
@ -116,8 +125,6 @@ public class PermanentCard extends PermanentImpl {
} }
this.flipCard = card.isFlipCard(); this.flipCard = card.isFlipCard();
this.flipCardName = card.getFlipCardName(); this.flipCardName = card.getFlipCardName();
this.faceDown = card.isFaceDown();
this.morphCard = card.isMorphCard();
} }
public Card getCard() { public Card getCard() {
@ -134,12 +141,6 @@ public class PermanentCard extends PermanentImpl {
Player controller = game.getPlayer(controllerId); Player controller = game.getPlayer(controllerId);
if (controller != null && controller.removeFromBattlefield(this, game)) { if (controller != null && controller.removeFromBattlefield(this, game)) {
Card originalCard = game.getCard(this.getId()); Card originalCard = game.getCard(this.getId());
if (isFaceDown()) {
setFaceDown(false);
if (originalCard != null) {
originalCard.setFaceDown(false); //TODO: Do this in a better way
}
}
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects); ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, controllerId, fromZone, toZone, appliedEffects);
if (!game.replaceEvent(event)) { if (!game.replaceEvent(event)) {
Player owner = game.getPlayer(ownerId); Player owner = game.getPlayer(ownerId);
@ -190,10 +191,6 @@ public class PermanentCard extends PermanentImpl {
@Override @Override
public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) { public boolean moveToExile(UUID exileId, String name, UUID sourceId, Game game, ArrayList<UUID> appliedEffects) {
Zone fromZone = game.getState().getZone(objectId); Zone fromZone = game.getState().getZone(objectId);
if (isFaceDown() && fromZone.equals(Zone.BATTLEFIELD) && (isMorphed() || isManifested())) {
setFaceDown(false);
game.getCard(this.getId()).setFaceDown(false); //TODO: Do this in a better way
}
Player controller = game.getPlayer(controllerId); Player controller = game.getPlayer(controllerId);
if (controller != null && controller.removeFromBattlefield(this, game)) { if (controller != null && controller.removeFromBattlefield(this, game)) {
ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects); ZoneChangeEvent event = new ZoneChangeEvent(this, sourceId, ownerId, fromZone, Zone.EXILED, appliedEffects);
@ -228,16 +225,6 @@ public class PermanentCard extends PermanentImpl {
if (super.turnFaceUp(game, playerId)) { if (super.turnFaceUp(game, playerId)) {
setManifested(false); setManifested(false);
setMorphed(false); setMorphed(false);
card.setFaceDown(false);
return true;
}
return false;
}
@Override
public boolean turnFaceDown(Game game, UUID playerId) {
if (super.turnFaceDown(game, playerId)) {
card.setFaceDown(true);
return true; return true;
} }
return false; return false;
@ -258,17 +245,9 @@ public class PermanentCard extends PermanentImpl {
card.adjustChoices(ability, game); card.adjustChoices(ability, game);
} }
@Override
public void setFaceDown(boolean value) {
super.setFaceDown(value);
if (card != null) {
card.setFaceDown(value);
}
}
@Override @Override
public ManaCosts<ManaCost> getManaCost() { public ManaCosts<ManaCost> getManaCost() {
if (isFaceDown()) { // face down permanent has always {0} mana costs if (faceDown) { // face down permanent has always {0} mana costs
manaCost.clear(); manaCost.clear();
return manaCost; return manaCost;
} }

View file

@ -93,6 +93,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
protected boolean controlledFromStartOfControllerTurn; protected boolean controlledFromStartOfControllerTurn;
protected int turnsOnBattlefield; protected int turnsOnBattlefield;
protected boolean phasedIn = true; protected boolean phasedIn = true;
protected boolean faceDown;
protected boolean attacking; protected boolean attacking;
protected int blocking; protected int blocking;
// number of creatures the permanent can block // number of creatures the permanent can block
@ -139,6 +140,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
this.controlledFromStartOfControllerTurn = permanent.controlledFromStartOfControllerTurn; this.controlledFromStartOfControllerTurn = permanent.controlledFromStartOfControllerTurn;
this.turnsOnBattlefield = permanent.turnsOnBattlefield; this.turnsOnBattlefield = permanent.turnsOnBattlefield;
this.phasedIn = permanent.phasedIn; this.phasedIn = permanent.phasedIn;
this.faceDown = permanent.faceDown;
this.attacking = permanent.attacking; this.attacking = permanent.attacking;
this.blocking = permanent.blocking; this.blocking = permanent.blocking;
this.maxBlocks = permanent.maxBlocks; this.maxBlocks = permanent.maxBlocks;
@ -431,6 +433,16 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
return false; return false;
} }
@Override
public void setFaceDown(boolean value, Game game) {
this.faceDown = value;
}
@Override
public boolean isFaceDown(Game game) {
return faceDown;
}
@Override @Override
public boolean isFlipped() { public boolean isFlipped() {
return flipped; return flipped;
@ -838,7 +850,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override @Override
public void entersBattlefield(UUID sourceId, Game game, Zone fromZone, boolean fireEvent) { public void entersBattlefield(UUID sourceId, Game game, Zone fromZone, boolean fireEvent) {
controlledFromStartOfControllerTurn = false; controlledFromStartOfControllerTurn = false;
if (this.isFaceDown()) { if (this.isFaceDown(game)) {
// remove some attributes here, bceause first apply effects comes later otherwise abilities (e.g. color related) will unintended trigger // remove some attributes here, bceause first apply effects comes later otherwise abilities (e.g. color related) will unintended trigger
MorphAbility.setPermanentToFaceDownCreature(this); MorphAbility.setPermanentToFaceDownCreature(this);
} }
@ -1226,7 +1238,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override @Override
public String getLogName() { public String getLogName() {
if (name.isEmpty()) { if (name.isEmpty()) {
if (isFaceDown()) { if (faceDown) {
return "face down creature"; return "face down creature";
} else { } else {
return "a creature without name"; return "a creature without name";

View file

@ -267,10 +267,7 @@ public class Spell implements StackObject, Card {
} }
} else { } else {
updateOptionalCosts(0); updateOptionalCosts(0);
if (isFaceDown()) { result = card.putOntoBattlefield(game, fromZone, ability.getSourceId(), controllerId, false, faceDown);
card.setFaceDown(true);
}
result = card.putOntoBattlefield(game, fromZone, ability.getSourceId(), controllerId);
return result; return result;
} }
} }
@ -628,7 +625,7 @@ public class Spell implements StackObject, Card {
@Override @Override
public int getConvertedManaCost() { public int getConvertedManaCost() {
int cmc = 0; int cmc = 0;
if (this.isMorphCard() && this.isFaceDown()) { if (faceDown) {
return 0; return 0;
} }
for (Ability spellAbility: spellAbilities) { for (Ability spellAbility: spellAbilities) {
@ -717,24 +714,24 @@ public class Spell implements StackObject, Card {
} }
@Override @Override
public void setFaceDown(boolean value) { public void setFaceDown(boolean value, Game game) {
faceDown = value; faceDown = value;
} }
@Override @Override
public boolean turnFaceUp(Game game, UUID playerId) { public boolean turnFaceUp(Game game, UUID playerId) {
setFaceDown(false); setFaceDown(false, game);
return true; return true;
} }
@Override @Override
public boolean turnFaceDown(Game game, UUID playerId) { public boolean turnFaceDown(Game game, UUID playerId) {
setFaceDown(true); setFaceDown(true, game);
return true; return true;
} }
@Override @Override
public boolean isFaceDown() { public boolean isFaceDown(Game game) {
return faceDown; return faceDown;
} }
@ -855,7 +852,12 @@ public class Spell implements StackObject, Card {
} }
@Override @Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, ArrayList<UUID> appliedEffects) { public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean putOntoBattlefield(Game game, Zone fromZone, UUID sourceId, UUID controllerId, boolean tapped, boolean facedown, ArrayList<UUID> appliedEffects) {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@ -869,11 +871,6 @@ public class Spell implements StackObject, Card {
return card.getUsesVariousArt(); return card.getUsesVariousArt();
} }
@Override
public void setUsesVariousArt(boolean usesVariousArt) {
card.setUsesVariousArt(usesVariousArt);
}
@Override @Override
public List<Mana> getMana() { public List<Mana> getMana() {
return card.getMana(); return card.getMana();
@ -973,16 +970,6 @@ public class Spell implements StackObject, Card {
return card; return card;
} }
@Override
public void setMorphCard(boolean morphCard) {
throw new UnsupportedOperationException("Not supported");
}
@Override
public boolean isMorphCard() {
return card.isMorphCard();
}
@Override @Override
public Card getMainCard() { public Card getMainCard() {
return card.getMainCard(); return card.getMainCard();

View file

@ -498,6 +498,19 @@ public interface Player extends MageItem, Copyable<Player> {
* @return * @return
*/ */
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped); boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped);
/**
* Uses putOntoBattlefield and posts also a info message about in the game log
*
* @param card
* @param game
* @param fromZone
* @param sourceId
* @param tapped the card enters the battlefield tapped
* @param facedown the card enters the battlefield facedown
* @return
*/
boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped, boolean facedown);
/** /**
* Checks if the playerToCheckId is from an opponent in range * Checks if the playerToCheckId is from an opponent in range

View file

@ -2835,13 +2835,18 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) { public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId) {
return this.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, false); return this.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, false, false);
} }
@Override @Override
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped) { public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped) {
return this.putOntoBattlefieldWithInfo(card, game, fromZone, sourceId, tapped, false);
}
@Override
public boolean putOntoBattlefieldWithInfo(Card card, Game game, Zone fromZone, UUID sourceId, boolean tapped, boolean facedown) {
boolean result = false; boolean result = false;
if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped)) { if (card.putOntoBattlefield(game, fromZone, sourceId, this.getId(), tapped, facedown)) {
game.informPlayers(new StringBuilder(this.getName()) game.informPlayers(new StringBuilder(this.getName())
.append(" puts ").append(card.getLogName()) .append(" puts ").append(card.getLogName())
.append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ") .append(" from ").append(fromZone.toString().toLowerCase(Locale.ENGLISH)).append(" ")