Package nl.nuggit.moltest.model

Examples of nl.nuggit.moltest.model.Player


    int active = 0;
    try (Scanner scanner = new Scanner(playersFile)) {
      while (scanner.hasNextLine()) {
        String line = scanner.nextLine().trim();
        if (line.startsWith(PLAYER)) {
          Player player = new Player(line.trim());
          players.add(player);
          if (player.isActive()) {
            active++;
          }
        }
      }
    } catch (FileNotFoundException e) {
View Full Code Here


    Collections.sort(sortedResults, new ResultsLowestFirstComparator());
    int eliminatedPlayers = 0;
    int i = 0;
    while (eliminatedPlayers < numberOfPlayersToEliminate) {
      Result eliminated = sortedResults.get(i++);
      Player player = eliminated.getPlayer();
      if (player.getId() != wieIsDeMol) {
        player.setStatus(PlayerStatus.ELIMINATED);
        updatePlayer(player);
        eliminatedPlayers++;
      }
    }
  }
View Full Code Here

         BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile))) {
      String line;
      while ((line = reader.readLine()) != null) {
        String updatedLine = null;
        if (line.startsWith(PLAYER)) {
          Player oldPlayer = new Player(line.trim());
          if (oldPlayer.getId() == player.getId()) {
            updatedLine = player.toString();
          }
        }

        if (updatedLine == null) {
View Full Code Here

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginServlet extends BaseServlet {
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Player player;
    if (DataService.registrationOpen) {
      player = registerPlayer(request, response);
    } else {
      player = loginPlayer(request, response);
    }
View Full Code Here

      viewHome(request, response);
    }
  }

  private Player registerPlayer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Player player = new Player(request.getParameter("name"),
        request.getParameter("dateOfBirth"),
        request.getParameter("password"));
    String validationError = player.validationError();
    if (validationError != null) {
      request.getSession().invalidate();
      viewIndex(request, response, validationError);
      player = null;
    } else {
View Full Code Here

    }
    return player;
  }

  private Player loginPlayer(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Player player = DataService.findPlayer(request.getParameter("password"));
    if (player == null) {
      viewIndex(request, response, "Wachtwoord onbekend");
    }
    return player;
  }
View Full Code Here

import java.io.IOException;

public class TestServlet extends BaseServlet {

  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Player player = (Player) request.getSession().getAttribute("player");
    if (player == null) {
      viewIndex(request, response, "Je bent niet ingelogd");
      return;
    }
    Result result = (Result) request.getSession().getAttribute("result");
View Full Code Here

  @Override
  public String getOptions() {
    StringBuilder sb = new StringBuilder();
    List<Player> activePlayers = DataService.getActivePlayers();
    for (int i = 0; i < activePlayers.size(); i++) {
      Player player = activePlayers.get(i);
      sb.append(i + 1).append(" : ").append(player.getName()).append("<BR/>");
    }
    return sb.toString();
  }
View Full Code Here

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class HomeServlet extends BaseServlet {
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    Player player = (Player) request.getSession().getAttribute("player");
    if (player == null) {
      viewIndex(request, response, "Je bent niet ingelogd");
      return;
    }
    if (!player.isActive()) {
      viewElimination(request, response);
      return;
    }
    if (DataService.currentTestId == 0) {
      viewWait(request, response);
View Full Code Here

TOP

Related Classes of nl.nuggit.moltest.model.Player

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.