mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 12:49:39 -08:00
- Fixed #5653. Refactored The Tabernacle at Pendrell Vale. It works better in cases where the user leaves the game.
This commit is contained in:
parent
1e40f80e57
commit
167deb812e
2 changed files with 69 additions and 16 deletions
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.cards.k;
|
package mage.cards.k;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
|
@ -16,8 +15,8 @@ import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
import mage.constants.Outcome;
|
||||||
import mage.constants.SubType;
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.common.FilterCreatureCard;
|
import mage.filter.common.FilterCreatureCard;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
|
||||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
@ -74,7 +73,7 @@ class KindredSummonsEffect extends OneShotEffect {
|
||||||
if (subType == null) {
|
if (subType == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FilterCreaturePermanent filterPermanent = new FilterCreaturePermanent("creature you control of the chosen type");
|
FilterControlledCreaturePermanent filterPermanent = new FilterControlledCreaturePermanent("creature you control of the chosen type");
|
||||||
filterPermanent.add(new SubtypePredicate(subType));
|
filterPermanent.add(new SubtypePredicate(subType));
|
||||||
int numberOfCards = game.getBattlefield().countAll(filterPermanent, source.getControllerId(), game);
|
int numberOfCards = game.getBattlefield().countAll(filterPermanent, source.getControllerId(), game);
|
||||||
Cards revealed = new CardsImpl();
|
Cards revealed = new CardsImpl();
|
||||||
|
|
@ -82,9 +81,14 @@ class KindredSummonsEffect extends OneShotEffect {
|
||||||
Cards otherCards = new CardsImpl();
|
Cards otherCards = new CardsImpl();
|
||||||
FilterCreatureCard filterCard = new FilterCreatureCard("creature card of the chosen type");
|
FilterCreatureCard filterCard = new FilterCreatureCard("creature card of the chosen type");
|
||||||
filterCard.add(new SubtypePredicate(subType));
|
filterCard.add(new SubtypePredicate(subType));
|
||||||
|
if (numberOfCards == 0) { // no matches so nothing is revealed
|
||||||
|
game.informPlayers("There are 0 creature cards of the chosen type in " + controller.getName() + "'s library.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
for (Card card : controller.getLibrary().getCards(game)) {
|
for (Card card : controller.getLibrary().getCards(game)) {
|
||||||
revealed.add(card);
|
revealed.add(card);
|
||||||
if (card != null && filterCard.match(card, game)) {
|
if (card != null
|
||||||
|
&& filterCard.match(card, game)) {
|
||||||
chosenSubtypeCreatureCards.add(card);
|
chosenSubtypeCreatureCards.add(card);
|
||||||
if (chosenSubtypeCreatureCards.size() == numberOfCards) {
|
if (chosenSubtypeCreatureCards.size() == numberOfCards) {
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
package mage.cards.t;
|
package mage.cards.t;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -8,12 +7,11 @@ import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||||
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.abilities.effects.common.continuous.GainAbilityAllEffect;
|
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
@ -29,14 +27,10 @@ public final class TheTabernacleAtPendrellVale extends CardImpl {
|
||||||
addSuperType(SuperType.LEGENDARY);
|
addSuperType(SuperType.LEGENDARY);
|
||||||
|
|
||||||
// All creatures have "At the beginning of your upkeep, destroy this creature unless you pay {1}."
|
// All creatures have "At the beginning of your upkeep, destroy this creature unless you pay {1}."
|
||||||
Ability ability = new BeginningOfUpkeepTriggeredAbility(new DestroySourceUnlessPaysEffect(new ManaCostsImpl("{1}")), TargetController.YOU, false);
|
this.addAbility(new SimpleStaticAbility(
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
|
Zone.BATTLEFIELD,
|
||||||
new GainAbilityAllEffect(
|
new TheTabernacleAtPendrellValeEffect())
|
||||||
ability,
|
);
|
||||||
Duration.WhileOnBattlefield,
|
|
||||||
new FilterCreaturePermanent("All creatures")
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TheTabernacleAtPendrellVale(final TheTabernacleAtPendrellVale card) {
|
public TheTabernacleAtPendrellVale(final TheTabernacleAtPendrellVale card) {
|
||||||
|
|
@ -49,6 +43,59 @@ public final class TheTabernacleAtPendrellVale extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TheTabernacleAtPendrellValeEffect extends ContinuousEffectImpl {
|
||||||
|
|
||||||
|
Ability ability = new BeginningOfUpkeepTriggeredAbility(
|
||||||
|
new DestroySourceUnlessPaysEffect(
|
||||||
|
new ManaCostsImpl("{1}")),
|
||||||
|
TargetController.YOU,
|
||||||
|
false);
|
||||||
|
|
||||||
|
public TheTabernacleAtPendrellValeEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.AddAbility);
|
||||||
|
ability = ability.copy();
|
||||||
|
this.ability.newId();
|
||||||
|
staticText = "All creatures have \"At the beginning of your upkeep, destroy this creature unless you pay {1}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public TheTabernacleAtPendrellValeEffect(final TheTabernacleAtPendrellValeEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
this.ability = effect.ability.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TheTabernacleAtPendrellValeEffect copy() {
|
||||||
|
return new TheTabernacleAtPendrellValeEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
|
||||||
|
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(CardType.CREATURE)) {
|
||||||
|
if (permanent != null) {
|
||||||
|
switch (layer) {
|
||||||
|
case AbilityAddingRemovingEffects_6:
|
||||||
|
if (sublayer == SubLayer.NA
|
||||||
|
&& !permanent.getAbilities().contains(ability)) {
|
||||||
|
permanent.addAbility(ability, source.getSourceId(), game);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Game game, Ability source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasLayer(Layer layer) {
|
||||||
|
return layer == Layer.AbilityAddingRemovingEffects_6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DestroySourceUnlessPaysEffect extends OneShotEffect {
|
class DestroySourceUnlessPaysEffect extends OneShotEffect {
|
||||||
|
|
||||||
protected Cost cost;
|
protected Cost cost;
|
||||||
|
|
@ -67,7 +114,9 @@ class DestroySourceUnlessPaysEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
Player player = game.getPlayer(source.getControllerId());
|
Player player = game.getPlayer(source.getControllerId());
|
||||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||||
if (player != null && permanent != null && source.getSourceObjectZoneChangeCounter() == permanent.getZoneChangeCounter(game)) {
|
if (player != null
|
||||||
|
&& permanent != null
|
||||||
|
&& source.getSourceObjectZoneChangeCounter() == permanent.getZoneChangeCounter(game)) {
|
||||||
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) {
|
if (player.chooseUse(Outcome.Benefit, "Pay " + cost.getText() + '?', source, game)) {
|
||||||
cost.clearPaid();
|
cost.clearPaid();
|
||||||
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
|
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue