Ejemplo n.º 1
0
  @Override
  protected void newGame() {
    try {
      File templateFile =
          new File(this.getTemplateFolder() + this.getFileSeparator() + "2x12_8x8.xml");

      if (!templateFile.exists()) {
        GameLoader gameLoader = new GameLoader(GamePlayer.getInputStream("templates/2x12_8x8.xml"));

        new GameSaver(gameLoader.getEngine().getBoard(), templateFile);
      }

      GameLoader gameLoader = new GameLoader(templateFile);

      NewGameConfigurator configurator = new NewGameConfigurator(gameLoader, this);

      if (configurator.isResult()) {
        this.engine = configurator.getEngine();
        this.engine.addTurnListener(this.turnListener);
        this.setBoardWidget(new BoardWidget(this.engine.getBoard()));
        this.displayMessage(
            getEngine().getBoard().getCurrentPlayer().getName() + ", it's your turn.");
      }
    } catch (Exception e) {
      this.displayMessage(e.getMessage());
    }
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }

    if (args.length == 0) {
      new GamePlayer();
    } else if (args.length == 1) {
      GameLoader gameLoader = new GameLoader(GamePlayer.getInputStream("templates/2x12_8x8.xml"));

      new GamePlayer(gameLoader.getEngine().getBoard());
    }
  }