[LTC] Implement Trap the Trespassers

This commit is contained in:
theelk801 2023-06-19 19:15:48 -04:00
parent 3404a34b2d
commit 2e9eb7fb33
4 changed files with 124 additions and 5 deletions

View file

@ -103,6 +103,10 @@ class CirdanTheShipwrightEffect extends OneShotEffect {
class CirdanTheShipwrightVote extends VoteHandler<Player> { class CirdanTheShipwrightVote extends VoteHandler<Player> {
CirdanTheShipwrightVote() {
this.secret = true;
}
@Override @Override
protected Set<Player> getPossibleVotes(Ability source, Game game) { protected Set<Player> getPossibleVotes(Ability source, Game game) {
return game return game

View file

@ -0,0 +1,118 @@
package mage.cards.t;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.choices.VoteHandler;
import mage.constants.AbilityWord;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPermanent;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author TheElk801
*/
public final class TrapTheTrespassers extends CardImpl {
public TrapTheTrespassers(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}");
// Secret council -- Each player secretly votes for a creature you don't control, then those votes are revealed. For each creature with one or more votes, put that many stun counters on it, then tap it.
this.getSpellAbility().addEffect(new TrapTheTrespassersEffect());
this.getSpellAbility().setAbilityWord(AbilityWord.SECRET_COUNCIL);
}
private TrapTheTrespassers(final TrapTheTrespassers card) {
super(card);
}
@Override
public TrapTheTrespassers copy() {
return new TrapTheTrespassers(this);
}
}
class TrapTheTrespassersEffect extends OneShotEffect {
TrapTheTrespassersEffect() {
super(Outcome.Benefit);
staticText = "each player secretly votes for a creature you don't control, then those votes are revealed. " +
"For each creature with one or more votes, put that many stun counters on it, then tap it";
}
private TrapTheTrespassersEffect(final TrapTheTrespassersEffect effect) {
super(effect);
}
@Override
public TrapTheTrespassersEffect copy() {
return new TrapTheTrespassersEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
if (!game.getBattlefield().contains(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL, source, game, 1)) {
return false;
}
TrapTheTrespassersVote vote = new TrapTheTrespassersVote(source, game);
vote.doVotes(source, game);
for (Map.Entry<Permanent, Integer> entry : vote.getVotesPerCreature(game).entrySet()) {
entry.getKey().addCounters(CounterType.STUN.createInstance(entry.getValue()), source, game);
entry.getKey().tap(source, game);
}
return true;
}
}
class TrapTheTrespassersVote extends VoteHandler<Permanent> {
private final FilterPermanent filter;
TrapTheTrespassersVote(Ability source, Game game) {
this.filter = new FilterCreaturePermanent(
"creature not controlled by " + game.getPlayer(source.getControllerId()).getName()
);
this.filter.add(Predicates.not(new ControllerIdPredicate(source.getControllerId())));
this.secret = true;
}
@Override
protected Set<Permanent> getPossibleVotes(Ability source, Game game) {
return new HashSet<>();
}
@Override
protected Permanent playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) {
TargetPermanent target = new TargetPermanent(filter);
target.setNotTarget(true);
decidingPlayer.choose(Outcome.UnboostCreature, target, source, game);
return game.getPermanent(target.getFirstTarget());
}
@Override
protected String voteName(Permanent vote) {
return vote.getIdName();
}
Map<Permanent, Integer> getVotesPerCreature(Game game) {
return playerMap
.values()
.stream()
.flatMap(Collection::stream)
.collect(Collectors.toMap(Function.identity(), x -> 1, Integer::sum));
}
}

View file

@ -241,6 +241,7 @@ public final class TalesOfMiddleEarthCommander extends ExpansionSet {
cards.add(new SetCardInfo("Trading Post", 288, Rarity.RARE, mage.cards.t.TradingPost.class)); cards.add(new SetCardInfo("Trading Post", 288, Rarity.RARE, mage.cards.t.TradingPost.class));
cards.add(new SetCardInfo("Tranquil Cove", 340, Rarity.COMMON, mage.cards.t.TranquilCove.class)); cards.add(new SetCardInfo("Tranquil Cove", 340, Rarity.COMMON, mage.cards.t.TranquilCove.class));
cards.add(new SetCardInfo("Tranquil Thicket", 341, Rarity.UNCOMMON, mage.cards.t.TranquilThicket.class)); cards.add(new SetCardInfo("Tranquil Thicket", 341, Rarity.UNCOMMON, mage.cards.t.TranquilThicket.class));
cards.add(new SetCardInfo("Trap the Trespassers", 25, Rarity.RARE, mage.cards.t.TrapTheTrespassers.class));
cards.add(new SetCardInfo("Travel Through Caradhras", 44, Rarity.RARE, mage.cards.t.TravelThroughCaradhras.class)); cards.add(new SetCardInfo("Travel Through Caradhras", 44, Rarity.RARE, mage.cards.t.TravelThroughCaradhras.class));
cards.add(new SetCardInfo("Treasure Nabber", 230, Rarity.RARE, mage.cards.t.TreasureNabber.class)); cards.add(new SetCardInfo("Treasure Nabber", 230, Rarity.RARE, mage.cards.t.TreasureNabber.class));
cards.add(new SetCardInfo("Unbreakable Formation", 179, Rarity.RARE, mage.cards.u.UnbreakableFormation.class)); cards.add(new SetCardInfo("Unbreakable Formation", 179, Rarity.RARE, mage.cards.u.UnbreakableFormation.class));

View file

@ -18,7 +18,7 @@ public abstract class VoteHandler<T> {
protected final Map<UUID, List<T>> playerMap = new HashMap<>(); protected final Map<UUID, List<T>> playerMap = new HashMap<>();
protected VoteHandlerAI<T> aiVoteHint = null; protected VoteHandlerAI<T> aiVoteHint = null;
private boolean secret = false; protected boolean secret = false;
public void doVotes(Ability source, Game game) { public void doVotes(Ability source, Game game) {
doVotes(source, game, null); doVotes(source, game, null);
@ -189,8 +189,4 @@ public abstract class VoteHandler<T> {
.map(Map.Entry::getKey) .map(Map.Entry::getKey)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
} }
public void setSecret(boolean secret) {
this.secret = secret;
}
} }