Word word = new Word(line, position);
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();
}