Package userManagement

Examples of userManagement.Player


     
      Iterator<Player> it = playerList.iterator();
      boolean found = false;
     
      while(it.hasNext() && !found) {
        Player player = it.next();
        if (player.getName().equals(fromName)) {
          found = true;
         
          gameLoader.playerLeft(player);
          it.remove();
        }
View Full Code Here


  @Override
  public PlayerInterface getCurrentUser() {
    if(gamehub == null){
      System.out.println("running in test mode, constructing test player.");
      return new Player("Test-user", "Test-user",null);
    }
    return (PlayerInterface)gamehub.getCurrentUser();
  }
View Full Code Here

        playerList.add(p);
      }
      return playerList;
    }else{
      ArrayList<PlayerInterface> l = new ArrayList<PlayerInterface>();
      l.add(new Player("debug-mode", "DEBUG", null));
      return l;
    }
  }
View Full Code Here

           JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null);
        if (confirmed == JOptionPane.YES_OPTION) {

          for (Friend friend : getCurrentUser().getFriends()) {
            if (friend.getName().equals(vanUser)) {
              Player player = new Player(friend.getName(), friend.getAlias(), friend.getIp());
              player.setStatus(friend.getStatus());
              invitedPlayerList.add(player);
            }
          }

          openGameLounge(false);
        } else {
          invitedPlayerList.clear();
        }

      } else if (networkInput.startsWith(I_HAVE_INVITED_TOKEN)) {

        String invitedPlayerName = networkInput.split(" ")[1];
        String invitedPlayerAlias = networkInput.split(" ")[2];
        InetAddress invitedPlayerIp = null;
        try {
          invitedPlayerIp = Inet4Address.getByName(networkInput.split(" ")[3]);
        } catch (UnknownHostException ex) {
          Logger.getLogger(GatheringLoungeModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        FriendStatus invitedPlayerStatus = FriendStatus.valueOf(networkInput.split(" ")[4]);

        Player player = new Player(invitedPlayerName, invitedPlayerAlias, invitedPlayerIp);
        player.setStatus(invitedPlayerStatus);
        invitedPlayerList.add(player);

      } else if (networkInput.startsWith(RECEIVE_PROFILE_TOKEN)) {

        String[] input = networkInput.split(" ");
View Full Code Here

      Friend friend = (Friend) selectedFriends[i];

      NetworkAdapter.getSingleton().sendMessage(INVITE_TOKEN + " " + super.getCurrentUser().getName(),
         friend.getIp().getHostAddress(), friend.getName());

      Player player = new Player(friend.getName(), friend.getAlias(), friend.getIp());
      player.setStatus(friend.getStatus());
      invitedPlayerList.add(player);

    }

    openGameLounge(true);
View Full Code Here

  @Override
  public Component getListCellRendererComponent(JList list, Object value,
     int index, boolean isSelected, boolean cellHasFocus) {

    Player player = (Player) value;

    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

    setOpaque(true);

    SquareIcon icon = new SquareIcon(player.getStatus().getColor(), 10, getHorizontalAlignment(), 10, 10);
    String text = "";


    if (player.getTeamId() == 0) {
      text += "?";
    } else {
      text += player.getTeamId();
    }

    text += " - ";

    text += player.getAlias();

    setIcon(icon);
    setIconTextGap(15);
    setText(text);
View Full Code Here

    playerList = new ArrayList<Player>();
    this.invitedPlayerList = invitedPlayerList;
    for (Player player : invitedPlayerList) {

      final Player speler = player;

      executor.execute(new Runnable() {

        @Override
        public void run() {
          if (NetworkAdapter.getSingleton().getSocketThreadWithIpAndVerifier(speler.getIp().getHostAddress(), speler.getName()) == null) {
            NetworkAdapter.getSingleton().openConnection(speler.getIp().getHostAddress(), speler.getName());
          }

          NetworkAdapter.getSingleton().sendMessage(GameLoungeModel.JOIN_TOKEN + " " + getCurrentUser().getName() + " " + getCurrentUser().getStatus(),
             speler.getIp().getHostAddress(), speler.getName());
        }
      });

    }
View Full Code Here

        if (!exists) {

          Iterator<Player> ite = invitedPlayerList.iterator();
          while (ite.hasNext() && !exists) {

            Player invitedPlayer = ite.next();

            if (invitedPlayer.getName().equals(fromName)) {
              playerList.add(invitedPlayer);
              FriendStatus status = FriendStatus.valueOf(networkInput.split(" ")[2]);
              invitedPlayer.setStatus(status);

              Chat.getSingleton().addChatter(GAMELOUNGE_NAME, invitedPlayer);

              String message = GAME_CHANGED_TOKEN + "@@@";

              message += gameFileName + "@@@";
              message += gameName + "@@@";
              message += gamePlayers + "@@@";
              message += gameTeams + "@@@";
              message += gameDescription;

              NetworkAdapter.getSingleton().sendMessage(message, fromIp, port);

              NetworkAdapter.getSingleton().sendMessage(JOIN_TOKEN + " " + getCurrentUser().getName() + " " + getCurrentUser().getStatus(), fromIp, port);

              fireStateChanged();

              exists = true;
            }

          }

        }

      } else if (networkInput.startsWith(GatheringLoungeModel.I_HAVE_INVITED_TOKEN)) {

        String invitedPlayerName = networkInput.split(" ")[1];
        String invitedPlayerAlias = networkInput.split(" ")[2];
        InetAddress invitedPlayerIp = null;
        try {
          invitedPlayerIp = Inet4Address.getByName(networkInput.split(" ")[3]);
        } catch (UnknownHostException ex) {
          Logger.getLogger(GatheringLoungeModel.class.getName()).log(Level.SEVERE, null, ex);
        }
        int invitedPlayerPort = Integer.parseInt(networkInput.split(" ")[4]);
        FriendStatus invitedPlayerStatus = FriendStatus.valueOf(networkInput.split(" ")[5]);

        Player player = new Player(invitedPlayerName, invitedPlayerAlias, invitedPlayerIp);
        player.setStatus(invitedPlayerStatus);
        invitedPlayerList.add(player);

      } else if (networkInput.startsWith(GAME_STARTED_TOKEN)) {

        if (getCurrentUser().getStatus() == FriendStatus.IN_GAMELOUNGE) {

          leaveGameLounge();

        } else {
          receivingFase = true;

          Chat.getSingleton().addChatMessage(GAMELOUNGE_NAME, "GameInfo", "Teams set. All receive the game!");

          getCurrentUser().setStatus(FriendStatus.IN_GAMELOUNGE);

          for (Friend friend : getCurrentUser().getFriends()) {
            NetworkAdapter.getSingleton().sendMessage(AbstractLoungeModel.STATUS_CHANGE_TOKEN + " " + getCurrentUser().getStatus(),
               friend.getIp().getHostAddress(), friend.getName());
          }

          for (Player player : playerList) {
            if (player.getStatus() != FriendStatus.IS_HOSTING) {
              player.setStatus(FriendStatus.IN_GAMELOUNGE);
            }
          }

          amountReady = 1;

          fireStateChanged();

          requestGame();
        }

      } else if (networkInput.startsWith(KICK_TOKEN)) {

        leaveGameLounge();

      } else if (networkInput.startsWith(STATUS_CHANGE_TOKEN)) {

        String status = networkInput.split(" ")[1];
        FriendStatus newState = FriendStatus.valueOf(status);

        for (Friend friend : playerList) {

          if (friend.getName().equals(fromName)) {

            if (newState == FriendStatus.IN_GAMELOUNGE && !receivingFase) {
              amountReady--;
            } else if (newState == FriendStatus.READY || newState == FriendStatus.IS_HOSTING) {
              amountReady++;
            }

            friend.setStatus(newState);

          }
        }

        fireStateChanged();

        if (amountReady == gamePlayers && receivingFase && isHosting && newState == FriendStatus.READY) {
          for (Player player : playerList) {
            NetworkAdapter.getSingleton().sendMessage(GAME_REALLY_STARTED_TOKEN, player.getIp().getHostAddress(), player.getName());
          }

          startStartTimer();
        }

      } else if (networkInput.startsWith(GAME_REALLY_STARTED_TOKEN)) {

        startStartTimer();

      } else if (networkInput.startsWith(LEAVE_TOKEN)) {

        Iterator<Player> iterator = playerList.iterator();
        while (iterator.hasNext()) {
          Friend friend = iterator.next();
          if (friend.getName().equals(fromName)) {
            if (friend.getStatus() == FriendStatus.READY) {
              amountReady--;
            }
            friend.setStatus(FriendStatus.IN_GATHERINGLOUNGE);

            Chat.getSingleton().removeChatter(GAMELOUNGE_NAME, friend);
            iterator.remove();
          }
        }

        fireStateChanged();

      } else if (networkInput.startsWith("LEFT: ")) {

        Iterator<Player> iterator = playerList.iterator();
        while (iterator.hasNext()) {
          Friend friend = iterator.next();
          if (friend.getName().equals(fromName)) {
            if (friend.getStatus() == FriendStatus.READY) {
              amountReady--;
            }
            friend.setStatus(FriendStatus.OFFLINE);

            Chat.getSingleton().removeChatter(GAMELOUNGE_NAME, friend);
            iterator.remove();
          }
        }

        fireStateChanged();

      } else if (networkInput.startsWith(HOST_TOKEN)) {

        JOptionPane.showMessageDialog(null, "The host has left! You are the host now!",
           "You're hosting!",
           JOptionPane.INFORMATION_MESSAGE);

        if (getCurrentUser().getStatus() == FriendStatus.READY) {
          amountReady--; // Compensering voor de statuschange
        }

        getCurrentUser().setStatus(FriendStatus.IS_HOSTING);

        for (Friend friend : getCurrentUser().getFriends()) {
          NetworkAdapter.getSingleton().sendMessage(STATUS_CHANGE_TOKEN + " " + getCurrentUser().getStatus(),
             friend.getIp().getHostAddress(), friend.getName());
        }

        for (Player player : playerList) {
          NetworkAdapter.getSingleton().sendMessage(STATUS_CHANGE_TOKEN + " " + getCurrentUser().getStatus(),
             player.getIp().getHostAddress(), player.getName());
        }

        isHosting = true;

        fireStateChanged();

      } else if (networkInput.startsWith(GAME_CHANGED_TOKEN)) {

        String[] input = networkInput.split("@@@");

        gameFileName = input[1];
        gameName = input[2];
        gamePlayers = Integer.parseInt(input[3]);
        gameTeams = Integer.parseInt(input[4]);
        gameDescription = input[5];

        getCurrentUser().setTeamId(0);
        for (Player player : playerList) {
          player.setTeamId(0);
        }

        fireStateChanged();

      } else if (networkInput.startsWith(TEAM_CHANGED_TOKEN)) {

        int teamid = Integer.parseInt(networkInput.split(" ")[1]);

        for (Player player : playerList) {
          if (player.getName().equals(fromName)) {
            player.setTeamId(teamid);
            break;
          }
        }

        fireStateChanged();
View Full Code Here

  public void kickPlayers() {
    Object[] objects = playerJList.getSelectedValues();

    for (int i = 0; i < objects.length; i++) {
      Player player = (Player) objects[i];
      NetworkAdapter.getSingleton().sendMessage(KICK_TOKEN, player.getIp().getHostAddress(), player.getName());
    }
  }
View Full Code Here

      }

      NetworkAdapter.getSingleton().sendMessage(GatheringLoungeModel.INVITE_TOKEN + " " + super.getCurrentUser().getName(),
         friend.getIp().getHostAddress(), friend.getName());

      Player player = new Player(friend.getName(), friend.getAlias(), friend.getIp());
      player.setStatus(friend.getStatus());
      invitedPlayerList.add(player);
    }

  }
View Full Code Here

TOP

Related Classes of userManagement.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.