forked from External/mage
getPermanent directly, not via getBattlefield
This commit is contained in:
parent
ad66b7439b
commit
10230f0d99
30 changed files with 45 additions and 45 deletions
|
|
@ -67,7 +67,7 @@ class AetherVialEffect extends OneShotEffect {
|
|||
|
||||
@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 = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
if (permanent == null) {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class TargetMatchesFilterCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent target = game.getBattlefield().getPermanent(source.getFirstTarget());
|
||||
Permanent target = game.getPermanent(source.getFirstTarget());
|
||||
if (target != null) {
|
||||
if (filter.match(target, source.getControllerId(), source, game)) {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class DaughterOfAutumnPreventDamageTargetEffect 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 (filter.match(permanent, permanent.getControllerId(), source, game)) {
|
||||
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class HazduhrTheAbbotRedirectDamageEffect 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 (filter.match(permanent, permanent.getControllerId(), source, game)) {
|
||||
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class MartyrdomActivatedAbility extends ActivatedAbilityImpl {
|
|||
if (!playerId.equals(caster)) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId());
|
||||
Permanent permanent = game.getPermanent(this.getSourceId());
|
||||
if (permanent == null || !permanent.isCreature(game)) {
|
||||
return ActivationStatus.getFalse();
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ class MartyrdomRedirectDamageTargetEffect 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 (filter.match(permanent, permanent.getControllerId(), source, game)) {
|
||||
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class MerseineActivatedAbility extends SimpleActivatedAbility {
|
|||
|
||||
@Override
|
||||
public ActivationStatus canActivate(UUID playerId, Game game) {
|
||||
Permanent sourcePermanent = game.getBattlefield().getPermanent(this.getSourceId());
|
||||
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
|
|
@ -116,7 +116,7 @@ class MerseineCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
Permanent sourcePermanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
|
|
@ -128,7 +128,7 @@ class MerseineCost extends CostImpl {
|
|||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
Permanent sourcePermanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
|
||||
if (sourcePermanent != null) {
|
||||
Permanent attachedTo = game.getPermanent(sourcePermanent.getAttachedTo());
|
||||
if (attachedTo != null) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class MurderousSpoilsEffect extends OneShotEffect {
|
|||
if (target != null) {
|
||||
List<Permanent> attachments = new ArrayList<>();
|
||||
for (UUID uuid : target.getAttachments()) {
|
||||
Permanent attached = game.getBattlefield().getPermanent(uuid);
|
||||
Permanent attached = game.getPermanent(uuid);
|
||||
if (attached.hasSubtype(SubType.EQUIPMENT, game)) {
|
||||
attachments.add(attached);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ enum EnchantedOrEquippedSourceCondition 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.isEnchantment(game)
|
||||
|| attached.hasSubtype(SubType.EQUIPMENT, game))) {
|
||||
|
|
|
|||
|
|
@ -98,14 +98,14 @@ enum OathkeeperEquippedSamuraiCondition 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 = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
}
|
||||
if (permanent != null) {
|
||||
Permanent attachedTo = null;
|
||||
if (permanent.getAttachedTo() != null) {
|
||||
attachedTo = game.getBattlefield().getPermanent(permanent.getAttachedTo());
|
||||
attachedTo = game.getPermanent(permanent.getAttachedTo());
|
||||
if (attachedTo == null) {
|
||||
attachedTo = (Permanent) game.getLastKnownInformation(permanent.getAttachedTo(), Zone.BATTLEFIELD);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ enum PalladiaMorsTheRuinerCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
PalladiaMorsTheRuinerWatcher watcher = game.getState().getWatcher(PalladiaMorsTheRuinerWatcher.class);
|
||||
return permanent != null && !watcher.getDamagers().contains(new MageObjectReference(permanent, game));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class PyromancerAscensionCopyTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (event.getPlayerId().equals(this.getControllerId())) {
|
||||
Spell spell = game.getStack().getSpell(event.getTargetId());
|
||||
if (isControlledInstantOrSorcery(spell, game)) {
|
||||
Permanent permanent = game.getBattlefield().getPermanent(this.getSourceId());
|
||||
Permanent permanent = game.getPermanent(this.getSourceId());
|
||||
if (permanent != null && permanent.getCounters(game).getCount(CounterType.QUEST) >= 2) {
|
||||
this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId()));
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ enum RampagingCyclopsCondition 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.isAttacking()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class RatchetBombEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent p = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
Permanent p = game.getPermanent(source.getSourceId());
|
||||
if (p == null) {
|
||||
p = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
|
||||
if (p == null) {
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class ShamanEnKorRedirectFromTargetEffect 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 (filter.match(permanent, permanent.getControllerId(), source, game)) {
|
||||
if (sourceObject.equals(new MageObjectReference(event.getSourceId(), game))) {
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@ class AttachedAttackedOrBlockedSinceYourLastUpkeepCondition implements Condition
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
AttackedOrBlockedSinceYourLastUpkeepWatcher watcher = game.getState().getWatcher(AttackedOrBlockedSinceYourLastUpkeepWatcher.class);
|
||||
if (permanent != null && permanent.getAttachedTo() != null && watcher != 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ class ShimianNightStalkerRedirectDamageEffect 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 (filter.match(permanent, permanent.getControllerId(), source, game)) {
|
||||
if (event.getSourceId() != null && event.getTargetId() != null) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class TrainingDroneEffect extends RestrictionEffect {
|
|||
if (permanent.getId().equals(source.getSourceId())) {
|
||||
List<UUID> attachments = permanent.getAttachments();
|
||||
for (UUID uuid : attachments) {
|
||||
Permanent attached = game.getBattlefield().getPermanent(uuid);
|
||||
Permanent attached = game.getPermanent(uuid);
|
||||
if (attached.hasSubtype(SubType.EQUIPMENT, game)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class BlockedOrBeenBlockedSinceYourLastUpkeepCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent wiitigo = game.getBattlefield().getPermanent(source.getSourceId());
|
||||
Permanent wiitigo = game.getPermanent(source.getSourceId());
|
||||
BlockedOrBeenBlockedSinceYourLastUpkeepWatcher watcher = game.getState().getWatcher(
|
||||
BlockedOrBeenBlockedSinceYourLastUpkeepWatcher.class);
|
||||
if (wiitigo != null
|
||||
|
|
|
|||
|
|
@ -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