mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 14:32:06 -08:00
Fixed some cards where it was possible to sacrifice not controlled permanents (e.g. Fireblast).
This commit is contained in:
parent
4a5140d0ab
commit
705debfe8a
34 changed files with 206 additions and 337 deletions
|
|
@ -39,9 +39,7 @@ import mage.game.Game;
|
|||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -87,14 +85,14 @@ public class SacrificeEffect extends OneShotEffect{
|
|||
int realCount = game.getBattlefield().countAll(filter, player.getId(), game);
|
||||
amount = Math.min(amount, realCount);
|
||||
|
||||
Target target = new TargetControlledPermanent(amount, amount, filter, true);
|
||||
Target target = new TargetPermanent(amount, amount, filter, true);
|
||||
|
||||
// A spell or ability could have removed the only legal target this player
|
||||
// had, if thats the case this ability should fizzle.
|
||||
if (amount > 0 && target.canChoose(source.getSourceId(), player.getId(), game)) {
|
||||
boolean abilityApplied = false;
|
||||
while (!target.isChosen() && target.canChoose(player.getId(), game) && player.isInGame()) {
|
||||
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
|
||||
player.chooseTarget(Outcome.Sacrifice, target, source, game);
|
||||
}
|
||||
|
||||
for ( int idx = 0; idx < target.getTargets().size(); idx++) {
|
||||
|
|
|
|||
|
|
@ -36,11 +36,13 @@ import mage.abilities.dynamicvalue.DynamicValue;
|
|||
import mage.abilities.dynamicvalue.common.StaticValue;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.TargetController;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
/**
|
||||
|
|
@ -81,15 +83,17 @@ public class SacrificeOpponentsEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
List<UUID> perms = new ArrayList<UUID>();
|
||||
List<UUID> perms = new ArrayList<>();
|
||||
filter.add(new ControllerPredicate(TargetController.YOU));
|
||||
for (UUID playerId : game.getOpponents(source.getControllerId())) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
|
||||
int numTargets = Math.min(amount.calculate(game, source, this), game.getBattlefield().countAll(filter, player.getId(), game));
|
||||
TargetControlledPermanent target = new TargetControlledPermanent(numTargets, numTargets, filter, false);
|
||||
TargetPermanent target = new TargetPermanent(numTargets, numTargets, filter, false);
|
||||
if (target.canChoose(player.getId(), game)) {
|
||||
while (!target.isChosen() && player.isInGame()) {
|
||||
player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
|
||||
player.chooseTarget(Outcome.Sacrifice, target, source, game);
|
||||
}
|
||||
perms.addAll(target.getTargets());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
package mage.filter.common;
|
||||
|
||||
import mage.constants.CardType;
|
||||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
|
||||
public class FilterControlledPlaneswalkerPermanent extends FilterControlledPermanent {
|
||||
|
||||
public FilterControlledPlaneswalkerPermanent() {
|
||||
this("planeswalker you control");
|
||||
}
|
||||
|
||||
public FilterControlledPlaneswalkerPermanent(String name) {
|
||||
super(name);
|
||||
this.add(new CardTypePredicate(CardType.PLANESWALKER));
|
||||
}
|
||||
|
||||
public FilterControlledPlaneswalkerPermanent(final FilterControlledPlaneswalkerPermanent filter) {
|
||||
super(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilterControlledPlaneswalkerPermanent copy() {
|
||||
return new FilterControlledPlaneswalkerPermanent(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -52,14 +52,14 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
|||
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
|
||||
super("planeswalker or player");
|
||||
|
||||
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<Predicate<Permanent>>();
|
||||
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<>();
|
||||
for (UUID defenderId : defenders) {
|
||||
permanentPredicates.add(new ControllerIdPredicate(defenderId));
|
||||
}
|
||||
planeswalkerFilter = new FilterPlaneswalkerPermanent();
|
||||
planeswalkerFilter.add(Predicates.or(permanentPredicates));
|
||||
|
||||
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<Predicate<Player>>();
|
||||
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<>();
|
||||
for (UUID defenderId : defenders) {
|
||||
playerPredicates.add(new PlayerIdPredicate(defenderId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class TargetControlledPermanent extends TargetPermanent {
|
|||
this(1, 1, filter, false);
|
||||
}
|
||||
|
||||
public TargetControlledPermanent(int minNumTargets, int maxNumTargets, FilterPermanent filter, boolean notTarget) {
|
||||
public TargetControlledPermanent(int minNumTargets, int maxNumTargets, FilterControlledPermanent filter, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue