ensure that parameter permanent in WhenPutIntoGraveyeard trigger is not null before calling its methods

master
melvin 2011-08-25 12:42:47 +08:00
parent 291a92c252
commit 85a20ff543
4 changed files with 28 additions and 24 deletions

View File

@ -29,7 +29,11 @@ public class Archon_of_Justice {
}
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object data[],final Object[] choiceResults) {
public void executeEvent(
final MagicGame game,
final MagicEvent event,
final Object data[],
final Object[] choiceResults) {
final MagicPermanent permanent=event.getTarget(game,choiceResults,0);
if (permanent!=null) {
game.doAction(new MagicRemoveFromPlayAction(permanent,MagicLocationType.Exile));

View File

@ -14,16 +14,15 @@ public class Butcher_of_Malakir {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final Object data) {
final MagicGraveyardTriggerData triggerData=(MagicGraveyardTriggerData)data;
if (MagicLocationType.Play==triggerData.fromLocation) {
final MagicPlayer controller=permanent.getController();
return new MagicEvent(
permanent,
controller,
new Object[]{permanent,game.getOpponent(controller)},
this,
"Your opponent sacrifices a creature.");
}
return null;
final MagicPlayer controller = (permanent != null) ? permanent.getController() : null;
return (MagicLocationType.Play==triggerData.fromLocation) ?
new MagicEvent(
permanent,
controller,
new Object[]{permanent,game.getOpponent(controller)},
this,
"Your opponent sacrifices a creature."):
null;
}
@Override
@ -45,17 +44,18 @@ public class Butcher_of_Malakir {
public static final MagicTrigger T2 = new MagicTrigger(MagicTriggerType.WhenOtherPutIntoGraveyardFromPlay) {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final Object data) {
final MagicPermanent otherPermanent=(MagicPermanent)data;
final MagicPlayer controller=permanent.getController();
if (otherPermanent!=permanent&&otherPermanent.getController()==controller&&otherPermanent.isCreature()) {
return new MagicEvent(
permanent,
controller,
new Object[]{permanent,game.getOpponent(controller)},
this,
"Your opponent sacrifices a creature.");
}
return null;
final MagicPermanent otherPermanent = (MagicPermanent)data;
final MagicPlayer controller = permanent.getController();
return (otherPermanent != permanent &&
otherPermanent.getController() == controller &&
otherPermanent.isCreature()) ?
new MagicEvent(
permanent,
controller,
new Object[]{permanent,game.getOpponent(controller)},
this,
"Your opponent sacrifices a creature."):
null;
}
@Override

View File

@ -16,7 +16,7 @@ public class Sprouting_Thrinax {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final Object data) {
final MagicGraveyardTriggerData triggerData=(MagicGraveyardTriggerData)data;
final MagicPlayer player = permanent.getController();
final MagicPlayer player = (permanent != null) ? permanent.getController() : null;
return (MagicLocationType.Play==triggerData.fromLocation) ?
new MagicEvent(
permanent,

View File

@ -16,7 +16,7 @@ public class Tuktuk_the_Explorer {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final Object data) {
final MagicGraveyardTriggerData triggerData=(MagicGraveyardTriggerData)data;
final MagicPlayer player = permanent.getController();
final MagicPlayer player = (permanent != null) ? permanent.getController() : null;
return (MagicLocationType.Play==triggerData.fromLocation) ?
new MagicEvent(
permanent,