mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
updated searching/shuffling interaction
This commit is contained in:
parent
607b554fac
commit
e03aaee4b6
29 changed files with 270 additions and 170 deletions
|
@ -98,16 +98,18 @@ class InameDeathAspectEffect extends SearchEffect<InameDeathAspectEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false);
|
||||
if (player != null && player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Constants.Zone.GRAVEYARD, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -93,15 +93,16 @@ class PathToExileEffect extends OneShotEffect {
|
|||
if (permanent.moveToZone(Zone.EXILED, source.getId(), game, false)) {
|
||||
if (player.chooseUse(Outcome.PutCardInPlay, "Use Path to Exile effect?", game)) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterBasicLandCard());
|
||||
player.searchLibrary(target, game);
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
if (card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), permanent.getControllerId())) {
|
||||
Permanent land = game.getPermanent(card.getId());
|
||||
if (land != null)
|
||||
land.setTapped(true);
|
||||
}
|
||||
}
|
||||
if (player.searchLibrary(target, game)) {
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
if (card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), permanent.getControllerId())) {
|
||||
Permanent land = game.getPermanent(card.getId());
|
||||
if (land != null)
|
||||
land.setTapped(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -102,12 +102,12 @@ class IncreasingAmbitionEffect extends SearchEffect<IncreasingAmbitionEffect> {
|
|||
else {
|
||||
target = new TargetCardInLibrary();
|
||||
}
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Constants.Zone.HAND, source.getId(), game, false);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null)
|
||||
card.moveToZone(Constants.Zone.HAND, source.getId(), game, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ public class BitterheartWitch extends CardImpl<BitterheartWitch> {
|
|||
this.addAbility(DeathtouchAbility.getInstance());
|
||||
|
||||
// When Bitterheart Witch dies, you may search your library for a Curse card, put it onto the battlefield attached to target player, then shuffle your library.
|
||||
this.addAbility(new DiesTriggeredAbility(new BitterheartWitchEffect(), true));
|
||||
Ability ability = new DiesTriggeredAbility(new BitterheartWitchEffect(), true);
|
||||
ability.addTarget(new TargetPlayer());
|
||||
this.addAbility(ability);
|
||||
|
||||
}
|
||||
|
||||
|
@ -98,25 +100,21 @@ class BitterheartWitchEffect extends OneShotEffect<BitterheartWitchEffect> {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
TargetPlayer target = new TargetPlayer();
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
Player targetPlayer = game.getPlayer(source.getFirstTarget());
|
||||
if (player != null && targetPlayer != null) {
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary(filter);
|
||||
targetCard.setRequired(true);
|
||||
if (player.searchLibrary(targetCard, game)) {
|
||||
Card card = game.getCard(targetCard.getFirstTarget());
|
||||
if (card != null) {
|
||||
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
|
||||
player.chooseTarget(Outcome.Detriment, target, source, game);
|
||||
Player targetPlayer = game.getPlayer(target.getFirstTarget());
|
||||
if (targetPlayer != null) {
|
||||
player.shuffleLibrary(game);
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
||||
return targetPlayer.addAttachment(card.getId(), game);
|
||||
}
|
||||
}
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getSourceId(), source.getControllerId());
|
||||
targetPlayer.addAttachment(card.getId(), game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -106,9 +106,10 @@ class CaravanVigilEffect extends OneShotEffect<CaravanVigilEffect> {
|
|||
}
|
||||
}
|
||||
player.revealCards("Caravan Vigil", cards, game);
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class SeedguideAsh extends CardImpl<SeedguideAsh> {
|
|||
this.power = new MageInt(4);
|
||||
this.toughness = new MageInt(4);
|
||||
// When Seedguide Ash dies, you may search your library for up to three Forest cards and put them onto the battlefield tapped. If you do, shuffle your library.
|
||||
this.addAbility(new DiesTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 3, filter), true, Constants.Outcome.PutLandInPlay), true));
|
||||
this.addAbility(new DiesTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(0, 3, filter), true, false, Constants.Outcome.PutLandInPlay), true));
|
||||
}
|
||||
|
||||
public SeedguideAsh(final SeedguideAsh card) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BorderlandRanger extends CardImpl<BorderlandRanger> {
|
|||
this.color.setGreen(true);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(filter)), true));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(filter), false), true));
|
||||
}
|
||||
|
||||
public BorderlandRanger(final BorderlandRanger card) {
|
||||
|
|
|
@ -95,38 +95,41 @@ class CultivateEffect extends OneShotEffect<CultivateEffect> {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, new FilterBasicLandCard());
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
revealed.add(card);
|
||||
}
|
||||
player.revealCards("Cultivate", revealed, game);
|
||||
if (target.getTargets().size() == 2) {
|
||||
TargetCard target2 = new TargetCard(Zone.PICK, filter);
|
||||
target2.setRequired(true);
|
||||
player.choose(Outcome.Benefit, revealed, target2, game);
|
||||
Card card = revealed.get(target2.getFirstTarget(), game);
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
|
||||
revealed.remove(card);
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null)
|
||||
permanent.setTapped(true);
|
||||
card = revealed.getCards(game).iterator().next();
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
}
|
||||
else if (target.getTargets().size() == 1) {
|
||||
Card card = revealed.getCards(game).iterator().next();
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null)
|
||||
permanent.setTapped(true);
|
||||
}
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
revealed.add(card);
|
||||
}
|
||||
player.revealCards("Cultivate", revealed, game);
|
||||
if (target.getTargets().size() == 2) {
|
||||
TargetCard target2 = new TargetCard(Zone.PICK, filter);
|
||||
target2.setRequired(true);
|
||||
player.choose(Outcome.Benefit, revealed, target2, game);
|
||||
Card card = revealed.get(target2.getFirstTarget(), game);
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
|
||||
revealed.remove(card);
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null)
|
||||
permanent.setTapped(true);
|
||||
card = revealed.getCards(game).iterator().next();
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
}
|
||||
else if (target.getTargets().size() == 1) {
|
||||
Card card = revealed.getCards(game).iterator().next();
|
||||
card.putOntoBattlefield(game, Zone.LIBRARY, source.getId(), source.getControllerId());
|
||||
Permanent permanent = game.getPermanent(card.getId());
|
||||
if (permanent != null)
|
||||
permanent.setTapped(true);
|
||||
}
|
||||
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -104,15 +104,19 @@ class HoardingDragonEffect extends OneShotEffect<HoardingDragonEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null){
|
||||
game.getExile().add(exileId, "Hoarding Dragon exile", card);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
return true;
|
||||
if (player != null) {
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null)
|
||||
card.moveToExile(exileId, "Hoarding Dragon exile", source.getSourceId(), game);
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -133,10 +133,10 @@ class ArachnusSpinnerEffect extends OneShotEffect<ArachnusSpinnerEffect> {
|
|||
if (player.searchLibrary(target, game)) {
|
||||
card = game.getCard(target.getFirstTarget());
|
||||
if (card != null) {
|
||||
player.shuffleLibrary(game);
|
||||
zone = Zone.LIBRARY;
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
if (card != null) {
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
|
|
|
@ -116,12 +116,10 @@ class DistantMemoriesEffect extends OneShotEffect<DistantMemoriesEffect> {
|
|||
} else {
|
||||
player.drawCards(3, game);
|
||||
}
|
||||
} else {
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ class GreenSunsZenithSearchEffect extends OneShotEffect<GreenSunsZenithSearchEff
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null)
|
||||
return false;
|
||||
FilterCard filter = new FilterCard("green creature card with converted mana cost X or less");
|
||||
filter.getColor().setGreen(true);
|
||||
filter.setUseColor(true);
|
||||
|
@ -92,14 +94,14 @@ class GreenSunsZenithSearchEffect extends OneShotEffect<GreenSunsZenithSearchEff
|
|||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId : (List<UUID>) target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
card.putOntoBattlefield(game, Constants.Zone.HAND, source.getId(), source.getControllerId());
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
Card card = player.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null)
|
||||
card.putOntoBattlefield(game, Constants.Zone.HAND, source.getId(), source.getControllerId());
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TreasureMage extends CardImpl<TreasureMage> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
|
||||
SearchEffect effect = new SearchLibraryRevealPutInHandEffect(target);
|
||||
SearchEffect effect = new SearchLibraryRevealPutInHandEffect(target, false);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(effect, true));
|
||||
}
|
||||
|
||||
|
|
|
@ -111,16 +111,18 @@ class BrutalizerExarchEffect1 extends OneShotEffect<BrutalizerExarchEffect1> {
|
|||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterCreatureCard("creature card in your library"));
|
||||
target.setRequired(true);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
Card card = game.getCard(target.getFirstTarget());
|
||||
Card card = player.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
Cards cards = new CardsImpl();
|
||||
cards.add(card);
|
||||
player.revealCards("Brutalizer Exarch", cards, game);
|
||||
player.shuffleLibrary(game);
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
if (card != null)
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public class SilvergladeElemental extends CardImpl<SilvergladeElemental> {
|
|||
this.color.setGreen(true);
|
||||
this.power = new MageInt(4);
|
||||
this.toughness = new MageInt(4);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), false), true));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(filter), false, false), true));
|
||||
}
|
||||
|
||||
public SilvergladeElemental(final SilvergladeElemental card) {
|
||||
|
|
|
@ -90,6 +90,8 @@ class StrataScytheImprintEffect extends OneShotEffect<StrataScytheImprintEffect>
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null)
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard());
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
|
@ -103,8 +105,8 @@ class StrataScytheImprintEffect extends OneShotEffect<StrataScytheImprintEffect>
|
|||
}
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TrinketMage extends CardImpl<TrinketMage> {
|
|||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
|
||||
SearchEffect effect = new SearchLibraryRevealPutInHandEffect(target);
|
||||
SearchEffect effect = new SearchLibraryRevealPutInHandEffect(target, false);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(effect, true));
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class FarhavenElf extends CardImpl<FarhavenElf> {
|
|||
this.toughness = new MageInt(1);
|
||||
|
||||
// When Farhaven Elf enters the battlefield, you may search your library for a basic land card and put it onto the battlefield tapped. If you do, shuffle your library.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(new FilterBasicLandCard()), true), true));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(new FilterBasicLandCard()), true, false), true));
|
||||
}
|
||||
|
||||
public FarhavenElf(final FarhavenElf card) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class RangerOfEos extends CardImpl<RangerOfEos> {
|
|||
this.toughness = new MageInt(2);
|
||||
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, 2, filter);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(target), true));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(target, false), true));
|
||||
}
|
||||
|
||||
public RangerOfEos(final RangerOfEos card) {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CivicWayfinder extends CardImpl<CivicWayfinder> {
|
|||
this.color.setGreen(true);
|
||||
this.power = new MageInt(2);
|
||||
this.toughness = new MageInt(2);
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(new FilterBasicLandCard())), true));
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryRevealPutInHandEffect(new TargetCardInLibrary(new FilterBasicLandCard()), false), true));
|
||||
}
|
||||
|
||||
public CivicWayfinder(final CivicWayfinder card) {
|
||||
|
|
|
@ -120,11 +120,9 @@ class QuestForTheHolyRelicEffect extends OneShotEffect<QuestForTheHolyRelicEffec
|
|||
Permanent permanent = game.getPermanent(targetCreature.getFirstTarget());
|
||||
permanent.addAttachment(equipment.getId(), game);
|
||||
}
|
||||
|
||||
player.shuffleLibrary(game);
|
||||
}
|
||||
}
|
||||
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package org.mage.test.cards.events;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class TestSearchShuffle extends CardTestPlayerBase {
|
||||
|
||||
|
||||
/**
|
||||
* even though Leonin Arbiter prevents searching, the library should still
|
||||
* get shuffled and Cosi's Trickster will still get a counter
|
||||
*/
|
||||
@Test
|
||||
public void testEvent() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Cosi's Trickster");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Leonin Arbiter");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Arid Mesa");
|
||||
|
||||
activateAbility(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "{T}, Pay 1 life");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 19);
|
||||
assertLife(playerB, 20);
|
||||
assertPermanentCount(playerA, "Arid Mesa", 0);
|
||||
assertPermanentCount(playerA, "Mountain", 0);
|
||||
assertPermanentCount(playerA, "Plains", 0);
|
||||
assertCounterCount("Cosi's Trickster", CounterType.P1P1, 1);
|
||||
}
|
||||
}
|
|
@ -57,7 +57,7 @@ public class FetchLandActivatedAbility extends ActivatedAbilityImpl<FetchLandAct
|
|||
filter.getSubtype().addAll(Arrays.asList(subTypes));
|
||||
filter.setScopeSubtype(ComparisonScope.Any);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
addEffect(new SearchLibraryPutInPlayEffect(target, false, Outcome.PutLandInPlay));
|
||||
addEffect(new SearchLibraryPutInPlayEffect(target, false, true, Outcome.PutLandInPlay));
|
||||
}
|
||||
|
||||
public FetchLandActivatedAbility(FetchLandActivatedAbility ability) {
|
||||
|
|
|
@ -48,14 +48,20 @@ import mage.target.common.TargetCardInLibrary;
|
|||
public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutInHandEffect> {
|
||||
|
||||
private boolean revealCards = false;
|
||||
private boolean forceShuffle;
|
||||
|
||||
public SearchLibraryPutInHandEffect(TargetCardInLibrary target) {
|
||||
this(target, false);
|
||||
this(target, false, true);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInHandEffect(TargetCardInLibrary target, boolean revealCards) {
|
||||
this(target, revealCards, true);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInHandEffect(TargetCardInLibrary target, boolean revealCards, boolean forceShuffle) {
|
||||
super(target, Outcome.DrawCard);
|
||||
this.revealCards = revealCards;
|
||||
this.forceShuffle = forceShuffle;
|
||||
setText();
|
||||
}
|
||||
|
||||
|
@ -72,30 +78,35 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
if (revealCards) {
|
||||
cards.add(card);
|
||||
if (player == null)
|
||||
return false;
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null){
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
if (revealCards) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (revealCards) {
|
||||
String name = "Reveal";
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (sourceCard != null) {
|
||||
name = sourceCard.getName();
|
||||
if (revealCards) {
|
||||
String name = "Reveal";
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (sourceCard != null) {
|
||||
name = sourceCard.getName();
|
||||
}
|
||||
player.revealCards(name, cards, game);
|
||||
}
|
||||
player.revealCards(name, cards, game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
// shuffle anyway
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
if (forceShuffle)
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
|
@ -108,7 +119,10 @@ public class SearchLibraryPutInHandEffect extends SearchEffect<SearchLibraryPutI
|
|||
else {
|
||||
sb.append("a ").append(target.getTargetName()).append(revealCards ? ", reveal it, " : "").append(" and put that card into your hand");
|
||||
}
|
||||
sb.append(". Then shuffle your library");
|
||||
if (forceShuffle)
|
||||
sb.append(". Then shuffle your library");
|
||||
else
|
||||
sb.append(". If you do, shuffle your library");
|
||||
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -47,24 +47,35 @@ import mage.target.common.TargetCardInLibrary;
|
|||
public class SearchLibraryPutInPlayEffect extends SearchEffect<SearchLibraryPutInPlayEffect> {
|
||||
|
||||
private boolean tapped;
|
||||
private boolean forceShuffle;
|
||||
|
||||
public SearchLibraryPutInPlayEffect(TargetCardInLibrary target) {
|
||||
this(target, false, Outcome.PutCardInPlay);
|
||||
this(target, false, true, Outcome.PutCardInPlay);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInPlayEffect(TargetCardInLibrary target, boolean tapped) {
|
||||
this(target, tapped, Outcome.PutCardInPlay);
|
||||
this(target, tapped, true, Outcome.PutCardInPlay);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInPlayEffect(TargetCardInLibrary target, boolean tapped, Outcome outcome) {
|
||||
public SearchLibraryPutInPlayEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle) {
|
||||
this(target, tapped, forceShuffle, Outcome.PutCardInPlay);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInPlayEffect(TargetCardInLibrary target, boolean tapped, Outcome outcome) {
|
||||
this(target, tapped, true, outcome);
|
||||
}
|
||||
|
||||
public SearchLibraryPutInPlayEffect(TargetCardInLibrary target, boolean tapped, boolean forceShuffle, Outcome outcome) {
|
||||
super(target, outcome);
|
||||
this.tapped = tapped;
|
||||
this.forceShuffle = forceShuffle;
|
||||
setText();
|
||||
}
|
||||
|
||||
public SearchLibraryPutInPlayEffect(final SearchLibraryPutInPlayEffect effect) {
|
||||
super(effect);
|
||||
this.tapped = effect.tapped;
|
||||
this.forceShuffle = effect.forceShuffle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,6 +86,8 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect<SearchLibraryPutI
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null)
|
||||
return false;
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
|
@ -89,12 +102,12 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect<SearchLibraryPutI
|
|||
}
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
// shuffle anyway
|
||||
player.shuffleLibrary(game);
|
||||
if (forceShuffle)
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -115,7 +128,10 @@ public class SearchLibraryPutInPlayEffect extends SearchEffect<SearchLibraryPutI
|
|||
}
|
||||
if (tapped)
|
||||
sb.append(" tapped");
|
||||
sb.append(". Then shuffle your library");
|
||||
if (forceShuffle)
|
||||
sb.append(". Then shuffle your library");
|
||||
else
|
||||
sb.append(". If you do, shuffle your library");
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,20 +63,24 @@ public class SearchLibraryPutOnLibraryEffect extends SearchEffect<SearchLibraryP
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.searchLibrary(target, game);
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
if (target.getTargets().size() > 0) {
|
||||
if (player == null)
|
||||
return false;
|
||||
if (player.searchLibrary(target, game)) {
|
||||
List<Card> cards = new ArrayList<Card>();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null)
|
||||
cards.add(card);
|
||||
cards.add(card);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
for (Card card: cards) {
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||
}
|
||||
for (Card card: cards) {
|
||||
card.moveToZone(Zone.LIBRARY, source.getId(), game, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
// shuffle anyway
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
|
|
|
@ -47,13 +47,21 @@ import mage.target.common.TargetCardInLibrary;
|
|||
*/
|
||||
public class SearchLibraryRevealPutInHandEffect extends SearchEffect<SearchLibraryRevealPutInHandEffect> {
|
||||
|
||||
public SearchLibraryRevealPutInHandEffect(TargetCardInLibrary target) {
|
||||
boolean forceShuffle;
|
||||
|
||||
public SearchLibraryRevealPutInHandEffect(TargetCardInLibrary target) {
|
||||
this(target, true);
|
||||
}
|
||||
|
||||
public SearchLibraryRevealPutInHandEffect(TargetCardInLibrary target, boolean forceShuffle) {
|
||||
super(target, Outcome.DrawCard);
|
||||
this.forceShuffle = forceShuffle;
|
||||
setText();
|
||||
}
|
||||
|
||||
public SearchLibraryRevealPutInHandEffect(final SearchLibraryRevealPutInHandEffect effect) {
|
||||
super(effect);
|
||||
this.forceShuffle = effect.forceShuffle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,20 +72,26 @@ public class SearchLibraryRevealPutInHandEffect extends SearchEffect<SearchLibra
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
revealed.add(card);
|
||||
}
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
player.revealCards("Search", revealed, game);
|
||||
}
|
||||
return true;
|
||||
if (player == null)
|
||||
return false;
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId: (List<UUID>)target.getTargets()) {
|
||||
Card card = player.getLibrary().getCard(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Zone.HAND, source.getId(), game, false);
|
||||
revealed.add(card);
|
||||
}
|
||||
}
|
||||
player.revealCards("Search", revealed, game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
if (forceShuffle)
|
||||
player.shuffleLibrary(game);
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setText() {
|
||||
|
@ -90,7 +104,10 @@ public class SearchLibraryRevealPutInHandEffect extends SearchEffect<SearchLibra
|
|||
else {
|
||||
sb.append("a ").append(target.getTargetName()).append(", reveal that card, and put it into your hand");
|
||||
}
|
||||
sb.append(", then shuffle your library");
|
||||
if (forceShuffle)
|
||||
sb.append(". Then shuffle your library");
|
||||
else
|
||||
sb.append(". If you do, shuffle your library");
|
||||
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -63,23 +63,24 @@ class TransmuteEffect extends OneShotEffect<TransmuteEffect> {
|
|||
filter.setConvertedManaCost(sourceCard.getManaCost().convertedManaCost());
|
||||
filter.setConvertedManaCostComparison(Filter.ComparisonType.Equal);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
|
||||
player.searchLibrary(target, game);
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Constants.Zone.HAND, source.getId(), game, false);
|
||||
revealed.add(card);
|
||||
if (player.searchLibrary(target, game)) {
|
||||
if (target.getTargets().size() > 0) {
|
||||
Cards revealed = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
card.moveToZone(Constants.Zone.HAND, source.getId(), game, false);
|
||||
revealed.add(card);
|
||||
}
|
||||
}
|
||||
player.revealCards("Search", revealed, game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
player.revealCards("Search", revealed, game);
|
||||
}
|
||||
player.shuffleLibrary(game);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1096,8 +1096,8 @@ public abstract class PlayerImpl<T extends PlayerImpl<T>> implements Player, Ser
|
|||
newTarget = target;
|
||||
if (newTarget.choose(Outcome.Neutral, playerId, null, game)) {
|
||||
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.LIBRARY_SEARCHED, playerId, playerId));
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue