@Override
 public Deck loadDeck(String name) {
   DeckData data;
   try {
     data = gson.fromJson(readSource(getDeckUri(name)), DeckData.class);
     CardLibrary cl = loadCardLibrary();
     Card identityCard = cl.getCard(data.getIdentity());
     Deck deck = new Deck(cl.getItentity(identityCard.getKey()), data.getName());
     for (CardRef ref : data.getCards()) {
       deck.add(cl.getCard(ref.getCard()), ref.getCount());
     }
     return deck;
   } catch (JsonIOException e) {
     e.printStackTrace();
   } catch (JsonSyntaxException e) {
     e.printStackTrace();
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   }
   return null;
 }
示例#2
0
 /**
  * 获取卡号 //TODO:yinger 没有使用!
  *
  * @return
  */
 public static byte[] getCardNumByte() {
   byte[] snr = {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
   byte[] buffer = new byte[100];
   int a = 1; // initialize as 1 fail
   // 0-success 1-fail
   try {
     a = cl.MF_Read((byte) 0, (byte) 0, (byte) 1, snr, buffer);
   } catch (Exception e) {
     a = -1;
   }
   snr[4] = (byte) a;
   return snr;
 }
示例#3
0
 /** 获取卡号(可用) */
 public static long getCardNum() {
   byte[] snr = {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff};
   byte[] buffer = new byte[100];
   int a = 1; // initialize as 1 fail
   // 0-success 1-fail
   try {
     a = cl.MF_Read((byte) 0, (byte) 0, (byte) 1, snr, buffer);
   } catch (Exception e) {
     a = 1;
   }
   if (a == 1) {
     return -1;
   } else {
     return bytes2long(snr, 0);
   }
 }
 @Override
 public CardLibrary loadCardLibrary() {
   CardLibrary cl = new CardLibrary(getRuleFactory());
   cl.addAll(loadCards());
   return cl;
 }
示例#5
0
 public void init(List<Card> cards) {
   setCard(CardLibrary.get(getContext()).nextCard(cards));
 }