Package nl.nuggit.words.board

Examples of nl.nuggit.words.board.Line


    return word;
  }

  private Boolean checkCrossword(Line line, int position, Word word,
      int wordIndex) {
    Line crossingLine = board.getOrthogonalLine(line, position + wordIndex);
    if (!hasAdjacentTiles(line, crossingLine)) {
      return null;
    }
    // find start
    int startPosition = line.getPosition();
    while (startPosition > 0
        && crossingLine.getSquares()[startPosition - 1].getTile() != null) {
      startPosition--;
    }
    // find end
    int endPosition = line.getPosition();
    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
View Full Code Here

TOP

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

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.