Пример #1
0
  /**
   * getBasics.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @param color a {@link java.lang.String} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getBasics(ArrayList<Card> cards, String color) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) {
      String name = c.getName();

      if (c.isEnchanted()) ; // do nothing
      else if (name.equals("Swamp") || name.equals("Bog")) {
        if (color == Constant.Color.Black) {
          ret.add(c);
        }
      } else if (name.equals("Forest") || name.equals("Grass")) {
        if (color == Constant.Color.Green) {
          ret.add(c);
        }

      } else if (name.equals("Plains") || name.equals("White Sand")) {
        if (color == Constant.Color.White) {
          ret.add(c);
        }

      } else if (name.equals("Mountain") || name.equals("Rock")) {
        if (color == Constant.Color.Red) {
          ret.add(c);
        }

      } else if (name.equals("Island") || name.equals("Underwater")) {
        if (color == Constant.Color.Blue) {
          ret.add(c);
        }
      }
    }

    return ret;
  }
Пример #2
0
 /**
  * getCard.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param name a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getCard(ArrayList<Card> cards, String name) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.getName().equals(name)) ret.add(c);
   }
   return ret;
 }
Пример #3
0
    /**
     * When the player click the BET button, check the input validity and process.
     *
     * @param e
     */
    @Override
    public void mouseClicked(MouseEvent e) {
      if (betButton.isEnabled()) {
        int bet = 0;
        try {
          bet = Integer.parseInt(betInput.getText());
          if (bet <= 0 || bet > player.getMoney()) throw null;
        } catch (Exception ex) {
          JOptionPane.showMessageDialog(null, "Invalid bet");
          betInput.setText(null);
          betInput.requestFocusInWindow();
          return;
        }

        int d1 = dealer.makeDecision();
        if (d1 != -1) {
          dealer.changeCard(d1, genNewCard());
          int d2 = dealer.makeDecision();
          if (d2 != -1) dealer.changeCard(d2, genNewCard());
        }

        player.makeBet(bet);
        for (Card card : player.getCards()) card.showFront();
        for (Card card : player.getCards()) card.addMouseListener(new ReplaceListener());
        betButton.setEnabled(false);
        resultButton.setEnabled(true);
        repaint();
      }
    }
Пример #4
0
 /**
  * getGlobalEnchantments.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getGlobalEnchantments(ArrayList<Card> cards) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.isGlobalEnchantment() && !c.isCreature()) ret.add(c);
   }
   return ret;
 }
Пример #5
0
 /**
  * getTokenCreatures.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getTokenCreatures(ArrayList<Card> cards) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.isCreature() && c.isToken() && !c.isEquipped() && !c.isEnchanted()) ret.add(c);
   }
   return ret;
 }
Пример #6
0
 /**
  * getPlaneswalkers.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getPlaneswalkers(ArrayList<Card> cards) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.isPlaneswalker() && !c.isArtifact()) ret.add(c);
   }
   return ret;
 }
Пример #7
0
  /**
   * getNonBasicLand.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @param landName a {@link java.lang.String} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getNonBasicLand(ArrayList<Card> cards, String landName) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) if (c.getName().equals(landName)) ret.add(c);

    return ret;
  }
Пример #8
0
 /**
  * getMoxen.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param moxName a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getMoxen(ArrayList<Card> cards, String moxName) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     String name = c.getName();
     if (name.equals(moxName) && !c.isCreature()) ret.add(c);
   }
   return ret;
 }
Пример #9
0
 /**
  * getTokenCreatures.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param tokenName a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getTokenCreatures(ArrayList<Card> cards, String tokenName) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     String name = c.getName();
     if (c.isCreature() && c.isToken() && name.equals(tokenName)) ret.add(c);
   }
   return ret;
 }
Пример #10
0
 /**
  * devModeUntapPerm.
  *
  * @since 1.0.15
  */
 public static void devModeUntapPerm() {
   CardList play = AllZoneUtil.getCardsInPlay();
   Object o = GuiUtils.getChoiceOptional("Choose a permanent", play.toArray());
   if (null == o) return;
   else {
     Card c = (Card) o;
     c.untap();
   }
 }
Пример #11
0
 /** devModeGenerateMana. */
 public static void devModeGenerateMana() {
   Card dummy = new Card();
   dummy.setOwner(AllZone.getHumanPlayer());
   dummy.setController(AllZone.getHumanPlayer());
   Ability_Mana abMana =
       new Ability_Mana(dummy, "0", "W U B G R 1", 10) {
         private static final long serialVersionUID = -2164401486331182356L;
       };
   abMana.produceMana();
 }
Пример #12
0
 /**
  * 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;
 }
Пример #13
0
 /**
  * When the player click a card for replacing, process and change the card.
  *
  * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
  */
 @Override
 public void mouseClicked(MouseEvent e) {
   if (numReplaced < 2) {
     Card nCard = genNewCard();
     nCard.addMouseListener(this);
     player.changeCard(player.getCards().indexOf(e.getSource()), nCard);
     ++numReplaced;
     repaint();
   }
 }
Пример #14
0
 // called when the User chooses a prebuilt or custom deck
 public void setPlayerDeck(String deckName) {
   if (deckName.equals("Yugi")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(yugiDeck);
   } else if (deckName.equals("Kiaba")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(kiabaDeck);
   } else if (deckName.equals("Joey")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(joeyDeck);
   } else if (deckName.equals("Pegasus")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(pegasusDeck);
   } else if (deckName.equals("Marik")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(marikDeck);
   } else if (deckName.equals("Weevil")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(weevilDeck);
   } else if (deckName.equals("Rex")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(rexDeck);
   } else if (deckName.equals("Random")) {
     currentPlayer = Card.addPrebuiltDeckToPlayerClass(randomDeck);
   } else if (deckName.equals("Custom1")) {
     currentPlayer = player1;
     currentFile = customDeck1File;
   } else if (deckName.equals("Custom2")) {
     currentPlayer = player2;
     currentFile = customDeck2File;
   } else if (deckName.equals("Custom3")) {
     currentPlayer = player3;
     currentFile = customDeck3File;
   } else if (deckName.equals("Custom4")) {
     currentPlayer = player4;
     currentFile = customDeck4File;
   }
 }
Пример #15
0
  /**
   * formatCardType.
   *
   * @param card a {@link forge.Card} object.
   * @return a {@link java.lang.String} object.
   */
  public static String formatCardType(Card card) {
    ArrayList<String> list = card.getType();
    StringBuilder sb = new StringBuilder();

    ArrayList<String> superTypes = new ArrayList<String>();
    ArrayList<String> cardTypes = new ArrayList<String>();
    ArrayList<String> subTypes = new ArrayList<String>();
    for (String t : list) {
      if (CardUtil.isASuperType(t)) superTypes.add(t);
      if (CardUtil.isACardType(t)) cardTypes.add(t);
      if (CardUtil.isASubType(t)) subTypes.add(t);
    }

    for (String type : superTypes) {
      sb.append(type).append(" ");
    }
    for (String type : cardTypes) {
      sb.append(type).append(" ");
    }
    if (!subTypes.isEmpty()) sb.append("- ");
    for (String type : subTypes) {
      sb.append(type).append(" ");
    }

    return sb.toString();
  }
Пример #16
0
  public String ReadFromSmartCard(byte file, byte id, int lent) {
    String info = "none";
    try {
      if (this.terminal != null && this.terminal.isCardPresent()) {
        if (this.SelectFileFromSmartCard(file, id)) {
          CardChannel channel = card1.getBasicChannel();
          byte[] val = infoTOwrite.getBytes();
          // new CommandAPDU(0x80,0xD2,0x01,0x00,val)
          r = channel.transmit(new CommandAPDU(0x80, 0xB2, 0x01, 0x00, lent));
          // channel.transmit((Buffer)apdu, apdu);
          System.out.println("The response2 to string is: " + r.toString());
          System.out.println("The response2 to Sting() DATA ISSS: " + r.getData().toString());
          byte dat[] = r.getData();
          System.out.println("The response2 DATA ISSS: " + r.getData());
          System.out.println(
              "The RESPONSE2 FOR GETDATA() IS "
                  + new Concatenation().ConvertByteToString(r.getData()));
          System.out.println(
              "The RESPONSE2 FOR GETBYTE() IS "
                  + new Concatenation().ConvertByteToString(r.getBytes()));
          // Integer.toHexString(javaCard.getStatusWords()).toUpperCase()
          System.out.println("The SW1 is: " + Integer.toHexString(r.getSW1()));
          System.out.println("The SW2 is: " + Integer.toHexString(r.getSW2()));
          System.out.println("The tHE WhoLE SW is: " + Integer.toHexString(r.getSW()));
          // r = channel.transmit(new CommandAPDU(new
          // byte[]{CLASS,(byte)0xA4,(byte)0x00,(byte)0x00,(byte)0x02,0,(byte)0x02,0}));
          if (Integer.toHexString(r.getSW()).equals("9000")
              || Integer.toHexString(r.getSW()).equals("9102")) {
            info = new Concatenation().ConvertByteToString(r.getData());

            System.out.println("OPERATION ON THE FILE WAS SUCCESSFUL");
          } else {
            System.out.println("OPERATION ON THE FILE WAS NOT SUCCESSFUL");
          }
        } else {
          System.out.println("FILE selection WAS nOt SUCCESSFUL:Thus cannot read from it");
        }
      } else {
        JOptionPane.showMessageDialog(
            null,
            "Card is absent.Please insert your smartCard\n to connnect it in 5 secs\nWaiting...");
      }

    } catch (CardException ce) {
      System.out.println("The Error cause is:" + ce.getMessage());
      ce.printStackTrace();
    } finally {
      try {
        this.card1.disconnect(true);
      } catch (CardException ce) {
        System.out.println("COULDN'T DISCONNECT CARD is:" + ce.getMessage());
        ce.printStackTrace();
      }
    }
    return info.trim();
  }
Пример #17
0
 /**
  * devModeAddCounter.
  *
  * @since 1.0.15
  */
 public static void devModeAddCounter() {
   CardList play = AllZoneUtil.getCardsInPlay();
   Object o = GuiUtils.getChoiceOptional("Add counters to which card?", play.toArray());
   if (null == o) return;
   else {
     Card c = (Card) o;
     Counters counter = GuiUtils.getChoiceOptional("Which type of counter?", Counters.values());
     if (null == counter) return;
     else {
       Integer integers[] = new Integer[99];
       for (int j = 0; j < 99; j++) integers[j] = Integer.valueOf(j);
       Integer i = GuiUtils.getChoiceOptional("How many counters?", integers);
       if (null == i) return;
       else {
         c.addCounterFromNonEffect(counter, i);
       }
     }
   }
 }
Пример #18
0
  /**
   * 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;
  }
Пример #19
0
  public boolean InitializePersonalizationFILE() {
    byte id = (byte) 0x02;

    Boolean IsWriiten = false;
    try {
      if (this.terminal != null && this.terminal.isCardPresent()) {
        if (this.SubmittIC() && this.SelectFileFromSmartCard(PERSONALIZE_FILE, id)) {
          CardChannel channel = card1.getBasicChannel();

          // byte USERid=(byte)0x11;
          // new CommandAPDU(0x80,0xD2,0x01,0x00,val)
          // 80 D2 00 00 06 05 03 00 00 F0 02
          // 0x80,0xD2,0x00,0x00,0x06,0x05,0x03,0x00,0x00,0xF0,0x02
          // r= channel.transmit(new CommandAPDU(0x80,0xD2,0x01,0x00,val));80 D2 00 00 04 00 00 03
          // 00
          byte[] SelectFilecomAPDUBytes =
              new byte[] {CLASS, writeINS2, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x00};
          r = channel.transmit(new CommandAPDU(SelectFilecomAPDUBytes));
          // channel.transmit((Buffer)apdu, apdu);
          System.out.println("The response2 to string is: " + r.toString());
          System.out.println("The response2 to Sting() DATA ISSS: " + r.getData().toString());
          byte dat[] = r.getData();

          // Integer.toHexString(javaCard.getStatusWords()).toUpperCase()
          System.out.println("The SW1 is: " + Integer.toHexString(r.getSW1()));
          System.out.println("The SW2 is: " + Integer.toHexString(r.getSW2()));
          System.out.println("The tHE WhoLE SW is: " + Integer.toHexString(r.getSW()));
          // r = channel.transmit(new CommandAPDU(new
          // byte[]{CLASS,(byte)0xA4,(byte)0x00,(byte)0x00,(byte)0x02,0,(byte)0x02,0}));
          if (Integer.toHexString(r.getSW()).equals("9000")
              || Integer.toHexString(r.getSW()).equals("9102")) {
            IsWriiten = true;

            System.out.println(" WRITTEN OPERATION ON THE FILE WAS SUCCESSFUL");
          } else {
            IsWriiten = false;
            System.out.println(" WRITTEN OPERATION ON THE FILE WAS NOT SUCCESSFUL");
          }
        } else {
          System.out.println("FILE selection WAS nOt SUCCESSFUL:Thus cannot write to it");
        }
      } else {
        JOptionPane.showMessageDialog(
            null,
            "Card is absent.Please insert your smartCard\n to connnect it in 5 secs\nWaiting...");
      }

    } catch (CardException ce) {
      System.out.println("The Error cause is:" + ce.getMessage());
      ce.printStackTrace();
    }

    return IsWriiten;
  }
Пример #20
0
  /**
   * getNonBasics.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getNonBasics(ArrayList<Card> cards) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) {
      if (!c.isLand() && !c.getName().startsWith("Mox") && !(c instanceof ManaPool)) {
        ret.add(c);
      } else {
        String name = c.getName();
        if (c.isEnchanted()
            || name.equals("Swamp")
            || name.equals("Bog")
            || name.equals("Forest")
            || name.equals("Grass")
            || name.equals("Plains")
            || name.equals("White Sand")
            || name.equals("Mountain")
            || name.equals("Rock")
            || name.equals("Island")
            || name.equals("Underwater")
            || name.equals("Badlands")
            || name.equals("Bayou")
            || name.equals("Plateau")
            || name.equals("Scrubland")
            || name.equals("Savannah")
            || name.equals("Taiga")
            || name.equals("Tropical Island")
            || name.equals("Tundra")
            || name.equals("Underground Sea")
            || name.equals("Volcanic Island")
            || name.startsWith("Mox")
            || c instanceof ManaPool) {
          // do nothing.
        } else {
          ret.add(c);
        }
      }
    }

    return ret;
  }
Пример #21
0
 private void judge() {
   if (player.numOfSpecialCards() > dealer.numOfSpecialCards()) {
     player.win();
     dealer.lose();
   } else if (player.numOfSpecialCards() < dealer.numOfSpecialCards()) {
     dealer.win();
     player.lose();
   } else {
     int playerScore = 0, dealerScore = 0;
     for (Card card : player.getCards()) {
       if (!card.isSpecial()) playerScore += card.getValue();
       playerScore %= 10;
     }
     for (Card card : dealer.getCards()) {
       if (!card.isSpecial()) dealerScore += card.getValue();
       dealerScore %= 10;
     }
     if (playerScore > dealerScore) {
       player.win();
       dealer.lose();
     } else {
       dealer.win();
       player.lose();
     }
   }
 }
Пример #22
0
 /**
  * When the player click the RESULT button, update the UI and judge the game, and then restart a
  * round or a game.
  *
  * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
  */
 @Override
 public void mouseClicked(MouseEvent e) {
   if (resultButton.isEnabled()) {
     for (Card card : dealer.getCards()) card.showFront();
     betInput.setText(null);
     judge();
     bestScore = player.getMoney() > bestScore ? player.getMoney() : bestScore;
     ++roundsPlayed;
     repaint();
     if (player.getMoney() == 0) {
       JOptionPane.showMessageDialog(null, "All money lost, starting a new game :(");
       newGame();
     } else {
       removeAll();
       if (roundsPlayed == 5) {
         roundsPlayed = 0;
         JOptionPane.showMessageDialog(null, "reshuffling...");
         cardUsed.clear();
       }
       initRound();
       repaint();
     }
   }
 }
Пример #23
0
 /**
  * getNonCreatureArtifacts.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getNonCreatureArtifacts(ArrayList<Card> cards) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     String name = c.getName();
     if (c.isArtifact()
         && !c.isCreature()
         && !c.isLand()
         && !c.isGlobalEnchantment()
         && !(c.isEquipment() && c.isEquipping())
         && !name.equals("Mox Emerald")
         && !name.equals("Mox Jet")
         && !name.equals("Mox Pearl")
         && !name.equals("Mox Ruby")
         && !name.equals("Mox Sapphire")) ret.add(c);
   }
   return ret;
 }
Пример #24
0
  public DetectiveNotes(ArrayList<Card> cards) {
    // Sets the standard window information
    this.setLayout(new GridLayout(0, 2));
    setTitle("Detective Notes");
    setSize(600, 700);

    // Initialize the lists
    playerList = new ArrayList<String>();
    weaponList = new ArrayList<String>();
    roomList = new ArrayList<String>();

    // Adds an "unsure" option to each list
    playerList.add("Unsure");
    weaponList.add("Unsure");
    roomList.add("Unsure");

    // Reads the card names out of the file, storing it in the appropriate list
    for (Card card : cards) {
      if (card.getCardType() == CardType.PERSON) playerList.add(card.getName());
      else if (card.getCardType() == CardType.WEAPON) weaponList.add(card.getName());
      else if (card.getCardType() == CardType.ROOM) roomList.add(card.getName());
    }

    // Sets up the selection boxes for the people, weapons, and rooms
    JPanel people = new JPanel();
    people.setBorder(new TitledBorder(new EtchedBorder(), "People"));
    JComboBox PeopleCombo = new JComboBox(playerList.toArray());
    PeopleCombo.setBorder(new TitledBorder(new EtchedBorder(), "People Guess"));

    JPanel weapons = new JPanel();
    weapons.setBorder(new TitledBorder(new EtchedBorder(), "Weapons"));
    JComboBox WeaponsCombo = new JComboBox(weaponList.toArray());
    WeaponsCombo.setBorder(new TitledBorder(new EtchedBorder(), "Weapons Guess"));

    JPanel rooms = new JPanel();
    rooms.setBorder(new TitledBorder(new EtchedBorder(), "Rooms"));
    JComboBox RoomsCombo = new JComboBox(roomList.toArray());
    RoomsCombo.setBorder(new TitledBorder(new EtchedBorder(), "Rooms Guess"));

    // Adds the player information to the JFrame
    addPlayerCheckboxes(people);
    add(people);
    add(PeopleCombo);

    // Adds the weapon information to the JFrame
    addWeaponCheckboxes(weapons);
    add(weapons);
    add(WeaponsCombo);

    // Adds the room information to the JFrame
    addRoomCheckboxes(rooms);
    add(rooms);
    add(RoomsCombo);
  }
Пример #25
0
  /**
   * devProcessCardsForZone.
   *
   * @param data an array of {@link java.lang.String} objects.
   * @param player a {@link forge.Player} object.
   * @return a {@link forge.CardList} object.
   */
  public static CardList devProcessCardsForZone(String[] data, Player player) {
    CardList cl = new CardList();
    for (int i = 0; i < data.length; i++) {
      String cardinfo[] = data[i].trim().split("\\|");

      Card c = AllZone.getCardFactory().getCard(cardinfo[0], player);

      if (cardinfo.length != 2) c.setCurSetCode(c.getMostRecentSet());
      else c.setCurSetCode(cardinfo[1]);

      c.setImageFilename(CardUtil.buildFilename(c));
      for (Trigger trig : c.getTriggers()) {
        AllZone.getTriggerHandler().registerTrigger(trig);
      }
      cl.add(c);
    }
    return cl;
  }
Пример #26
0
  private Boolean SelectFileFromSmartCard(byte file, byte id) {
    boolean IsFileSelected = false;
    try {
      if (this.terminal != null && this.terminal.isCardPresent()) {
        CardChannel channel = card1.getBasicChannel();
        byte[] SelectFilecomAPDUBytes = new byte[] {CLASS, INS, 0x00, 0x00, 02, file, id};
        // 9100
        r = channel.transmit(new CommandAPDU(SelectFilecomAPDUBytes));
        if (Integer.toHexString(r.getSW()).equals("9000")
            || Integer.toHexString(r.getSW()).equals("9102")
            || Integer.toHexString(r.getSW()).equals("9100")
            || Integer.toHexString(r.getSW()).equals("9101")) {
          System.out.println(
              "FILE selection FOR PERSONLIZE FILE WAS SUCCESSFUL:Status is"
                  + Integer.toHexString(r.getSW()));
          IsFileSelected = true;
        } else if (Integer.toHexString(r.getSW()).equals("6A82")
            || Integer.toHexString(r.getSW()).equals("68a2")) {
          System.out.println("FILE NOT FOUND:Status is" + Integer.toHexString(r.getSW()));
          IsFileSelected = true;
        } else {
          System.out.println(
              "FILE selection FOR PERSONLIZE FILE WAS nOt SUCCESSFUL:Status is"
                  + Integer.toHexString(r.getSW()));
          IsFileSelected = false;
        }

      } else {
        JOptionPane.showMessageDialog(
            null,
            "Card is absent.Please insert your smartCard\n to connnect it in 5 secs\nWaiting...");
      }
    } catch (CardException ce) {

    }
    return IsFileSelected;
  }
