Improve attachment to permanent logic; implement [PIP] Codsworth, Handy Helper (#12098)

* [PIP] Implement Codsworth, Handy Helper

* Fix Codsworth and Halvar

* Write tests for attachments

* Fix auras going to graveyard when attaching to illegal targets

* Fix Captured by the Consulate interaction

* Fix failing tests, add additional test

* Add source name to log message

* Implement requested changes

* Revert removed null check

* Remove filter check, clean up code

* Add additional test

* Fix failing roles test

* Account for all current attachment edge cases

* Implement rule 303.4g

* Apply requested changes
This commit is contained in:
PurpleCrowbar 2024-08-24 06:03:33 +01:00 committed by GitHub
parent 9fcbfdeac6
commit 8d249aa691
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 580 additions and 20 deletions

View file

@ -73,7 +73,7 @@ public interface Target extends Serializable {
*/
boolean canTarget(UUID id, Ability source, Game game);
boolean stillLegalTarget(UUID id, Ability source, Game game);
boolean stillLegalTarget(UUID playerId, UUID id, Ability source, Game game);
boolean canTarget(UUID playerId, UUID id, Ability source, Game game);

View file

@ -409,7 +409,7 @@ public abstract class TargetImpl implements Target {
illegalTargets.add(targetId);
continue;
}
if (!stillLegalTarget(targetId, source, game)) {
if (!stillLegalTarget(source.getControllerId(), targetId, source, game)) {
illegalTargets.add(targetId);
}
}
@ -546,8 +546,8 @@ public abstract class TargetImpl implements Target {
}
@Override
public boolean stillLegalTarget(UUID id, Ability source, Game game) {
return canTarget(id, source, game);
public boolean stillLegalTarget(UUID controllerId, UUID id, Ability source, Game game) {
return canTarget(controllerId, id, source, game);
}
@Override

View file

@ -53,10 +53,10 @@ public class TargetTappedPermanentAsYouCast extends TargetPermanent {
// See ruling: https://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/253345-dream-leash
@Override
public boolean stillLegalTarget(UUID id, Ability source, Game game) {
public boolean stillLegalTarget(UUID controllerId, UUID id, Ability source, Game game) {
Permanent permanent = game.getPermanent(id);
return permanent != null
&& getFilter().match(permanent, game)
&& super.canTarget(id, game); // check everything but leave out the tapped requirement
&& super.canTarget(controllerId, id, source, game); // check everything but leave out the tapped requirement
}
}