use of mage.game.permanent.PermanentCard in project mage by magefree.
the class ShadowKinApplier method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
cards.addAll(player.millCards(3, source, game));
}
}
if (cards.isEmpty()) {
return false;
}
TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE);
target.setNotTarget(true);
controller.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
if (card == null || sourcePermanent == null) {
return true;
}
controller.moveCards(card, Zone.EXILED, source, game);
Permanent blueprint = new PermanentCard(card, source.getControllerId(), game);
blueprint.assignNewId();
CopyApplier applier = new ShadowKinApplier();
applier.apply(game, blueprint, source, sourcePermanent.getId());
CopyEffect copyEffect = new CopyEffect(Duration.Custom, blueprint, sourcePermanent.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
Ability newAbility = source.copy();
copyEffect.init(newAbility, game);
game.addEffect(copyEffect, newAbility);
return true;
}
use of mage.game.permanent.PermanentCard in project mage by magefree.
the class TamiyoCompleatedSageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getFirstTarget());
if (player == null || card == null) {
return false;
}
player.moveCards(card, Zone.EXILED, source, game);
return new CreateTokenCopyTargetEffect().setSavedPermanent(new PermanentCard(card, source.getControllerId(), game)).apply(game, source);
}
use of mage.game.permanent.PermanentCard in project mage by magefree.
the class VolrathTheShapestealerCopyApplier method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent volrathTheShapestealer = game.getPermanent(source.getSourceId());
Permanent newBluePrint = null;
if (controller == null || volrathTheShapestealer == null) {
return false;
}
Card copyFromCard = game.getPermanent(source.getFirstTarget());
if (copyFromCard == null) {
return true;
}
newBluePrint = new PermanentCard(copyFromCard, source.getControllerId(), game);
newBluePrint.assignNewId();
CopyApplier applier = new VolrathTheShapestealerCopyApplier();
applier.apply(game, newBluePrint, source, volrathTheShapestealer.getId());
CopyEffect copyEffect = new CopyEffect(Duration.UntilYourNextTurn, newBluePrint, volrathTheShapestealer.getId());
copyEffect.newId();
copyEffect.setApplier(applier);
Ability newAbility = source.copy();
copyEffect.init(newAbility, game);
game.addEffect(copyEffect, newAbility);
return true;
}
use of mage.game.permanent.PermanentCard in project mage by magefree.
the class ModalDoubleFacesCardsTest method test_Zones_AfterCast_1.
@Test
public void test_Zones_AfterCast_1() {
// Akoum Warrior {5}{R} - creature
// Akoum Teeth - land
addCard(Zone.HAND, playerA, "Akoum Warrior");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 6);
// prepare mdf permanent
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akoum Warrior");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkPermanentCount("prepare", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Akoum Warrior", 1);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN);
execute();
assertAllCommandsUsed();
Card card = currentGame.getState().getBattlefield().getAllPermanents().stream().filter(p -> CardUtil.haveSameNames(p, "Akoum Warrior", currentGame)).findFirst().orElse(null);
Assert.assertNotNull(card);
Assert.assertEquals("permanent card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(card.getId()));
Assert.assertEquals("main permanent card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(card.getMainCard().getId()));
Assert.assertEquals("half card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(((PermanentCard) card).getCard().getId()));
Assert.assertEquals("main card must be on battlefield", Zone.BATTLEFIELD, currentGame.getState().getZone(((PermanentCard) card).getCard().getMainCard().getId()));
}
use of mage.game.permanent.PermanentCard in project mage by magefree.
the class RevealAndShuffleIntoLibrarySourceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
MageObject sourceObject = source.getSourceObjectIfItStillExists(game);
Player controller = game.getPlayer(source.getControllerId());
if (sourceObject != null && controller != null) {
Player owner = null;
Cards cards = new CardsImpl();
Permanent permanent = null;
if (sourceObject instanceof Spell) {
sourceObject = ((Spell) sourceObject).getCard();
}
if (sourceObject instanceof Permanent) {
permanent = (Permanent) sourceObject;
owner = game.getPlayer(permanent.getOwnerId());
if (sourceObject instanceof PermanentCard) {
cards.add(permanent);
}
} else if (sourceObject instanceof Card) {
owner = game.getPlayer(((Card) sourceObject).getOwnerId());
cards.add((Card) sourceObject);
}
if (owner != null) {
Zone fromZone = game.getState().getZone(sourceObject.getId());
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
}
if (permanent != null) {
controller.moveCardToLibraryWithInfo(permanent, source, game, fromZone, true, true);
} else {
controller.moveCardToLibraryWithInfo((Card) sourceObject, source, game, fromZone, true, true);
}
if (!cards.isEmpty()) {
controller.shuffleLibrary(source, game);
}
}
return true;
}
return false;
}
Aggregations