forked from External/mage
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
|
|
@ -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