Package nl.nuggit.words.board

Examples of nl.nuggit.words.board.Tile


  public void play() {
    int tilePosition = startPosition;
    for (Tile tile : tiles) {
      Square square = line.getSquares()[tilePosition];
      Tile boardTile = square.getTile();
      if (boardTile == null) {
        square.setTile(tile);
      } else if (boardTile != tile) {
        throw new IllegalStateException(String.format(
            "Tile mismatch board:%s, word:%s", boardTile, tile));
View Full Code Here


    int score = 0;
    int wordFactor = 1;
    for (int wordIndex = 0; wordIndex < candidate.length(); wordIndex++) {
      Character symbol = candidate.charAt(wordIndex);
      Square square = line.getSquares()[position + wordIndex];
      Tile tile = square.getTile();
      int letterValue;
      if (tile != null) {
        if (tile.getLetter().getSymbol().equals(symbol)) {
          // matching tile on the board
          boardTileUsed = true;
          word.getTiles().add(tile);
          letterValue = tile.getLetter().getValue();
        } else {
          // tile mismatch on board
          fullMatch = false;
          break;
        }
      } else {
        Letter letter = language.getLetter(symbol);
        if (trayCopy.remove(symbol)) {
          // we place a matching tile
          tilesTakenFromTray++;
          word.getTiles().add(new Tile(letter));
          Booster booster = square.getBooster();
          letterValue = letter.getValue();
          if (booster != null) {
            letterValue = letterValue * booster.letterFactor();
            wordFactor = wordFactor * booster.wordFactor();
          }
        } else if (trayCopy.remove(Language.BLANK)) {
          // we place a blank tile
          tilesTakenFromTray++;
          word.getTiles().add(new Tile(new AppliedBlank(letter)));
          letterValue = 0;

        } else {
          // we don't have a suitable tile
          fullMatch = false;
View Full Code Here

    while (endPosition < (crossingLine.getSquares().length - 1)
        && crossingLine.getSquares()[endPosition + 1].getTile() != null) {
      endPosition++;
    }

    Tile newTile = word.getTiles().get(wordIndex);

    // construct crossword and count tiles already on the board
    StringBuilder sb = new StringBuilder();
    int score = 0;
    for (int i = startPosition; i <= endPosition; i++) {
      if (i == line.getPosition()) {
        // skip the new tile
        sb.append(newTile.getLetter().getSymbol());
        continue;
      }
      Tile tile = crossingLine.getSquares()[i].getTile();
      sb.append(tile.getLetter().getSymbol());
      score += tile.getLetter().getValue();
    }

    // count the new tile, possibly with booster
    int letterValue = newTile.getLetter().getValue();
    Booster booster = line.getSquares()[position + wordIndex].getBooster();
View Full Code Here

TOP

Related Classes of nl.nuggit.words.board.Tile

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.