getPermanent directly, not via getBattlefield

This commit is contained in:
xenohedron 2024-06-02 01:10:46 -04:00
parent ad66b7439b
commit 10230f0d99
30 changed files with 45 additions and 45 deletions

View file

@ -26,9 +26,9 @@ public class AttachedToMatchesFilterCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.getAttachedTo() != null) {
Permanent attachedTo = game.getBattlefield().getPermanent(permanent.getAttachedTo());
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
if (attachedTo == null) {
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
}

View file

@ -36,11 +36,11 @@ public class EnchantedSourceCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
int numberOfFoundEnchantments = 0;
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
Permanent attached = game.getPermanent(uuid);
if (attached != null && attached.isEnchantment(game) && (!aurasOnly || attached.hasSubtype(SubType.AURA, game))) {
numberOfFoundEnchantments += 1;
}

View file

@ -22,7 +22,7 @@ public enum EnchantedTargetCondition implements Condition {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
if (targetPermanent != null) {
for (UUID uuid : targetPermanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
Permanent attached = game.getPermanent(uuid);
if (attached != null && attached.isEnchantment(game)) {
return true;
}

View file

@ -29,11 +29,11 @@ public class EquippedHasSubtypeCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent == null || permanent.getAttachedTo() == null) {
return false;
}
Permanent attachedTo = game.getBattlefield().getPermanent(permanent.getAttachedTo());
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
if (attachedTo == null) {
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
}

View file

@ -31,9 +31,9 @@ public class EquippedHasSupertypeCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.getAttachedTo() != null) {
Permanent attachedTo = game.getBattlefield().getPermanent(permanent.getAttachedTo());
Permanent attachedTo = game.getPermanent(permanent.getAttachedTo());
if (attachedTo == null) {
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
}

View file

@ -20,11 +20,11 @@ public enum EquippedMultipleSourceCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
int countEquipped = 0;
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
Permanent attached = game.getPermanent(uuid);
if (attached != null && attached.hasSubtype(SubType.EQUIPMENT, game)) {
countEquipped++;
if (countEquipped >= 2) {
@ -41,4 +41,4 @@ public enum EquippedMultipleSourceCondition implements Condition {
return "has multiple Equipments attached";
}
}
}

View file

@ -20,10 +20,10 @@ public enum EquippedSourceCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
for (UUID uuid : permanent.getAttachments()) {
Permanent attached = game.getBattlefield().getPermanent(uuid);
Permanent attached = game.getPermanent(uuid);
if (attached != null && attached.hasSubtype(SubType.EQUIPMENT, game)) {
return true;
}

View file

@ -17,7 +17,7 @@ public enum SourceAttackingCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
return permanent.isAttacking();
}
@ -30,4 +30,4 @@ public enum SourceAttackingCondition implements Condition {
}
}
}

View file

@ -17,7 +17,7 @@ public enum SourceBlockedCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
return permanent.isBlocked(game);
}
@ -30,4 +30,4 @@ public enum SourceBlockedCondition implements Condition {
}
}
}

View file

@ -20,7 +20,7 @@ public enum SourceTappedCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
return permanent != null && permanent.isTapped() == tapped;
}

View file

@ -80,7 +80,7 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
if (source != null) {
return source.getControllerId();
}
Permanent permanent = game.getBattlefield().getPermanent(sourceId);
Permanent permanent = game.getPermanent(sourceId);
if (permanent != null) {
return permanent.getControllerId();
}

View file

@ -28,7 +28,7 @@ public class RedirectDamageFromSourceToTargetEffect extends RedirectionEffect {
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null) {
if (event.getTargetId().equals(source.getSourceId())) {
if (getTargetPointer().getFirst(game, source) != null) {