mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Various NPE fixes based on server log
This commit is contained in:
parent
ebbbc1daf1
commit
bee12d709c
3 changed files with 46 additions and 41 deletions
|
@ -102,7 +102,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
rules.add(sbRule.toString());
|
||||
}
|
||||
String rule = ability.getRule();
|
||||
if (rule.length() > 0) {
|
||||
if (rule != null && rule.length() > 0) {
|
||||
rules.add(Character.toUpperCase(rule.charAt(0)) + rule.substring(1));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent.getTarget().getAttachments() != null && zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
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.)
|
||||
|
@ -80,6 +81,7 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
if (triggered) {
|
||||
for (Effect effect : getEffects()) {
|
||||
if (zEvent.getTarget() != null) {
|
||||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
if (setTargetPointer.equals(SetTargetPointer.ATTACHED_TO_CONTROLLER)) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
|
@ -89,12 +91,13 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,8 +120,9 @@ public class AwakenAbility extends SpellAbility {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
UUID targetId = null;
|
||||
if (source != null && source.getTargets() != null) {
|
||||
for (Target target : source.getTargets()) {
|
||||
if (target.getFilter().getMessage().equals(filterMessage)) {
|
||||
if (target.getFilter() != null && target.getFilter().getMessage().equals(filterMessage)) {
|
||||
targetId = target.getFirstTarget();
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +135,7 @@ public class AwakenAbility extends SpellAbility {
|
|||
effect.setTargetPointer(fixedTarget);
|
||||
return effect.apply(game, source);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue