forked from External/mage
remove redundant null checks, remove some static fields
This commit is contained in:
parent
05dcfeaaa1
commit
a0e54fbb7b
21 changed files with 84 additions and 104 deletions
|
|
@ -10,7 +10,6 @@ import mage.constants.Zone;
|
|||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class ActivateIfConditionActivatedAbility extends ActivatedAbilityImpl {
|
||||
|
|
@ -37,15 +36,12 @@ public class ActivateIfConditionActivatedAbility extends ActivatedAbilityImpl {
|
|||
} else {
|
||||
sb.append(" Activate this ability only ");
|
||||
}
|
||||
if (condition.toString() != null) {
|
||||
if (!condition.toString().startsWith("during")
|
||||
&& !condition.toString().startsWith("before")) {
|
||||
sb.append("if ");
|
||||
}
|
||||
sb.append(condition.toString()).append('.');
|
||||
} else {
|
||||
sb.append(" [Condition toString() == null] ");
|
||||
if (!condition.toString().startsWith("during")
|
||||
&& !condition.toString().startsWith("before")) {
|
||||
sb.append("if ");
|
||||
}
|
||||
sb.append(condition.toString()).append('.');
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,41 +62,40 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent != null) {
|
||||
if (zEvent.getTarget() != null && zEvent.getTarget().getAttachments() != null && zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If both (attachment and attached went to graveyard at the same time, the attachemnets can be already removed from the attached object.)
|
||||
// So check here with the LKI of the enchantment
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null
|
||||
&& zEvent.getTargetId() != null && attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId().equals(attachment.getAttachedTo())) {
|
||||
Permanent attachedTo = game.getPermanentOrLKIBattlefield(attachment.getAttachedTo());
|
||||
if (attachedTo != null
|
||||
&& attachment.getAttachedToZoneChangeCounter() == attachedTo.getZoneChangeCounter(game)) { // zoneChangeCounter is stored in Permanent
|
||||
triggered = true;
|
||||
if (zEvent.getTarget() != null && zEvent.getTarget().getAttachments() != null && zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If both (attachment and attached went to graveyard at the same time, the attachemnets can be already removed from the attached object.)
|
||||
// So check here with the LKI of the enchantment
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null
|
||||
&& zEvent.getTargetId() != null && attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId().equals(attachment.getAttachedTo())) {
|
||||
Permanent attachedTo = game.getPermanentOrLKIBattlefield(attachment.getAttachedTo());
|
||||
if (attachedTo != null
|
||||
&& attachment.getAttachedToZoneChangeCounter() == attachedTo.getZoneChangeCounter(game)) { // zoneChangeCounter is stored in Permanent
|
||||
triggered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (triggered) {
|
||||
for (Effect effect : getEffects()) {
|
||||
if (zEvent.getTarget() != null) {
|
||||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
if (setTargetPointer == SetTargetPointer.ATTACHED_TO_CONTROLLER) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachedTo != null) {
|
||||
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (triggered) {
|
||||
for (Effect effect : getEffects()) {
|
||||
if (zEvent.getTarget() != null) {
|
||||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
if (setTargetPointer == SetTargetPointer.ATTACHED_TO_CONTROLLER) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachedTo != null) {
|
||||
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class RollPlanarDieEffect extends OneShotEffect {
|
|||
for (int i = 0; i < chaosEffects.size(); i++) {
|
||||
Effect effect = chaosEffects.get(i);
|
||||
Target target = null;
|
||||
if (chaosTargets != null && chaosTargets.size() > i) {
|
||||
if (chaosTargets.size() > i) {
|
||||
target = chaosTargets.get(i);
|
||||
}
|
||||
boolean done = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue