mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Prevent crash when canceling prompt for card or player
This commit is contained in:
@@ -92,12 +92,16 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
public class Card extends GameEntity implements Comparable<Card>, IIdentifiable {
|
||||
private static HashMap<Integer, Card> cardCache = new HashMap<Integer, Card>();
|
||||
public static Card get(CardView cardView) {
|
||||
if (cardView == null) { return null; }
|
||||
return cardCache.get(cardView.getId());
|
||||
}
|
||||
public static CardCollection getList(Iterable<CardView> cardViews) {
|
||||
CardCollection list = new CardCollection();
|
||||
for (CardView cv : cardViews) {
|
||||
list.add(get(cv));
|
||||
Card c = get(cv);
|
||||
if (c != null) {
|
||||
list.add(c);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -83,12 +83,16 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
|
||||
private static HashMap<Integer, Player> playerCache = new HashMap<Integer, Player>();
|
||||
public static Player get(PlayerView playerView) {
|
||||
if (playerView == null) { return null; }
|
||||
return playerCache.get(playerView.getId());
|
||||
}
|
||||
public static List<Player> getList(Iterable<PlayerView> playerViews) {
|
||||
List<Player> list = new ArrayList<Player>();
|
||||
for (PlayerView pv : playerViews) {
|
||||
list.add(get(pv));
|
||||
Player p = get(pv);
|
||||
if (p != null) {
|
||||
list.add(p);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user