mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
* Proliferate - fixed that it highlights all permanents instead with counters only;
This commit is contained in:
parent
a5ef712924
commit
3ff871c6de
7 changed files with 37 additions and 133 deletions
|
@ -27,7 +27,8 @@ public final class GuildpactInformant extends CardImpl {
|
|||
// Flying
|
||||
this.addAbility(FlyingAbility.getInstance());
|
||||
|
||||
// Whenever Guildpact Informant deals combat damage to a player or planeswalker, proliferate. (Choose any number of permanents and/or players, then give each another counter of each kind already there.)
|
||||
// Whenever Guildpact Informant deals combat damage to a player or planeswalker,
|
||||
// proliferate. (Choose any number of permanents and/or players, then give each another counter of each kind already there.)
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
|
||||
new ProliferateEffect(), false
|
||||
).setOrPlaneswalker(true));
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.common;
|
||||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
|
@ -45,6 +44,7 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility
|
|||
this.text = ability.text;
|
||||
this.setTargetPointer = ability.setTargetPointer;
|
||||
this.onlyOpponents = ability.onlyOpponents;
|
||||
this.orPlaneswalker = ability.orPlaneswalker;
|
||||
}
|
||||
|
||||
public DealsCombatDamageToAPlayerTriggeredAbility setOrPlaneswalker(boolean orPlaneswalker) {
|
||||
|
|
|
@ -4,11 +4,12 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.counters.Counter;
|
||||
import mage.filter.common.FilterPermanentOrPlayerWithCounter;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.Target;
|
||||
import mage.target.common.TargetPermanentOrPlayerWithCounter;
|
||||
import mage.target.common.TargetPermanentOrPlayer;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
@ -47,7 +48,7 @@ public class ProliferateEffect extends OneShotEffect {
|
|||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
Target target = new TargetPermanentOrPlayerWithCounter(0, Integer.MAX_VALUE, true);
|
||||
Target target = new TargetPermanentOrPlayer(0, Integer.MAX_VALUE, new FilterPermanentOrPlayerWithCounter(), true);
|
||||
Map<String, Serializable> options = new HashMap<>();
|
||||
options.put("UI.right.btn.text", "Done");
|
||||
controller.choose(Outcome.Benefit, target, source.getSourceId(), game, options);
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
|
||||
package mage.filter.common;
|
||||
|
||||
import mage.MageItem;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageItem;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
@ -28,24 +26,24 @@ public class FilterPermanentOrPlayerWithCounter extends FilterPermanentOrPlayer
|
|||
|
||||
@Override
|
||||
public boolean match(MageItem o, Game game) {
|
||||
if (o instanceof Player) {
|
||||
if (((Player)o).getCounters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
} else if (o instanceof Permanent) {
|
||||
if (((Permanent)o).getCounters(game).isEmpty()) {
|
||||
return false;
|
||||
if (super.match(o, game)) {
|
||||
if (o instanceof Player) {
|
||||
return !((Player) o).getCounters().isEmpty();
|
||||
} else if (o instanceof Permanent) {
|
||||
return !((Permanent) o).getCounters(game).isEmpty();
|
||||
}
|
||||
}
|
||||
return super.match(o, game);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(MageItem o, UUID sourceId, UUID playerId, Game game) {
|
||||
if (o instanceof Player) {
|
||||
return playerFilter.match((Player) o, sourceId, playerId, game);
|
||||
} else if (o instanceof Permanent) {
|
||||
return permanentFilter.match((Permanent) o, sourceId, playerId, game);
|
||||
if (super.match(o, sourceId, playerId, game)) {
|
||||
if (o instanceof Player) {
|
||||
return !((Player) o).getCounters().isEmpty();
|
||||
} else if (o instanceof Permanent) {
|
||||
return !((Permanent) o).getCounters(game).isEmpty();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -8,23 +8,22 @@ package mage.target.common;
|
|||
import mage.filter.common.FilterOpponentOrPlaneswalker;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class TargetOpponentOrPlaneswalker extends TargetPermanentOrPlayer {
|
||||
|
||||
public TargetOpponentOrPlaneswalker() {
|
||||
this(1, 1, new FilterOpponentOrPlaneswalker("opponent or planeswalker"), false);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(int numTargets) {
|
||||
this(numTargets, numTargets, new FilterOpponentOrPlaneswalker(), false);
|
||||
this(1);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(FilterOpponentOrPlaneswalker filter) {
|
||||
this(1, 1, filter, false);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(int numTargets) {
|
||||
this(numTargets, numTargets, new FilterOpponentOrPlaneswalker("opponent or planeswalker"), false);
|
||||
}
|
||||
|
||||
public TargetOpponentOrPlaneswalker(int minNumTargets, int maxNumTargets, FilterOpponentOrPlaneswalker filter, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, filter, notTarget);
|
||||
}
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
package mage.target.common;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.filter.common.FilterPermanentOrPlayer;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetImpl;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class TargetPermanentOrPlayer extends TargetImpl {
|
||||
|
||||
protected FilterPermanentOrPlayer filter;
|
||||
protected FilterPermanent filterPermanent;
|
||||
|
||||
public TargetPermanentOrPlayer() {
|
||||
this(1, 1);
|
||||
|
@ -46,14 +44,12 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
this.zone = Zone.ALL;
|
||||
this.filter = filter;
|
||||
this.targetName = filter.getMessage();
|
||||
this.filterPermanent = this.filter.getPermanentFilter();
|
||||
this.notTarget = notTarget;
|
||||
}
|
||||
|
||||
public TargetPermanentOrPlayer(final TargetPermanentOrPlayer target) {
|
||||
super(target);
|
||||
this.filter = target.filter.copy();
|
||||
this.filterPermanent = target.filterPermanent.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,10 +57,6 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(FilterPermanentOrPlayer filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
|
@ -118,7 +110,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
* {@link mage.players.Player} that can be chosen. Should only be used for
|
||||
* Ability targets since this checks for protection, shroud etc.
|
||||
*
|
||||
* @param sourceId - the target event source
|
||||
* @param sourceId - the target event source
|
||||
* @param sourceControllerId - controller of the target event source
|
||||
* @param game
|
||||
* @return - true if enough valid {@link mage.game.permanent.Permanent} or
|
||||
|
@ -130,14 +122,14 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) {
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, sourceId, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT, sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
|
@ -170,7 +162,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent, sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (filter.match(permanent, null, sourceControllerId, game) && filter.match(permanent, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
|
@ -187,11 +179,11 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
MageObject targetSource = game.getObject(sourceId);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.getPlayerFilter().match(player, sourceId, sourceControllerId, game)) {
|
||||
if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterPermanent(), sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceId, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
|
@ -204,11 +196,11 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
Set<UUID> possibleTargets = new HashSet<>();
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && filter.getPlayerFilter().match(player, game)) {
|
||||
if (player != null && filter.match(player, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, sourceControllerId, game)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (filter.match(permanent, null, sourceControllerId, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
|
@ -237,6 +229,6 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
}
|
||||
|
||||
public FilterPermanent getFilterPermanent() {
|
||||
return filterPermanent.copy();
|
||||
return filter.getPermanentFilter().copy();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
|
||||
|
||||
package mage.target.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.filter.common.FilterPermanentOrPlayerWithCounter;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import java.util.UUID;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.permanent.CounterPredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nantuko
|
||||
*/
|
||||
public class TargetPermanentOrPlayerWithCounter extends TargetPermanentOrPlayer {
|
||||
|
||||
protected final FilterPermanentOrPlayerWithCounter targetFilter;
|
||||
|
||||
public TargetPermanentOrPlayerWithCounter() {
|
||||
this(1, 1);
|
||||
}
|
||||
|
||||
public TargetPermanentOrPlayerWithCounter(int numTargets) {
|
||||
this(numTargets, numTargets);
|
||||
}
|
||||
|
||||
public TargetPermanentOrPlayerWithCounter(int minNumTargets, int maxNumTargets) {
|
||||
this(minNumTargets, maxNumTargets, false);
|
||||
}
|
||||
|
||||
public TargetPermanentOrPlayerWithCounter(int minNumTargets, int maxNumTargets, boolean notTarget) {
|
||||
super(minNumTargets, maxNumTargets, notTarget);
|
||||
this.targetFilter = new FilterPermanentOrPlayerWithCounter();
|
||||
this.filterPermanent = new FilterPermanent();
|
||||
this.filterPermanent.add(new CounterPredicate(null));
|
||||
this.targetName = targetFilter.getMessage();
|
||||
}
|
||||
|
||||
public TargetPermanentOrPlayerWithCounter(final TargetPermanentOrPlayerWithCounter target) {
|
||||
super(target);
|
||||
this.targetFilter = target.targetFilter.copy();
|
||||
super.setFilter(this.targetFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetPermanentOrPlayerWithCounter copy() {
|
||||
return new TargetPermanentOrPlayerWithCounter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
if (permanent.getCounters(game).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (player.getCounters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.canTarget(id, game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
if (permanent != null) {
|
||||
if (permanent.getCounters(game).isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (player.getCounters().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.canTarget(id, source, game);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue