mirror of
https://github.com/correl/mage.git
synced 2024-12-26 11:09:27 +00:00
* ManaSpentToCastWatcher - Fixed possible null pointer exception.
This commit is contained in:
parent
b8f0c38101
commit
7aa27a9800
1 changed files with 6 additions and 7 deletions
|
@ -25,7 +25,6 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.watchers.common;
|
package mage.watchers.common;
|
||||||
|
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
@ -58,16 +57,16 @@ public class ManaSpentToCastWatcher extends Watcher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void watch(GameEvent event, Game game) {
|
public void watch(GameEvent event, Game game) {
|
||||||
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) {
|
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.HAND) {
|
||||||
Spell spell = (Spell) game.getObject(event.getTargetId());
|
Spell spell = (Spell) game.getObject(event.getTargetId());
|
||||||
if (this.getSourceId().equals(spell.getSourceId())) {
|
if (spell != null && this.getSourceId().equals(spell.getSourceId())) {
|
||||||
payment = spell.getSpellAbility().getManaCostsToPay().getPayment();
|
payment = spell.getSpellAbility().getManaCostsToPay().getPayment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && this.getSourceId().equals(event.getSourceId())) {
|
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && this.getSourceId().equals(event.getSourceId())) {
|
||||||
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) {
|
if (((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD)) {
|
||||||
payment = null;
|
payment = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue