Fixed some possible exceptions.

This commit is contained in:
LevelX2 2016-02-06 02:12:51 +01:00
parent e936f7dc0f
commit d2eb6151f1
20 changed files with 133 additions and 132 deletions

View file

@ -24,12 +24,10 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
*/
package mage.abilities.costs.common;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.costs.Cost;
import mage.abilities.costs.CostImpl;
@ -67,7 +65,7 @@ public class PayLoyaltyCost extends CostImpl {
@Override
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) {
Permanent planeswalker = game.getPermanent(sourceId);
if (planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game)) {
if (planeswalker != null && planeswalker.getCounters().getCount(CounterType.LOYALTY) + amount >= 0 && planeswalker.canLoyaltyBeUsed(game)) {
if (amount > 0) {
planeswalker.getCounters().addCounter(CounterType.LOYALTY.createInstance(amount));
} else if (amount < 0) {

View file

@ -43,6 +43,7 @@ import java.util.Set;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.MageSingleton;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
@ -743,6 +744,9 @@ public class ContinuousEffects implements Serializable {
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {
effect.setValue("targetAbility", targetAbility);
if (effect.applies(event, sourceAbility, game)) {
if (targetAbility instanceof ActivatedAbility && ((ActivatedAbility) targetAbility).isCheckPlayableMode()) {
checkPlayableMode = true;
}
if (!checkPlayableMode) {
String message = effect.getInfoMessage(sourceAbility, event, game);
if (message != null && !message.isEmpty()) {

View file

@ -88,10 +88,10 @@ public class PlaneswalkerRedirectionEffect extends RedirectionEffect {
player.choose(Outcome.Damage, redirectTarget, null, game);
}
if (!game.isSimulation()) {
game.informPlayers(new StringBuilder(player.getLogName()).append(" redirects ")
.append(event.getAmount())
.append(" damage to ")
.append(game.getPermanent(redirectTarget.getFirstTarget()).getLogName()).toString());
Permanent redirectTo = game.getPermanent(redirectTarget.getFirstTarget());
if (redirectTo != null) {
game.informPlayers(player.getLogName() + " redirects " + event.getAmount() + " damage to " + redirectTo.getLogName());
}
}
return true;
}

View file

@ -69,6 +69,6 @@ public class CounterTargetEffect extends OneShotEffect {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "counter target " + mode.getTargets().get(0).getTargetName();
return "counter target " + (mode.getTargets().get(0) != null ? mode.getTargets().get(0).getTargetName() : "spell");
}
}

View file

@ -34,7 +34,7 @@ import mage.players.Player;
*/
public class EpicEffect extends OneShotEffect {
final String rule = "<br><br/>Epic <i>(For the rest of the game, you can't cast spells. At the beginning of each of your upkeeps for the rest of the game, copy this spell except for its epic ability. If the spell has targets, you may choose new targets for the copy)";
final String rule = "<br>Epic <i>(For the rest of the game, you can't cast spells. At the beginning of each of your upkeeps for the rest of the game, copy this spell except for its epic ability. If the spell has targets, you may choose new targets for the copy)";
public EpicEffect() {
super(Outcome.Benefit);