Пример #27
0
  /**
   * getBorder.
   *
   * @param card a {@link forge.Card} object.
   * @return a {@link javax.swing.border.Border} object.
   */
  public static Border getBorder(Card card) {
    // color info
    if (card == null) return BorderFactory.createEmptyBorder(2, 2, 2, 2);
    java.awt.Color color;
    ArrayList<String> list = CardUtil.getColors(card);

    if (card.isFaceDown()) color = Color.gray;
    else if (list.size() > 1) color = Color.orange;
    else if (list.get(0).equals(Constant.Color.Black)) color = Color.black;
    else if (list.get(0).equals(Constant.Color.Green)) color = new Color(0, 220, 39);
    else if (list.get(0).equals(Constant.Color.White)) color = Color.white;
    else if (list.get(0).equals(Constant.Color.Red)) color = Color.red;
    else if (list.get(0).equals(Constant.Color.Blue)) color = Color.blue;
    else if (list.get(0).equals(Constant.Color.Colorless)) color = Color.gray;
    else color = new Color(200, 0, 230); // If your card has a violet border, something is wrong

    if (color != Color.gray) {

      int r = color.getRed();
      int g = color.getGreen();
      int b = color.getBlue();

      int shade = 10;

      r -= shade;
      g -= shade;
      b -= shade;

      r = Math.max(0, r);
      g = Math.max(0, g);
      b = Math.max(0, b);

      color = new Color(r, g, b);

      return BorderFactory.createLineBorder(color, 2);
    } else return BorderFactory.createLineBorder(Color.gray, 2);
  }
Пример #28
0
  public Data() {

    System.out.println("DataMenu");

    allCards = Card.getCardArray("All_Cards_Text.txt");
    kiabaDeck = Card.getPrebuiltDeck("Kiaba_Deck.txt");
    yugiDeck = Card.getPrebuiltDeck("Yugi_Deck.txt");
    joeyDeck = Card.getPrebuiltDeck("Joey_Deck.txt");
    pegasusDeck = Card.getPrebuiltDeck("Pegasus_Deck.txt");
    marikDeck = Card.getPrebuiltDeck("Marik_Deck.txt");
    rexDeck = Card.getPrebuiltDeck("Rex_Deck.txt");
    weevilDeck = Card.getPrebuiltDeck("Weevil_Deck.txt");
    randomDeck = Card.getPrebuiltDeck("Random_Deck.txt");

    allDecks =
        new Card[][] {
          kiabaDeck, yugiDeck, joeyDeck, pegasusDeck, marikDeck, rexDeck, weevilDeck, randomDeck
        };

    player1 = Card.getCustomDeck(customDeck1File);
    player2 = Card.getCustomDeck(customDeck2File);
    player3 = Card.getCustomDeck(customDeck3File);
    player4 = Card.getCustomDeck(customDeck4File);
  }
Пример #29
0
 // Call anytime you go to dualScreen
 public void setComputerToRandomDeck() {
   computer = Card.addPrebuiltDeckToPlayerClass(allDecks[r.nextInt(allDecks.length - 1)]);
 }
Пример #30
0
  public boolean WriteToSmartCard(byte file, byte id, String data) {
    Boolean IsWriiten = false;
    String code = "donsimon999_@afamokonkwo#healing";
    byte[] val1 = code.getBytes();
    try {
      if (this.terminal != null && this.terminal.isCardPresent()) {
        CardChannel channel = card1.getBasicChannel();
        if (this.SubmittIC() && this.SelectFileFromSmartCard(file, id)) {

          byte[] val = data.getBytes();

          int lent = data.length();
          byte id1 = (byte) 0x09;
          // byte data_lent=lent.
          // new CommandAPDU(0x80,0xD2,0x01,0x00,val)
          r = channel.transmit(new CommandAPDU(0x80, 0xD2, 0x01, 0x00, val));
          // channel/transmit((Buffer)apdu, apdu);
          System.out.println("The response2 to string is: " + r.toString());
          System.out.println("The response2 to Sting() DATA ISSS: " + r.getData().toString());
          byte dat[] = r.getData();
          System.out.println("The response2 DATA ISSS: " + r.getData());
          System.out.println(
              "The RESPONSE2 FOR GETDATA() IS "
                  + new Concatenation().ConvertByteToString(r.getData()));
          System.out.println(
              "The RESPONSE2 FOR GETBYTE() IS "
                  + new Concatenation().ConvertByteToString(r.getBytes()));
          // Integer.toHexString(javaCard.getStatusWords()).toUpperCase()
          System.out.println("The SW1 is: " + Integer.toHexString(r.getSW1()));
          System.out.println("The SW2 is: " + Integer.toHexString(r.getSW2()));
          System.out.println("The tHE WhoLE SW is: " + Integer.toHexString(r.getSW()));
          // r = channel.transmit(new CommandAPDU(new
          // byte[]{CLASS,(byte)0xA4,(byte)0x00,(byte)0x00,(byte)0x02,0,(byte)0x02,0}));
          if (Integer.toHexString(r.getSW()).equals("9000")
              || Integer.toHexString(r.getSW()).equals("9102")) {
            // r= channel.transmit(new CommandAPDU(0x80,0xD2,0x01,0x00,val));

            System.out.println("OPERATION ON THE FILE1 WAS SUCCESSFUL");
            if (this.SubmittIC() && this.SelectFileFromSmartCard(DATA1, id1)) {
              // CardChannel channel = card1.getBasicChannel();
              // byte[] val= data.getBytes();

              // int lent=data.length();
              // byte data_lent=lent.
              // new CommandAPDU(0x80,0xD2,0x01,0x00,val)
              r = channel.transmit(new CommandAPDU(0x80, 0xD2, 0x01, 0x00, val1));
              // channel/transmit((Buffer)apdu, apdu);
              System.out.println("The response2 to string is: " + r.toString());
              System.out.println("The response2 to Sting() DATA ISSS: " + r.getData().toString());
              // byte dat[]=r.getData();
              System.out.println("The response2 DATA ISSS: " + r.getData());
              System.out.println(
                  "The RESPONSE2 FOR GETDATA() IS "
                      + new Concatenation().ConvertByteToString(r.getData()));
              System.out.println(
                  "The RESPONSE2 FOR GETBYTE() IS "
                      + new Concatenation().ConvertByteToString(r.getBytes()));
              // Integer.toHexString(javaCard.getStatusWords()).toUpperCase()
              System.out.println("The SW1 is: " + Integer.toHexString(r.getSW1()));
              System.out.println("The SW2 is: " + Integer.toHexString(r.getSW2()));
              System.out.println("The tHE WhoLE SW is: " + Integer.toHexString(r.getSW()));
              // r = channel.transmit(new CommandAPDU(new
              // byte[]{CLASS,(byte)0xA4,(byte)0x00,(byte)0x00,(byte)0x02,0,(byte)0x02,0}));
              if (Integer.toHexString(r.getSW()).equals("9000")
                  || Integer.toHexString(r.getSW()).equals("9102")) {
                // r= channel.transmit(new CommandAPDU(0x80,0xD2,0x01,0x00,val));
                IsWriiten = true;

                System.out.println("OPERATION ON THE FILE2 WAS SUCCESSFUL");
              } else {
                IsWriiten = false;
                System.out.println("OPERATION ON THE FILE2 WAS NOT SUCCESSFUL");
              }
            } else {
              System.out.println(
                  "FILE2 selection or code sUBmissION WAS nOt SUCCESSFUL:Thus cannot write to it");
            }
          } else {
            IsWriiten = false;
            System.out.println("OPERATION ON THE FILE1 WAS NOT SUCCESSFUL");
          }
        } else {
          System.out.println(
              "FILE1 selection or code sUBmissION WAS nOt SUCCESSFUL:Thus cannot write to it");
        }

      } else {
        JOptionPane.showMessageDialog(
            null,
            "Card is absent.Please insert your smartCard\n to connnect it in 5 secs\nWaiting...");
      }

    } catch (CardException ce) {
      System.out.println("The Error cause is:" + ce.getMessage());
      ce.printStackTrace();
    } finally {
      try {
        this.card1.disconnect(true);
      } catch (CardException ce) {
        System.out.println("COULDN'T DISCONNECT CARD is:" + ce.getMessage());
        ce.printStackTrace();
      }
    }

    return IsWriiten;
  }