mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
[filters] converted FilterPlayer to Predicates
This commit is contained in:
parent
b230fc883a
commit
28fe29854c
6 changed files with 190 additions and 93 deletions
|
@ -36,6 +36,7 @@ import mage.Constants.TargetController;
|
||||||
import mage.abilities.effects.common.PreventAllDamageToEffect;
|
import mage.abilities.effects.common.PreventAllDamageToEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.filter.common.FilterCreatureOrPlayer;
|
import mage.filter.common.FilterCreatureOrPlayer;
|
||||||
|
import mage.filter.predicate.other.PlayerPredicate;
|
||||||
import mage.filter.predicate.permanent.ControllerPredicate;
|
import mage.filter.predicate.permanent.ControllerPredicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,7 +49,7 @@ public class SafePassage extends CardImpl<SafePassage> {
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.getCreatureFilter().add(new ControllerPredicate(TargetController.YOU));
|
filter.getCreatureFilter().add(new ControllerPredicate(TargetController.YOU));
|
||||||
filter.getPlayerFilter().setPlayerTarget(TargetController.YOU);
|
filter.getPlayerFilter().add(new PlayerPredicate(TargetController.YOU));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SafePassage(UUID ownerId) {
|
public SafePassage(UUID ownerId) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ package mage.filter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Constants.TargetController;
|
|
||||||
import mage.filter.predicate.ObjectPlayer;
|
import mage.filter.predicate.ObjectPlayer;
|
||||||
import mage.filter.predicate.ObjectPlayerPredicate;
|
import mage.filter.predicate.ObjectPlayerPredicate;
|
||||||
import mage.filter.predicate.ObjectSourcePlayer;
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
|
@ -47,9 +46,6 @@ import mage.players.Player;
|
||||||
public class FilterPlayer extends FilterImpl<Player> {
|
public class FilterPlayer extends FilterImpl<Player> {
|
||||||
|
|
||||||
protected List<ObjectPlayerPredicate<ObjectPlayer<Player>>> extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Player>>>();
|
protected List<ObjectPlayerPredicate<ObjectPlayer<Player>>> extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Player>>>();
|
||||||
protected List<UUID> playerId = new ArrayList<UUID>();
|
|
||||||
protected boolean notPlayer;
|
|
||||||
protected TargetController playerTarget = TargetController.ANY;
|
|
||||||
|
|
||||||
public FilterPlayer() {
|
public FilterPlayer() {
|
||||||
this("player");
|
this("player");
|
||||||
|
@ -62,58 +58,18 @@ public class FilterPlayer extends FilterImpl<Player> {
|
||||||
public FilterPlayer(final FilterPlayer filter) {
|
public FilterPlayer(final FilterPlayer filter) {
|
||||||
super(filter);
|
super(filter);
|
||||||
this.extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Player>>>(filter.extraPredicates);
|
this.extraPredicates = new ArrayList<ObjectPlayerPredicate<ObjectPlayer<Player>>>(filter.extraPredicates);
|
||||||
this.playerId.addAll(filter.playerId);
|
|
||||||
this.notPlayer = filter.notPlayer;
|
|
||||||
this.playerTarget = filter.playerTarget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(ObjectPlayerPredicate predicate) {
|
public void add(ObjectPlayerPredicate predicate) {
|
||||||
extraPredicates.add(predicate);
|
extraPredicates.add(predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean match(Player player, UUID sourceId, UUID playerId, Game game) {
|
||||||
public boolean match(Player player, Game game) {
|
if (!this.match(player, game)) {
|
||||||
|
return false;
|
||||||
if (playerId.size() > 0 && playerId.contains(player.getId()) == notPlayer)
|
|
||||||
return notFilter;
|
|
||||||
|
|
||||||
return !notFilter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean match(Player player, UUID sourceId, UUID controllerId, Game game) {
|
return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(player, sourceId, playerId), game);
|
||||||
if (!this.match(player, game))
|
|
||||||
return notFilter;
|
|
||||||
|
|
||||||
if (playerTarget != TargetController.ANY && controllerId != null) {
|
|
||||||
switch(playerTarget) {
|
|
||||||
case YOU:
|
|
||||||
if (!player.getId().equals(controllerId))
|
|
||||||
return notFilter;
|
|
||||||
break;
|
|
||||||
case OPPONENT:
|
|
||||||
if (!game.getOpponents(controllerId).contains(player.getId()))
|
|
||||||
return notFilter;
|
|
||||||
break;
|
|
||||||
case NOT_YOU:
|
|
||||||
if (player.getId().equals(controllerId))
|
|
||||||
return notFilter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Predicates.and(extraPredicates).apply(new ObjectSourcePlayer(player, sourceId, controllerId), game);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<UUID> getPlayerId() {
|
|
||||||
return playerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotPlayer(boolean notPlayer) {
|
|
||||||
this.notPlayer = notPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerTarget(TargetController playerTarget) {
|
|
||||||
this.playerTarget = playerTarget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification, are
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
* permitted provided that the following conditions are met:
|
* permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
* conditions and the following disclaimer.
|
* conditions and the following disclaimer.
|
||||||
*
|
*
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
* 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
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
* provided with the distribution.
|
* provided with the distribution.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* 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
|
* 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
|
* 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
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 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
|
* 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
|
* 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
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* The views and conclusions contained in the software and documentation are those of the
|
* 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
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.filter.common;
|
package mage.filter.common;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -35,6 +34,7 @@ import mage.filter.FilterImpl;
|
||||||
import mage.filter.FilterPlayer;
|
import mage.filter.FilterPlayer;
|
||||||
import mage.filter.predicate.Predicate;
|
import mage.filter.predicate.Predicate;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
|
import mage.filter.predicate.other.PlayerIdPredicate;
|
||||||
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
import mage.filter.predicate.permanent.ControllerIdPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
|
@ -51,14 +51,20 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
||||||
|
|
||||||
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
|
public FilterPlaneswalkerOrPlayer(Set<UUID> defenders) {
|
||||||
super("planeswalker or player");
|
super("planeswalker or player");
|
||||||
|
|
||||||
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<Predicate<Permanent>>();
|
ArrayList<Predicate<Permanent>> permanentPredicates = new ArrayList<Predicate<Permanent>>();
|
||||||
for (UUID defenderId : defenders) {
|
for (UUID defenderId : defenders) {
|
||||||
permanentPredicates.add(new ControllerIdPredicate(defenderId));
|
permanentPredicates.add(new ControllerIdPredicate(defenderId));
|
||||||
}
|
}
|
||||||
planeswalkerFilter = new FilterPlaneswalkerPermanent();
|
planeswalkerFilter = new FilterPlaneswalkerPermanent();
|
||||||
planeswalkerFilter.add(Predicates.or(permanentPredicates));
|
planeswalkerFilter.add(Predicates.or(permanentPredicates));
|
||||||
|
|
||||||
|
ArrayList<Predicate<Player>> playerPredicates = new ArrayList<Predicate<Player>>();
|
||||||
|
for (UUID defenderId : defenders) {
|
||||||
|
playerPredicates.add(new PlayerIdPredicate(defenderId));
|
||||||
|
}
|
||||||
playerFilter = new FilterPlayer();
|
playerFilter = new FilterPlayer();
|
||||||
playerFilter.getPlayerId().addAll(defenders);
|
planeswalkerFilter.add(Predicates.or(playerPredicates));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilterPlaneswalkerOrPlayer(final FilterPlaneswalkerOrPlayer filter) {
|
public FilterPlaneswalkerOrPlayer(final FilterPlaneswalkerOrPlayer filter) {
|
||||||
|
@ -70,12 +76,11 @@ public class FilterPlaneswalkerOrPlayer extends FilterImpl<Object> {
|
||||||
@Override
|
@Override
|
||||||
public boolean match(Object o, Game game) {
|
public boolean match(Object o, Game game) {
|
||||||
if (o instanceof Player) {
|
if (o instanceof Player) {
|
||||||
return playerFilter.match((Player)o, game);
|
return playerFilter.match((Player) o, game);
|
||||||
|
} else if (o instanceof Permanent) {
|
||||||
|
return planeswalkerFilter.match((Permanent) o, game);
|
||||||
}
|
}
|
||||||
else if (o instanceof Permanent) {
|
return false;
|
||||||
return planeswalkerFilter.match((Permanent)o, game);
|
|
||||||
}
|
|
||||||
return notFilter;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
56
Mage/src/mage/filter/predicate/other/PlayerIdPredicate.java
Normal file
56
Mage/src/mage/filter/predicate/other/PlayerIdPredicate.java
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* 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.predicate.other;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.filter.predicate.Predicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author North
|
||||||
|
*/
|
||||||
|
public class PlayerIdPredicate implements Predicate<Player> {
|
||||||
|
|
||||||
|
private final UUID playerId;
|
||||||
|
|
||||||
|
public PlayerIdPredicate(UUID playerId) {
|
||||||
|
this.playerId = playerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Player input, Game game) {
|
||||||
|
return playerId.equals(input.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "PlayerId(" + playerId + ')';
|
||||||
|
}
|
||||||
|
}
|
82
Mage/src/mage/filter/predicate/other/PlayerPredicate.java
Normal file
82
Mage/src/mage/filter/predicate/other/PlayerPredicate.java
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* 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.predicate.other;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.TargetController;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayer;
|
||||||
|
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.players.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author North
|
||||||
|
*/
|
||||||
|
public class PlayerPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {
|
||||||
|
|
||||||
|
private TargetController targetPlayer;
|
||||||
|
|
||||||
|
public PlayerPredicate(TargetController player) {
|
||||||
|
this.targetPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
|
||||||
|
Player player = input.getObject();
|
||||||
|
UUID playerId = input.getPlayerId();
|
||||||
|
if (player == null || playerId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (targetPlayer) {
|
||||||
|
case YOU:
|
||||||
|
if (player.getId().equals(playerId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case OPPONENT:
|
||||||
|
if (game.getOpponents(playerId).contains(player.getId())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NOT_YOU:
|
||||||
|
if (!player.getId().equals(playerId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Player(" + targetPlayer + ')';
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,18 +25,20 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.target.common;
|
package mage.target.common;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.Constants.TargetController;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
import mage.filter.FilterPlayer;
|
||||||
|
import mage.filter.predicate.other.PlayerPredicate;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.target.TargetPlayer;
|
import mage.target.TargetPlayer;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
* @author North
|
||||||
*/
|
*/
|
||||||
public class TargetOpponent extends TargetPlayer<TargetOpponent> {
|
public class TargetOpponent extends TargetPlayer<TargetOpponent> {
|
||||||
|
|
||||||
|
@ -45,8 +47,8 @@ public class TargetOpponent extends TargetPlayer<TargetOpponent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public TargetOpponent(boolean required) {
|
public TargetOpponent(boolean required) {
|
||||||
super();
|
super(1, 1, false, new FilterPlayer("opponent"));
|
||||||
this.targetName = "opponent";
|
this.filter.add(new PlayerPredicate(TargetController.OPPONENT));
|
||||||
setRequired(required);
|
setRequired(required);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,15 +58,11 @@ public class TargetOpponent extends TargetPlayer<TargetOpponent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||||
filter.getPlayerId().clear();
|
|
||||||
filter.getPlayerId().addAll(game.getOpponents(sourceControllerId));
|
|
||||||
return super.canChoose(sourceId, sourceControllerId, game);
|
return super.canChoose(sourceId, sourceControllerId, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||||
filter.getPlayerId().clear();
|
|
||||||
filter.getPlayerId().addAll(game.getOpponents(source.getControllerId()));
|
|
||||||
return super.canTarget(id, source, game);
|
return super.canTarget(id, source, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,5 +70,4 @@ public class TargetOpponent extends TargetPlayer<TargetOpponent> {
|
||||||
public TargetOpponent copy() {
|
public TargetOpponent copy() {
|
||||||
return new TargetOpponent(this);
|
return new TargetOpponent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue