Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACR] Add Viewpoint Synchronization #13068

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions Mage.Sets/src/mage/cards/v/ViewpointSynchronization.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package mage.cards.v;

import java.util.UUID;

import mage.abilities.effects.common.search.SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect;
import mage.abilities.keyword.FreerunningAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.StaticFilters;
import mage.target.common.TargetCardInLibrary;

/**
*
* @author Kr4u7
*/
public final class ViewpointSynchronization extends CardImpl {

public ViewpointSynchronization(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{G}");


// Freerunning {2}{G}
this.addAbility(new FreerunningAbility("{2}{G}"));

// Search your library for up to three basic land cards and reveal them. Put two of them onto the battlefield tapped and the other into your hand, then shuffle.
this.getSpellAbility().addEffect(new SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect(
new TargetCardInLibrary(0, 3, StaticFilters.FILTER_CARD_BASIC_LANDS)));
}

private ViewpointSynchronization(final ViewpointSynchronization card) {
super(card);
}

@Override
public ViewpointSynchronization copy() {
return new ViewpointSynchronization(this);
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/AssassinsCreed.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private AssassinsCreed() {
cards.add(new SetCardInfo("The Spear of Leonidas", 38, Rarity.RARE, mage.cards.t.TheSpearOfLeonidas.class));
cards.add(new SetCardInfo("Towering Viewpoint", 77, Rarity.UNCOMMON, mage.cards.t.ToweringViewpoint.class));
cards.add(new SetCardInfo("Tranquilize", 284, Rarity.COMMON, mage.cards.t.Tranquilize.class));
cards.add(new SetCardInfo("Viewpoint Synchronization", 43, Rarity.UNCOMMON, mage.cards.v.ViewpointSynchronization.class));
cards.add(new SetCardInfo("Waterlogged Grove", 116, Rarity.RARE, mage.cards.w.WaterloggedGrove.class));
cards.add(new SetCardInfo("Yggdrasil, Rebirth Engine", 78, Rarity.MYTHIC, mage.cards.y.YggdrasilRebirthEngine.class));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package mage.abilities.effects.common.search;

import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.SearchEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;

/**
* @author Kr4u7
*/
public class SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect extends SearchEffect {

private static final FilterCard filter = new FilterCard("card to put on the battlefield tapped");

public SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect(TargetCardInLibrary target) {
super(target, Outcome.PutLandInPlay);
staticText = "search your library for " + target.getDescription() +
", reveal those cards, put two onto the battlefield tapped and the other into your hand, then shuffle";
}

protected SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect(final SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect effect) {
super(effect);
}

@Override
public SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect copy() {
return new SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect(this);
}

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source);
if (controller == null || sourceObject == null) {
return false;
}

if (controller.searchLibrary(target, source, game)) {
if (!target.getTargets().isEmpty()) {
Cards revealed = new CardsImpl(target.getTargets());
controller.revealCards(sourceObject.getIdName(), revealed, game);

if (target.getTargets().size() >= 2) {
Cards cardsToHand = new CardsImpl(revealed);
while (cardsToHand.size()>1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use a while loop. Instead, increase the max number of targets on the TargetCardInLibrary.

I'm not a fan of this code duplication. Instead, consider if you can accomplish it by adding an int numToBattlefield parameter to the common class you copied this from.

TargetCardInLibrary targetCardToBattlefield = new TargetCardInLibrary(filter);
controller.choose(Outcome.PutLandInPlay, revealed, targetCardToBattlefield, source, game);

Card cardToBattlefield = revealed.get(targetCardToBattlefield.getFirstTarget(), game);

if (cardToBattlefield != null) {
controller.moveCards(cardToBattlefield, Zone.BATTLEFIELD, source, game, true, false, false, null);
cardsToHand.remove(cardToBattlefield);
}
}
controller.moveCardsToHandWithInfo(cardsToHand, source, game, true);
} else if (target.getTargets().size() == 1) {
Cards cards = new CardsImpl(revealed);
Card cardToBattlefield = cards.getRandom(game);
if (cardToBattlefield != null) {
controller.moveCards(cardToBattlefield, Zone.BATTLEFIELD, source, game, true, false, false, null);
}
}
}
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
}
Loading