Beispiel #1
0
  public Map<String, List<Class<? extends Card>>> getCards() throws CardLoader.CardLoaderException {
    if (this.classMap == null) {
      CardLoader.CardLoaderException failAfter = null;

      Map<String, List<Class<? extends Card>>> ret =
          new HashMap<String, List<Class<? extends Card>>>();

      for (Map.Entry<String, List<String>> entry : this.cards.entrySet()) {
        List<Class<? extends Card>> clsList = new LinkedList<Class<? extends Card>>();
        ret.put(entry.getKey(), clsList);

        for (String cardName : entry.getValue()) {
          Class<? extends Card> cls = null;
          try {
            cls = CardLoader.getCard(cardName);
          } catch (CardLoaderException e) {
            if (failAfter == null) failAfter = e;
            else failAfter.combine(e);
          }
          clsList.add(cls);
        }
      }

      if (null != failAfter) throw failAfter;

      this.classMap = ret;
    }

    return this.classMap;
  }
Beispiel #2
0
 public static Set get() {
   if (set == null) {
     Set ret = new Set();
     for (Class<? extends Card> card : org.rnd.jmagic.CardLoader.getAllCards()) {
       Name name = card.getAnnotation(Name.class);
       if (name != null)
         // when naming cards for meddling mage, you name one
         // side of a split card, not both sides.
         java.util.Arrays.stream(name.value().split(" // ")).forEach(n -> ret.add(n));
     }
     set = new Set.Unmodifiable(ret);
   }
   return set;
 }