/** * setupPlayZone. * * @param p a {@link arcane.ui.PlayArea} object. * @param c an array of {@link forge.Card} objects. */ public static void setupPlayZone(PlayArea p, Card c[]) { List<Card> tmp, diff; tmp = new ArrayList<Card>(); for (arcane.ui.CardPanel cpa : p.cardPanels) tmp.add(cpa.gameCard); diff = new ArrayList<Card>(tmp); diff.removeAll(Arrays.asList(c)); if (diff.size() == p.cardPanels.size()) p.clear(); else { for (Card card : diff) { p.removeCardPanel(p.getCardPanel(card.getUniqueNumber())); } } diff = new ArrayList<Card>(Arrays.asList(c)); diff.removeAll(tmp); arcane.ui.CardPanel toPanel = null; for (Card card : diff) { toPanel = p.addCard(card); Animation.moveCard(toPanel); } for (Card card : c) { toPanel = p.getCardPanel(card.getUniqueNumber()); if (card.isTapped()) { toPanel.tapped = true; toPanel.tappedAngle = arcane.ui.CardPanel.TAPPED_ANGLE; } else { toPanel.tapped = false; toPanel.tappedAngle = 0; } toPanel.attachedPanels.clear(); if (card.isEnchanted()) { ArrayList<Card> enchants = card.getEnchantedBy(); for (Card e : enchants) { arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber()); if (cardE != null) toPanel.attachedPanels.add(cardE); } } if (card.isEquipped()) { ArrayList<Card> enchants = card.getEquippedBy(); for (Card e : enchants) { arcane.ui.CardPanel cardE = p.getCardPanel(e.getUniqueNumber()); if (cardE != null) toPanel.attachedPanels.add(cardE); } } if (card.isEnchanting()) { toPanel.attachedToPanel = p.getCardPanel(card.getEnchanting().get(0).getUniqueNumber()); } else if (card.isEquipping()) { toPanel.attachedToPanel = p.getCardPanel(card.getEquipping().get(0).getUniqueNumber()); } else toPanel.attachedToPanel = null; toPanel.setCard(toPanel.gameCard); } p.invalidate(); p.repaint(); }
/** * getEnchantedLands. * * @param cards a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object. */ public static ArrayList<Card> getEnchantedLands(ArrayList<Card> cards) { ArrayList<Card> ret = new ArrayList<Card>(); for (Card c : cards) { if (c.isLand() && c.isEnchanted()) { ret.addAll(c.getEnchantedBy()); ret.add(c); } } return ret; }
/** * getEquippedEnchantedCreatures. * * @param cards a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object. */ public static ArrayList<Card> getEquippedEnchantedCreatures(ArrayList<Card> cards) { ArrayList<Card> ret = new ArrayList<Card>(); for (Card c : cards) { if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) { if (c.isEquipped()) ret.addAll(c.getEquippedBy()); if (c.isEnchanted()) ret.addAll(c.getEnchantedBy()); ret.add(c); } } return ret; }