Fixed multiple NPE errors in cards;

This commit is contained in:
Oleg Agafonov 2020-01-28 03:37:49 +04:00
parent 285ed5801f
commit 105062beb7
14 changed files with 104 additions and 94 deletions

View file

@ -1,7 +1,5 @@
package mage.abilities.effects.common;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -13,9 +11,11 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.Set;
import java.util.UUID;
/**
* @author LevelX2
*
*/
public class HideawayPlayEffect extends OneShotEffect {
@ -40,12 +40,16 @@ public class HideawayPlayEffect extends OneShotEffect {
if (permanent != null) {
zone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanent.getZoneChangeCounter(game)));
}
if (zone == null
|| zone.isEmpty()) {
if (zone == null) {
return true;
}
Card card = zone.getCards(game).iterator().next();
Set<Card> cards = zone.getCards(game);
if (cards.isEmpty()) {
return true;
}
Card card = cards.iterator().next();
Player controller = game.getPlayer(source.getControllerId());
if (card != null && controller != null) {
if (controller.chooseUse(Outcome.PlayForFree, "Do you want to play " + card.getIdName() + " for free now?", source, game)) {

View file

@ -285,6 +285,9 @@ public final class ZonesHandler {
public static List<Card> chooseOrder(String message, Cards cards, Player player, Game game) {
List<Card> order = new ArrayList<>();
if (cards.isEmpty()) {
return order;
}
TargetCard target = new TargetCard(Zone.ALL, new FilterCard(message));
target.setRequired(true);
while (player.isInGame() && cards.size() > 1) {