Esempio n. 1
0
 private static void showThankYouPrompt(String playerName) {
   SOptionPane.showMessageDialog(
       "Thank you, "
           + playerName
           + ". "
           + "You will not be prompted again but you can change\n"
           + "your name at any time using the \"Player Name\" setting in Preferences\n"
           + "or via the constructed match setup screen\n");
 }
Esempio n. 2
0
  public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) {
    // TODO: Uncomment the line below if this function stops being used to refresh
    // the current screen in some places (such as Continue and Restart in the match screen)
    // if (currentScreen == screen) { return; }

    // give previous screen a chance to perform special switch handling and/or cancel switching away
    // from screen
    if (currentScreen != screen && !Singletons.getView().getNavigationBar().canSwitch(screen)) {
      return false;
    }

    if (currentScreen != null
        && currentScreen
            .isMatchScreen()) { // hide targeting overlay and reset image if was on match screen
      // SOverlayUtils.hideTargetingOverlay();
      if (isMatchBackgroundImageVisible()) {
        FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage(new ImageIcon());
      }
    }

    clearChildren(JLayeredPane.DEFAULT_LAYER);
    SOverlayUtils.hideOverlay();
    ImageCache.clear(); // reduce memory usage by clearing image cache when switching screens

    currentScreen = screen;

    // load layout for new current screen
    screen.getController().register();
    try {
      SLayoutIO.loadLayout(null);
    } catch (final InvalidLayoutFileException ex) {
      SOptionPane.showMessageDialog(
          String.format(
              "Your %s layout file could not be read. It will be deleted after you press OK.\nThe game will proceed with default layout.",
              screen.getTabCaption()),
          "Warning!");
      if (screen.deleteLayoutFile()) {
        SLayoutIO.loadLayout(null); // try again
      }
    }

    screen.getController().initialize();
    screen.getView().populate();

    if (screen.isMatchScreen()) {
      if (isMatchBackgroundImageVisible()) {
        FView.SINGLETON_INSTANCE
            .getPnlInsets()
            .setForegroundImage(FSkin.getIcon(FSkinProp.BG_MATCH));
      }
      // SOverlayUtils.showTargetingOverlay();
    }

    Singletons.getView().getNavigationBar().updateSelectedTab();
    return true;
  }
  /**
   * Constructor for SealedDeck.
   *
   * @param poolType a {@link java.lang.String} object.
   */
  private SealedCardPoolGenerator(final LimitedPoolType poolType) {
    switch (poolType) {
      case Full:
        // Choose number of boosters
        if (!chooseNumberOfBoosters(new UnOpenedProduct(SealedProduct.Template.genericBooster))) {
          return;
        }
        landSetCode =
            CardEdition.Predicates.getRandomSetWithAllBasicLands(FModel.getMagicDb().getEditions())
                .getCode();
        break;

      case Block:
      case FantasyBlock:
        List<CardBlock> blocks = new ArrayList<CardBlock>();
        Iterable<CardBlock> src =
            poolType == LimitedPoolType.Block ? FModel.getBlocks() : FModel.getFantasyBlocks();
        for (CardBlock b : src) {
          blocks.add(b);
        }

        final CardBlock block = SGuiChoose.oneOrNone("Choose Block", blocks);
        if (block == null) {
          return;
        }

        final int nPacks = block.getCntBoostersSealed();
        final Stack<String> sets = new Stack<String>();

        for (CardEdition edition : block.getSets()) {
          sets.add(edition.getCode());
        }

        for (String ms : block.getMetaSetNames()) {
          sets.push(ms);
        }

        if (sets.size() > 1) {
          final List<String> setCombos = getSetCombos(sets, nPacks);
          if (setCombos == null || setCombos.isEmpty()) {
            throw new RuntimeException(
                "Unsupported amount of packs (" + nPacks + ") in a Sealed Deck block!");
          }

          final String p =
              setCombos.size() > 1
                  ? SGuiChoose.oneOrNone("Choose packs to play with", setCombos)
                  : setCombos.get(0);
          if (p == null) {
            return;
          }

          for (String pz : TextUtil.split(p, ',')) {
            String[] pps = TextUtil.splitWithParenthesis(pz.trim(), ' ');
            String setCode = pps[pps.length - 1];
            int nBoosters = pps.length > 1 ? Integer.parseInt(pps[0]) : 1;
            while (nBoosters-- > 0) {
              this.product.add(block.getBooster(setCode));
            }
          }
        } else {
          IUnOpenedProduct prod = block.getBooster(sets.get(0));
          for (int i = 0; i < nPacks; i++) {
            this.product.add(prod);
          }
        }

        landSetCode = block.getLandSet().getCode();
        break;

      case Custom:
        String[] dList;
        final ArrayList<CustomLimited> customs = new ArrayList<CustomLimited>();

        // get list of custom draft files
        final File dFolder = new File(ForgeConstants.SEALED_DIR);
        if (!dFolder.exists()) {
          throw new RuntimeException(
              "GenerateSealed : folder not found -- folder is " + dFolder.getAbsolutePath());
        }

        if (!dFolder.isDirectory()) {
          throw new RuntimeException(
              "GenerateSealed : not a folder -- " + dFolder.getAbsolutePath());
        }

        dList = dFolder.list();

        for (final String element : dList) {
          if (element.endsWith(FILE_EXT)) {
            final List<String> dfData = FileUtil.readFile(ForgeConstants.SEALED_DIR + element);
            final CustomLimited cs = CustomLimited.parse(dfData, FModel.getDecks().getCubes());
            if (cs.getSealedProductTemplate().getNumberOfCardsExpected()
                > 5) { // Do not allow too small cubes to be played as 'stand-alone'!
              customs.add(cs);
            }
          }
        }

        // present list to user
        if (customs.isEmpty()) {
          SOptionPane.showMessageDialog("No custom sealed files found.");
          return;
        }

        final CustomLimited draft = SGuiChoose.oneOrNone("Choose Custom Sealed Pool", customs);
        if (draft == null) {
          return;
        }

        UnOpenedProduct toAdd =
            new UnOpenedProduct(draft.getSealedProductTemplate(), draft.getCardPool());
        toAdd.setLimitedPool(draft.isSingleton());
        if (!chooseNumberOfBoosters(toAdd)) {
          return;
        }

        landSetCode = draft.getLandSetCode();
        break;
    }
  }