mirror of
https://github.com/correl/mage.git
synced 2024-11-15 03:00:16 +00:00
Beamtown Bullies now properly targets opponent (#10439)
* Beamtown Bullies now properly targets opponent Fixes magefree/mage#9975 * Fixed filter initialization
This commit is contained in:
parent
2194aee865
commit
b0809c4a7a
4 changed files with 28 additions and 41 deletions
|
@ -18,14 +18,17 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.FilterOpponent;
|
||||
import mage.filter.FilterPlayer;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.other.ActivePlayerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPlayer;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
import mage.target.common.TargetOpponentWhoseTurnItIs;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -36,10 +39,12 @@ import java.util.UUID;
|
|||
public final class TheBeamtownBullies extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterCard("nonlegendary creature card");
|
||||
private static final FilterPlayer playerFilter = new FilterOpponent();
|
||||
|
||||
static {
|
||||
filter.add(Predicates.not(SuperType.LEGENDARY.getPredicate()));
|
||||
filter.add(CardType.CREATURE.getPredicate());
|
||||
playerFilter.add(ActivePlayerPredicate.instance);
|
||||
}
|
||||
public TheBeamtownBullies(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{R}{G}");
|
||||
|
@ -59,6 +64,8 @@ public final class TheBeamtownBullies extends CardImpl {
|
|||
Ability ability = new SimpleActivatedAbility(new TheBeamtownBulliesEffect(), new TapSourceCost());
|
||||
|
||||
// Choose a non-legendary creature to put on the battlefield under their control
|
||||
|
||||
ability.addTarget(new TargetPlayer(1, 1, false, playerFilter));
|
||||
ability.addTarget(new TargetCardInYourGraveyard(filter));
|
||||
|
||||
this.addAbility(ability);
|
||||
|
@ -85,17 +92,12 @@ class TheBeamtownBulliesEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
// Ability is targeted
|
||||
TargetPlayer targetOpponent = new TargetOpponentWhoseTurnItIs(game);
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
controller.chooseTarget(Outcome.Neutral, targetOpponent, source, game);
|
||||
Player opponent = game.getPlayer(targetOpponent.getFirstTarget());
|
||||
Player opponent = game.getPlayer(source.getFirstTarget());
|
||||
|
||||
// check to ensure it is the chosen opponent's turn
|
||||
if (opponent != null && opponent.getId().equals(game.getActivePlayerId()))
|
||||
if (opponent != null)
|
||||
{
|
||||
// Put the chosen card onto the battlefield under opponents control
|
||||
Card card = game.getCard(source.getTargets().getFirstTarget());
|
||||
Card card = game.getCard(source.getTargets().get(1).getFirstTarget());
|
||||
if (card == null || !opponent.moveCards(card, Zone.BATTLEFIELD, source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -31,11 +31,12 @@ public class FilterPlayer extends FilterImpl<Player> {
|
|||
this.extraPredicates.addAll(filter.extraPredicates);
|
||||
}
|
||||
|
||||
public void add(ObjectSourcePlayerPredicate predicate) {
|
||||
public FilterPlayer add(ObjectSourcePlayerPredicate predicate) {
|
||||
if (isLockedFilter()) {
|
||||
throw new UnsupportedOperationException("You may not modify a locked filter");
|
||||
}
|
||||
extraPredicates.add(predicate);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package mage.filter.predicate.other;
|
||||
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
|
||||
public enum ActivePlayerPredicate implements Predicate<Player> {
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Player input, Game game) {
|
||||
return game.isActivePlayer(input.getId());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.filter.FilterOpponent;
|
||||
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.target.TargetPlayer;
|
||||
|
||||
/**
|
||||
* @author Arketec
|
||||
*/
|
||||
public class TargetOpponentWhoseTurnItIs extends TargetPlayer {
|
||||
|
||||
public TargetOpponentWhoseTurnItIs(Game game) {
|
||||
this(game,false);
|
||||
|
||||
}
|
||||
|
||||
public TargetOpponentWhoseTurnItIs(Game game, boolean notTarget) {
|
||||
super(1, 1, notTarget, new FilterOpponent());
|
||||
super.filter.add(new PlayerIdPredicate(game.getActivePlayerId()));
|
||||
}
|
||||
|
||||
private TargetOpponentWhoseTurnItIs(final TargetOpponentWhoseTurnItIs target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetOpponentWhoseTurnItIs copy() {
|
||||
return new TargetOpponentWhoseTurnItIs(this);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue