[LTC] Implement The Black Gate (#10725)

This commit is contained in:
Susucre 2023-08-03 06:25:54 +02:00 committed by GitHub
parent ec3bb197fb
commit 5a6ee98b41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 154 additions and 2 deletions

View file

@ -0,0 +1,151 @@
package mage.cards.t;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.TapSourceUnlessPaysEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByAllTargetEffect;
import mage.abilities.mana.BlackManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.filter.FilterPlayer;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.util.CardUtil;
import java.util.UUID;
/**
* @author Susucr
*/
public final class TheBlackGate extends CardImpl {
public TheBlackGate(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.LAND}, "");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.GATE);
// As The Black Gate enters the battlefield, you may pay 3 life. If you don't, it enters the battlefield tapped.
this.addAbility(new AsEntersBattlefieldAbility(
new TapSourceUnlessPaysEffect(new PayLifeCost(3)),
"you may pay 3 life. If you don't, it enters the battlefield tapped"
));
// {T}: Add {B}.
this.addAbility(new BlackManaAbility());
// {1}{B}, {T}: Choose a player with the most life or tied for most life. Target creature can't be blocked by creatures that player controls this turn.
ActivatedAbility ability = new SimpleActivatedAbility(
new BlackGateEffect(),
new ManaCostsImpl("{1}{B}")
);
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
}
private TheBlackGate(final TheBlackGate card) {
super(card);
}
@Override
public TheBlackGate copy() {
return new TheBlackGate(this);
}
}
enum BlackGatePredicate implements ObjectSourcePlayerPredicate<Player> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
Player player = input.getObject();
UUID playerId = input.getPlayerId();
if (player == null || playerId == null) {
return false;
}
int life = player.getLife();
for (UUID otherPlayerId : game.getState().getPlayersInRange(playerId, game)) {
Player otherPlayer = game.getPlayer(otherPlayerId);
if (otherPlayer == null) {
continue;
}
if (life < otherPlayer.getLife()) {
return false;
}
}
return true;
}
}
class BlackGateEffect extends OneShotEffect {
private static final FilterPlayer filter = new FilterPlayer("player with the most life or tied for most life");
static {
filter.add(BlackGatePredicate.instance);
}
BlackGateEffect() {
super(Outcome.Benefit);
staticText = "Choose a player with the most life or tied for most life. "
+ "Target creature can't be blocked by creatures that player controls this turn.";
}
private BlackGateEffect(final BlackGateEffect effect) {
super(effect);
}
@Override
public BlackGateEffect copy() {
return new BlackGateEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent creature = game.getPermanent(source.getFirstTarget());
if (controller == null || creature == null) {
return false;
}
TargetPlayer target = new TargetPlayer(filter);
target.setNotTarget(true);
if (!controller.choose(Outcome.Detriment, target, source, game)) {
return false;
}
Player player = game.getPlayer(target.getFirstTarget());
if (player == null) {
return false;
}
game.informPlayers(controller.getLogName() + " chose " + player.getLogName() + CardUtil.getSourceLogName(game, source));
FilterCreaturePermanent filterCantBlock = new FilterCreaturePermanent("creatures controlled by" + player.getName());
filterCantBlock.add(new ControllerIdPredicate(player.getId()));
ContinuousEffect effect = new CantBeBlockedByAllTargetEffect(filterCantBlock, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature, game));
game.addEffect(effect, source);
return true;
}
}

View file

@ -266,6 +266,7 @@ public final class TalesOfMiddleEarthCommander extends ExpansionSet {
cards.add(new SetCardInfo("Taunt from the Rampart", 71, Rarity.RARE, mage.cards.t.TauntFromTheRampart.class));
cards.add(new SetCardInfo("Terramorphic Expanse", 337, Rarity.COMMON, mage.cards.t.TerramorphicExpanse.class));
cards.add(new SetCardInfo("The Balrog of Moria", 46, Rarity.RARE, mage.cards.t.TheBalrogOfMoria.class));
cards.add(new SetCardInfo("The Black Gate", 80, Rarity.RARE, mage.cards.t.TheBlackGate.class));
cards.add(new SetCardInfo("The Gaffer", 12, Rarity.RARE, mage.cards.t.TheGaffer.class));
cards.add(new SetCardInfo("The Great Henge", 348, Rarity.MYTHIC, mage.cards.t.TheGreatHenge.class));
cards.add(new SetCardInfo("The Ozolith", 351, Rarity.MYTHIC, mage.cards.t.TheOzolith.class));

View file

@ -26,7 +26,7 @@ public class FilterPlayer extends FilterImpl<Player> {
super(name);
}
public FilterPlayer(final FilterPlayer filter) {
protected FilterPlayer(final FilterPlayer filter) {
super(filter);
this.extraPredicates.addAll(filter.extraPredicates);
}

View file

@ -41,7 +41,7 @@ public class TargetPlayer extends TargetImpl {
this.notTarget = notTarget;
}
public TargetPlayer(final TargetPlayer target) {
protected TargetPlayer(final TargetPlayer target) {
super(target);
this.filter = target.filter.copy();
}