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;
|
||||
}
|
||||
|
||||
@@ -399,17 +399,17 @@ public class CardFactory {
|
||||
}
|
||||
|
||||
private static void readCardFace(Card c, ICardFace face) {
|
||||
for(String a : face.getAbilities()) c.addIntrinsicAbility(a);
|
||||
for(String k : face.getKeywords()) c.addIntrinsicKeyword(k);
|
||||
for(String r : face.getReplacements()) c.addReplacementEffect(ReplacementHandler.parseReplacement(r, c, true));
|
||||
for(String s : face.getStaticAbilities()) c.addStaticAbilityString(s);
|
||||
for(String t : face.getTriggers()) c.addTrigger(TriggerHandler.parseTrigger(t, c, true));
|
||||
for(Entry<String, String> v : face.getVariables()) c.setSVar(v.getKey(), v.getValue());
|
||||
for (String a : face.getAbilities()) c.addIntrinsicAbility(a);
|
||||
for (String k : face.getKeywords()) c.addIntrinsicKeyword(k);
|
||||
for (String r : face.getReplacements()) c.addReplacementEffect(ReplacementHandler.parseReplacement(r, c, true));
|
||||
for (String s : face.getStaticAbilities()) c.addStaticAbilityString(s);
|
||||
for (String t : face.getTriggers()) c.addTrigger(TriggerHandler.parseTrigger(t, c, true));
|
||||
for (Entry<String, String> v : face.getVariables()) c.setSVar(v.getKey(), v.getValue());
|
||||
|
||||
c.setName(face.getName());
|
||||
c.setManaCost(face.getManaCost());
|
||||
c.setText(face.getNonAbilityText());
|
||||
if( face.getInitialLoyalty() > 0 ) c.setBaseLoyalty(face.getInitialLoyalty());
|
||||
if (face.getInitialLoyalty() > 0) c.setBaseLoyalty(face.getInitialLoyalty());
|
||||
|
||||
c.getCurrentState().setOracleText(face.getOracleText().replace("\\n", "\r\n"));
|
||||
|
||||
@@ -422,11 +422,11 @@ public class CardFactory {
|
||||
ccc.add(col1);
|
||||
c.setColor(ccc);
|
||||
|
||||
if ( face.getIntPower() >= 0 ) {
|
||||
if (face.getIntPower() >= 0) {
|
||||
c.setBasePower(face.getIntPower());
|
||||
c.setBasePowerString(face.getPower());
|
||||
}
|
||||
if ( face.getIntToughness() >= 0 ) {
|
||||
if (face.getIntToughness() >= 0) {
|
||||
c.setBaseToughness(face.getIntToughness());
|
||||
c.setBaseToughnessString(face.getToughness());
|
||||
}
|
||||
|
||||
@@ -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