Esempio n. 1
0
 /** updateGUI. */
 public static void updateGUI() {
   AllZone.getComputerBattlefield().updateObservers();
   AllZone.getHumanBattlefield().updateObservers();
   AllZone.getHumanHand().updateObservers();
   AllZone.getComputerPlayer().updateObservers();
   AllZone.getHumanPlayer().updateObservers();
 }
Esempio n. 2
0
 /**
  * devModeTutor.
  *
  * @since 1.0.15
  */
 public static void devModeTutor() {
   CardList lib = AllZoneUtil.getPlayerCardsInLibrary(AllZone.getHumanPlayer());
   Object o = GuiUtils.getChoiceOptional("Choose a card", lib.toArray());
   if (null == o) return;
   else {
     Card c = (Card) o;
     AllZone.getGameAction().moveToHand(c);
   }
 }
Esempio n. 3
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();
 }
Esempio n. 4
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;
  }
Esempio n. 5
0
  /**
   * setupLandPanel.
   *
   * @param j a {@link javax.swing.JPanel} object.
   * @param c an array of {@link forge.Card} objects.
   */
  public static void setupLandPanel(JPanel j, Card c[]) {
    ArrayList<Card> a = new ArrayList<Card>();
    for (int i = 0; i < c.length; i++)
      if ((!(c[i].isCreature()
                      || c[i].isEnchantment()
                      || c[i].isArtifact()
                      || c[i].isPlaneswalker())
                  || (c[i].isLand()
                      && c[i].isArtifact()
                      && !c[i].isCreature()
                      && !c[i].isEnchantment()))
              && !AllZone.getGameAction().isAttachee(c[i])
          || (c[i].getName().startsWith("Mox") && !c[i].getName().equals("Mox Diamond")))
        a.add(c[i]);

    setupPanel(j, a, true);
  }
Esempio n. 6
0
 /**
  * devModeUnlimitedLand.
  *
  * @since 1.0.16
  */
 public static void devModeUnlimitedLand() {
   AllZone.getHumanPlayer().addMaxLandsToPlay(100);
 }
Esempio n. 7
0
  /** devSetupGameState. */
  public static void devSetupGameState() {
    String t_humanLife = "-1";
    String t_computerLife = "-1";
    String t_humanSetupCardsInPlay = "NONE";
    String t_computerSetupCardsInPlay = "NONE";
    String t_humanSetupCardsInHand = "NONE";
    String t_computerSetupCardsInHand = "NONE";
    String t_humanSetupGraveyard = "NONE";
    String t_computerSetupGraveyard = "NONE";
    String t_humanSetupLibrary = "NONE";
    String t_computerSetupLibrary = "NONE";
    String t_humanSetupExile = "NONE";
    String t_computerSetupExile = "NONE";
    String t_changePlayer = "NONE";
    String t_changePhase = "NONE";

    String wd = ".";
    JFileChooser fc = new JFileChooser(wd);
    int rc = fc.showDialog(null, "Select Game State File");
    if (rc != JFileChooser.APPROVE_OPTION) return;

    try {
      FileInputStream fstream = new FileInputStream(fc.getSelectedFile().getAbsolutePath());
      DataInputStream in = new DataInputStream(fstream);
      BufferedReader br = new BufferedReader(new InputStreamReader(in));

      String temp = "";

      while ((temp = br.readLine()) != null) {
        String[] temp_data = temp.split("=");

        if (temp_data.length < 2) continue;
        if (temp_data[0].toCharArray()[0] == '#') continue;

        String categoryName = temp_data[0];
        String categoryValue = temp_data[1];

        if (categoryName.toLowerCase().equals("humanlife")) t_humanLife = categoryValue;
        else if (categoryName.toLowerCase().equals("ailife")) t_computerLife = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinplay"))
          t_humanSetupCardsInPlay = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinplay"))
          t_computerSetupCardsInPlay = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinhand"))
          t_humanSetupCardsInHand = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinhand"))
          t_computerSetupCardsInHand = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsingraveyard"))
          t_humanSetupGraveyard = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsingraveyard"))
          t_computerSetupGraveyard = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinlibrary"))
          t_humanSetupLibrary = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinlibrary"))
          t_computerSetupLibrary = categoryValue;
        else if (categoryName.toLowerCase().equals("humancardsinexile"))
          t_humanSetupExile = categoryValue;
        else if (categoryName.toLowerCase().equals("aicardsinexile"))
          t_computerSetupExile = categoryValue;
        else if (categoryName.toLowerCase().equals("activeplayer")) t_changePlayer = categoryValue;
        else if (categoryName.toLowerCase().equals("activephase")) t_changePhase = categoryValue;
      }

      in.close();
    } catch (FileNotFoundException fnfe) {
      JOptionPane.showMessageDialog(
          null, "File not found: " + fc.getSelectedFile().getAbsolutePath());
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, "Error loading battle setup file!");
      return;
    }

    int setHumanLife = Integer.parseInt(t_humanLife);
    int setComputerLife = Integer.parseInt(t_computerLife);

    String humanSetupCardsInPlay[] = t_humanSetupCardsInPlay.split(";");
    String computerSetupCardsInPlay[] = t_computerSetupCardsInPlay.split(";");
    String humanSetupCardsInHand[] = t_humanSetupCardsInHand.split(";");
    String computerSetupCardsInHand[] = t_computerSetupCardsInHand.split(";");
    String humanSetupGraveyard[] = t_humanSetupGraveyard.split(";");
    String computerSetupGraveyard[] = t_computerSetupGraveyard.split(";");
    String humanSetupLibrary[] = t_humanSetupLibrary.split(";");
    String computerSetupLibrary[] = t_computerSetupLibrary.split(";");
    String humanSetupExile[] = t_humanSetupExile.split(";");
    String computerSetupExile[] = t_computerSetupExile.split(";");

    CardList humanDevSetup = new CardList();
    CardList computerDevSetup = new CardList();
    CardList humanDevHandSetup = new CardList();
    CardList computerDevHandSetup = new CardList();
    CardList humanDevGraveyardSetup = new CardList();
    CardList computerDevGraveyardSetup = new CardList();
    CardList humanDevLibrarySetup = new CardList();
    CardList computerDevLibrarySetup = new CardList();
    CardList humanDevExileSetup = new CardList();
    CardList computerDevExileSetup = new CardList();

    if (!t_changePlayer.trim().toLowerCase().equals("none")) {
      if (t_changePlayer.trim().toLowerCase().equals("human")) {
        AllZone.getPhase().setPlayerTurn(AllZone.getHumanPlayer());
      }
      if (t_changePlayer.trim().toLowerCase().equals("ai")) {
        AllZone.getPhase().setPlayerTurn(AllZone.getComputerPlayer());
      }
    }

    if (!t_changePhase.trim().toLowerCase().equals("none")) {
      AllZone.getPhase().setDevPhaseState(t_changePhase);
    }

    if (!t_humanSetupCardsInPlay.trim().toLowerCase().equals("none"))
      humanDevSetup = devProcessCardsForZone(humanSetupCardsInPlay, AllZone.getHumanPlayer());

    if (!t_humanSetupCardsInHand.trim().toLowerCase().equals("none"))
      humanDevHandSetup = devProcessCardsForZone(humanSetupCardsInHand, AllZone.getHumanPlayer());

    if (!t_computerSetupCardsInPlay.trim().toLowerCase().equals("none"))
      computerDevSetup =
          devProcessCardsForZone(computerSetupCardsInPlay, AllZone.getComputerPlayer());

    if (!t_computerSetupCardsInHand.trim().toLowerCase().equals("none"))
      computerDevHandSetup =
          devProcessCardsForZone(computerSetupCardsInHand, AllZone.getComputerPlayer());

    if (!t_computerSetupGraveyard.trim().toLowerCase().equals("none"))
      computerDevGraveyardSetup =
          devProcessCardsForZone(computerSetupGraveyard, AllZone.getComputerPlayer());

    if (!t_humanSetupGraveyard.trim().toLowerCase().equals("none"))
      humanDevGraveyardSetup =
          devProcessCardsForZone(humanSetupGraveyard, AllZone.getHumanPlayer());

    if (!t_humanSetupLibrary.trim().toLowerCase().equals("none"))
      humanDevLibrarySetup = devProcessCardsForZone(humanSetupLibrary, AllZone.getHumanPlayer());

    if (!t_computerSetupLibrary.trim().toLowerCase().equals("none"))
      computerDevLibrarySetup =
          devProcessCardsForZone(computerSetupLibrary, AllZone.getComputerPlayer());

    if (!t_humanSetupExile.trim().toLowerCase().equals("none"))
      humanDevExileSetup = devProcessCardsForZone(humanSetupExile, AllZone.getHumanPlayer());

    if (!t_computerSetupExile.trim().toLowerCase().equals("none"))
      computerDevExileSetup =
          devProcessCardsForZone(computerSetupExile, AllZone.getComputerPlayer());

    AllZone.getTriggerHandler().suppressMode("ChangesZone");

    for (Card c : humanDevSetup) {
      AllZone.getHumanHand().add(c);
      AllZone.getGameAction().moveToPlay(c);
      c.setSickness(false);
    }

    for (Card c : computerDevSetup) {
      AllZone.getComputerHand().add(c);
      AllZone.getGameAction().moveToPlay(c);
      c.setSickness(false);
    }

    if (computerDevGraveyardSetup.size() > 0)
      AllZone.getComputerGraveyard().setCards(computerDevGraveyardSetup.toArray());
    if (humanDevGraveyardSetup.size() > 0)
      AllZone.getHumanGraveyard().setCards(humanDevGraveyardSetup.toArray());

    if (computerDevHandSetup.size() > 0)
      AllZone.getComputerHand().setCards(computerDevHandSetup.toArray());
    if (humanDevHandSetup.size() > 0) AllZone.getHumanHand().setCards(humanDevHandSetup.toArray());

    if (humanDevLibrarySetup.size() > 0)
      AllZone.getHumanLibrary().setCards(humanDevLibrarySetup.toArray());
    if (computerDevLibrarySetup.size() > 0)
      AllZone.getComputerLibrary().setCards(computerDevLibrarySetup.toArray());

    if (humanDevExileSetup.size() > 0)
      AllZone.getHumanExile().setCards(humanDevExileSetup.toArray());
    if (computerDevExileSetup.size() > 0)
      AllZone.getComputerExile().setCards(computerDevExileSetup.toArray());

    AllZone.getTriggerHandler().clearSuppression("ChangesZone");

    if (setComputerLife > 0) AllZone.getComputerPlayer().setLife(setComputerLife, null);
    if (setHumanLife > 0) AllZone.getHumanPlayer().setLife(setHumanLife, null);

    AllZone.getGameAction().checkStateEffects();
    AllZone.getPhase().updateObservers();
    AllZone.getHumanExile().updateObservers();
    AllZone.getComputerExile().updateObservers();
    AllZone.getHumanHand().updateObservers();
    AllZone.getComputerHand().updateObservers();
    AllZone.getHumanGraveyard().updateObservers();
    AllZone.getComputerGraveyard().updateObservers();
    AllZone.getHumanBattlefield().updateObservers();
    AllZone.getComputerBattlefield().updateObservers();
    AllZone.getHumanLibrary().updateObservers();
    AllZone.getComputerLibrary().updateObservers();
  }