Package pdp.scrabble.game

Examples of pdp.scrabble.game.Letter


    lastP++; // Down index
      }

      // Current word letter
      for (int v = firstP; v <= lastP; v++) {
    Letter letter = this.getCase(v, axis).getLetter();
    word = word.append(letter.getName());
    if (letter.getName() == Bag.JOKER) {
        jokers.add(letter);
    }
      }
  }
  else {
      while (this.getCase(axis, firstP - 1).getState() != FREE) {
    firstP--; // Left index
      }
      while (this.getCase(axis, lastP + 1).getState() != FREE) {
    lastP++; // Right index
      }

      // Current word letter
      for (int h = firstP; h <= lastP; h++) {
    Letter letter = this.getCase(axis, h).getLetter();
    word = word.append(letter.getName());
    if (letter.getName() == Bag.JOKER) {
        jokers.add(letter);
    }
      }
  }
View Full Code Here


     */
    private int calculateWordPoints(
      boolean isVert, int axis, int first, int last) {

  BoardCase boardCase = null;
  Letter letter = null;
  int wordMult = 1, score = 0, letterValue = 0;

  // Check from first letter to last
  for (int index = first; index <= last; index++) {
      if (isVert) {
    boardCase = this.getCase(index, axis);
      }
      else {
    boardCase = this.getCase(axis, index);
      }

      letter = boardCase.getLetter();
      letterValue = letter.getValue();

      // Apply bonus if not already used
      if (!boardCase.getMultUsed()) {
    letterValue *= boardCase.getLetterMult();
    wordMult *= boardCase.getWordMult();
View Full Code Here

    public void switchCasesLetter(int v1, int h1, int v2, int h2) {
  BoardCase case1 = this.getCase(v1, h1);
  BoardCase case2 = this.getCase(v2, h2);

  Letter letter1 = case1.getLetter();
  Letter letter2 = case2.getLetter();

  BoardCaseState state1 = case1.getState();
  BoardCaseState state2 = case2.getState();

  if (state1 == FREE) {
View Full Code Here

    private char[][] charTab = new char[Board.HORI_DIM][Board.VERT_DIM];
   
    public AIBoardModel(Board board) {
  for (int i=0 ; i<board.VERT_DIM ; i++)
      for (int j=0 ; j<board.HORI_DIM ; j++) {
    Letter tmp = board.getCase(i, j).getLetter();
    if (tmp == null)
        charTab[i][j] = ' ';
    else
        charTab[i][j] = board.getCase(i, j).getLetter().getName();
      }
View Full Code Here

    }
   
    public void update(Board board) {
  for (int i=0 ; i<Board.VERT_DIM ; i++)
      for (int j=0 ; j<Board.HORI_DIM ; j++) {
    Letter tmp = board.getCase(i, j).getLetter();
    if (tmp == null) {
        if (charTab[i][j] != ' ')
      charTab[i][j] = ' ';
    }
    else if (this.charTab[i][j] != tmp.getName())
        charTab[i][j] = tmp.getName();
     
    }
View Full Code Here

  catch (ArrayIndexOutOfBoundsException e) {
      fail("ArrayIndexOutOfBoundsException was not expected");
  }

  try {
      Letter letter = null;
      bag.addLetter(letter);
      System.out.println("Can add a null letter in bag");
  }
  catch (NullPointerException ex) {
      fail("NullPointerException was not expected");
View Full Code Here

    @SuppressWarnings("unchecked")
    Iterator<Element> Eletters = element.getChildren().iterator();

    while (Eletters.hasNext()) {
      Element Eletter = Eletters.next();
      Letter letter = Factory.FACTORY.createLetter(' ', 0, 0);
      letter.load(Eletter);
      lettres.add(letter);
    }
  }
View Full Code Here

    // Random index in ArrayList
    int index = Tool.random(0, this.letters.size()-1);

    // Get a letter
    Letter letter = this.letters.get(index);
    // Remove letter from bag
    this.letters.remove(index);
    // Return letter
    return letter;
  }
View Full Code Here

    @SuppressWarnings("unchecked")
    Iterator<Element> Eletters = (element.getChildren()).iterator();

    while (Eletters.hasNext()) {
      Element Eletter = Eletters.next();
      Letter letter = FACTORY.createLetter(' ', 0, 0);

      letter.load(Eletter);
      this.letters.add(letter);
    }
  }
View Full Code Here

              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.");
              }
View Full Code Here

TOP

Related Classes of pdp.scrabble.game.Letter

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.