mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
fixing another place for NPE
This commit is contained in:
@@ -33,22 +33,6 @@ public final class AllZoneUtil {
|
|||||||
return creats.filter(CardListFilter.creatures);
|
return creats.filter(CardListFilter.creatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* use to get a list of creatures in play with a given keyword.
|
|
||||||
*
|
|
||||||
* @param keyword the keyword to get creatures for
|
|
||||||
* @return a CardList containing all creatures in play with a given keyword
|
|
||||||
*/
|
|
||||||
public static CardList getCreaturesInPlayWithKeyword(final String keyword) {
|
|
||||||
CardList list = getCreaturesInPlay();
|
|
||||||
list = list.filter(new CardListFilter() {
|
|
||||||
public boolean addCard(final Card c) {
|
|
||||||
return c.hasKeyword(keyword);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets a list of all cards of a certain type that a given player has in given zone.
|
* gets a list of all cards of a certain type that a given player has in given zone.
|
||||||
@@ -70,8 +54,12 @@ public final class AllZoneUtil {
|
|||||||
*/
|
*/
|
||||||
public static CardList getCardsIn(final Constant.Zone zone) {
|
public static CardList getCardsIn(final Constant.Zone zone) {
|
||||||
CardList cards = new CardList();
|
CardList cards = new CardList();
|
||||||
for (Player p : Singletons.getModel().getGameState().getPlayers()) {
|
if ( zone == Zone.Stack) {
|
||||||
cards.addAll(p.getZone(zone).getCards());
|
cards.addAll(AllZone.getStackZone().getCards());
|
||||||
|
} else {
|
||||||
|
for (Player p : AllZone.getPlayersInGame()) {
|
||||||
|
cards.addAll(p.getZone(zone).getCards());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return cards;
|
return cards;
|
||||||
}
|
}
|
||||||
@@ -386,8 +374,9 @@ public final class AllZoneUtil {
|
|||||||
*/
|
*/
|
||||||
public static CardList getCardsInGame() {
|
public static CardList getCardsInGame() {
|
||||||
CardList all = new CardList();
|
CardList all = new CardList();
|
||||||
getCardsInGame(AllZone.getHumanPlayer(), all);
|
for (Player p : AllZone.getPlayersInGame()) {
|
||||||
getCardsInGame(AllZone.getComputerPlayer(), all);
|
getCardsInGame(p, all);
|
||||||
|
}
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +385,7 @@ public final class AllZoneUtil {
|
|||||||
CardList all = toAdd == null ? new CardList() : toAdd;
|
CardList all = toAdd == null ? new CardList() : toAdd;
|
||||||
all.addAll(player.getZone(Zone.Graveyard).getCards());
|
all.addAll(player.getZone(Zone.Graveyard).getCards());
|
||||||
all.addAll(player.getZone(Zone.Hand).getCards());
|
all.addAll(player.getZone(Zone.Hand).getCards());
|
||||||
all.addAll(player.getZone(Zone.Library).getCards());
|
all.addAll(player.getZone(Zone.Library).getCards()); // not sure if library should be included.
|
||||||
all.addAll(player.getZone(Zone.Battlefield).getCards());
|
all.addAll(player.getZone(Zone.Battlefield).getCards());
|
||||||
all.addAll(player.getZone(Zone.Exile).getCards());
|
all.addAll(player.getZone(Zone.Exile).getCards());
|
||||||
//should this include Human_Command ?
|
//should this include Human_Command ?
|
||||||
|
|||||||
@@ -538,8 +538,7 @@ public class Upkeep implements java.io.Serializable {
|
|||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
private static CardList abyss_getTargets(final Player player, final Card card) {
|
private static CardList abyss_getTargets(final Player player, final Card card) {
|
||||||
CardList creats = AllZoneUtil.getCreaturesInPlay(player);
|
CardList creats = AllZoneUtil.getCreaturesInPlay(player).filter(CardListFilter.nonartifacts);
|
||||||
creats = creats.filter(CardListFilter.nonartifacts);
|
|
||||||
creats = creats.getTargetableCards(card);
|
creats = creats.getTargetableCards(card);
|
||||||
return creats;
|
return creats;
|
||||||
}
|
}
|
||||||
@@ -561,8 +560,7 @@ public class Upkeep implements java.io.Serializable {
|
|||||||
final Ability sacrificeArtifact = new Ability(c, "") {
|
final Ability sacrificeArtifact = new Ability(c, "") {
|
||||||
@Override
|
@Override
|
||||||
public void resolve() {
|
public void resolve() {
|
||||||
CardList artifacts = player.getCardsIn(Zone.Battlefield);
|
CardList artifacts = player.getCardsIn(Zone.Battlefield).filter(CardListFilter.artifacts);
|
||||||
artifacts = artifacts.filter(CardListFilter.artifacts);
|
|
||||||
|
|
||||||
if (player.isHuman()) {
|
if (player.isHuman()) {
|
||||||
AllZone.getInputControl().setInput(new Input() {
|
AllZone.getInputControl().setInput(new Input() {
|
||||||
|
|||||||
Reference in New Issue
Block a user