예제 #1
0
  @Override
  public void visitGameNotification(GameNotification n) {
    synchronized (matches) {
      if (!matches.isEmpty()) {
        return;
      }
    }

    try {
      GameInfo info = n.getInfo();

      int matchCount = info.getMaps().length;
      int matchNumber = 0;
      for (String map : info.getMaps()) {
        if (map.endsWith(".xml")) map = map.substring(0, map.indexOf('.'));
        Match match = new Match(info, map, options, matchNumber++, matchCount);
        debug("queuing match " + match);
        matches.add(match);
      }
    } catch (Exception e) {
      e.printStackTrace();
      fail("couldn't start the match: " + e.getMessage());
    }
  }
예제 #2
0
  /**
   * Runs the server. The server will wait for some match info (which specifies the teams and set of
   * maps to run) and then begin running matches.
   */
  public void run() {
    int aWins = 0, bWins = 0;

    while (!matches.isEmpty()) {
      Match match = matches.peek();
      if (!finished.isEmpty())
        match.setInitialTeamMemory(finished.getLast().getComputedTeamMemory());

      try {
        debug("running match " + match);
        match.initialize();
        runMatch(match, proxyWriter);
        finished.add(match);
        matches.remove(match);

        if (match.getWinner() == Team.A) aWins++;
        else if (match.getWinner() == Team.B) bWins++;

        match.finish();

        // Allow best of three scrimmages -- single game scrims should still work fine
        // TODO:This "win mode" should probably be something from the database
        if (mode == Mode.TOURNAMENT || mode == Mode.SCRIMMAGE) {
          if (aWins == 2 || bWins == 2) break;
        }

      } catch (Exception e) {
        ErrorReporter.report(e);
        error("couldn't run match: ");

        this.state = State.ERROR;
      }
    }

    proxyWriter.terminate();
  }
예제 #3
0
  @Override
  public void visitInjectNotification(InjectNotification n) {
    InjectDelta result = matches.peek().inject(n.getInternalSignal());

    proxyWriter.enqueue(result);
  }