(WIP) Replacing blocking/blocked by predicates (#8729)

* replaced blocking/blocked by predicates

* added test for knight of dusk (currently fails)

* added source parameter to filters and everything else that needs it

* some changes to various predicates

* test fix

* small changes to filter code

* merge fix

* fixed a test failure

* small change to Karn, Scion of Urza

* removed sourceId from filter methods and other similar places

* added new getobject method to fix some test failures

* a few more fixes

* fixed merge conflicts

* merge fix
This commit is contained in:
Evan Kranzler 2022-03-23 18:45:02 -04:00 committed by GitHub
parent 53877424a0
commit 80e11b2052
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1719 changed files with 3384 additions and 3325 deletions

View file

@ -28,8 +28,8 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
}
@Override
public boolean canTarget(UUID controllerId, UUID id, UUID sourceId, Game game, boolean flag) {
return opponentId != null && super.canTarget(opponentId, id, sourceId, game, flag);
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game, boolean flag) {
return opponentId != null && super.canTarget(opponentId, id, source, game, flag);
}
@Override
@ -41,12 +41,12 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
boolean canSourceControllerTarget = true;
if (!isNotTarget()) {
if (!permanent.canBeTargetedBy(game.getObject(source.getId()), controllerId, game)
|| !permanent.canBeTargetedBy(game.getObject(source.getSourceId()), controllerId, game)) {
|| !permanent.canBeTargetedBy(game.getObject(source), controllerId, game)) {
canSourceControllerTarget = false;
}
}
canSourceControllerTarget &= super.canTarget(opponentId, id, source, game);
canSourceControllerTarget &= filter.match(permanent, source.getSourceId(), opponentId, game);
canSourceControllerTarget &= filter.match(permanent, opponentId, source, game);
return canSourceControllerTarget;
}
}
@ -75,8 +75,8 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
}
@Override
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
MageObject sourceObject = game.getObject(sourceId);
public boolean canChoose(UUID sourceControllerId, Ability source, Game game) {
MageObject sourceObject = game.getObject(source);
Player player = game.getPlayer(sourceControllerId);
if (sourceObject == null || player == null) {
return false;
@ -88,7 +88,7 @@ public class TargetOpponentsChoicePermanent extends TargetPermanent {
if (opp != null && player.hasOpponent(opp.getId(), game)) {
for (Permanent perm : game.getBattlefield().getActivePermanents(opp.getId(), game)) {
if (!targets.containsKey(perm.getId())
&& filter.match(perm, sourceId, opp.getId(), game)
&& filter.match(perm, opp.getId(), source, game)
&& perm.canBeTargetedBy(sourceObject, sourceControllerId, game)) {
counter++;
if (counter >= minNumberOfTargets) {