Package pdp.scrabble.ihm

Examples of pdp.scrabble.ihm.PlayerPanel


  public void setPlayerTurn(int id) {
    Player player = this.getPlayer(id);
    this.playerTurn = id;
    if (!player.isAI()) {
      this.mainFrame.setPlayerPanelPlayer(player);
      PlayerPanel ppanel = this.mainFrame.getPlayerPanel();
      ppanel.getButton("Help").setEnabled(true);
      ppanel.getButton("Game Over").setEnabled(true);
    }
    else {
      this.mainFrame.setPlayerPanelPlayer(null);
    }
  }
View Full Code Here


    this.server.sendReadyMulti(this.player.getID());
  }


  public void launchGameMulti() throws RemoteException, InterruptedException {
    final PlayerPanel ppanel = this.mainFrame.getPlayerPanel();
    this.panel.getButton("Ready").setText(getGameLang("Launched"));
    ppanel.getButton("Help").setEnabled(true);
    ppanel.getButton("Game Over").setEnabled(true);
    ppanel.getButton("Reset").setEnabled(true);
    ppanel.getScorePanel().setVisible(false);

    this.game.board().setDictionary(this.game.dictionary());

    if (this.client != null) {
      this.game.board().addObserver((ClientImpl) this.client);
    }

    for (int i = 0; i < Rack.MAX_RACK_LETTERS; i++) {
      this.player.getRack().addLetter(this.server.pickLetter());
    }

    // If server creator, start playing or wait for turn
    if (this.serverCreator) {
      this.server.setPlayertable(
          this.player.getID(), null, getGameLang("Playing"), -1);


      this.isMyTurn = true;
    }
    else {
      this.server.setPlayertable(
          this.player.getID(), null, getGameLang("Thinking"), -1);
      this.isMyTurn = false;
      ppanel.lock();

    }

    this.mainFrame.setPlayerPanelPlayer(this.player);
    ppanel.getButton("Game Over").addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (mainFrame.getGameSelection() == 2) {
          try {
            mainFrame.getMultiplayerPanel().getAction().disconnect();
          }
          catch (RemoteException ex) {
            Display.error("Server", "Error while disconnecting !");
          }
          catch (MalformedURLException ex) {
            Display.error("Server", "Error while disconnecting !");
          }
        }
      }
    });


    // Change turn when pick
    ppanel.getButton("Validate").addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (mainFrame.getGameSelection() == 2) {
          try {
            try {
              player.validate();
              player.endTurn(true);
            }
            catch (BoardWrongWordPlace ex) {
              Display.error(
                  "Multiplayer", "This word doesn't exists !");
              return;
            }

            int len = Rack.MAX_RACK_LETTERS - player.getRack().getLetters().length();
            for (int i = 0; i < len; i++) {
              Letter letter = server.pickLetter();
              if (letter != null) {
                player.getRack().addLetter(letter);
              }
            }
            ppanel.getButton("Validate").setEnabled(false);
            ppanel.getButton("Cancel").setEnabled(false);
            ppanel.getButton("Reset").setEnabled(false);
            ppanel.getButton("Game Over").setEnabled(true);
            panel.endTurn();
            server.setPlayertable(player.getID(), player.getName(),
                null, player.getScore());
          }
          catch (RemoteException ex) {
            Display.error(
                "Multiplayer", "Error while changing player turn !");
          }
        }
      }
    });

    ppanel.getButton("Reset").addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (mainFrame.getGameSelection() == 2) {
          List<Integer> selectedLetters = ppanel.action().getLettersToReset();
          Iterator<Integer> itr = selectedLetters.iterator();
          while (itr.hasNext()) {
            int letterToReset = itr.next();
            Letter letter = player.getRack().getLetter(letterToReset);
            if (letter != null) {
              try {
                Letter let = server.exchangeLetter(letter);
                player.getRack().changeLetter(letterToReset, let);
              }
              catch (RemoteException ex) {
                Display.error("Reset", "Error while reseting letter.");
              }
            }
          }
          ppanel.action().clearLettersToReset();
        }
      }
    });

    this.panel.repaint();
View Full Code Here

    // Remove letter on board
    this.board.resetCase(vertCase, horiCase);
    this.board.removeCaseNew(boardCase);
    if (this.board.numberOfNewCases() == 0) {
        PlayerPanel pp = this.mainFrame.getPlayerPanel();
        pp.getButton("Validate").setEnabled(false);
        pp.getButton("Cancel").setEnabled(false);
    }

    // Update player panel
    this.mainFrame.repaint();
      }
View Full Code Here

TOP

Related Classes of pdp.scrabble.ihm.PlayerPanel

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.