Merge remote-tracking branch 'origin/master'

This commit is contained in:
Oleg Agafonov 2019-05-01 12:49:44 +04:00
commit abfb67eea4
2 changed files with 64 additions and 12 deletions

View file

@ -23,6 +23,7 @@ import mage.players.Player;
import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
import mage.abilities.costs.Cost;
/**
* @author jeffwadsworth
@ -98,9 +99,14 @@ class BolassCitadelPlayTheTopCardEffect extends AsThoughEffectImpl {
Player controller = game.getPlayer(cardOnTop.getOwnerId());
if (controller != null
&& cardOnTop.equals(controller.getLibrary().getFromTop(game))) {
// add the life cost first
PayLifeCost cost = new PayLifeCost(cardOnTop.getManaCost().convertedManaCost());
Costs costs = new CostsImpl();
costs.add(cost);
// check for additional costs that must be paid
for (Cost additionalCost : cardOnTop.getSpellAbility().getCosts()) {
costs.add(additionalCost);
}
controller.setCastSourceIdWithAlternateMana(cardOnTop.getId(), null, costs);
return true;
}

View file

@ -23,15 +23,17 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.UginTheIneffableToken;
import mage.players.Player;
import mage.target.TargetPermanent;
import mage.target.targetpointer.FixedTarget;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.effects.AsThoughEffectImpl;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import static mage.constants.Outcome.Benefit;
@ -83,9 +85,9 @@ class UginTheIneffableEffect extends OneShotEffect {
UginTheIneffableEffect() {
super(Benefit);
staticText = "Exile the top card of your library face down and look at it. " +
"Create a 2/2 colorless Spirit creature token. When that token leaves the battlefield, " +
"put the exiled card into your hand.";
staticText = "Exile the top card of your library face down and look at it. "
+ "Create a 2/2 colorless Spirit creature token. When that token leaves the battlefield, "
+ "put the exiled card into your hand.";
}
private UginTheIneffableEffect(final UginTheIneffableEffect effect) {
@ -108,15 +110,27 @@ class UginTheIneffableEffect extends OneShotEffect {
player.lookAtCards(sourcePermanent.getIdName(), card, game);
player.moveCards(card, Zone.EXILED, source, game);
card.turnFaceDown(game, source.getControllerId());
Token token = new UginTheIneffableToken();
token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId());
Set<MageObjectReference> tokenObjs = new HashSet<>();
for (UUID tokenId : token.getLastAddedTokenIds()) {
tokenObjs.add(new MageObjectReference(tokenId, game));
CreateTokenEffect effect = new CreateTokenEffect(new UginTheIneffableToken());
effect.apply(game, source);
for (UUID addedTokenId : effect.getLastAddedTokenIds()) {
// display referenced exiled face-down card on token
SimpleStaticAbility sa = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("Referenced object: " + card.getIdName()));
GainAbilityTargetEffect gainAbilityEffect = new GainAbilityTargetEffect(sa, Duration.WhileOnBattlefield);
gainAbilityEffect.setTargetPointer(new FixedTarget(addedTokenId));
game.addEffect(gainAbilityEffect, source);
// look at face-down card in exile
UginTheIneffableLookAtFaceDownEffect lookAtEffect = new UginTheIneffableLookAtFaceDownEffect();
lookAtEffect.setTargetPointer(new FixedTarget(card.getId()));
game.addEffect(lookAtEffect, source);
tokenObjs.add(new MageObjectReference(addedTokenId, game));
game.addDelayedTriggeredAbility(new UginTheIneffableDelayedTriggeredAbility(
tokenObjs, new MageObjectReference(card, game)
), source);
}
game.addDelayedTriggeredAbility(new UginTheIneffableDelayedTriggeredAbility(
tokenObjs, new MageObjectReference(card, game)
), source);
return true;
}
}
@ -167,3 +181,35 @@ class UginTheIneffableDelayedTriggeredAbility extends DelayedTriggeredAbility {
return "When this token leaves the battlefield, put the exiled card into your hand.";
}
}
class UginTheIneffableLookAtFaceDownEffect extends AsThoughEffectImpl {
UginTheIneffableLookAtFaceDownEffect() {
super(AsThoughEffectType.LOOK_AT_FACE_DOWN, Duration.EndOfGame, Outcome.Benefit);
}
private UginTheIneffableLookAtFaceDownEffect(final UginTheIneffableLookAtFaceDownEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public UginTheIneffableLookAtFaceDownEffect copy() {
return new UginTheIneffableLookAtFaceDownEffect(this);
}
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
UUID cardId = getTargetPointer().getFirst(game, source);
if (cardId == null) {
this.discard();
}
return affectedControllerId.equals(source.getControllerId())
&& objectId.equals(cardId)
&& game.getState().getExile().containsId(cardId, game);
}
}