Example #1
0
 private void cleanMatches() {
   for (final HostedMatch match : ImmutableList.copyOf(currentMatches)) {
     if (match.isMatchOver()) {
       currentMatches.remove(match);
     }
   }
 }
Example #2
0
  private void startGame(final GameType gameType) {
    final DeckProxy humanDeck = VSubmenuWinston.SINGLETON_INSTANCE.getLstDecks().getSelectedItem();
    final int aiIndex = 0;

    if (humanDeck == null) {
      FOptionPane.showErrorDialog(
          "No deck selected for human.\n(You may need to build a new deck)", "No Deck");
      return;
    }

    if (FModel.getPreferences().getPrefBoolean(FPref.ENFORCE_DECK_LEGALITY)) {
      final String errorMessage =
          gameType.getDeckFormat().getDeckConformanceProblem(humanDeck.getDeck());
      if (null != errorMessage) {
        FOptionPane.showErrorDialog(
            "Your deck " + errorMessage + " Please edit or choose a different deck.",
            "Invalid Deck");
        return;
      }
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.startGameOverlay();
            SOverlayUtils.showOverlay();
          }
        });

    final DeckGroup opponentDecks = FModel.getDecks().getWinston().get(humanDeck.getName());
    final Deck aiDeck = opponentDecks.getAiDecks().get(aiIndex);
    if (aiDeck == null) {
      throw new IllegalStateException("Draft: Computer deck is null!");
    }

    final List<RegisteredPlayer> starter = new ArrayList<RegisteredPlayer>();
    final RegisteredPlayer human =
        new RegisteredPlayer(humanDeck.getDeck()).setPlayer(GamePlayerUtil.getGuiPlayer());
    starter.add(human);
    starter.add(new RegisteredPlayer(aiDeck).setPlayer(GamePlayerUtil.createAiPlayer()));

    final HostedMatch hostedMatch = GuiBase.getInterface().hostMatch();
    hostedMatch.startMatch(
        GameType.Winston, null, starter, human, GuiBase.getInterface().getNewGuiGame());

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            SOverlayUtils.hideOverlay();
          }
        });
  }