forked from External/mage
* Fixed some possible null pointer exceptions seen in xmage.de server log.
This commit is contained in:
parent
71ed488c1e
commit
f0ee60eedb
3 changed files with 27 additions and 18 deletions
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.d;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -52,7 +53,7 @@ public class DreamThief extends CardImpl {
|
|||
private static final String rule = "draw a card if you've cast another blue spell this turn";
|
||||
|
||||
public DreamThief(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
|
||||
this.subtype.add(SubType.FAERIE);
|
||||
this.subtype.add(SubType.ROGUE);
|
||||
|
||||
|
|
@ -84,9 +85,12 @@ class CastBlueSpellThisTurnCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
for (Spell spell : watcher.getSpellsCastThisTurn(source.getControllerId())) {
|
||||
if (!spell.getSourceId().equals(source.getSourceId()) && spell.getColor(game).isBlue()) {
|
||||
return true;
|
||||
List<Spell> spells = watcher.getSpellsCastThisTurn(source.getControllerId());
|
||||
if (spells != null) {
|
||||
for (Spell spell : spells) {
|
||||
if (!spell.getSourceId().equals(source.getSourceId()) && spell.getColor(game).isBlue()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ import mage.game.events.NumberOfTriggersEvent;
|
|||
public class Panharmonicon extends CardImpl {
|
||||
|
||||
public Panharmonicon(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// If an artifact or creature entering the battlefield causes a triggered ability of a permanent you control to trigger, that ability triggers an additional time.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PanharmoniconEffect()));
|
||||
|
|
@ -95,7 +95,9 @@ class PanharmoniconEffect extends ReplacementEffectImpl {
|
|||
if (source.getControllerId().equals(event.getPlayerId())) {
|
||||
GameEvent sourceEvent = numberOfTriggersEvent.getSourceEvent();
|
||||
// Only EtB triggers
|
||||
if (sourceEvent.getType() == EventType.ENTERS_THE_BATTLEFIELD && sourceEvent instanceof EntersTheBattlefieldEvent) {
|
||||
if (sourceEvent != null
|
||||
&& sourceEvent.getType() == EventType.ENTERS_THE_BATTLEFIELD
|
||||
&& sourceEvent instanceof EntersTheBattlefieldEvent) {
|
||||
EntersTheBattlefieldEvent entersTheBattlefieldEvent = (EntersTheBattlefieldEvent) sourceEvent;
|
||||
// Only for entering artifacts or creatures
|
||||
if (entersTheBattlefieldEvent.getTarget().isArtifact()
|
||||
|
|
@ -116,4 +118,4 @@ class PanharmoniconEffect extends ReplacementEffectImpl {
|
|||
event.setAmount(event.getAmount() + 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.cards.t;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
|
|
@ -49,7 +50,7 @@ import mage.target.common.TargetOpponent;
|
|||
public class TreacherousPitDweller extends CardImpl {
|
||||
|
||||
public TreacherousPitDweller(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{B}{B}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{B}{B}");
|
||||
this.subtype.add(SubType.DEMON);
|
||||
|
||||
this.power = new MageInt(4);
|
||||
|
|
@ -77,24 +78,24 @@ class TreacherousPitDwellerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
private static final String ruleText = "When {this} enters the battlefield from a graveyard, ";
|
||||
|
||||
public TreacherousPitDwellerTriggeredAbility() {
|
||||
super(Zone.BATTLEFIELD, new TreacherousPitDwellerEffect(),false);
|
||||
super(Zone.BATTLEFIELD, new TreacherousPitDwellerEffect(), false);
|
||||
addTarget(new TargetOpponent());
|
||||
}
|
||||
|
||||
public TreacherousPitDwellerTriggeredAbility(final TreacherousPitDwellerTriggeredAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
return event.getTargetId().equals(getSourceId()) && ((EntersTheBattlefieldEvent) event).getFromZone() == Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
return event.getTargetId().equals(getSourceId()) && ((EntersTheBattlefieldEvent) event).getFromZone() == Zone.GRAVEYARD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreacherousPitDwellerTriggeredAbility copy() {
|
||||
return new TreacherousPitDwellerTriggeredAbility(this);
|
||||
|
|
@ -104,7 +105,7 @@ class TreacherousPitDwellerTriggeredAbility extends TriggeredAbilityImpl {
|
|||
public String getRule() {
|
||||
return ruleText + super.getRule();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class TreacherousPitDwellerEffect extends ContinuousEffectImpl {
|
||||
|
|
@ -125,10 +126,12 @@ class TreacherousPitDwellerEffect extends ContinuousEffectImpl {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
|
||||
MageObject permanent = source.getSourceObjectIfItStillExists(game); // it can also return Card object
|
||||
Player targetOpponent = game.getPlayer(source.getFirstTarget());
|
||||
if (permanent != null && targetOpponent != null) {
|
||||
return permanent.changeControllerId(targetOpponent.getId(), game);
|
||||
if (permanent != null
|
||||
&& (permanent instanceof Permanent)
|
||||
&& targetOpponent != null) {
|
||||
return ((Permanent) permanent).changeControllerId(targetOpponent.getId(), game);
|
||||
} else {
|
||||
discard();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue