Package org.ggp.base.server.event

Examples of org.ggp.base.server.event.ServerMatchUpdatedEvent


  }

  @Override
  public void observe(Event genericEvent) {
    if (!(genericEvent instanceof ServerMatchUpdatedEvent)) return;
    ServerMatchUpdatedEvent event = (ServerMatchUpdatedEvent)genericEvent;
    Match match = event.getMatch();

    DefaultTableModel model = (DefaultTableModel) queueTable.getModel();
    for (int i = 0; i < model.getRowCount(); i++) {
      String rowMatchId = model.getValueAt(i, 0).toString();
      if (rowMatchId.equals(match.getMatchId())) {
        String status = "active";
        if (match.isAborted()) status = "aborted";
        if (match.isCompleted()) status = "done";
        model.setValueAt(status, i, 3);
        if (match.isCompleted()) {
          model.setValueAt(getLinebreakString(match.getGoalValues()), i, 5);
        }
        List<Integer> errorCounts = new ArrayList<Integer>();
        List<String> errorCountStrings = new ArrayList<String>();
        for (int j = 0; j < match.getPlayerNamesFromHost().size(); j++) {
          errorCounts.add(0);
        }
        for (List<String> errors : match.getErrorHistory()) {
          for (int j = 0; j < errors.size(); j++) {
            if (!errors.get(j).isEmpty()) {
              errorCounts.set(j, errorCounts.get(j) + 1);
            }
          }
        }
        for (int errorCount : errorCounts) {
          if (errorCount > 0) {
            errorCountStrings.add("<font color=red>" + errorCount + "</font>");
          } else {
            errorCountStrings.add("0");
          }
        }
        model.setValueAt(getLinebreakString(errorCountStrings), i, 6);
        model.setValueAt(match.getStateHistory().size()-1, i, 7);

        if (event.getExternalPublicationKey() != null) {
          matchIdToURL.put(match.getMatchId(), "http://www.ggp.org/view/all/matches/" + event.getExternalPublicationKey() + "/");
        }
        if (event.getExternalFilename() != null) {
          matchIdToFilename.put(match.getMatchId(), event.getExternalFilename());
        }

        return;
      }
    }
View Full Code Here


  }

  @Override
  public void observe(Event genericEvent) {
    if (!(genericEvent instanceof ServerMatchUpdatedEvent)) return;
    ServerMatchUpdatedEvent event = (ServerMatchUpdatedEvent)genericEvent;
    Match match = event.getMatch();
    if (!match.isAborted() && !match.isCompleted()) return;
    activePlayers.removeAll(match.getPlayerNamesFromHost());
  }
View Full Code Here

            while (!stateMachine.isTerminal(currentState)) {
                publishWhenNecessary();
                saveWhenNecessary();
                notifyObservers(new ServerNewGameStateEvent(currentState));
                notifyObservers(new ServerTimeEvent(match.getPlayClock() * 1000));
                notifyObservers(new ServerMatchUpdatedEvent(match, spectatorServerKey, saveToFilename));
                previousMoves = sendPlayRequests();

                notifyObservers(new ServerNewMovesEvent(previousMoves));
                currentState = stateMachine.getNextState(currentState, previousMoves);

                match.appendMoves2(previousMoves);
                match.appendState(currentState.getContents());
                appendErrorsToMatchDescription();

                if (match.isAborted()) {
                  return;
                }
            }
            match.markCompleted(stateMachine.getGoals(currentState));
            publishWhenNecessary();
            saveWhenNecessary();
            notifyObservers(new ServerNewGameStateEvent(currentState));
            notifyObservers(new ServerCompletedMatchEvent(getGoals()));
            notifyObservers(new ServerMatchUpdatedEvent(match, spectatorServerKey, saveToFilename));
            sendStopRequests(previousMoves);
        } catch (InterruptedException ie) {
          if (match.isAborted()) {
            return;
          } else {
View Full Code Here

        interrupt();
        sendAbortRequests();
        saveWhenNecessary();
        publishWhenNecessary();
        notifyObservers(new ServerAbortedMatchEvent());
        notifyObservers(new ServerMatchUpdatedEvent(match, spectatorServerKey, saveToFilename));
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

TOP

Related Classes of org.ggp.base.server.event.ServerMatchUpdatedEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.