-
Notifications
You must be signed in to change notification settings - Fork 784
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
Kr4u7
wants to merge
1
commit into
magefree:master
Choose a base branch
from
Kr4u7:ACR-implement-Viewpoint-Synchronization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...ities/effects/common/search/SearchLibraryPutOneInHandRestOntoBattlefieldTappedEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
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; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.