scrabble-solver
Version:
Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.
30 lines (23 loc) • 794 B
text/typescript
import { BONUS_CHARACTER } from '@scrabble-solver/constants';
import { Bonus } from './Bonus';
import { type BonusValue } from './BonusValue';
import { type Cell } from './Cell';
import { type Config } from './Config';
export class CharacterBonus extends Bonus {
public readonly type = BONUS_CHARACTER;
public canApply(config: Config, cell: Cell): boolean {
return super.canApply(config, cell) && this.matchesCellTileScore(config, cell);
}
public matchesCellTileScore(config: Config, cell: Cell): boolean {
if (typeof this.score === 'undefined') {
return true;
}
return this.score === config.pointsMap[cell.tile.character];
}
public get value(): BonusValue {
return {
characterMultiplier: this.multiplier,
wordMultiplier: 1,
};
}
}