Search in sources :

Example 1 with CardIconCategory

use of mage.abilities.icon.CardIconCategory in project mage by magefree.

the class MageLayer method updateCardIcons.

private void updateCardIcons(CardView card) {
    Map<CardIconsPanel, List<CardIcon>> newIcons = new HashMap<>();
    this.iconsPanels.forEach(panel -> newIcons.put(panel, new ArrayList<>()));
    List<CardIcon> allIcons = new ArrayList<>();
    // main icons
    allIcons.addAll(card.getCardIcons());
    // playable icons
    if (card.getPlayableStats().getPlayableImportantAmount() > 0) {
        allIcons.add(new PlayableCountIcon(card.getPlayableStats()));
    }
    // create panels
    allIcons.forEach(cardIcon -> {
        CardIconCategory category = cardIcon.getIconType().getCategory();
        // debug panel must take all icons (position depends on render settings)
        if (iconsDebugPanel != null) {
            newIcons.get(iconsDebugPanel).add(cardIcon);
        }
        // playable panel (bottom left corner)
        if (iconsPlayablePanel != null && category == CardIconCategory.PLAYABLE_COUNT) {
            newIcons.get(iconsPlayablePanel).add(cardIcon);
        }
        // abilities panel (left side)
        if (iconsAbilitiesPanel != null && category == CardIconCategory.ABILITY) {
            newIcons.get(iconsAbilitiesPanel).add(cardIcon);
        }
        // commander panel (top center)
        if (iconsCommanderPanel != null && category == CardIconCategory.COMMANDER) {
            newIcons.get(iconsCommanderPanel).add(cardIcon);
        }
    });
    this.iconsPanels.forEach(panel -> panel.updateIcons(newIcons.get(panel)));
}
Also used : HashMap(java.util.HashMap) CardIconsPanel(mage.client.cards.CardIconsPanel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) PlayableCountIcon(mage.abilities.icon.system.PlayableCountIcon) CardIcon(mage.abilities.icon.CardIcon) CardIconCategory(mage.abilities.icon.CardIconCategory)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 CardIcon (mage.abilities.icon.CardIcon)1 CardIconCategory (mage.abilities.icon.CardIconCategory)1 PlayableCountIcon (mage.abilities.icon.system.PlayableCountIcon)1 CardIconsPanel (mage.client.cards.CardIconsPanel)1