mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 12:31:59 -08:00
getPermanent directly, not via getBattlefield
This commit is contained in:
parent
ad66b7439b
commit
10230f0d99
30 changed files with 45 additions and 45 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue