mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Fixed NPE errors on missing card (game.getCard can't find card);
This commit is contained in:
parent
c30316512b
commit
745bfa2836
9 changed files with 25 additions and 13 deletions
|
@ -99,6 +99,7 @@ class DanceOfTheManseEffect extends OneShotEffect {
|
|||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet()));
|
||||
player.moveCards(cards, Zone.BATTLEFIELD, source, game);
|
||||
if (source.getManaCostsToPay().getX() < 6) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import mage.filter.common.FilterCreatureCard;
|
|||
import mage.game.Game;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -68,6 +69,7 @@ class DeathbellowWarCryTarget extends TargetCardInLibrary {
|
|||
.getTargets()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.map(Card::getName)
|
||||
.noneMatch(card.getName()::equals);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mage.cards.d;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
|
@ -8,7 +7,6 @@ import mage.abilities.costs.common.SacrificeSourceCost;
|
|||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
|
@ -23,8 +21,10 @@ import mage.players.Player;
|
|||
import mage.target.TargetCard;
|
||||
import mage.target.common.TargetOpponent;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class DiscordantDirge extends CardImpl {
|
||||
|
@ -81,9 +81,9 @@ class DiscordantDirgeEffect extends OneShotEffect {
|
|||
TargetCard target = new TargetCard(0, verseCounters, Zone.HAND, new FilterCard());
|
||||
target.setNotTarget(true);
|
||||
if (controller.choose(Outcome.Benefit, targetOpponent.getHand(), target, game)) {
|
||||
target.getTargets().stream().map(game::getCard).filter((card) -> (card != null
|
||||
&& targetOpponent.getHand().contains(card.getId()))).forEachOrdered((card) -> {
|
||||
targetOpponent.discard(card, source, game);
|
||||
target.getTargets().stream().map(game::getCard).filter(Objects::nonNull).filter((card) -> (card != null
|
||||
&& targetOpponent.getHand().contains(card.getId()))).forEachOrdered((card) -> {
|
||||
targetOpponent.discard(card, source, game);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import mage.target.Target;
|
|||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -74,6 +75,7 @@ class ForeverYoungEffect extends OneShotEffect {
|
|||
.map(Target::getTargets)
|
||||
.flatMap(Collection::stream)
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet())
|
||||
), game, source, true);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import mage.game.Game;
|
|||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -88,6 +89,7 @@ class KethisTheHiddenHandEffect extends ContinuousEffectImpl {
|
|||
player.getGraveyard()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(Card::isLegendary)
|
||||
.forEach(card -> affectedObjectList.add(new MageObjectReference(card, game)));
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ import mage.constants.Outcome;
|
|||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
|
@ -79,6 +81,7 @@ class ScrollOfFateEffect extends OneShotEffect {
|
|||
.getTargets()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
cards.stream().forEach(card -> {
|
||||
ManaCosts manaCosts = null;
|
||||
|
|
|
@ -12,6 +12,7 @@ import mage.filter.common.FilterCreatureCard;
|
|||
import mage.game.Game;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -70,6 +71,7 @@ class SharedSummonsTarget extends TargetCardInLibrary {
|
|||
.getTargets()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.filter(Objects::nonNull)
|
||||
.noneMatch(c -> c != null && c.getName().equals(card.getName()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class CardsImpl extends LinkedHashSet<UUID> implements Cards, Serializabl
|
|||
|
||||
@Override
|
||||
public Set<Card> getCards(FilterCard filter, Game game) {
|
||||
return stream().map(game::getCard).filter(card -> filter.match(card, game)).collect(Collectors.toSet());
|
||||
return stream().map(game::getCard).filter(Objects::nonNull).filter(card -> filter.match(card, game)).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -164,7 +164,7 @@ public class Library implements Serializable {
|
|||
* @return
|
||||
*/
|
||||
public List<Card> getCards(Game game) {
|
||||
return library.stream().map(game::getCard).collect(Collectors.toList());
|
||||
return library.stream().map(game::getCard).filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Set<Card> getTopCards(Game game, int amount) {
|
||||
|
|
Loading…
Reference in a new issue