Merge pull request #2642 from HCrescent/master

Shared Fate: added Look at face down effect and fixed play from exile…
This commit is contained in:
LevelX2 2016-11-30 11:07:07 +01:00 committed by GitHub
commit d2eaf1e2d0

View file

@ -51,7 +51,7 @@ import mage.util.CardUtil;
/** /**
* *
* @author emerald000 * @author emerald000 / HCrescent
*/ */
public class SharedFate extends CardImpl { public class SharedFate extends CardImpl {
@ -63,6 +63,7 @@ public class SharedFate extends CardImpl {
// Each player may look at and play cards he or she exiled with Shared Fate. // Each player may look at and play cards he or she exiled with Shared Fate.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SharedFatePlayEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SharedFatePlayEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SharedFateLookEffect()));
} }
public SharedFate(final SharedFate card) { public SharedFate(final SharedFate card) {
@ -151,16 +152,56 @@ class SharedFatePlayEffect extends AsThoughEffectImpl {
@Override @Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) { public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (game.getState().getZone(objectId).equals(Zone.EXILED)) {
if (sourcePermanent != null) { Player player = game.getPlayer(affectedControllerId);
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game)); Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (exileZone != null) { UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
Card card = exileZone.get(objectId, game); if (exileId != null) {
Player player = game.getPlayer(affectedControllerId); ExileZone exileZone = game.getExile().getExileZone(exileId);
if (card != null && player != null) { if (exileZone != null && exileZone.contains(objectId)) {
player.lookAtCards(card.getName(), card, game); if (player.chooseUse(outcome, "Play " + game.getCard(objectId).getIdName() + "?", source, game)) {
// You already get asked to confirm when casting a spell, but not when playing a land. return true;
return !card.getCardType().contains(CardType.LAND) || player.chooseUse(Outcome.Benefit, "Play " + card.getName() + "?", source, game); }
}
}
}
return false;
}
}
class SharedFateLookEffect extends AsThoughEffectImpl {
public SharedFateLookEffect() {
super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "Each player may look at the cards exiled with {this}";
}
public SharedFateLookEffect(final SharedFateLookEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public SharedFateLookEffect copy() {
return new SharedFateLookEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (game.getState().getZone(objectId).equals(Zone.EXILED)) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
UUID exileId = CardUtil.getExileZoneId(source.getSourceId().toString() + sourcePermanent.getZoneChangeCounter(game) + affectedControllerId.toString(), game);
if (exileId != null) {
ExileZone exileZone = game.getExile().getExileZone(exileId);
if (exileZone != null && exileZone.contains(objectId)) {
Card card = game.getCard(objectId);
if (card != null && game.getState().getZone(objectId) == Zone.EXILED) {
return true;
}
} }
} }
} }