mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
fixed some NPEs
This commit is contained in:
parent
def31fef83
commit
6f87867788
7 changed files with 42 additions and 34 deletions
|
@ -98,7 +98,7 @@ public class ProteanHydra extends CardImpl<ProteanHydra> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = game.getPermanent(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
if (permanent != null && source.getManaCostsToPay().getVariableCosts().size() > 0) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
permanent.addCounters(new PlusOneCounter(amount));
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.sets.magic2011;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Duration;
|
||||
|
@ -102,9 +103,10 @@ class GargoyleSentinelEffect extends ContinuousEffectImpl<GargoyleSentinelEffect
|
|||
switch (layer) {
|
||||
case AbilityAddingRemovingEffects_6:
|
||||
if (sublayer == SubLayer.NA) {
|
||||
for (Ability ability: permanent.getAbilities()) {
|
||||
if (ability.getId().equals(DefenderAbility.getInstance().getId()))
|
||||
permanent.getAbilities().remove(ability);
|
||||
for (Iterator<Ability> i = permanent.getAbilities().iterator(); i.hasNext();) {
|
||||
Ability entry = i.next();
|
||||
if (entry.getId().equals(DefenderAbility.getInstance().getId()))
|
||||
i.remove();
|
||||
}
|
||||
permanent.getAbilities().add(FlyingAbility.getInstance());
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public abstract class RedirectionEffect<T extends RedirectionEffect<T>> extends
|
|||
DamageEvent damageEvent = (DamageEvent)event;
|
||||
Permanent permanent = game.getPermanent(redirectTarget.getFirstTarget());
|
||||
Ability damageSource = getSource(damageEvent.getSourceId(), game);
|
||||
if (permanent != null) {
|
||||
if (permanent != null && damageSource != null) {
|
||||
permanent.damage(damageEvent.getAmount(), damageSource.getId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ public class DestroyTargetEffect extends OneShotEffect<DestroyTargetEffect> {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int affectedTargets = 0;
|
||||
if (source.getTargets().size() > 0) {
|
||||
for (UUID permanentId : source.getTargets().get(0).getTargets()) {
|
||||
Permanent permanent = game.getPermanent(permanentId);
|
||||
if (permanent != null) {
|
||||
|
@ -74,6 +75,7 @@ public class DestroyTargetEffect extends OneShotEffect<DestroyTargetEffect> {
|
|||
affectedTargets++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return affectedTargets > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ public class ReturnToHandTargetEffect extends OneShotEffect<ReturnToHandTargetEf
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
if (source.getTargets().size() > 0) {
|
||||
switch (source.getTargets().get(0).getZone()) {
|
||||
case BATTLEFIELD:
|
||||
Permanent permanent = game.getPermanent(source.getFirstTarget());
|
||||
|
@ -72,6 +73,7 @@ public class ReturnToHandTargetEffect extends OneShotEffect<ReturnToHandTargetEf
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,15 +63,17 @@ public class BoostPowerXSourceEffect extends ContinuousEffectImpl<BoostPowerXSou
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
int amount = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
if (amount == 0) {
|
||||
if (source.getManaCostsToPay().getVariableCosts().size() > 0) {
|
||||
int amountX = source.getManaCostsToPay().getVariableCosts().get(0).getAmount();
|
||||
if (amountX == 0) {
|
||||
return false;
|
||||
}
|
||||
Permanent target = (Permanent) game.getPermanent(source.getSourceId());
|
||||
if (target != null) {
|
||||
target.addPower(amount);
|
||||
target.addPower(amountX);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
//TODO: this is awkward - improve
|
||||
if (event.getType() == EventType.ZONE_CHANGE) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent)event;
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD) {
|
||||
if (zEvent.getFromZone() == Zone.BATTLEFIELD && zEvent.getTarget() != null) {
|
||||
if (zEvent.getTarget() instanceof PermanentCard) {
|
||||
((PermanentCard)zEvent.getTarget()).checkPermanentOnlyTriggers(zEvent, game);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue