Ejemplo n.º 1
0
  public JPanel initialize(String selected_robots) {
    try {
      manager = new RobocodeManager(false, null);

      Thread.currentThread().setName("Application Thread");

      BattleProperties battleProperties = manager.getBattleManager().getBattleProperties();
      // battleProperties.setSelectedRobots("test.mtest12,test.mtest14");
      battleProperties.setSelectedRobots(selected_robots);
      manager.getBattleManager().startNewBattle(battleProperties, true, false);
      manager.getBattleManager().getBattle().setDesiredTPS(20);

      JPanel panel = manager.getWindowManager().getRobocodeFrame().getRobocodeContentPane();
      panel.setBounds(100, 100, 500, 600);
      panel.setOpaque(true);
      return panel;
    } catch (Throwable e) {
      Logger.log(e);
      return null;
    }
  }
Ejemplo n.º 2
0
  public void finishButtonActionPerformed() {
    if (robotSelectionPanel.getSelectedRobotsCount() > 24) {
      if (JOptionPane.showConfirmDialog(
              this,
              "Warning:  The battle you are about to start ("
                  + robotSelectionPanel.getSelectedRobotsCount()
                  + " robots) "
                  + " is very large and will consume a lot of CPU and memory.  Do you wish to proceed?",
              "Large Battle Warning",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.WARNING_MESSAGE)
          == JOptionPane.NO_OPTION) {
        return;
      }
    }
    if (robotSelectionPanel.getSelectedRobotsCount() == 1) {
      if (JOptionPane.showConfirmDialog(
              this,
              "You have only selected one robot.  For normal battles you should select at least 2.\nDo you wish to proceed anyway?",
              "Just one robot?",
              JOptionPane.YES_NO_OPTION,
              JOptionPane.QUESTION_MESSAGE)
          == JOptionPane.NO_OPTION) {
        return;
      }
    }
    battleProperties.setSelectedRobots(robotSelectionPanel.getSelectedRobotsAsString());
    battleProperties.setBattlefieldWidth(getBattleFieldTab().getBattleFieldWidth());
    battleProperties.setBattlefieldHeight(getBattleFieldTab().getBattleFieldHeight());
    battleProperties.setNumRounds(getRobotSelectionPanel().getNumRounds());
    battleProperties.setGunCoolingRate(getRulesTab().getGunCoolingRate());
    battleProperties.setInactivityTime(getRulesTab().getInactivityTime());

    // Dispose this dialog before starting the battle due to pause/resume battle state
    dispose();

    // Start new battle after the dialog has been disposed and hence has called resumeBattle()
    manager.getBattleManager().startNewBattle(battleProperties, false);
  }