mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
implement [MH3] Volatile Stormdrake ; provide source Ability to canBeTargetedBy and HexproofBaseAbility::checkObject
This commit is contained in:
parent
8ec4ffd9de
commit
2d625f0364
49 changed files with 399 additions and 171 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,7 +33,7 @@ public class HexproofAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.abilities.keyword;
|
|||
|
||||
import mage.MageObject;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.icon.CardIcon;
|
||||
|
|
@ -9,10 +10,12 @@ import mage.abilities.icon.CardIconImpl;
|
|||
import mage.abilities.icon.CardIconType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* an abstract base class for hexproof abilities
|
||||
|
|
@ -21,11 +24,11 @@ import java.util.*;
|
|||
*/
|
||||
public abstract class HexproofBaseAbility extends SimpleStaticAbility implements MageSingleton {
|
||||
|
||||
HexproofBaseAbility() {
|
||||
protected HexproofBaseAbility() {
|
||||
super(Zone.BATTLEFIELD, null);
|
||||
}
|
||||
|
||||
public abstract boolean checkObject(MageObject source, Game game);
|
||||
public abstract boolean checkObject(MageObject sourceObject, Ability source, Game game);
|
||||
|
||||
public static Set<HexproofBaseAbility> getFromColor(ObjectColor color) {
|
||||
Set<HexproofBaseAbility> abilities = new HashSet<>();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -31,8 +32,8 @@ public class HexproofFromArtifactsCreaturesAndEnchantments extends HexproofBaseA
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.isArtifact(game) || source.isCreature(game) || source.isEnchantment(game);
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.isArtifact(game) || sourceObject.isCreature(game) || sourceObject.isEnchantment(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,8 +33,8 @@ public class HexproofFromBlackAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.getColor(game).isBlack();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.getColor(game).isBlack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,8 +33,8 @@ public class HexproofFromBlueAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.getColor(game).isBlue();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.getColor(game).isBlue();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -31,8 +32,8 @@ public class HexproofFromEachColorAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return !source.getColor(game).isColorless();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return !sourceObject.getColor(game).isColorless();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,8 +33,8 @@ public class HexproofFromGreenAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.getColor(game).isGreen();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.getColor(game).isGreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,8 +33,8 @@ public class HexproofFromMonocoloredAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return !source.getColor(game).isMulticolored() && !source.getColor(game).isColorless();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return !sourceObject.getColor(game).isMulticolored() && !sourceObject.getColor(game).isColorless();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
||||
public class HexproofFromMulticoloredAbility extends HexproofBaseAbility {
|
||||
|
||||
private static final HexproofFromMulticoloredAbility instance;
|
||||
|
|
@ -31,8 +32,8 @@ public class HexproofFromMulticoloredAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.getColor().isMulticolored();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.getColor().isMulticolored();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -31,8 +32,8 @@ public class HexproofFromPlaneswalkersAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.isPlaneswalker(game);
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.isPlaneswalker(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,8 +33,8 @@ public class HexproofFromRedAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.getColor(game).isRed();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.getColor(game).isRed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package mage.abilities.keyword;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
|
|
@ -32,8 +33,8 @@ public class HexproofFromWhiteAbility extends HexproofBaseAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean checkObject(MageObject source, Game game) {
|
||||
return source.getColor(game).isWhite();
|
||||
public boolean checkObject(MageObject sourceObject, Ability source, Game game) {
|
||||
return sourceObject.getColor(game).isWhite();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public interface Permanent extends Card, Controllable {
|
|||
|
||||
void unattach(Game game);
|
||||
|
||||
boolean canBeTargetedBy(MageObject source, UUID controllerId, Game game);
|
||||
boolean canBeTargetedBy(MageObject sourceObject, UUID controllerId, Ability source, Game game);
|
||||
|
||||
boolean hasProtectionFrom(MageObject source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -1302,8 +1302,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeTargetedBy(MageObject source, UUID sourceControllerId, Game game) {
|
||||
if (source != null) {
|
||||
public boolean canBeTargetedBy(MageObject sourceObject, UUID sourceControllerId, Ability source, Game game) {
|
||||
if (sourceObject != null) {
|
||||
if (abilities.containsKey(ShroudAbility.getInstance().getId())) {
|
||||
if (game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.SHROUD, null, sourceControllerId, game).isEmpty()) {
|
||||
return false;
|
||||
|
|
@ -1315,17 +1315,17 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
&& abilities.stream()
|
||||
.filter(HexproofBaseAbility.class::isInstance)
|
||||
.map(HexproofBaseAbility.class::cast)
|
||||
.anyMatch(ability -> ability.checkObject(source, game))) {
|
||||
.anyMatch(ability -> ability.checkObject(sourceObject, source, game))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasProtectionFrom(source, game)) {
|
||||
if (hasProtectionFrom(sourceObject, game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// example: Fiendslayer Paladin tried to target with Ultimate Price
|
||||
return !game.getContinuousEffects().preventedByRuleModification(
|
||||
new TargetEvent(this, source.getId(), sourceControllerId),
|
||||
new TargetEvent(this, sourceObject.getId(), sourceControllerId),
|
||||
null,
|
||||
game,
|
||||
true
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ public interface Player extends MageItem, Copyable<Player> {
|
|||
|
||||
boolean triggerAbility(TriggeredAbility ability, Game game);
|
||||
|
||||
boolean canBeTargetedBy(MageObject source, UUID sourceControllerId, Game game);
|
||||
boolean canBeTargetedBy(MageObject sourceObject, UUID sourceControllerId, Ability source, Game game);
|
||||
|
||||
boolean hasProtectionFrom(MageObject source, Game game);
|
||||
|
||||
|
|
|
|||
|
|
@ -687,11 +687,11 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeTargetedBy(MageObject source, UUID sourceControllerId, Game game) {
|
||||
public boolean canBeTargetedBy(MageObject sourceObject, UUID sourceControllerId, Ability source, Game game) {
|
||||
if (this.hasLost() || this.hasLeft()) {
|
||||
return false;
|
||||
}
|
||||
if (source != null) {
|
||||
if (sourceObject != null) {
|
||||
if (abilities.containsKey(ShroudAbility.getInstance().getId())
|
||||
&& game.getContinuousEffects().asThough(this.getId(), AsThoughEffectType.SHROUD, null, sourceControllerId, game).isEmpty()) {
|
||||
return false;
|
||||
|
|
@ -703,17 +703,17 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
&& abilities.stream()
|
||||
.filter(HexproofBaseAbility.class::isInstance)
|
||||
.map(HexproofBaseAbility.class::cast)
|
||||
.anyMatch(ability -> ability.checkObject(source, game))) {
|
||||
.anyMatch(ability -> ability.checkObject(sourceObject, source, game))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasProtectionFrom(source, game)) {
|
||||
if (hasProtectionFrom(sourceObject, game)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// example: Peace Talks
|
||||
return !game.getContinuousEffects().preventedByRuleModification(
|
||||
new TargetEvent(this, source.getId(), sourceControllerId),
|
||||
new TargetEvent(this, sourceObject.getId(), sourceControllerId),
|
||||
null,
|
||||
game,
|
||||
true
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ public class TargetPermanent extends TargetObject {
|
|||
// first for protection from spells or abilities (e.g. protection from colored spells, r1753)
|
||||
// second for protection from sources (e.g. protection from artifacts + equip ability)
|
||||
if (!isNotTarget()) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game)
|
||||
|| !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, source, game)
|
||||
|| !permanent.canBeTargetedBy(game.getObject(source), controllerId, source, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ public class TargetPermanent extends TargetObject {
|
|||
MageObject targetSource = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) {
|
||||
if (!targets.containsKey(permanent.getId())) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
count++;
|
||||
if (count >= remainingTargets) {
|
||||
return true;
|
||||
|
|
@ -155,7 +155,7 @@ public class TargetPermanent extends TargetObject {
|
|||
MageObject targetSource = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, source, game)) {
|
||||
if (!targets.containsKey(permanent.getId())) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, sourceControllerId, source, game)) {
|
||||
if (player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (player.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -109,7 +109,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && !player.hasLeft() && filter.match(player, sourceControllerId, source, game)) {
|
||||
if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (isNotTarget() || player.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ public class TargetPlayer extends TargetImpl {
|
|||
Player player = game.getPlayer(id);
|
||||
if (player != null) {
|
||||
if (source != null) {
|
||||
return (isNotTarget() || player.canBeTargetedBy(game.getObject(source), source.getControllerId(), game))
|
||||
return (isNotTarget() || player.canBeTargetedBy(game.getObject(source), source.getControllerId(), source, game))
|
||||
&& filter.match(player, source.getControllerId(), source, game);
|
||||
} else {
|
||||
return filter.match(player, game);
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class TargetCardInGraveyardBattlefieldOrStack extends TargetCard {
|
|||
}
|
||||
MageObject targetSource = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent, sourceControllerId, source, game)) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ public class TargetCardInGraveyardBattlefieldOrStack extends TargetCard {
|
|||
Set<UUID> possibleTargets = super.possibleTargets(sourceControllerId, source, game); // in graveyard first
|
||||
MageObject targetSource = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filterPermanent, sourceControllerId, source, game)) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,10 +71,10 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
if (source != null) {
|
||||
MageObject targetSource = game.getObject(source);
|
||||
if (permanent != null) {
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(permanent, source.getControllerId(), source, game);
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), source, game) && filter.match(permanent, source.getControllerId(), source, game);
|
||||
}
|
||||
if (player != null) {
|
||||
return player.canBeTargetedBy(targetSource, source.getControllerId(), game) && filter.match(player, game);
|
||||
return player.canBeTargetedBy(targetSource, source.getControllerId(), source, game) && filter.match(player, game);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
MageObject targetSource = game.getObject(source);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, game)) {
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, source, game) && filter.match(player, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -108,7 +108,7 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -157,13 +157,13 @@ public class TargetCreatureOrPlayer extends TargetImpl {
|
|||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null
|
||||
&& player.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
&& player.canBeTargetedBy(targetSource, sourceControllerId, source, game)
|
||||
&& filter.getPlayerFilter().match(player, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getCreatureFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)
|
||||
&& filter.getCreatureFilter().match(permanent, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
|
|||
if (source != null) {
|
||||
boolean canSourceControllerTarget = true;
|
||||
if (!isNotTarget()) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game)
|
||||
|| !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, source, game)
|
||||
|| !permanent.canBeTargetedBy(game.getObject(source), controllerId, source, game)) {
|
||||
canSourceControllerTarget = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
|
|||
for (Permanent perm : game.getBattlefield().getActivePermanents(opp.getId(), game)) {
|
||||
if (!targets.containsKey(perm.getId())
|
||||
&& filter.match(perm, opp.getId(), source, game)
|
||||
&& perm.canBeTargetedBy(sourceObject, sourceControllerId, game)) {
|
||||
&& perm.canBeTargetedBy(sourceObject, sourceControllerId, source, game)) {
|
||||
counter++;
|
||||
if (counter >= minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class TargetPermanentAmount extends TargetAmount {
|
|||
return filter.match(permanent, game);
|
||||
}
|
||||
MageObject targetSource = source.getSourceObject(game);
|
||||
return (notTarget || permanent.canBeTargetedBy(targetSource, source.getControllerId(), game))
|
||||
return (notTarget || permanent.canBeTargetedBy(targetSource, source.getControllerId(), source, game))
|
||||
&& filter.match(permanent, source.getControllerId(), source, game);
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ public class TargetPermanentAmount extends TargetAmount {
|
|||
.getActivePermanents(filter, sourceControllerId, source, game)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(permanent -> notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
|
||||
.filter(permanent -> notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game))
|
||||
.map(Permanent::getId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
MageObject targetSource = game.getObject(source);
|
||||
if (permanent != null) {
|
||||
if (!isNotTarget()) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), game)
|
||||
|| !permanent.canBeTargetedBy(game.getObject(source), source.getControllerId(), game)) {
|
||||
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), source.getControllerId(), source, game)
|
||||
|| !permanent.canBeTargetedBy(game.getObject(source), source.getControllerId(), source, game)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
}
|
||||
if (player != null) {
|
||||
if (!isNotTarget()) {
|
||||
if (!player.canBeTargetedBy(targetSource, source.getControllerId(), game)
|
||||
if (!player.canBeTargetedBy(targetSource, source.getControllerId(), source, game)
|
||||
|| !filter.match(player, source.getControllerId(), source, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
MageObject targetSource = game.getObject(source);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(player, sourceControllerId, source, game)) {
|
||||
if (player != null && player.canBeTargetedBy(targetSource, sourceControllerId, source, game) && filter.match(player, sourceControllerId, source, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -134,7 +134,7 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -183,12 +183,12 @@ public class TargetPermanentOrPlayer extends TargetImpl {
|
|||
MageObject targetSource = game.getObject(source);
|
||||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(player, sourceControllerId, source, game)) {
|
||||
if (player != null && (notTarget || player.canBeTargetedBy(targetSource, sourceControllerId, source, game)) && filter.match(player, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(playerId);
|
||||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if ((notTarget || permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
|||
if (source != null) {
|
||||
MageObject targetSource = source.getSourceObject(game);
|
||||
if (permanent != null) {
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game)
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), source, game)
|
||||
&& filter.match(permanent, source.getControllerId(), source, game);
|
||||
}
|
||||
if (player != null) {
|
||||
return player.canBeTargetedBy(targetSource, source.getControllerId(), game)
|
||||
return player.canBeTargetedBy(targetSource, source.getControllerId(), source, game)
|
||||
&& filter.match(player, game);
|
||||
}
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
|||
for (UUID playerId : game.getState().getPlayersInRange(sourceControllerId, game)) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player == null
|
||||
|| !player.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
|| !player.canBeTargetedBy(targetSource, sourceControllerId, source, game)
|
||||
|| !filter.match(player, game)) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -109,7 +109,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
|||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (!permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) {
|
||||
if (!permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game)) {
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
|
|
@ -160,7 +160,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
|||
.stream()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(player -> player.canBeTargetedBy(targetSource, sourceControllerId, game)
|
||||
.filter(player -> player.canBeTargetedBy(targetSource, sourceControllerId, source, game)
|
||||
&& filter.match(player, game)
|
||||
)
|
||||
.map(Player::getId)
|
||||
|
|
@ -170,7 +170,7 @@ public abstract class TargetPermanentOrPlayerAmount extends TargetAmount {
|
|||
.getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(permanent -> permanent.canBeTargetedBy(targetSource, sourceControllerId, game))
|
||||
.filter(permanent -> permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game))
|
||||
.map(Permanent::getId)
|
||||
.forEach(possibleTargets::add);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
|||
public boolean canChoose(UUID sourceControllerId, Ability source, Game game) {
|
||||
MageObject sourceObject = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, source, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
|||
Set<UUID> possibleTargets = new HashSet<>(20);
|
||||
MageObject sourceObject = game.getObject(source);
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if (permanent.canBeTargetedBy(sourceObject, sourceControllerId, source, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ public class TargetPermanentOrSuspendedCard extends TargetImpl {
|
|||
if (permanent != null) {
|
||||
if (source != null) {
|
||||
MageObject targetSource = game.getObject(source);
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game)
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), source, game)
|
||||
&& filter.match(permanent, source.getControllerId(), source, game);
|
||||
} else {
|
||||
return filter.match(permanent, game);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
|
|||
if (permanent != null) {
|
||||
if (source != null) {
|
||||
MageObject targetSource = game.getObject(source);
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), game)
|
||||
return permanent.canBeTargetedBy(targetSource, source.getControllerId(), source, game)
|
||||
&& filter.match(permanent, source.getControllerId(), source, game);
|
||||
} else {
|
||||
return filter.match(permanent, game);
|
||||
|
|
@ -132,7 +132,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
|
|||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
count++;
|
||||
if (count >= this.minNumberOfTargets) {
|
||||
return true;
|
||||
|
|
@ -189,7 +189,7 @@ public class TargetSpellOrPermanent extends TargetImpl {
|
|||
}
|
||||
}
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter.getPermanentFilter(), sourceControllerId, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, source, game) && filter.match(permanent, sourceControllerId, source, game)) {
|
||||
possibleTargets.add(permanent.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue